:root {
  --paper: #f4f1e8;
  --card: #fffdf7;
  --ink: #1b1917;
  --ink-2: #3d382f;
  --muted: #736b5d;
  --rule: #ded5c3;
  --rule-soft: #ece5d7;
  --red: #ad3a25;
  --red-soft: #fbeee9;
  --teal: #14615b;
  --teal-soft: #e8f1ef;
  --hl: #f7f0dd;
  --shadow: 0 1px 0 #fff, 0 2px 10px rgba(60, 48, 30, .07);
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 105, 80, .035) 0 1px, transparent 1px 4px);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: .01em;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------- 顶栏 ---------- */
.head { position: sticky; top: 0; z-index: 30; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px;
  padding: 14px clamp(14px, 4vw, 40px);
  background: linear-gradient(180deg, #22201c 0%, #2b2823 100%);
  color: #f3ede0;
  border-bottom: 3px solid var(--red);
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 340px; }

.mark {
  flex: none;
  writing-mode: vertical-rl;
  font-family: var(--serif);
  font-size: 15px; letter-spacing: .3em;
  padding: 8px 5px;
  color: #f6e7d8;
  background: var(--red);
  border-radius: 2px;
}

.brand-txt { min-width: 0; }
.brand-txt h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(17px, 2.3vw, 22px);
  font-weight: 600; letter-spacing: .04em;
}
.brand-txt p { margin: 3px 0 0; font-size: 12.5px; color: #bdb2a0; letter-spacing: .02em; }

/* ---------- 汇总数字（吸顶行右侧） ---------- */
.ledger {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 0 auto; padding: 0;
}
.led {
  display: flex; align-items: baseline; gap: 7px;
  padding: 4px 11px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 3px solid #b6ab93;
  border-radius: 2px;
  white-space: nowrap;
}
.led dt { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; }
.led dd { margin: 0; font-size: 15.5px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.led .flag { font-family: var(--sans); font-size: 10.5px; font-weight: 400; color: var(--red); letter-spacing: 0; }
.led.over { border-color: rgba(173, 58, 37, .35); border-left-color: var(--red); background: var(--red-soft); }
.led.over dd { color: var(--red); }

/* ---------- tab ---------- */
.tabbar {
  display: flex; align-items: stretch; gap: 6px;
  padding: 0 clamp(14px, 4vw, 40px);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 6px 12px -10px rgba(60, 48, 30, .5);
}

.tab {
  appearance: none;
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
  margin-bottom: -1px;
  padding: 11px 18px 12px;
  font-family: var(--sans); font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 3px solid transparent;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  text-align: left;
  transition: color .15s, background .15s, border-color .15s;
}
.tab:hover { color: var(--ink-2); background: rgba(255, 253, 247, .7); }
.tab:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.tab-no {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 2px 6px; border-radius: 2px;
  color: #fff; background: #b3a992;
}
.tab-txt { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.tab-txt small {
  font-size: 11.5px; color: inherit; opacity: .72;
  font-family: var(--mono); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--card);
  border-color: var(--rule);
  border-bottom-color: var(--card);
  box-shadow: inset 0 3px 0 var(--red);
  font-weight: 600;
}
.tab[aria-selected="true"] .tab-no { background: var(--red); }

/* ---------- 主体 ---------- */
main { padding: clamp(18px, 3.4vw, 34px) clamp(14px, 4vw, 40px) 10px; max-width: 1240px; margin: 0 auto; }
.panel[hidden] { display: none; }

.lede {
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--teal);
  border-radius: 3px;
  box-shadow: var(--shadow);
}
.lede p { margin: 0 0 8px; }
.lede p:last-child { margin-bottom: 0; }
.lede .warn-inline {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--rule);
  color: var(--ink-2);
}
.lede strong { color: var(--ink); }

.blk { margin-top: 26px; }

.blk > h2 {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px;
  padding-bottom: 8px;
  font-family: var(--serif);
  font-size: 19px; font-weight: 600; letter-spacing: .03em;
  border-bottom: 2px solid var(--ink);
}
.blk > h2 .no {
  flex: none;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 2px 7px; border-radius: 2px;
  color: #fff; background: var(--ink);
  transform: translateY(-2px);
}
.blk > h2 small {
  font-family: var(--sans); font-size: 12.5px; font-weight: 400;
  color: var(--muted); letter-spacing: .02em;
}
.blk > h2 .amt {
  margin-left: auto;
  font-family: var(--mono); font-size: 18px; font-weight: 700; font-style: normal;
  color: var(--red); letter-spacing: -.02em;
}
.blk > h2 .amt::before { content: "¥"; font-size: 12px; margin-right: 2px; opacity: .6; }

/* ---------- 表格 ---------- */
.tbl-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.tbl { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 13.8px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule-soft); }
.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  font-size: 11.5px; font-weight: 600; letter-spacing: .1em;
  color: #5c5446; text-transform: none;
  background: var(--hl);
  border-bottom: 1.5px solid var(--rule);
  white-space: nowrap;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #fbf7ec; }
.tbl td:first-child { font-weight: 600; color: var(--ink); }

.c-money { text-align: right; white-space: nowrap; }
.c-qty { white-space: nowrap; color: var(--muted); }
.c-idx { width: 34px; text-align: center; color: var(--muted); }
.c-cat { width: 130px; }
.c-when { width: 168px; }

.tbl .hz-cell { border-left: 2px solid var(--teal-soft); background: rgba(20, 97, 91, .028); color: var(--ink-2); }

.tbl tr.sub td {
  font-weight: 700; color: var(--ink);
  background: var(--hl);
  border-top: 1.5px solid var(--rule);
}
.tbl tr.sub .c-money { color: var(--red); font-size: 15px; }
.tbl tr.grand td {
  font-family: var(--serif);
  font-size: 16px; font-weight: 700;
  color: #fff; background: var(--ink);
  border: none;
}
.tbl tr.grand .c-money { color: #ffcbb8; font-family: var(--mono); font-size: 19px; }
.tbl tr.cut td { color: var(--muted); background: #faf7f0; }
.tbl tr.cut td:first-child del { color: #a2988a; }
.tbl tr.key td { background: rgba(173, 58, 37, .045); }
.tbl tr.new td { background: rgba(20, 97, 91, .05); }

.tbl.adapt td:nth-child(2) { width: 168px; }
.tbl.summary td:nth-child(2) { width: 108px; }

.delta { display: block; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; }
.delta.up { color: var(--red); }
.delta.down { color: var(--teal); }
.delta.flat { color: var(--muted); font-family: var(--sans); }
.chg-up { color: var(--red); }
.chg-down { color: var(--teal); }

.tag {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 2px;
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  letter-spacing: .06em; vertical-align: 2px; white-space: nowrap;
}
.tag.red { color: #fff; background: var(--red); }
.tag.hz { color: #fff; background: var(--teal); }

/* ---------- 备注 ---------- */
.note {
  margin: 10px 0 0;
  padding: 10px 14px 10px 16px;
  font-size: 13.4px; color: var(--ink-2);
  background: rgba(255, 253, 247, .78);
  border-left: 3px solid var(--rule);
  border-radius: 0 3px 3px 0;
}
.note + .note { margin-top: 6px; }
.note.red-line {
  color: #6d2415;
  background: var(--red-soft);
  border-left-color: var(--red);
}
.note strong { color: inherit; }

/* ---------- 拍板项 ---------- */
.decide { margin: 0; padding: 0; list-style: none; counter-reset: d; }
.decide > li {
  position: relative;
  margin-bottom: 10px;
  padding: 14px 18px 14px 56px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--red);
  border-radius: 3px;
  box-shadow: var(--shadow);
  counter-increment: d;
}
.decide > li::before {
  content: counter(d, cjk-decimal);
  position: absolute; left: 16px; top: 13px;
  font-family: var(--serif); font-size: 22px; font-weight: 600;
  color: var(--red); opacity: .55;
}
.decide h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.decide p { margin: 0 0 6px; font-size: 13.8px; color: var(--ink-2); }
.decide ul { margin: 4px 0 8px; padding-left: 20px; font-size: 13.8px; color: var(--ink-2); }
.decide li:last-child { margin-bottom: 0; }

/* ---------- 页脚 ---------- */
.foot {
  max-width: 1240px;
  margin: 34px auto 0;
  padding: 18px clamp(14px, 4vw, 40px) 40px;
  border-top: 1px solid var(--rule);
  font-size: 12.4px; color: var(--muted);
}
.foot p { margin: 0 0 6px; }
.foot strong { color: var(--ink-2); }

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .led:not(.over) { display: none; }
}

@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 12px 14px; }
  .tabbar { padding: 0 10px; gap: 4px; }
  .tab { flex: 1 1 0; padding: 9px 10px 10px; gap: 7px; }
  .tab-txt small { display: none; }
  .ledger { gap: 6px; }
  .led { padding: 3px 8px; gap: 5px; }
  .led dt { font-size: 9.5px; }
  .led dd { font-size: 13.5px; }
  main { padding: 16px 14px 6px; }
  .tbl { min-width: 560px; font-size: 13px; }
  .tbl th, .tbl td { padding: 8px 9px; }
  .blk > h2 { font-size: 17px; }
  .blk > h2 .amt { font-size: 16px; }
}

@media (max-width: 760px) {
  .led:not(.over) { display: none; }
  .led .flag { display: none; }
}

@media (max-width: 560px) {
  .mark { display: none; }
  .brand-txt h1 { font-size: 16px; }
}

@media print {
  .head, .tabbar { position: static; }
  .panel[hidden] { display: block; }
  body { background: #fff; }
  .tbl-wrap, .lede, .decide > li { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
