/* =========================================================
   TAS 總務處業務系統 — 介面樣式
   版面比照電腦教室管理系統（CRM）：頂部工具列＋左側選單＋高密度卡片內容。
   配色採長庚大學授權網站的長庚橘；預設深色，可切淺色或跟隨系統。
   主色色碼集中在下方 --accent 系列，如需與授權網站逐色對齊只改這裡。
   ========================================================= */
:root {
  --bg: #f6f3ee; --chrome: #ffffff;
  --surface: #ffffff; --surface-2: #f3efe8; --surface-3: #ebe5db;
  --ink: #1f1a16; --ink-2: #4d453e; --ink-3: #857a70;
  --line: #e6dfd4; --line-2: #d6cdbf;
  --rack: #2b231d; --rack-2: #3a3029; --rack-ink: #f1e8df; --rack-ink-2: #b3a597;
  /* 主色：長庚橘 */
  --accent: #e0651b; --accent-2: #c45412; --accent-ink: #ffffff; --accent-soft: #fde9dc; --accent-text: #c45412;
  --ok: #1f8a4c; --ok-soft: #e1f3e8;
  --bad: #c63b32; --bad-soft: #fbe3e0;
  --warn: #b7791f; --warn-soft: #fbf0d9;
  --new: #2563eb; --new-soft: #e3ecfd;
  --review: #7c3aed; --review-soft: #efe7fd;
  --track: #0f766e; --track-soft: #dcf2ef;
  --radius: 8px; --radius-sm: 6px;
  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 32px -16px rgba(0,0,0,.3);
  --sans: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --top-h: 52px; --side-w: 236px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110f; --chrome: #1c1815;
    --surface: #1c1815; --surface-2: #25201c; --surface-3: #2f2924;
    --ink: #f0e9e2; --ink-2: #c4b8ad; --ink-3: #8f8379; --line: #342d27; --line-2: #43392f;
    --accent: #f28a3c; --accent-2: #f7a463; --accent-ink: #241204; --accent-soft: #3a2414; --accent-text: #f28a3c;
    --ok: #4cc28a; --ok-soft: #13301f; --bad: #ef7a6f; --bad-soft: #3a1c19; --warn: #e3a94b; --warn-soft: #33270f;
    --new: #7aa7ff; --new-soft: #17243f; --review: #b794f6; --review-soft: #2a1d45; --track: #4fd1c5; --track-soft: #0f2d2a;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 12px 32px -16px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14110f; --chrome: #1c1815;
  --surface: #1c1815; --surface-2: #25201c; --surface-3: #2f2924;
  --ink: #f0e9e2; --ink-2: #c4b8ad; --ink-3: #8f8379; --line: #342d27; --line-2: #43392f;
  --accent: #f28a3c; --accent-2: #f7a463; --accent-ink: #241204; --accent-soft: #3a2414; --accent-text: #f28a3c;
  --ok: #4cc28a; --ok-soft: #13301f; --bad: #ef7a6f; --bad-soft: #3a1c19; --warn: #e3a94b; --warn-soft: #33270f;
  --new: #7aa7ff; --new-soft: #17243f; --review: #b794f6; --review-soft: #2a1d45; --track: #4fd1c5; --track-soft: #0f2d2a;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 12px 32px -16px rgba(0,0,0,.8);
  color-scheme: dark;
}

/* ---------- 基礎 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono, .num { font-family: var(--mono); font-feature-settings: "tnum"; }
.num { font-size: .95em; }
.ic { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------- 版面：頂部工具列 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; gap: 10px; padding: 0 16px 0 10px;
  background: var(--chrome); border-bottom: 1px solid var(--line);
}
.tb-burger {
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 6px; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: var(--ink-2);
}
.tb-burger:hover { background: var(--surface-2); color: var(--ink); }
.tb-brand { display: flex; align-items: center; gap: 9px; color: var(--accent); text-decoration: none; font-weight: 700; font-size: 16.5px; white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; flex: none; border-radius: 7px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 15px; line-height: 1;
}
.ver-chip {
  margin-left: 2px; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-3); font: 600 10.5px/1.7 var(--mono);
}
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13.5px; }
.tb-user { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.tb-user b { font-weight: 500; }
.tb-role { padding: 1px 8px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; }
.tb-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.tb-link:hover { color: var(--accent); }
.tb-logout .btn { min-height: 32px; padding: 0 14px; font-weight: 600; border-color: var(--ink-2); background: transparent; }
.tb-logout .btn:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

/* ---------- 版面：左側選單 ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
body.nav-collapsed .app { grid-template-columns: 0 minmax(0, 1fr); }
body.nav-collapsed .sidebar { visibility: hidden; }
.sidebar {
  position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--chrome); border-right: 1px solid var(--line); padding: 8px 0 12px;
}
.nav { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.nav-group { font-size: 11.5px; color: var(--ink-3); padding: 14px 18px 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px 9px 15px; border-left: 3px solid transparent;
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.nav a .ic { color: var(--ink-2); }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--surface-3); color: var(--accent); border-left-color: var(--accent); }
.nav a.active .ic { color: var(--accent); }
.nav a .count { margin-left: auto; font: 600 11.5px/1.6 var(--mono); padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.side-theme { border-top: 1px solid var(--line); padding: 10px 14px 0; }
.side-theme .lbl { font-size: 11.5px; color: var(--ink-3); margin-bottom: 6px; }
.side-theme .seg { display: flex; }
.side-theme .seg button { flex: 1; padding: 4px 4px; font-size: 12px; white-space: nowrap; }
.side-theme .seg button.on { color: var(--accent); font-weight: 600; background: var(--surface); }
.nav-scrim { display: none; }

/* ---------- 版面：內容區 ---------- */
.main { min-width: 0; padding: 18px 22px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0; line-height: 1.3; }
.page-head p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.eyebrow { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }

/* ---------- 卡片與格線 ---------- */
.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.card .sub { color: var(--ink-3); font-size: 13px; margin: 0 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.stat .k { font-size: 12.5px; color: var(--ink-3); }
.stat .v { font-family: var(--mono); font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty .big { font-family: var(--mono); font-size: 56px; font-weight: 600; color: var(--ink-3); line-height: 1; }

/* ---------- 小工具 ---------- */
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; margin-bottom: 12px; }
.inline { display: inline; margin: 0; }
.narrow { max-width: 560px; }
.grow { flex: 1; min-width: 160px; }
.w-auto { width: auto; }
.mt { margin-top: 16px; }
.flash-gap { margin-bottom: 16px; }
#main > .card, #main > form.card, #main > .grid { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); } .warn-text { color: var(--warn); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { min-height: 44px; padding: 0 18px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .ic { width: 16px; height: 16px; }

/* 中／EN 切換 */
.seg { display: inline-flex; padding: 2px; border-radius: 7px; background: var(--surface-3); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 3px 10px; border-radius: 5px; font-size: 12.5px; cursor: pointer; color: var(--ink-3); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.6;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before, .badge:empty::before { display: none; }

/* ---------- 訊息 ---------- */
.callout {
  padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); font-size: 14px;
  border-left: 3px solid var(--ink-3);
}
.callout.info { border-left-color: var(--accent); background: var(--accent-soft); color: var(--ink); border-color: transparent; border-left-color: var(--accent); }
.callout.ok { border-color: transparent; border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.callout.bad { border-color: transparent; border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.callout.warn { border-color: transparent; border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.callout ul { margin: 0; padding-left: 18px; }
.empty-hide:empty, .callout:empty, .validation-summary-valid { display: none; }

/* ---------- 表單 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field.check { justify-content: flex-end; }
.field.check label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); min-height: 38px; }
.input {
  width: 100%; min-height: 38px; padding: 7px 11px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.big { font-size: 16px; min-height: 46px; }
select.input { padding-right: 30px; }
.err, .field-validation-error { font-size: 12.5px; color: var(--bad); }
.input-validation-error { border-color: var(--bad) !important; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; padding: 0; }
.card.table-wrap { padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3);
  background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.row { display: table-cell; }
.table td.row > * { margin-right: 4px; }
.pager { margin-top: 10px; }


/* =========================================================
   登入閘門：比照長庚大學授權網站的單欄登入卡，配色與登入後相同（StockAI 青綠）。
   ========================================================= */
.gate {
  --intro: var(--surface-2);
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 32px 20px;
  background: var(--bg); color: var(--ink);
}
.gate-shell {
  width: min(460px, 100%);
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  background: var(--surface);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .45);
}
.gate-main { padding: 30px 34px 22px; display: flex; flex-direction: column; }

/* 頂部：系統標誌與語言切換 */
.gate-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--line);
}
.gate-logo { display: flex; align-items: center; gap: 14px; min-width: 0; }
.gate .brand-mark {
  width: 52px; height: 52px; flex: none; border-radius: 14px;
  display: grid; place-items: center;
  border: 2px solid var(--accent); color: var(--accent-text); background: var(--accent-soft);
  font-weight: 700; font-size: 26px; line-height: 1;
}
.gate-name { font-size: 21px; font-weight: 700; line-height: 1.3; }
.gate-sub { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.gate-sub.en { color: var(--ink-3); font-size: 12.5px; }
.gate-lang { flex: none; }
.gate .seg { background: var(--surface-2); border: 1px solid var(--line); }
.gate .seg button { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; padding: 4px 12px; color: var(--ink-3); }
.gate .seg button.on { background: var(--surface-3); color: var(--ink); font-weight: 600; box-shadow: none; }
.gate .seg .ic { width: 14px; height: 14px; }

/* 表單 */
.gate-card { flex: 1; }
.gate-title { font-size: 24px; font-weight: 700; margin: 0; line-height: 1.35; }
.gate-lead { font-size: 14.5px; color: var(--ink-3); margin: 4px 0 22px; }
.gate-card form { display: flex; flex-direction: column; }
.gate .label { display: block; font-size: 16.5px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.gate .input { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; color: var(--ink); }
.gate .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.gate .gate-input { min-height: 50px; font-size: 17px; padding: 12px 15px; }
.gate-gap { margin-top: 18px; }
.gate .err { display: block; font-size: 13px; margin-top: 5px; color: var(--bad); }
.gate .gate-rule { margin-top: 6px; }
.gate-msg { margin: 14px 0 0; padding: 10px 12px; border-radius: 9px; font-size: 14px; line-height: 1.6; }
.gate-msg.bad { background: var(--bad-soft); color: var(--bad); }
.gate-msg ul { margin: 0; padding-left: 18px; }
.gate-msg:empty, .gate-msg.validation-summary-valid { display: none; }
.gate .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.gate .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.gate .gate-go { width: 100%; min-height: 54px; margin-top: 26px; font-size: 17px; font-weight: 700; border-radius: 10px; letter-spacing: .08em; }
.gate-notes { margin: 20px 0 0; padding: 14px 16px 14px 32px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; line-height: 1.8; }
.gate-notes li::marker { color: var(--accent-text); }

/* 底部：外觀切換 */
.gate-bottom {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-3);
}

.nav-sec { display: flex; flex-direction: column; }
.nav-toggle { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; font: inherit; font-size: 17px; font-weight: 600; color: var(--ink-3); text-align: left; cursor: pointer; }
.nav-toggle span:first-child { flex: 1; }
.nav-toggle:hover { color: var(--ink-2); }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-sec.is-active > .nav-toggle { color: var(--accent); }
.nav-toggle .count { font: 600 13px/1.6 var(--mono); padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.nav-chev { width: 18px; height: 18px; flex: none; transition: transform .15s ease; }
.nav-sec.collapsed .nav-chev { transform: rotate(-90deg); }
.nav-sec.collapsed > .nav-items { display: none; }
.nav-items { display: flex; flex-direction: column; }
.nav .nav-toggle { padding: 16px 18px 6px; font-size: 13px; }
.nav-ver { margin-top: auto; padding: 10px 18px 4px; font: 500 11.5px var(--mono); color: var(--ink-3); }

/* ---------- 列印 ---------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; } .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { border: 0; padding: 0; }
}
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* ---------- 手機 ---------- */
@media (max-width: 820px) {
  body { font-size: 15px; }
  .app, body.nav-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--top-h); left: 0; bottom: 0; height: auto; width: 240px; z-index: 45;
    transform: translateX(-100%); transition: transform .2s ease; visibility: visible !important;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: var(--top-h) 0 0 0; z-index: 44; background: rgba(0,0,0,.45); }
  .nav a { min-height: 46px; }
  .tb-user, .tb-link, .ver-chip, .tb-right .seg { display: none; }
  .tb-brand { font-size: 15.5px; }
  .main { padding: 14px 14px 40px; }
  .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 20px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
  .input { min-height: 44px; font-size: 16px; }

  .gate { padding: 0; place-items: stretch; }
  .gate-shell { width: 100%; border: 0; border-radius: 0; box-shadow: none; min-height: 100dvh; }
  .gate-main { padding: 22px 20px 20px; min-height: 100dvh; }
  .gate-head { padding-bottom: 18px; margin-bottom: 22px; }
  .gate .brand-mark { width: 46px; height: 46px; font-size: 23px; }
  .gate-name { font-size: 19px; }
  .gate-title { font-size: 22px; }
  .gate .gate-input { min-height: 50px; font-size: 17px; }
  .gate .gate-go { min-height: 54px; }
}

.card { padding: 16px; }
.card h3, .card-head h3 { color: var(--accent-text); font-size: 15px; }
.table { font-size: 13.5px; }
.table th { background: transparent; color: var(--ink-2); font-weight: 600; font-size: 12.5px; padding: 8px 12px; }
.card.table-wrap .table th { background: var(--surface-2); }
.badge { border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* =========================================================
   TAS 專用元件
   ========================================================= */
/* 狀態徽章：新交辦 藍、進行中 橘、即將到期 黃、已延遲 紅、待審核 紫、追蹤 青、已完成 綠、撤銷／轉出 灰 */
.badge.new { background: var(--new-soft); color: var(--new); }
.badge.review { background: var(--review-soft); color: var(--review); }
.badge.track { background: var(--track-soft); color: var(--track); }
.badge.lg { font-size: 13.5px; padding: 3px 12px; }

/* 總覽卡片 */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { --c: var(--ink-2); display: block; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--radius); padding: 12px 16px; }
a.stat-card:hover { border-color: var(--c); }
.stat-card .k { font-size: 12.5px; color: var(--ink-3); }
.stat-card .v { font-family: var(--mono); font-size: 28px; font-weight: 600; line-height: 1.25; color: var(--c); }
.stat-card .s { font-size: 11.5px; color: var(--ink-3); }
.stat-card.c-accent { --c: var(--accent); } .stat-card.c-new { --c: var(--new); } .stat-card.c-bad { --c: var(--bad); }
.stat-card.c-warn { --c: var(--warn); } .stat-card.c-review { --c: var(--review); } .stat-card.c-track { --c: var(--track); } .stat-card.c-ok { --c: var(--ok); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 數字欄 */
.table td.n, .table th.n { text-align: right; font-family: var(--mono); }
.table td.n.zero { color: var(--ink-3); opacity: .6; }
.table td.n.hot { color: var(--bad); font-weight: 600; }
.table td.wrap { white-space: normal; min-width: 220px; }
.table a.t { color: var(--ink); font-weight: 500; text-decoration: none; }
.table a.t:hover { color: var(--accent); text-decoration: underline; }
.table .sub { display: block; font-size: 12px; color: var(--ink-3); }

/* 比率長條 */
.rate { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.rate .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.rate .bar i { display: block; height: 100%; background: var(--ok); }
.rate.tr .bar i { background: var(--bad); }
.rate b { font: 600 12.5px var(--mono); min-width: 38px; text-align: right; }

/* 篩選列、分頁籤 */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.filters .field { margin: 0; }
.filters .input { min-height: 36px; padding: 5px 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--accent-text); border-bottom-color: var(--accent); }
.tabs a .count { font: 600 11.5px/1.6 var(--mono); padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); margin-left: 4px; }
.tabs a.on .count { background: var(--accent-soft); color: var(--accent-text); }

/* 表單排版 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 820px) { .form-grid { grid-template-columns: 1fr; } }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; min-height: 38px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); cursor: pointer; }
.pick-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-list label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13.5px; cursor: pointer; background: var(--surface); }
.pick-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pick-list input { accent-color: var(--accent); }
.pick-list.all-on label:not(.pick-all) { opacity: .45; pointer-events: none; }
.seg-tabs { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-3); margin-bottom: 14px; }
.seg-tabs a { padding: 6px 16px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.seg-tabs a.on { background: var(--surface); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.due-preview { font-size: 12.5px; color: var(--accent-text); font-family: var(--mono); }

/* 專案子項目編輯 */
.subrows { display: flex; flex-direction: column; gap: 10px; }
.subrow { display: grid; grid-template-columns: 32px minmax(180px, 2fr) minmax(140px, 1fr) minmax(220px, 1.3fr) 36px; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.subrow .no { font: 600 14px var(--mono); color: var(--accent-text); padding-top: 8px; text-align: center; }
.subrow .field { margin: 0; }
.subrow textarea.input { min-height: 38px; margin-top: 6px; }
.subrow .rm { margin-top: 2px; }
@media (max-width: 960px) { .subrow { grid-template-columns: 28px 1fr; } .subrow > :nth-child(n+3) { grid-column: 2; } }

/* 案件明細 */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 6px; }
.detail-head h1 { font-size: 22px; margin: 0; line-height: 1.35; }
.case-no { font: 600 12.5px var(--mono); color: var(--ink-3); }
.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; }
.meta > div { padding: 10px 14px; border-left: 1px solid var(--line); min-width: 0; }
.meta > div:first-child { border-left: 0; }
.meta .k { font-size: 12px; color: var(--ink-3); }
.meta .v { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; }
.meta .v.mono { font-family: var(--mono); }
@media (max-width: 820px) { .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); } .meta > div:nth-child(3) { border-left: 0; } .meta > div:nth-child(n+3) { border-top: 1px solid var(--line); } }
.content-box { white-space: pre-wrap; line-height: 1.8; font-size: 14.5px; }
.progress-note { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }

/* 承辦軌跡摘要條 */
.trail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 16px; font-size: 13.5px; }
.trail .lbl { color: var(--ink-3); font-size: 12.5px; margin-right: 2px; }
.trail .arrow { color: var(--ink-3); }
.who { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 600; border: 1px solid var(--line-2); background: var(--surface); }
.who small { font-weight: 500; font-size: 11.5px; }
.who.failed { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent-text); background: var(--accent-soft); }
.who.failed .nm { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.who.moved { color: var(--ink-2); background: var(--surface-3); }
.who.moved .nm { text-decoration: line-through; }
.who.done { border-color: var(--ok); background: var(--ok); color: #fff; }
.who.active { border-color: var(--accent); color: var(--accent-text); }
.trail .sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; }

/* 時間軸 */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 10px 0 10px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .at { font: 500 12.5px/1.6 var(--mono); color: var(--ink-3); }
.timeline .what { font-size: 14px; }
.timeline .what .by { color: var(--ink-3); font-size: 12.5px; margin-left: 6px; }
.timeline .what .txt { display: block; color: var(--ink-2); white-space: pre-wrap; margin-top: 2px; }
.timeline li.sys .what { color: var(--ink-3); }
.timeline li.comment .txt { background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink); }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr; gap: 2px; } }

/* 附件 */
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; min-width: 0; }
.files a { color: var(--ink); text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files a:hover { color: var(--accent); }
.files .hint { white-space: nowrap; }
.file-kind { font-size: 11px; padding: 0 6px; border-radius: 3px; background: var(--surface-3); color: var(--ink-2); flex: none; }
.file-kind.mgr { background: var(--accent-soft); color: var(--accent-text); }

/* 動作面板 */
.actions { display: flex; flex-direction: column; gap: 10px; }
.act { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.act > summary { list-style: none; cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.act > summary::-webkit-details-marker { display: none; }
.act > summary::after { content: "▸"; margin-left: auto; color: var(--ink-3); transition: transform .15s; }
.act[open] > summary::after { transform: rotate(90deg); }
.act > summary .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.act.primary { border-color: var(--accent); }
.act.primary > summary { color: var(--accent-text); }
.act.danger > summary { color: var(--bad); }
.act form { padding: 0 14px 14px; }
.act .field { margin-bottom: 10px; }
.callout.big { font-size: 14.5px; padding: 12px 16px; }

/* 雜項 */
.muted { color: var(--ink-3); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.empty-row td { text-align: center; color: var(--ink-3); padding: 24px 12px !important; }
.pill-count { font: 600 12px var(--mono); padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.kbd { font: 500 12px var(--mono); padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--surface-2); }
.copy-area { width: 100%; min-height: 160px; font-family: var(--mono); font-size: 13px; }
/* 間距修正 */
.input.w-auto { width: auto; }
.card + .card, .split + .card, .card + .split, .split + .split, .stats + .card { margin-top: 16px; }
.detail > div > .card + .card, .actions .card { margin-top: 0; }
.detail > div { display: flex; flex-direction: column; gap: 16px; }
.detail > div > .card { margin: 0; }
.card-head form.row { flex-wrap: nowrap; }

/* =========================================================
   字體放大（使用者回饋：原字級太小）
   ========================================================= */
body { font-size: 17px; }
.main { padding: 22px 28px 56px; }
.page-head h1 { font-size: 26px; }
.page-head p, .muted { font-size: 15px; }
.hint, .table .sub { font-size: 14.5px; }
.card h3, .card-head h3 { font-size: 18px; }
.card .sub { font-size: 15px; }

/* 側欄與頂部 */
.tb-brand { font-size: 19px; }
.tb-right { font-size: 15.5px; }
.tb-role { font-size: 13.5px; }
.nav a { font-size: 17px; padding: 11px 16px 11px 15px; }
.nav a .ic { width: 21px; height: 21px; }
.nav a .count { font-size: 13.5px; }
.nav .nav-toggle { font-size: 14.5px; }
.side-theme .lbl, .side-theme .seg button { font-size: 13.5px; }

/* 表格 */
.table { font-size: 16px; }
.table th, .card.table-wrap .table th { font-size: 15px; padding: 11px 14px; }
.table td { padding: 11px 14px; }
.rate b { font-size: 15px; min-width: 46px; }
.rate .bar { height: 10px; }

/* 總覽卡片 */
.stat-card { padding: 14px 18px; }
.stat-card .k { font-size: 15.5px; }
.stat-card .v { font-size: 36px; }
.stat-card .s { font-size: 14px; }

/* 表單與按鈕 */
.btn { font-size: 16px; min-height: 40px; padding: 0 16px; }
.btn.sm { font-size: 15px; min-height: 34px; padding: 0 12px; }
.btn.lg { font-size: 17px; min-height: 48px; }
.input { font-size: 16.5px; min-height: 42px; }
.field > label, .label { font-size: 15px; }
.radio-row label, .pick-list label, .field.check label { font-size: 16px; }
.err, .field-validation-error { font-size: 14.5px; }
.callout { font-size: 16px; }
.badge { font-size: 14px; padding: 2px 9px; }
.badge.lg { font-size: 15.5px; }
.tabs a { font-size: 16px; }
.seg-tabs a { font-size: 16px; }
.due-preview { font-size: 14.5px; }

/* 案件明細 */
.detail-head h1 { font-size: 26px; }
.case-no { font-size: 14.5px; }
.meta .k { font-size: 14px; }
.meta .v { font-size: 17px; }
.content-box { font-size: 17px; }
.progress-note { font-size: 15px; }
.trail { font-size: 16px; }
.trail .lbl { font-size: 14.5px; }
.who small { font-size: 13.5px; }
.timeline li { grid-template-columns: 130px minmax(0, 1fr); }
.timeline .at { font-size: 14.5px; }
.timeline .what { font-size: 16px; }
.timeline .what .by { font-size: 14.5px; }
.files li { font-size: 16px; }
.file-kind { font-size: 13px; }
.act > summary { font-size: 16.5px; padding: 12px 16px; }
.detail { grid-template-columns: minmax(0, 1fr) 380px; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }

/* 登入頁 */
.gate-notes { font-size: 15px; }

/* 登入紀錄：月曆＋矩陣 */
.login-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
@media (max-width: 1100px) { .login-top { grid-template-columns: 1fr; } }
.login-top > .card { margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-h { text-align: center; font-size: 15px; color: var(--ink-3); font-weight: 600; padding: 4px 0; }
.cal-day { position: relative; display: flex; flex-direction: column; min-height: 86px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; }
.cal-day:hover { border-color: var(--accent); }
.cal-day .d { font: 600 17px var(--mono); }
.cal-day .hn { font-size: 12.5px; color: var(--bad); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-day .n { margin-top: auto; align-self: flex-end; font: 700 18px var(--mono); }
.cal-day .n small { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.cal-day.out { opacity: .35; }
.cal-day.off { background: var(--surface-2); }
.cal-day.all { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); background: color-mix(in srgb, var(--ok-soft) 70%, var(--surface)); }
.cal-day.all .n { color: var(--ok); }
.cal-day.some { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface)); }
.cal-day.some .n { color: var(--warn); }
.cal-day.none { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 70%, var(--surface)); }
.cal-day.none .n { color: var(--bad); }
.cal-day.today .d { color: var(--accent); }
.cal-day.today::after { content: "今天"; position: absolute; top: 8px; right: 8px; font-size: 11.5px; color: var(--accent-text); font-weight: 600; }
.cal-day.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 12px; font-size: 14.5px; color: var(--ink-2); }
.cal-legend .k { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: -8px; border: 1px solid var(--line-2); }
.cal-legend .k.all { background: var(--ok-soft); border-color: var(--ok); }
.cal-legend .k.some { background: var(--warn-soft); border-color: var(--warn); }
.cal-legend .k.none { background: var(--bad-soft); border-color: var(--bad); }
.cal-legend .k.off { background: var(--surface-2); }
.sec-t { margin: 14px 0 8px; font-size: 16px; color: var(--ink-2); }
.chips-name { display: flex; flex-wrap: wrap; gap: 6px; }
.matrix-wrap { overflow-x: auto; }
.table.matrix th, .table.matrix td { padding: 8px 6px; text-align: center; }
.table.matrix th .w { display: block; font-size: 12px; color: var(--ink-3); font-weight: 500; }
.table.matrix th.off, .table.matrix td.off { background: var(--surface-2); }
.table.matrix th.today { color: var(--accent-text); }
.table.matrix td.dot { color: var(--ok); font-size: 15px; min-width: 30px; }
.table.matrix td.miss { color: var(--bad); }
.table.matrix .sticky { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding-left: 14px; white-space: nowrap; }
.table.matrix th.sticky { background: var(--surface-2); z-index: 3; }
@media (max-width: 560px) { .cal-day { min-height: 64px; padding: 6px; } .cal-day .hn { display: none; } .cal-day .n { font-size: 15px; } }

/* 自行經辦 */
.accept-card { max-width: 640px; margin: 8px auto 24px; text-align: center; padding: 36px 32px; border-color: var(--accent); }
.accept-card .accept-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.accept-card h2 { margin: 0 0 8px; font-size: 24px; }
.accept-card p { color: var(--ink-2); font-size: 16.5px; margin: 0 0 20px; }
.accept-card .accept-btn { min-width: 220px; min-height: 56px; font-size: 20px; font-weight: 700; letter-spacing: .1em; }
.accept-card .hint { margin: 16px 0 0; }

/* 清單欄位排序 */
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.th-sort:hover { color: var(--accent-text); }
.th-sort .arr { font-size: 11px; opacity: .45; }
.th-sort.on { color: var(--accent-text); }
.th-sort.on .arr { opacity: 1; }
.table th.n .th-sort { justify-content: flex-end; }
.pager-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.pager-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.btn.disabled { opacity: .4; pointer-events: none; }

/* 列尾操作按鈕（自行經辦／開啟／刪除） */
.inline-form { display: inline; margin: 0; }
.table td.act-col, .table th.act-col { text-align: right; white-space: nowrap; width: 1%; }
.table td.act-col .btn + .inline-form, .table td.act-col .inline-form + .inline-form { margin-left: 6px; }
.table td.act-col .btn { vertical-align: middle; }
