:root {
  --ink: #2b2724;
  --ink-soft: #5a534d;
  --paper: #f7f4ec;
  --card: #ffffff;
  --line: #e3ddd0;
  --cinnabar: #a63a2e;
  --cinnabar-soft: #f3e2de;
  --gold: #b08a4a;
  --jade: #3d6b63;
  --muted: #8a8178;
  --shadow: 0 1px 2px rgba(43, 39, 36, .06), 0 8px 24px rgba(43, 39, 36, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--cinnabar); text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: #fffdf7;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-size: 20px;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--ink);
}
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 1px; }

.spacer { flex: 1; }
.who { color: var(--ink-soft); font-size: 13px; }
.who b { color: var(--cinnabar); font-weight: 600; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff; }
.btn.primary:hover { background: #93301f; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--cinnabar); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.layout { max-width: 1280px; margin: 0 auto; padding: 22px 28px 60px; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab {
  border: none;
  background: transparent;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--cinnabar); border-bottom-color: var(--cinnabar); font-weight: 600; }

.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; letter-spacing: 1px; }
.panel-head .hint { color: var(--muted); font-size: 12px; }
.panel-head .spacer { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.stat .v { font-size: 26px; font-weight: 600; color: var(--ink); font-family: "Georgia", serif; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 1px; background: #fcfaf4; }
table tr:hover td { background: #fffdf7; }
td.actions { white-space: nowrap; }

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); border-color: var(--gold); }
textarea { min-height: 72px; resize: vertical; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 120px; }
.filters .grow { flex: 1; min-width: 220px; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.pager .spacer { flex: 1; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #f0ece2;
  color: var(--ink-soft);
}
.pill.herb { background: #eaf0e2; color: #5a7042; }
.pill.formula { background: var(--cinnabar-soft); color: var(--cinnabar); }
.pill.acupoint { background: #e3edf0; color: #3a6070; }
.pill.text { background: #ece7f2; color: #5b4a7a; }
.pill.disease { background: #f0e5e8; color: #7a3a4a; }
.pill.warn { background: #f7ecd6; color: #8a6418; }
.pill.ok { background: #e6f0e8; color: #2f6b40; }

.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(43, 39, 36, .35);
  display: none; z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 620px; max-width: 94vw;
  background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(43, 39, 36, .12);
  transform: translateX(100%); transition: transform .22s ease;
  display: flex; flex-direction: column; z-index: 41;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.alert.err { background: var(--cinnabar-soft); color: #8a2b1f; }
.alert.ok { background: #e6f0e8; color: #2f6b40; }
.alert.info { background: #f0ece2; color: var(--ink-soft); }

.code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; letter-spacing: 3px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 12px; margin: 0 0 20px; letter-spacing: 1px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; }

.dropzone {
  border: 1px dashed var(--gold);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  color: var(--ink-soft);
  background: #fffdf7;
  cursor: pointer;
}
.dropzone.dragover { background: #fdf6e8; }

.batch-errors { max-height: 220px; overflow: auto; }
