/* ===========================================================================
   本草纸本 · 设计系统  (Lead 维护，两端共用；请勿修改，只引用)
   页面：public/index.html  /  public/admin/index.html
   =========================================================================== */

:root {
  /* 纸与墨 */
  --paper: #f7f2e6;
  --paper-2: #efe6d2;
  --paper-3: #fbf8f0;
  --paper-rgb: 247, 242, 230;
  --ink: #221f19;
  --ink-2: #58513f;
  --ink-3: #8a8270;
  --line: rgba(34, 31, 25, 0.12);
  --line-2: rgba(34, 31, 25, 0.22);
  /* 色 */
  --pine: #2f5d4e;
  --pine-2: #24463a;
  --pine-soft: rgba(47, 93, 78, 0.1);
  --jade: #7a9a7c;
  --seal: #a63b2a;
  --seal-2: #8c2f22;
  --seal-soft: rgba(166, 59, 42, 0.08);
  --gold: #b08a4a;
  --gold-soft: rgba(176, 138, 74, 0.16);
  --ok: #2f5d4e;
  --warn: #a87a2a;
  --danger: #a63b2a;

  /* 字体 */
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong",
    "SimSun", serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui,
    -apple-system, sans-serif;

  /* 尺度 */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(34, 31, 25, 0.04), 0 8px 24px rgba(34, 31, 25, 0.05);
  --shadow-2: 0 10px 40px rgba(34, 31, 25, 0.14);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --page-pad: 16px;
  --maxw: 1120px;
}

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

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

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 70% at 12% -10%, rgba(176, 138, 74, 0.09), transparent 60%),
    radial-gradient(90% 60% at 100% 105%, rgba(47, 93, 78, 0.07), transparent 55%),
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
[hidden] { display: none !important; }
::selection { background: rgba(176, 138, 74, 0.28); }

:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- 排版 ---------- */
.serif { font-family: var(--font-serif); }

.title-xl {
  font-family: var(--font-serif);
  font-size: clamp(26px, 7vw, 40px);
  line-height: 1.24;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.title-lg {
  font-family: var(--font-serif);
  font-size: clamp(21px, 4.4vw, 28px);
  line-height: 1.32;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.title-md {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.4;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.lead { color: var(--ink-2); font-size: 14px; line-height: 1.75; }
.muted { color: var(--ink-3); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 布局 ---------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}
.stack > * + * { margin-top: var(--stack-gap, 14px); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spacer { flex: 1 1 auto; }
.section { padding-block: 26px; }
.section + .section { border-top: 1px solid var(--line); }

/* ---------- 按钮 ---------- */
.btn {
  --btn-h: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-h);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
    border-color 0.18s var(--ease), transform 0.12s var(--ease), opacity 0.18s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled],
.btn[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--pine); color: #f7f2e6; }
.btn--primary:hover { background: var(--pine-2); }
.btn--ink { background: var(--ink); color: var(--paper); }
.btn--ink:hover { background: #000; }
.btn--seal { background: var(--seal); color: #fdf6ee; }
.btn--seal:hover { background: var(--seal-2); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn--ghost:hover { background: rgba(34, 31, 25, 0.04); border-color: var(--ink-3); }
.btn--quiet { background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn--quiet:hover { color: var(--ink); background: rgba(34, 31, 25, 0.05); }
.btn--sm { --btn-h: 36px; font-size: 13px; padding: 0 14px; font-weight: 500; }
.btn--block { width: 100%; }
.btn--danger-text { color: var(--seal); }
.btn__spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: rgba(var(--paper-rgb), 0.7);
  transition: background 0.18s, color 0.18s;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- 表单 ---------- */
.field { display: block; }
.field__label {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.field__label .req { color: var(--seal); font-weight: 500; }
.field__label .opt { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.field__control {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  background: var(--paper-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
  font-size: 15px;
  appearance: none;
}
textarea.field__control { min-height: 84px; resize: vertical; line-height: 1.6; }
select.field__control {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238A8270' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}
.field__control::placeholder { color: var(--ink-3); }
.field__control:hover { border-color: var(--ink-3); }
.field__control:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(47, 93, 78, 0.12);
  background: #fff;
}
.field__hint { margin-top: 5px; font-size: 12px; color: var(--ink-3); }
.field__error { margin-top: 5px; font-size: 12px; color: var(--seal); }
.field.is-invalid .field__control { border-color: var(--seal); background: #fdf6f3; }
.field-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-grid--2 { grid-template-columns: 1fr 1fr; } }

/* ---------- 卡片 / 面板 ---------- */
.card {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.panel { background: rgba(var(--paper-rgb), 0.6); border: 1px solid var(--line); border-radius: var(--radius); }
.card__pad { padding: 18px; }
@media (min-width: 700px) { .card__pad { padding: 22px; } }

/* ---------- 小件：编号印章 / 状态徽标 / 印章 ---------- */
.seal-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid rgba(166, 59, 42, 0.5);
  border-radius: 4px;
  color: var(--seal);
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  background: rgba(166, 59, 42, 0.03);
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: rgba(34, 31, 25, 0.03);
  white-space: nowrap;
}
.badge--ok { color: var(--pine); border-color: rgba(47, 93, 78, 0.28); background: var(--pine-soft); }
.badge--warn { color: var(--warn); border-color: rgba(168, 122, 42, 0.32); background: rgba(176, 138, 74, 0.12); }
.badge--danger { color: var(--seal); border-color: rgba(166, 59, 42, 0.28); background: var(--seal-soft); }
.badge--muted { color: var(--ink-3); }
.stamp {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 7px;
  border: 1.5px solid var(--seal);
  border-radius: 3px;
  color: var(--seal);
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: 0.18em;
  transform: rotate(-6deg);
  background: rgba(253, 246, 238, 0.55);
  opacity: 0.9;
}
.tag {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px; color: var(--ink-2);
  background: rgba(var(--paper-rgb), 0.8);
}

/* 筛选 chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  font-size: 13px;
  background: transparent;
  transition: all 0.16s var(--ease);
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- 统计 ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.stat__label { font-size: 12px; color: var(--ink-3); letter-spacing: 0.06em; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; } }

/* ---------- 分隔 ---------- */
.divider { height: 1px; background: var(--line); border: 0; }
.divider--ornament {
  display: flex; align-items: center; gap: 12px;
  color: var(--gold);
}
.divider--ornament::before,
.divider--ornament::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent);
}
.divider--ornament span { font-size: 10px; letter-spacing: 0.2em; }

/* ---------- 弹层：底部抽屉 / 居中弹窗 ---------- */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(24, 21, 16, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.22s var(--ease);
  z-index: 80;
}
.backdrop.is-open { opacity: 1; }

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
  background: var(--paper);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(102%);
  transition: transform 0.28s var(--ease);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet.is-open { transform: translateY(0); }
.sheet__grab {
  width: 44px; height: 4px; border-radius: 999px;
  background: var(--line-2);
  margin: 9px auto 2px;
  flex: none;
}
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet__title { font-family: var(--font-serif); font-size: 17px; letter-spacing: 0.05em; font-weight: 600; }
.sheet__body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot {
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--line);
  background: rgba(var(--paper-rgb), 0.94);
  flex: none;
}
@media (min-width: 700px) {
  .sheet {
    inset: 50% auto auto 50%;
    width: min(560px, calc(100vw - 40px));
    max-height: 86vh;
    transform: translate(-50%, -46%) scale(0.98);
    opacity: 0;
    border-radius: var(--radius-lg);
    padding-bottom: 0;
  }
  .sheet.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet__grab { display: none; }
}

/* ---------- toast ---------- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(28, 25, 20, 0.92);
  color: #f7f2e6;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.24s var(--ease);
}
.toast--ok { background: rgba(35, 70, 58, 0.95); }
.toast--error { background: rgba(140, 47, 34, 0.96); }
.toast.is-out { animation: toast-out 0.2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- 空状态 / 加载 ---------- */
.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}
.empty__icon { margin: 0 auto 12px; width: 44px; opacity: 0.5; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--pine);
  animation: spin 0.8s linear infinite;
}
.skeleton {
  background: linear-gradient(90deg, rgba(34,31,25,.05), rgba(34,31,25,.09), rgba(34,31,25,.05));
  background-size: 200% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skeleton { to { background-position: -200% 0; } }
.loading-line {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 28px; color: var(--ink-3); font-size: 13px;
}

/* ---------- 工具类 ---------- */
.u-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;
}
.u-nowrap { white-space: nowrap; }
.u-center { text-align: center; }
.u-right { text-align: right; }
.u-mt-0 { margin-top: 0 !important; }
.u-mt-1 { margin-top: 8px; }
.u-mt-2 { margin-top: 16px; }
.u-mt-3 { margin-top: 24px; }
.u-mb-1 { margin-bottom: 8px; }
.u-mb-2 { margin-bottom: 16px; }
.u-mb-3 { margin-bottom: 24px; }
.u-gap-1 { gap: 8px; }
.u-gap-2 { gap: 16px; }
.u-wrap { flex-wrap: wrap; }
.u-scroll-x {
  display: flex; gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.u-scroll-x::-webkit-scrollbar { display: none; }
.u-hide { display: none !important; }
@media (max-width: 559px) { .u-hide-sm { display: none !important; } }
@media (min-width: 560px) { .u-show-sm { display: none !important; } }

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