/* ═══════════════════════════════════════════════════════════════════
   WAREHOUSE 2.0 — SWISS EDITION
   國際主義排版風格:模塊網格 · 可見髮絲線 · 巨型數字 · 三色紀律
   紙 #F5F2EB · 墨 #141414 · 瑞士紅 #E0261C
   無圓角 · 無陰影 · 無漸變 · 結構即裝飾
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --paper:   #F5F2EB;
  --paper-2: #EFEBE1;
  --white:   #FCFBF7;
  --ink:     #141414;
  --ink-2:   #4A4740;
  --ink-3:   #85806F;
  --ink-4:   #B4AE9C;
  --red:     #E0261C;
  --red-soft:#F8E3E0;

  --rule:      #141414;                 /* 結構粗線 */
  --hair:      rgba(20,20,20,.16);      /* 髮絲線 */
  --hair-soft: rgba(20,20,20,.08);

  --ok:   #1F7A33;
  --warn: #B26B00;

  --f-text: "Inter","Helvetica Neue",Helvetica,Arial,"Noto Sans TC","PingFang TC","Microsoft JhengHei",sans-serif;
  --f-mono: "Space Grotesk","SF Mono",ui-monospace,Menlo,monospace;

  --mast-h: 100px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--f-text);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
#root { height: 100vh; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--paper); }

h1, h2, h3 { font-weight: 700; letter-spacing: -.035em; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(20,20,20,.25); }
::-webkit-scrollbar-thumb:hover { background: rgba(20,20,20,.45); }
::-webkit-scrollbar-track { background: transparent; }

/* ── 排印 ── */
.mono { font-family: var(--f-mono); }
.label {
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2);
}
.label.red { color: var(--red); }
.label.dim { color: var(--ink-3); }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }

/* ── 佈局原子 ── */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.g4{gap:4px}.g6{gap:6px}.g8{gap:8px}.g10{gap:10px}.g12{gap:12px}.g14{gap:14px}.g16{gap:16px}.g20{gap:20px}.g24{gap:24px}

/* ── 結構線 ── */
.rule-2 { border-top: 2px solid var(--rule); }
.rule-1 { border-top: 1px solid var(--hair); }

/* ── 單元格(取代卡片):透明底 + 髮絲邊界 ── */
.cell { background: transparent; }
.panel { background: var(--white); border: 1px solid var(--hair); }

/* ── 按鈕:矩形 · 描邊 · 反白懸停 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  background: transparent; color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  transition: background .14s, color .14s, border-color .14s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { background: #000; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:disabled:hover { background: transparent; color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red { border-color: var(--red); color: var(--red); }
.btn.red:hover { background: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn.lg { height: 48px; padding: 0 28px; font-size: 14px; }

/* ── 標籤:mono 方角 ── */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 21px; padding: 0 8px;
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 0;
  white-space: nowrap;
}
.tag .dot { width: 6px; height: 6px; background: currentColor; }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--red); }
.tag.plain { color: var(--ink-3); }
.tag.inv { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag.redinv { background: var(--red); color: #fff; border-color: var(--red); }

/* ── 輸入:下劃線制 ── */
.field {
  height: 44px; width: 100%; padding: 0 2px;
  background: transparent;
  border: 0; border-bottom: 1px solid var(--ink-4);
  border-radius: 0;
  font-size: 15px;
  transition: border-color .15s;
}
.field:focus { outline: none; border-bottom: 2px solid var(--ink); }
.field::placeholder { color: var(--ink-4); }
.field.boxed { border: 1px solid var(--hair); background: var(--white); padding: 0 12px; height: 40px; font-size: 13.5px; }
.field.boxed:focus { border: 1px solid var(--ink); }

/* ── 表格:年報式 ── */
.tbl2 { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl2 thead th {
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2);
  text-align: left; padding: 10px 14px;
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--hair);
  background: var(--paper);
  position: sticky; top: 0; z-index: 2;
}
.tbl2 tbody td { padding: 13px 14px; border-bottom: 1px solid var(--hair-soft); vertical-align: middle; }
.tbl2 tbody tr { transition: background .12s; }
.tbl2 tbody tr:hover { background: rgba(20,20,20,.035); }
.tbl2 tbody tr.on { background: var(--white); box-shadow: inset 3px 0 0 var(--red); }

/* ── 報頭(masthead)── */
.mast { flex-shrink: 0; background: var(--paper); position: relative; z-index: 10; }
.mast-top {
  height: 56px; display: flex; align-items: center; gap: 18px;
  padding: 0 36px;
  border-bottom: 2px solid var(--rule);
}
.mast-brand { display: flex; align-items: baseline; gap: 12px; }
.mast-brand .wordmark { font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
.mast-nav {
  height: 44px; display: flex; align-items: stretch; gap: 2px;
  padding: 0 24px;
  border-bottom: 1px solid var(--hair);
  overflow-x: auto; scrollbar-width: none;
}
.mast-nav::-webkit-scrollbar { display: none; }
.mnav {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 13px; position: relative;
  font-size: 13px; font-weight: 550; color: var(--ink-2);
  white-space: nowrap; transition: color .13s;
}
.mnav .idx { font-family: var(--f-mono); font-size: 9px; letter-spacing: .1em; color: var(--ink-4); transform: translateY(-4px); }
.mnav:hover { color: var(--ink); }
.mnav.on { color: var(--ink); font-weight: 700; }
.mnav.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; background: var(--red); }
.mnav .n-badge {
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 9.5px; font-weight: 700;
  background: var(--red); color: #fff;
}
.top-meta { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); padding: 5px 2px; border-bottom: 1px solid transparent; transition: all .13s; cursor: pointer; }
.top-meta:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ── 主區 ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.main-scroll { flex: 1; overflow-y: auto; padding: 0 36px 110px; scroll-behavior: smooth; }
.page { max-width: 1360px; margin: 0 auto; }

/* ── 頁題:編號 + 大字 ── */
.folio { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 30px 0 20px; border-bottom: 2px solid var(--rule); margin-bottom: 0; flex-wrap: wrap; }
.folio h1 { font-size: 42px; line-height: 1; letter-spacing: -.04em; }
.folio .folio-no { font-family: var(--f-mono); font-size: 11px; letter-spacing: .22em; color: var(--red); margin-bottom: 12px; }
.folio .folio-sub { font-size: 13px; color: var(--ink-3); margin-top: 12px; }

/* ── KPI 帶:巨型數字 + 豎向分格線 ── */
.kpi-band { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--hair); }
.kpi {
  padding: 26px 22px 24px; position: relative;
  border-right: 1px solid var(--hair);
  transition: background .15s;
}
.kpi:last-child { border-right: 0; }
.kpi:hover { background: rgba(20,20,20,.03); }
.kpi .k-label { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.kpi .k-value { font-family: var(--f-mono); font-size: 64px; font-weight: 700; line-height: .92; letter-spacing: -.04em; }
.kpi .k-value.red { color: var(--red); }
.kpi .k-unit { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 8px; letter-spacing: 0; }
.kpi .k-foot { margin-top: 16px; min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ── 區塊帶 ── */
.band { padding: 26px 0 30px; border-bottom: 1px solid var(--hair); }
.band-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.band-head h2 { font-size: 20px; letter-spacing: -.03em; display: flex; align-items: baseline; gap: 10px; }
.band-head h2 .bh-no { font-family: var(--f-mono); font-size: 10px; letter-spacing: .2em; color: var(--red); }
.band-head .bh-sub { font-size: 12px; color: var(--ink-3); }

/* ── 條形量表(取代環/甜甜圈)── */
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter .m-track { height: 10px; background: var(--paper-2); border: 1px solid var(--hair-soft); position: relative; }
.meter .m-fill { position: absolute; inset: 0 auto 0 0; background: var(--ink); }
.stackbar { display: flex; height: 14px; border: 1px solid var(--hair); }
.stackbar > i { display: block; height: 100%; }

/* ── 編號列表行 ── */
.ledger-row {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--hair-soft);
  transition: background .12s;
}
.ledger-row:hover { background: rgba(20,20,20,.03); }
.ledger-row .lr-idx { font-family: var(--f-mono); font-size: 11px; color: var(--ink-4); width: 26px; flex-shrink: 0; }

/* ── 篩選 chips:矩形分段 ── */
.seg { display: inline-flex; border: 1px solid var(--ink); }
.seg button { height: 32px; padding: 0 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); border-right: 1px solid var(--hair); transition: all .13s; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); background: rgba(20,20,20,.05); }
.seg button.on { background: var(--ink); color: var(--paper); }
.chip { height: 30px; padding: 0 12px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); border: 1px solid var(--hair); background: transparent; transition: all .13s; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── 進度髮絲條 ── */
.bar { height: 4px; background: var(--paper-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); transition: width .5s cubic-bezier(.22,.9,.25,1); }

/* ── 抽屜 ── */
.drawer {
  width: 372px; flex-shrink: 0; align-self: flex-start;
  position: sticky; top: 16px;
  background: var(--white); border: 1px solid var(--ink);
  animation: w2slide .3s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes w2slide { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 秘書塢 ── */
.dock {
  position: fixed; right: 28px; bottom: 28px; width: 396px; z-index: 90;
  background: var(--white); border: 1px solid var(--ink);
  animation: w2pop .28s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes w2pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.dock-fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 89;
  height: 48px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 650; letter-spacing: .02em;
  border: 1px solid var(--ink);
  transition: background .15s;
}
.dock-fab:hover { background: var(--red); border-color: var(--red); color: #fff; }
.bubble-u {
  align-self: flex-end; max-width: 86%;
  background: var(--ink); color: var(--paper);
  padding: 9px 13px; font-size: 13px; line-height: 1.55;
  animation: w2fade .2s ease both;
}
.bubble-a {
  align-self: flex-start; max-width: 94%;
  background: transparent; border-left: 2px solid var(--ink);
  padding: 4px 0 4px 13px; font-size: 13px; line-height: 1.65; color: var(--ink-2);
  animation: w2fade .2s ease both;
}
.bubble-a b { color: var(--ink); }
.dock-scroll { height: 330px; }
.dock.big { width: min(720px, calc(100vw - 56px)); }
.dock.big .dock-scroll { height: min(60vh, 620px); }

/* ── 秘書富文本(Markdown / 表格 / 公式)── */
.md { white-space: normal; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md strong, .md b { color: var(--ink); font-weight: 700; }
.md em { font-style: italic; }
.md h1, .md h2, .md h3, .md h4 {
  color: var(--ink); letter-spacing: -.02em; line-height: 1.3;
  margin: 14px 0 7px; padding-bottom: 5px;
  border-bottom: 1px solid var(--hair);
}
.md h1 { font-size: 16px; border-bottom: 2px solid var(--rule); }
.md h2 { font-size: 15px; }
.md h3 { font-size: 13.5px; }
.md h4 { font-size: 12.5px; border-bottom: 0; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md li { margin: 3px 0; }
.md a { color: var(--red); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--red); word-break: break-all; }
.md a:hover { background: var(--red-soft); }
.md code {
  font-family: var(--f-mono); font-size: 11.5px;
  background: var(--paper-2); border: 1px solid var(--hair-soft);
  padding: 1px 5px; color: var(--ink);
}
.md pre {
  margin: 0 0 8px; padding: 10px 12px; overflow-x: auto;
  background: var(--ink); border: 0;
}
.md pre code { background: transparent; border: 0; color: var(--paper); font-size: 11.5px; line-height: 1.6; padding: 0; }
.md blockquote { margin: 0 0 8px; padding: 2px 0 2px 12px; border-left: 2px solid var(--ink); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--hair); margin: 10px 0; }
.md img { max-width: 100%; border: 1px solid var(--hair); }
.md table {
  border-collapse: collapse; margin: 4px 0 10px; font-size: 12px;
  display: block; max-width: 100%; overflow-x: auto;
}
.md thead th {
  font-family: var(--f-mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
  text-align: left; padding: 6px 10px;
  border-top: 2px solid var(--rule); border-bottom: 1px solid var(--hair);
  background: var(--paper);
}
.md tbody td { padding: 6px 10px; border-bottom: 1px solid var(--hair-soft); color: var(--ink); }
.md .katex { font-size: 1.02em; }
.md .katex-display { margin: 8px 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.step-line {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .06em;
  color: var(--ink-3); padding: 1px 0;
  animation: w2fade .18s ease both;
}
@keyframes w2fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ── 動效(克制)── */
.rise { animation: w2rise .4s cubic-bezier(.22,.9,.25,1) both; }
@keyframes w2rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade { animation: w2fade .25s ease both; }
.blink-dot { width: 8px; height: 8px; background: var(--red); animation: w2blink 1.6s steps(2, start) infinite; }
@keyframes w2blink { to { visibility: hidden; } }

/* ── 登入:海報 ── */
.login-wrap { display: flex; height: 100vh; }
.login-art {
  flex: 1.2; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 52px;
  background: var(--paper);
  border-right: 2px solid var(--rule);
}
.login-grid { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--hair-soft) 1px, transparent 1px), linear-gradient(90deg, var(--hair-soft) 1px, transparent 1px);
  background-size: 72px 72px;
}
.login-art h1 { font-size: clamp(48px, 5.8vw, 94px); line-height: 1.08; letter-spacing: -.05em; position: relative; z-index: 2; }
.login-art h1 .hollow { color: transparent; -webkit-text-stroke: 2px var(--ink); }
.login-art .red-block { width: 88px; height: 26px; background: var(--red); position: relative; z-index: 2; }
.login-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--paper); overflow-y: auto; }
.login-card { width: min(380px, 100%); }

@media (max-width: 1100px) {
  .login-art { display: none; }
  .drawer { display: none; }
  .kpi-band { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: 0; }
}
