:root {
  --bg: #fff7ed;
  --panel: #fffdf8;
  --ink: #2b211b;
  --muted: #806f63;
  --line: #ead9c6;
  --brand: #c2410c;
  --brand-dark: #9a3412;
  --brand-soft: #ffedd5;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --blue: #2563eb;
  --amber: #b45309;
  --shadow: 0 18px 45px rgba(124, 45, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(251, 146, 60, 0.28), transparent 330px),
    linear-gradient(180deg, #fff1e5 0, rgba(255, 241, 229, 0) 340px),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 18px 36px;
}

.mobile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #f97316, var(--brand));
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand-row h1 {
  font-size: 22px;
  line-height: 1.25;
}

.brand-row p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.search-card,
.department-panel,
.policy-list-card,
.policy-detail,
.admin-panel,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.search-card {
  padding: 16px;
}

.department-panel {
  margin-top: 14px;
  overflow: hidden;
}

.compact-heading {
  padding: 14px 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fffaf3;
}

.search-box span {
  color: var(--muted);
  font-size: 24px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.quick-tags,
.category-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 2px;
}

.department-panel .category-strip {
  padding: 12px 16px 16px;
}

.tag-button,
.category-button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  background: #fffdf8;
  color: var(--ink);
  white-space: nowrap;
}

.category-button.active,
.tag-button:hover,
.category-button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.employee-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  font-size: 18px;
}

.section-heading p {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.policy-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding: 10px;
}

.policy-item,
.admin-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 13px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
}

.policy-item {
  display: grid;
  gap: 8px;
}

.policy-item:hover,
.policy-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.policy-title-row,
.policy-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.policy-title-row h3 {
  min-width: 0;
  font-size: 16px;
  line-height: 1.45;
}

.policy-meta {
  color: var(--muted);
  font-size: 12px;
}

.admin-item .policy-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 12px;
  margin: 10px 0 12px;
}

.admin-item .item-actions {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 0 9px;
  background: #f8eadb;
  color: #5f4636;
  font-size: 12px;
}

.status-pill {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 700;
}

.policy-item p,
.policy-detail p {
  color: var(--muted);
  line-height: 1.7;
}

.policy-detail {
  min-height: 540px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 237, 213, 0.56), rgba(255, 253, 248, 0) 190px),
    var(--panel);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.35;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.detail-stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf3;
}

.detail-stat span {
  color: var(--muted);
  font-size: 12px;
}

.detail-stat strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.policy-image,
.document-preview {
  display: block;
  width: 100%;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fffaf3;
}

.document-frame {
  width: 100%;
  height: 520px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.file-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.image-placeholder,
.file-placeholder {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  background: #fffaf3;
  color: var(--muted);
  text-align: center;
}

.content-lines {
  display: grid;
  gap: 10px;
}

.content-line {
  border-left: 3px solid var(--brand);
  padding: 2px 0 2px 12px;
  color: #5f4636;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.admin-app {
  min-height: 100vh;
}

.login-panel {
  width: min(460px, 100%);
  margin: 9vh auto 0;
  padding: 24px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.login-form label {
  color: #5f4636;
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf3;
  color: var(--ink);
  outline: 0;
}

.login-tip {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.admin-panel {
  overflow: hidden;
}

.policy-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.options-manager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

.option-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffaf3;
}

.option-box h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.option-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.option-input-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffdf8;
  outline: 0;
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.option-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 8px 0 11px;
  background: #f8eadb;
  color: #5f4636;
  font-size: 13px;
}

.option-tag button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fee4e2;
  color: var(--danger);
  line-height: 1;
}

.policy-form label {
  color: #5f4636;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.policy-form input,
.policy-form textarea,
.policy-form select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffaf3;
  color: var(--ink);
  outline: 0;
}

.policy-form textarea,
.policy-form textarea {
  resize: vertical;
  line-height: 1.65;
}

.media-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.preview-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf3;
}

.preview-box strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.preview-box p {
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.preview-box img {
  display: block;
  width: 100%;
  max-height: 260px;
  border-radius: 8px;
  object-fit: contain;
  background: #fffdf8;
}

.paste-upload {
  border: 1px dashed #d97706;
  border-radius: 8px;
  padding: 14px;
  background: #fff7ed;
  color: #5f4636;
  outline: 0;
}

.paste-upload:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.18);
}

.paste-upload strong {
  display: block;
  font-size: 14px;
}

.paste-upload p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.6;
}

.paste-upload input {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fffdf8;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
}

.danger-button {
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
}

.admin-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding: 0 16px 16px;
}

.admin-filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fffaf3;
}

.admin-filters input,
.admin-filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffdf8;
  color: var(--ink);
  outline: 0;
}

.wide-panel {
  grid-column: auto;
}

.admin-item {
  border-color: var(--line);
}

.admin-item h3 {
  font-size: 16px;
  line-height: 1.45;
}

.admin-item p {
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(20px);
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #101828;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

mark {
  border-radius: 4px;
  padding: 0 2px;
  background: #fde68a;
  color: #7c2d12;
}

@media (max-width: 860px) {
  .app {
    padding: 14px 12px 86px;
  }

  .mobile-hero {
    align-items: flex-start;
  }

  .ghost-button {
    min-height: 36px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .brand-row h1 {
    font-size: 19px;
  }

  .employee-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .policy-list {
    max-height: none;
  }

  .policy-detail {
    min-height: 0;
  }

  .detail-header {
    flex-direction: column;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .options-manager {
    grid-template-columns: 1fr;
  }

  .admin-filters {
    grid-template-columns: 1fr;
  }

  .media-preview {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .mobile-hero {
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

  .detail-header h2 {
    font-size: 21px;
  }
}
