/* 工商獎金封閉網站 — 設計系統：精緻極簡 / 編輯式
   暖紙背景 + 墨黑字 + 藍黑 accent + 五狀態語意色票。對比 ≥4.5:1，8px 節奏。 */

:root {
  --paper:      #faf8f4;
  --paper-2:    #f3efe7;
  --ink:        #1a1a1a;
  --ink-soft:   #4a4742;
  --muted:      #7c776e;
  --line:       #e5e0d6;
  --line-soft:  #efebe2;
  --accent:     #1f3a5f;   /* 藍黑 */
  --accent-2:   #2f5a8f;

  /* 狀態色票（文字色 / 底色） */
  --s-prog:   #9a6a00;  --s-prog-bg:   #fbf2dd;
  --s-pay:    #1f6e45;  --s-pay-bg:    #e4f1ea;
  --s-review: #b23c0c;  --s-review-bg: #fbe9df;
  --s-exempt: #6f6a62;  --s-exempt-bg: #eeebe4;
  --s-paid:   #1a5f8f;  --s-paid-bg:   #e3eef7;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(26,26,26,.04), 0 6px 22px rgba(26,26,26,.05);
  --serif: "Noto Serif TC", Georgia, "Songti TC", serif;
  --sans:  "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;

  /* 側邊工作列（興達品牌深藍+金，沿用 DESIGN.md） */
  --nav-w:      240px;
  --nav-bg:     #0F1A2E;   /* 深夜藍底 */
  --nav-bg-2:   #1E3366;   /* hover / active 區塊 */
  --nav-fg:     #cdd6e6;   /* 側欄淺字 */
  --nav-fg-on:  #ffffff;   /* active 字 */
  --nav-accent: #B68A36;   /* 金，active 左條 / icon 高亮 */
  --nav-line:   rgba(255,255,255,.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ── 左側工作列 sidebar ── */
.sidebar {
  position: fixed; left: 0; top: 0; width: var(--nav-w); height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto;
  background: var(--nav-bg); color: var(--nav-fg); z-index: 30;
}
.sidebar .brand { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: .5px;
  color: #fff; height: 64px; padding: 0 18px; display: flex; flex-direction: column;
  justify-content: center; border-bottom: 1px solid var(--nav-line); }
.sidebar .brand small { display:block; font-family: var(--sans); font-weight: 400; font-size: 10.5px;
  letter-spacing: 2px; text-transform: uppercase; color: #8a97ad; margin-top: 3px; }
.sidenav { flex: 1 1 auto; padding: 10px 10px 6px; }
.nav-grp { font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase;
  color: #7f8da3; font-weight: 700; padding: 14px 10px 6px; }
.nav-grp:first-child { padding-top: 4px; }
.sidenav a, .nav-act {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; margin: 1px 0;
  border-radius: 8px; color: var(--nav-fg); font-size: 14.5px; line-height: 1.2;
  border-left: 2px solid transparent;
}
.sidenav a:hover, .nav-act:hover { background: var(--nav-bg-2); color: #fff; text-decoration: none; }
.sidenav a.on { background: var(--nav-bg-2); color: var(--nav-fg-on); font-weight: 600;
  border-left: 2px solid var(--nav-accent); }
.nico { flex: 0 0 auto; display: inline-flex; color: #8a97ad; }
.sidenav a:hover .nico, .nav-act:hover .nico { color: #cdd6e6; }
.sidenav a.on .nico { color: var(--nav-accent); }
.ntxt { flex: 1 1 auto; }
.nav-badge { flex: 0 0 auto; margin-left: auto; min-width: 18px; text-align: center;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--nav-accent); color: #1a1306; }
.nav-foot { border-top: 1px solid var(--nav-line); padding: 8px 10px 12px; }
.nav-meta { font-size: 11px; color: #7f8da3; padding: 6px 11px 8px; line-height: 1.5; }

/* 漢堡鈕 + 遮罩（窄螢幕才出現） */
.nav-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 35;
  width: 42px; height: 42px; align-items: center; justify-content: center;
  background: var(--nav-bg); color: #fff; border: 1px solid var(--nav-line);
  border-radius: 10px; cursor: pointer; box-shadow: var(--shadow); }
.nav-scrim { display: none; position: fixed; inset: 0; z-index: 29;
  background: rgba(15,26,46,.45); }

/* ── 兩欄主版面（限寬+置中只在登入態的 sidebar 版面套用；登入頁走 .login-shell）── */
.has-sidebar .site-main { margin-left: var(--nav-w); }
.has-sidebar .content-inner { max-width: 1180px; margin: 0 auto; padding: 22px 28px 8px; }

/* 內容頂部橫幅：與側欄品牌帶同高(64px)、底線貫穿整個頂部 */
.topbar { position: sticky; top: 0; z-index: 25; height: 64px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; padding: 0 28px; background: var(--paper);
  border-bottom: 1px solid var(--line); }
.topbar-title { font-family: var(--serif); font-weight: 700; font-size: 19px;
  color: var(--ink); letter-spacing: .3px;
  /* flex item 預設 min-width:auto，但中文每個字都是合法斷點，所以被擠窄時
     不會溢出、而是一個字一行直排下來。寬螢幕不留退路：寧可切字尾也不要直排。 */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-meta { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); }
/* 快照過舊警示。樣式放這裡而不是 inline：inline style 贏過 media query，
   放 inline 就沒辦法在手機上把 nowrap 拿掉（2026-09-05 修）。 */
.snap-warn { background: #fff3cd; border: 1px solid #e2c15a; color: #7a5b00;
  padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
/* 連結整塊不斷行：它是要點的東西，換行時「立即重讀」與「→」被拆成兩行既難讀、
   點擊區也被切成兩塊。文字可以換行，這一顆不行。 */
.snap-warn a { margin-left: 6px; font-weight: 700; color: #7a5b00; white-space: nowrap; }

/* ── 頁首 ── */
.page-head { padding: 34px 0 18px; }
.kicker { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.page-head h1 { font-family: var(--serif); font-size: 34px; margin: 6px 0 4px; font-weight: 700; line-height: 1.15; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }
.page-title { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1.15;
  margin: 4px 0 4px; }
.muted { color: var(--muted); font-size: 14px; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ── 統計卡（分群導覽）── */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 22px 0 8px; }
.stat {
  display: block; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.stat:hover { transform: translateY(-2px); text-decoration: none; border-color: var(--accent); }
.stat.on { border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--ink) inset, var(--shadow); }
.stat .n { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1; }
.stat .l { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.stat .dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align: 1px; }

/* ── 狀態 pill ── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill .g { font-size: 12px; }
.st-prog   { color: var(--s-prog);   background: var(--s-prog-bg); }
.st-pay    { color: var(--s-pay);    background: var(--s-pay-bg); }
.st-review { color: var(--s-review); background: var(--s-review-bg); }
.st-exempt { color: var(--s-exempt); background: var(--s-exempt-bg); }
.st-paid   { color: var(--s-paid);   background: var(--s-paid-bg); }
.dot-prog{background:var(--s-prog)} .dot-pay{background:var(--s-pay)}
.dot-review{background:var(--s-review)} .dot-exempt{background:var(--s-exempt)} .dot-paid{background:var(--s-paid)}

/* ── 表格 ── */
.card { background:#fff; border:1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin: 16px 0; }
.card-head { display:flex; justify-content:space-between; align-items:center;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.card-head h2 { font-family: var(--serif); font-size: 18px; margin: 0; font-weight: 700; }
.card-head .meta { font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; font-size: 14px; }
thead th { font-size: 11.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
tbody tr { border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--paper); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.client { font-weight: 600; }
.tasktitle { color: var(--muted); font-size: 13px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.arrow { color: var(--muted); padding: 0 4px; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }

/* ── 按鈕 / 表單 ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14px; font-family: var(--sans); cursor: pointer; min-height: 38px; }
.btn:hover { background: var(--paper-2); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; font-family: var(--sans); background: #fff; color: var(--ink); min-height: 42px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
label { font-size: 13px; color: var(--ink-soft); font-weight: 600; display:block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* ── flash ── */
.flash { background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 8px;
  margin: 14px 0; font-size: 14px; }

/* ── 登入頁 ── */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 36px 32px; }
.login-card .kicker { text-align:center; }
.login-card h1 { font-family: var(--serif); font-size: 26px; text-align: center; margin: 8px 0 24px; }
.login-card .btn-primary { width: 100%; justify-content: center; }

/* ── 每人彙總 ── */
.bar-row { display:grid; grid-template-columns: 120px 1fr 90px; gap: 12px; align-items:center;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.bar-track { background: var(--paper-2); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-name { font-weight: 600; }
/* R7：有來源明細時，分隔線移到明細之後，小字與 bar/線分離不擁擠 */
.bar-row.has-src { border-bottom: 0; padding-bottom: 6px; }
.bar-src { font-size: 12px; color: var(--muted); line-height: 1.7;
  margin: 0 0 0 4px; padding-bottom: 13px; border-bottom: 1px solid var(--line-soft); }

/* ── 明細頁 ── */
.detail-grid { display:grid; grid-template-columns: repeat(2,1fr); gap: 0; }
.detail-grid .dt { padding: 14px 18px; border-bottom:1px solid var(--line-soft); }
.detail-grid .dt:nth-child(odd){ border-right:1px solid var(--line-soft); }
.dt .k { font-size:12px; letter-spacing:1px; text-transform:uppercase; color:var(--muted); }
.dt .v { font-size:18px; font-family:var(--serif); margin-top:4px; }

/* ── 讀取中 loading ── */
.loading-wrap { max-width: 520px; margin: 12vh auto; text-align: center; padding: 0 20px; }
.loading-wrap h1 { font-family: var(--serif); font-size: 26px; margin: 18px 0 8px; }
.loading-wrap p { color: var(--muted); font-size: 14px; line-height: 1.7; }
.spinner { width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: var(--paper-2); border-radius: 999px; overflow: hidden; margin: 22px 0 10px; }
.progress-bar { height: 100%; width: 40%; background: var(--accent); border-radius: 999px;
  animation: indet 1.3s ease-in-out infinite; }
@keyframes indet {
  0%   { margin-left: -40%; width: 40%; }
  50%  { margin-left: 30%;  width: 55%; }
  100% { margin-left: 100%; width: 40%; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner, .progress-bar { animation-duration: 2.4s; }
}

/* ── 本月結算進度（guided-monthly-settlement）── */
.settle { background:#fff; border:1px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin: 0 0 18px; }
.settle-kicker { font-size: 11px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.settle-steps { display:flex; align-items:center; gap: 8px; flex-wrap: wrap; }
.sstep { display:inline-flex; align-items:center; gap:7px; padding: 9px 14px;
  border:1px solid var(--line); border-radius: 999px; font-size: 14.5px; color: var(--ink);
  background: var(--paper); font-weight: 600; }
.sstep:hover { text-decoration:none; border-color: var(--accent); }
.sstep b { font-family: var(--serif); font-size: 18px; color: var(--s-review); }
.sstep .sn { color: var(--muted); font-weight: 400; }
.sstep.sdone { color: var(--muted); background:#fff; border-style: dashed; }
.sstep.sdone b { color: var(--s-pay); }
.sstep.sdone b::after { content: " ✓"; font-size: 13px; }
.sstep.son { border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--ink) inset; }
.sstep.sgoal { background:#fff; border-style: dashed; color: var(--muted); font-weight: 400; }
.sarrow { color: var(--muted); }
.settle-cta { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 14.5px; color: var(--ink-soft); display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.settle-done { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--s-pay);
  padding: 6px 0; }

/* 做事區內的工作分群卡 */
.stats.work { grid-template-columns: repeat(4, 1fr); margin: 14px 0 2px; }

/* 查看區（已算好的結果，純查看）：分群卡降為次要 */
.zone-view { background: var(--paper-2); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 12px 16px 14px; margin: 0 0 18px; }
.zone-label { font-size: 12px; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; }
.stats.secondary { gap: 10px; margin: 10px 0 0; }
.stats.secondary .stat { padding: 10px 14px; box-shadow: none; }
.stats.secondary .stat .n { font-size: 22px; }
.stats.secondary .stat .l { font-size: 12px; margin-top: 3px; }

/* 清單卡標題的做事/查看標籤 */
.zone-tag { display:inline-block; font-family: var(--sans); font-size: 11.5px; font-weight: 700;
  letter-spacing: 1px; padding: 3px 9px; border-radius: 999px; vertical-align: 2px; margin-right: 8px; }
.zone-tag.work { color: var(--s-review); background: var(--s-review-bg); }
.zone-tag.view { color: var(--s-paid); background: var(--s-paid-bg); }

/* 結構化操作回饋 flash */
.flash-progress { background: var(--s-pay); display:flex; align-items:center; gap: 8px; flex-wrap: wrap; }
.flash-progress .sep-dot { opacity:.7; }
.flash-progress .next-link { color:#fff; text-decoration: underline; font-weight: 700; }

/* 案件頁：情境化主動作橫幅 */
.act { border-radius: var(--radius); padding: 16px 18px; margin: 0 0 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow); }
.act-warn { background: var(--s-prog-bg); border-color: #e8c87a; }
.act-go   { background: var(--s-pay-bg);  border-color: #9ec9b0; }
.act-ok   { background: var(--s-paid-bg); border-color: #a9c8e0; }
.act-title { font-family: var(--serif); font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.act-body { font-size: 14.5px; color: var(--ink-soft); margin-bottom: 12px; }
.act-actions { display:flex; align-items:flex-end; gap: 10px; flex-wrap: wrap; }

/* 案件頁：工具卡收合（details）——標題常駐、預設收合、不藏功能 */
details.tool > summary { list-style: none; cursor: pointer; display:flex; align-items:center;
  justify-content: space-between; padding: 14px 18px; gap: 12px; }
details.tool > summary::-webkit-details-marker { display: none; }
details.tool > summary h2 { font-family: var(--serif); font-size: 17px; margin: 0; font-weight: 700; }
details.tool > summary::after { content: "展開 ▾"; font-size: 12.5px; color: var(--accent); white-space: nowrap; }
details.tool[open] > summary::after { content: "收合 ▴"; }
details.tool[open] > summary { border-bottom: 1px solid var(--line-soft); }
details.tool > summary:hover { background: var(--paper); }

footer.foot { color: var(--muted); font-size: 12px; text-align:center; padding: 30px 0 40px; }

/* ── 響應式 ── */
@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .page-head h1 { font-size: 27px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .dt:nth-child(odd){ border-right:0; }
  .hide-sm { display: none; }
  th, td { padding: 10px 12px; }
}
@media (max-width: 820px) {
  /* 系統內容多：寬表格在手機可橫向捲動，不再被 card 裁切 */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card > table { min-width: 540px; }
  /* 表單欄位在手機改為每行單欄、輸入框滿版好點按 */
  .inline-form { gap: 10px; }
  .inline-form > div { flex: 1 1 100%; min-width: 0; }
  .inline-form > div input, .inline-form > div select { width: 100%; }
}
/* 窄螢幕（筆電分割視窗 / 平板 / 手機）：側欄收為漢堡抽屜 */
@media (max-width: 899px) {
  .has-sidebar .site-main { margin-left: 0; }
  .has-sidebar .content-inner { padding: 18px 16px 8px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-toggle { display: inline-flex; }
  body.nav-open .nav-toggle { display: none; }
  body.nav-open .nav-scrim { display: block; }
  /* 漢堡鈕佔住左上角，頂部橫幅標題左側讓出空間避免被蓋 */
  .topbar { padding-left: 64px; }

  /* 手機：標題與快照警示改成上下兩列，不要擠在同一列互搶寬度。
     原本兩者同列，而警示是 nowrap、又長，flex 把寬度全給了它，
     標題被壓成 0 寬 → 中文逐字換行變成直排，還因為 height:64px 固定而溢出、
     蓋到下面的「上帝視角」那一行（2026-09-05 Vic 手機截圖回報）。 */
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap;
    align-items: center; padding-top: 10px; padding-bottom: 10px; row-gap: 8px; }
  .topbar-title { flex: 1 1 100%; font-size: 17px; }
  /* ⚠️ 這一列**不可以**用負 margin 去搶回 padding-left 的 64px。
     漢堡鈕是 position:fixed（top:12 left:12，42×42），佔的是 y 12–54，
     而第二列大約落在 y 44–70——**兩者垂直是重疊的**。
     拉到 x=0 就等於把警示塞到漢堡鈕底下，⚠ 與前幾個字被蓋掉
     （2026-09-05 第一版就是這樣，Vic 手機截圖回報「跑到左邊了」）。
     寧可窄 64px：≤480px 時它本來就會換行。 */
  .topbar-meta { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .page-head { padding: 22px 0 14px; }
  .bar-row { grid-template-columns: 92px 1fr 78px; gap: 8px; }
  /* 窄到這裡時警示本身也放不下一整行了：准它換行，否則會撐出橫向捲動。
     「立即重讀」那顆是要點的，寧可多佔一行也不能被推到畫面外。 */
  .snap-warn { white-space: normal; display: inline-block; line-height: 1.5; }
}
