:root {
  --ink: #102a43;
  --ink-2: #2b455c;
  --ink-3: #4f6578;
  --muted: #748494;
  --muted-2: #97a3ae;
  --line: #e8e5dd;
  --line-strong: #d9d5ca;
  --paper: #f7f4ec;
  --paper-deep: #efebe0;
  --card: #ffffff;
  --navy: #0d2338;
  --navy-2: #122e47;
  --teal: #2f7f72;
  --teal-dark: #215f56;
  --teal-soft: #e7f2ef;
  --teal-mist: #f1f8f6;
  --gold: #d7a24c;
  --gold-soft: #fbf3e2;
  --coral: #d9674a;
  --coral-soft: #fceee9;
  --blue: #396a93;
  --blue-soft: #edf3f8;
  --danger: #c34f4f;
  --danger-soft: #fbeceb;
  --success: #2a7a59;
  --success-soft: #e8f5ee;
  --warning: #a66a19;
  --warning-soft: #fdf4e2;
  --shadow-sm: 0 1px 2px rgba(16, 42, 67, 0.04), 0 4px 12px rgba(16, 42, 67, 0.04);
  --shadow-md: 0 10px 30px rgba(16, 42, 67, 0.08);
  --shadow-lg: 0 24px 70px rgba(16, 42, 67, 0.14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Consolas", monospace;
  --ease: cubic-bezier(0.22, 0.68, 0.32, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

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

body.no-scroll {
  overflow: hidden;
}

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

h1,
h2,
h3,
h4 {
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

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

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

img,
svg {
  display: block;
  max-width: 100%;
}

svg.icon {
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -0.18em;
}

table {
  border-collapse: collapse;
  width: 100%;
}

::selection {
  color: #fff;
  background: var(--teal);
}

:focus-visible {
  outline: 2px solid rgba(47, 127, 114, 0.75);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

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

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.no-wrap {
  white-space: nowrap;
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-teal {
  color: var(--teal);
}

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

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--btn-border);
  border-radius: 11px;
  color: var(--btn-fg);
  background: var(--btn-bg);
  font-size: 13.5px;
  font-weight: 580;
  line-height: 1.2;
  white-space: nowrap;
  transition:
    transform 0.18s var(--ease),
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

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

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

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

.btn .icon {
  margin-top: -1px;
}

.btn-primary {
  --btn-bg: var(--teal);
  --btn-fg: #fff;
  --btn-border: var(--teal);
  box-shadow: 0 6px 16px rgba(47, 127, 114, 0.2);
}

.btn-primary:hover {
  --btn-bg: var(--teal-dark);
  --btn-border: var(--teal-dark);
  box-shadow: 0 8px 20px rgba(47, 127, 114, 0.26);
}

.btn-dark {
  --btn-bg: var(--navy);
  --btn-fg: #fff;
  --btn-border: var(--navy);
}

.btn-dark:hover {
  --btn-bg: #173750;
}

.btn-secondary {
  --btn-bg: #fff;
  --btn-fg: var(--ink-2);
  --btn-border: var(--line-strong);
  box-shadow: 0 2px 5px rgba(16, 42, 67, 0.03);
}

.btn-secondary:hover {
  --btn-border: #bfc7c9;
  --btn-bg: #fbfbf9;
}

.btn-ghost {
  --btn-fg: var(--ink-3);
}

.btn-ghost:hover {
  --btn-bg: rgba(16, 42, 67, 0.055);
}

.btn-soft {
  --btn-bg: var(--teal-soft);
  --btn-fg: var(--teal-dark);
  --btn-border: transparent;
}

.btn-soft:hover {
  --btn-bg: #d9ebe6;
}

.btn-danger {
  --btn-bg: var(--danger-soft);
  --btn-fg: var(--danger);
  --btn-border: #f1d2d0;
}

.btn-danger:hover {
  --btn-bg: #f7dedc;
}

.btn-sm {
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12.5px;
  gap: 5px;
}

.btn-lg {
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 13px;
  font-size: 15px;
}

.btn-icon {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

/* ---------- Form controls ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

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

.field-label .required {
  color: var(--coral);
}

.field-hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

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

.input:hover,
.select:hover,
.textarea:hover {
  border-color: #c8c4b9;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 0;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 127, 114, 0.12);
}

.textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.65;
}

.select {
  appearance: none;
  padding-right: 34px;
  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='%23748494' 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 11px center;
  cursor: pointer;
}

.input-wrap {
  position: relative;
}

.input-wrap > .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}

.input-wrap .input {
  padding-left: 38px;
}

.input-wrap .input-action {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--muted);
}

.input-wrap .input-action:hover {
  color: var(--ink);
  background: rgba(16, 42, 67, 0.055);
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.55;
  cursor: pointer;
}

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

/* ---------- Misc shared ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 23px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink-3);
  background: #f2f4f4;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-teal {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

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

.badge-coral {
  color: #a84932;
  background: var(--coral-soft);
}

.badge-blue {
  color: #2c5b80;
  background: var(--blue-soft);
}

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

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

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

.badge-neutral {
  color: var(--muted);
  background: #f3f4f4;
}

.badge-outline {
  border-color: var(--line-strong);
  background: #fff;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar.lg {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.avatar.xl {
  width: 66px;
  height: 66px;
  font-size: 21px;
}

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar-stack .avatar {
  margin-left: -7px;
  border: 2px solid #fff;
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
  background: #fff;
  font-size: 12.5px;
  font-weight: 550;
  transition: all 0.16s ease;
}

.pill:hover {
  border-color: #c5c1b6;
}

.pill.active {
  color: #fff;
  border-color: var(--navy);
  background: var(--navy);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 32px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-bottom: 14px;
  border-radius: 18px;
  color: var(--teal);
  background: var(--teal-mist);
}

.empty-state h3 {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 15px;
}

.empty-state p {
  max-width: 330px;
  font-size: 12.5px;
  line-height: 1.65;
}

.empty-state .btn {
  margin-top: 16px;
}

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

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

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

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

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

.toast-root {
  position: fixed;
  z-index: 400;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  color: #fff;
  background: rgba(13, 35, 56, 0.96);
  box-shadow: 0 16px 40px rgba(13, 35, 56, 0.25);
  font-size: 12.5px;
  line-height: 1.55;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  animation: toastIn 0.25s var(--ease);
}

.toast.leaving {
  animation: toastOut 0.2s ease forwards;
}

.toast .icon {
  margin-top: 1px;
  color: #82c3b8;
}

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

.toast.toast-success .icon {
  color: #8bd2ae;
}

.toast.toast-warning .icon {
  color: #ecc47b;
}

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

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

.fade-up {
  animation: fadeUp 0.5s var(--ease) both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@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;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: span 1;
  }

  .toast-root {
    right: 12px;
    bottom: 80px;
    left: 12px;
    width: auto;
  }

  .toast {
    width: 100%;
  }
}
