:root {
  --bg: #f4f2ec;
  --bg-deep: #e8e4d9;
  --surface: #fffdf8;
  --surface-2: #f7f4ed;
  --surface-3: #ede9df;
  --ink: #1b1e33;
  --ink-2: #33374d;
  --muted: #6d7180;
  --faint: #989ca8;
  --line: rgba(27, 30, 51, 0.12);
  --line-strong: rgba(27, 30, 51, 0.22);
  --accent: #ee6039;
  --accent-2: #cf4824;
  --accent-soft: #fbe2d6;
  --moss: #2f2f75;
  --moss-dark: #191a3f;
  --moss-soft: #e3e5f2;
  --sage: #dce1ee;
  --gold: #d2a34c;
  --gold-soft: #f4e8ca;
  --plum: #705a83;
  --blue: #3f67a5;
  --red: #b74636;
  --shadow-xs: 0 1px 2px rgba(27, 30, 51, 0.04);
  --shadow-sm: 0 10px 30px rgba(27, 30, 51, 0.07);
  --shadow-md: 0 24px 70px rgba(27, 30, 51, 0.11);
  --shadow-lg: 0 40px 100px rgba(27, 30, 51, 0.17);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 34px;
  --radius-pill: 999px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-display: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --header-height: 76px;
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.026;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body.is-locked {
  overflow: hidden;
}

::selection {
  color: var(--ink);
  background: #f2c3a9;
}

h1,
h2,
h3,
h4,
h5,
p,
figure {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.2;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

img,
svg {
  display: block;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

li {
  list-style: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(231, 90, 43, 0.3);
  outline-offset: 2px;
}

.icon {
  width: 1.2em;
  height: 1.2em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.container {
  width: min(1180px, calc(100% - 64px));
  margin-inline: auto;
}

.container--wide {
  width: min(1320px, calc(100% - 56px));
}

.container--narrow {
  width: min(880px, calc(100% - 64px));
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.serif {
  font-family: var(--font-display);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.65;
}

.eyebrow--accent {
  color: var(--accent);
}

.eyebrow--light {
  color: rgba(255, 253, 248, 0.6);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.dot--green {
  background: #4b8e68;
}

.hide {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 21px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease),
    border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.99);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn .icon {
  font-size: 17px;
}

.btn--primary {
  background: var(--accent);
  color: #fffdf8;
  box-shadow: 0 8px 22px rgba(231, 90, 43, 0.2);
}

.btn--primary:hover {
  background: var(--accent-2);
  box-shadow: 0 12px 26px rgba(231, 90, 43, 0.26);
}

.btn--dark {
  background: var(--moss);
  color: var(--surface);
}

.btn--dark:hover {
  background: var(--moss-dark);
}

.btn--ink {
  background: var(--ink);
  color: var(--surface);
}

.btn--outline {
  border-color: var(--line-strong);
  background: transparent;
}

.btn--outline:hover {
  border-color: var(--ink);
  background: rgba(255, 253, 248, 0.45);
}

.btn--soft {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.btn--soft:hover {
  background: #f6d5c3;
}

.btn--ghost {
  color: var(--muted);
}

.btn--ghost:hover {
  background: rgba(23, 37, 29, 0.06);
  color: var(--ink);
}

.btn--danger {
  background: #f9e4df;
  color: var(--red);
}

.btn--danger:hover {
  background: #f5d4cd;
}

.btn--sm {
  min-height: 36px;
  padding: 0 14px;
  gap: 6px;
  font-size: 12.5px;
}

.btn--xs {
  min-height: 30px;
  padding: 0 11px;
  gap: 5px;
  font-size: 12px;
}

.btn--lg {
  min-height: 54px;
  padding: 0 27px;
  font-size: 15px;
}

.btn--block {
  width: 100%;
}

.btn--icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
}

.btn--loading {
  pointer-events: none;
}

.btn--loading::after {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  background: rgba(255, 253, 248, 0.7);
  transition: 0.2s var(--ease);
}

.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  transform: translateY(-1px);
}

.field {
  display: grid;
  gap: 7px;
}

.field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}

.field__hint {
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
}

.field__error {
  color: var(--red);
  font-size: 12px;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.75);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: #a5aaa3;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: rgba(23, 37, 29, 0.2);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--moss);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(47, 47, 117, 0.09);
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
}

.select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236d746d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.input--search {
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 24 24' fill='none' stroke='%236d746d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .field--full {
  grid-column: 1 / -1;
}

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--moss);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  position: relative;
  width: 40px;
  height: 23px;
  border-radius: 99px;
  background: #d8d4ca;
  transition: 0.2s var(--ease);
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  transition: 0.2s var(--ease);
}

.switch input:checked + .switch__track {
  background: var(--moss);
}

.switch input:checked + .switch__track::after {
  transform: translateX(17px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.badge .icon {
  font-size: 12px;
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.badge--green {
  background: var(--moss-soft);
  color: var(--moss);
}

.badge--gold {
  background: var(--gold-soft);
  color: #8d641e;
}

.badge--red {
  background: #f8e2de;
  color: var(--red);
}

.badge--blue {
  background: #e3edf7;
  color: var(--blue);
}

.badge--ink {
  background: var(--ink);
  color: var(--surface);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status--active {
  color: #3e7c57;
}

.status--pending,
.status--processing {
  color: #a57823;
}

.status--expired,
.status--disabled,
.status--rejected {
  color: var(--red);
}

.status--open {
  color: #a57823;
}

.status--replied {
  color: #3e7c57;
}

.status--closed,
.status--resolved {
  color: var(--muted);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.panel__title {
  font-size: 16px;
  font-weight: 600;
}

.panel__sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.panel__body {
  padding: 22px 24px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--moss-soft);
  color: var(--moss);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.avatar--orange {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.avatar--gold {
  background: var(--gold-soft);
  color: #8d641e;
}

.avatar--sm {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.avatar--lg {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.divider {
  height: 1px;
  border: 0;
  background: var(--line);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 220px;
  padding: 32px;
  text-align: center;
}

.empty-state__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--faint);
}

.empty-state__icon .icon {
  font-size: 25px;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
}

.empty-state p {
  max-width: 300px;
  color: var(--muted);
  font-size: 12.5px;
}

.skeleton {
  overflow: hidden;
  border-radius: 12px;
  background: #ece7dc;
  position: relative;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 1.4s infinite;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(23, 37, 29, 0.16);
  border-top-color: var(--moss);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-page {
  display: grid;
  place-items: center;
  min-height: 60vh;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.table-shell {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background 0.18s var(--ease);
}

.table tbody tr:hover {
  background: rgba(248, 244, 234, 0.65);
}

.table__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 24, 19, 0.55);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(90vh, 860px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s var(--ease);
  overscroll-behavior: contain;
}

.modal__panel--lg {
  width: min(940px, 100%);
}

.modal__panel--sm {
  width: min(440px, 100%);
}

.modal__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(12px);
}

.modal__head h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal__head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.modal__close {
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  color: var(--muted);
  transition: 0.18s var(--ease);
}

.modal__close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.modal__body {
  padding: 24px 26px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 26px 24px;
  border-top: 1px solid var(--line);
}

.toast-stack {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(440px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: auto;
  animation: toastIn 0.32s var(--ease);
}

.toast .icon {
  margin-top: 2px;
  color: #94c3a5;
  font-size: 16px;
}

.toast--error {
  background: #5a251d;
}

.toast--error .icon {
  color: #f1b0a4;
}

.toast.is-out {
  animation: toastOut 0.25s ease forwards;
}

.load-more {
  display: flex;
  justify-content: center;
  padding: 18px;
}

.section-gap {
  padding-block: 100px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@media (max-width: 760px) {
  .container,
  .container--wide,
  .container--narrow {
    width: calc(100% - 36px);
  }

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

  .modal {
    padding: 12px;
    align-items: flex-end;
  }

  .modal__panel {
    max-height: 92vh;
    border-radius: 22px;
  }

  .modal__head,
  .modal__body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .modal__footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .section-gap {
    padding-block: 68px;
  }

  .toast-stack {
    top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

[hidden] {
  display: none !important;
}

/* Keep long modal actions accessible */
.modal__footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(12px);
}

/* Official trademark mark */
.brand__mark,
.footer-brand .brand__mark,
.auth-visual .brand__mark,
.app-shell--admin .app-sidebar__brand .brand__mark {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

.brand__mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
