  :root {
    --bg:#f5f7f8; --panel:#ffffff; --panel-2:#fbfcfd; --ink:#17201d; --muted:#66736f;
    --line:#dce3e0; --green:#14B8A6; --blue:#2563EB; --danger:#a83f3a; --amber:#b9842b;
    --shadow:0 12px 30px rgba(20,37,32,.08);
  }
  :root[data-cfo-mode="dark"] {
    --bg:#0f141a; --panel:#1a232e; --panel-2:#212c38; --ink:#e8eef5; --muted:#8499ab;
    --line:#2c3845; --green:#2DD4BF; --blue:#5a9bf0; --danger:#e07a82; --amber:#e0b566;
    --shadow:0 6px 22px rgba(0,0,0,.45);
  }
  body { margin:0; background:var(--bg); color:var(--ink); font-family:Inter, system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
  .page { max-width:none; margin:0; padding:22px 26px 56px; }
  /* sheet 頁籤（建議匣 / 批次入帳）— 扁平、底下一條線 */
  /* 左側第二層 rail（與總帳一致） */
  .ai-wrap { max-width:none; margin:0; padding:0; }
  .layout{display:grid;grid-template-columns:var(--tabs-w,212px) minmax(0,1fr);gap:0;align-items:start;min-height:calc(100vh - 52px);transition:grid-template-columns .16s ease}
  .layout.tabs-railed{--tabs-w:72px}
  .module-content{min-width:0;padding:18px 24px 48px}
  .tabs{background:var(--panel);border:1px solid var(--line);border-radius:18px;box-shadow:0 10px 30px rgba(15,23,42,.10),0 2px 6px rgba(15,23,42,.05);padding:10px 8px 16px;position:sticky;top:62px;align-self:start;height:calc(100vh - 72px);margin:10px 12px 0 0;overflow-y:auto;overflow-x:hidden;transition:width .2s cubic-bezier(.32,.72,0,1),box-shadow .15s ease}
  .tabs-head{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:4px 6px 8px;margin-bottom:4px;border-bottom:1px solid var(--line)}
  .tabs-title{font-size:10px;font-weight:800;letter-spacing:1.4px;text-transform:uppercase;color:var(--muted);white-space:nowrap}
  .tabs-pin{border:0;background:transparent;color:var(--muted);width:26px;height:26px;border-radius:6px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
  .tabs-pin svg{width:15px;height:15px}.tabs-pin:hover{background:var(--line);color:var(--green)}.tabs-pin[aria-pressed="true"]{color:var(--green)}
  .tab-group{padding:1px 0}.tab-main{width:100%;border:0;background:transparent;color:var(--ink);display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px;font:inherit;font-size:14px;font-weight:750;cursor:pointer;text-align:left}.tab-main .label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tab-main:hover{background:var(--line)}.tab-group.current>.tab-main{color:var(--green);background:rgba(20,184,166,.06)}
  .tab-sublist{display:grid;gap:1px;margin:2px 0 4px}.tab-sub{width:100%;border:0;background:transparent;color:var(--ink-soft);display:flex;align-items:center;gap:10px;padding:7px 11px 7px 38px;border-radius:6px;font:inherit;font-size:13.5px;font-weight:500;cursor:pointer;text-align:left;position:relative;white-space:nowrap}.tab-sub::before{content:'';position:absolute;left:21px;top:50%;transform:translateY(-50%);width:4px;height:4px;border-radius:50%;background:var(--line)}.tab-sub:hover{background:var(--line);color:var(--ink)}.tab-sub.active{background:rgba(20,184,166,.08);color:var(--green);font-weight:750}.tab-sub.active::before{background:var(--green)}
  @media(min-width:981px){.tabs.rail{width:60px;overflow-x:visible}.tabs.rail:not(:hover){padding:10px 6px 16px;overflow-y:visible}.tabs.rail:not(:hover) .tabs-title{display:none}.tabs.rail:not(:hover) .tabs-head{justify-content:center;padding:4px 0 8px}.tabs.rail:not(:hover) .tab-main{justify-content:center;padding:10px 0;gap:0}.tabs.rail:not(:hover) .tab-main .label,.tabs.rail:not(:hover) .tab-sublist{display:none}.tabs.rail:hover{width:212px;min-width:212px;padding:10px 8px 16px;overflow-y:auto;box-shadow:0 18px 48px rgba(15,23,42,.18),0 4px 12px rgba(15,23,42,.08);z-index:60}}
  .mode-panel{background:var(--panel);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);padding:18px}
  .mode-panel[hidden]{display:none!important}
  .sv-title { font-size:16px; font-weight:850; color:var(--ink); margin:2px 0 12px; ;padding-bottom:8px;border-bottom:1px solid var(--line);margin-bottom:12px;}
  /* 標題旁 ⓘ 說明 */
  .itip { position:relative; display:inline-flex; align-items:center; margin-left:6px; color:var(--muted); cursor:help; font-size:15px; font-weight:400; vertical-align:middle; }
  .itip .itipbox { display:none; position:absolute; left:0; top:calc(100% + 8px); width:min(460px,86vw); background:#0f1d31; color:#fff; font-size:12px; font-weight:400; line-height:1.75; padding:12px 14px; border-radius:10px; z-index:50; box-shadow:0 10px 28px rgba(0,0,0,.28); }
  .itip:hover .itipbox, .itip:focus .itipbox, .itip:focus-within .itipbox { display:block; }
  /* 建議匣動作列：三顆按鈕一致、字不要大 */
  .inbox-actions { display:flex; gap:8px; flex-wrap:wrap; margin:0 0 14px; }
  .inbox-actions .btn { min-height:30px; padding:6px 12px; font-size:12px; font-weight:750; }
  .summary { margin-top:0; }
  .page-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:14px; }
  .eyebrow { font-size:11px; font-weight:850; letter-spacing:.12em; color:var(--green); text-transform:uppercase; }
  h1 { margin:4px 0 0; font-size:24px; line-height:1.15; letter-spacing:0; }
  .lede { margin:6px 0 0; max-width:760px; color:var(--muted); font-size:13px; line-height:1.65; }
  .actions, .head-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  .btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:34px; padding:7px 13px; border:1px solid var(--line); border-radius:8px; background:var(--panel); color:var(--ink); font-size:12.5px; font-weight:750; text-decoration:none; cursor:pointer; font-family:inherit; }
  .btn:hover { border-color:var(--green); color:var(--green); }
  .btn.primary { background:var(--green); border-color:var(--green); color:#fff; }
  .btn:disabled { opacity:.55; cursor:default; }
  .panel { background:var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); padding:18px; }
  .toolbar { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; align-items:center; margin-bottom:12px; }
  .count { display:inline-flex; align-items:center; justify-content:center; min-width:19px; height:19px; padding:0 6px; border-radius:999px; background:rgba(100,116,139,.13); color:var(--muted); font-size:11px; }
  /* 分類分頁：扁平頁籤（底線），與上方 sheet 頁籤一致 */
  .sheet-tabs { display:flex; gap:2px; flex-wrap:wrap; margin:12px 0; border-bottom:1px solid var(--line); }
  .sheet-tab { display:inline-flex; align-items:center; gap:7px; border:0; border-bottom:2px solid transparent; border-radius:0; background:transparent; color:var(--muted); min-height:0; margin-bottom:-1px; padding:7px 12px; font:inherit; font-size:12.5px; font-weight:800; cursor:pointer; }
  .sheet-tab:hover { color:var(--ink); }
  .sheet-tab.active { color:var(--green); border-bottom-color:var(--green); }
  .sheet-tab.active .count { background:rgba(20,184,166,.14); color:var(--green); }
  .sheet-dot { width:8px; height:8px; border-radius:999px; flex:0 0 auto; }
  /* 建議匣工具列：狀態 / 本頁筆數 / 整批動作 / 重新整理 收成一列 */
  .inbox-bar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:14px; padding:8px 12px; border:1px solid var(--line); border-radius:10px; background:var(--panel-2); color:var(--muted); font-size:12.5px; }
  .ib-status { display:inline-flex; align-items:center; gap:6px; font-weight:800; color:var(--ink); }
  .inbox-bar select { appearance:none; border:1px solid var(--line); background:var(--panel); color:var(--ink); border-radius:8px; min-height:32px; padding:6px 28px 6px 10px; font:inherit; font-weight:700; }
  .ib-meta { font-weight:700; }
  .ib-spacer { flex:1; }
  .ib-bulk { display:inline-flex; gap:8px; flex-wrap:wrap; }
  .sug-list { display:grid; gap:10px; }
  .sug-card { border:1px solid var(--line); border-radius:10px; background:var(--panel-2); padding:13px 14px; }
  .sug-card.adopt { border-left:3px solid var(--green); }
  .sug-card.redirect { border-left:3px solid var(--blue); }
  .sug-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:8px; }
  .sug-title { display:flex; align-items:center; gap:7px; flex-wrap:wrap; font-size:13.5px; font-weight:850; }
  .chip { display:inline-flex; align-items:center; min-height:20px; padding:2px 7px; border-radius:999px; background:rgba(100,116,139,.12); color:var(--muted); font-size:11px; font-weight:800; }
  .chip.green { color:#047857; background:rgba(20,184,166,.13); }
  .chip.blue { color:#1d4ed8; background:rgba(37,99,235,.12); }
  :root[data-cfo-mode="dark"] .chip.green { color:#5eead4; }
  :root[data-cfo-mode="dark"] .chip.blue { color:#93c5fd; }
  .conf { font-size:11.5px; color:var(--muted); white-space:nowrap; font-weight:800; }
  .sug-table { width:100%; border-collapse:collapse; font-size:12.5px; margin-top:4px; background:var(--panel); border-radius:8px; overflow:hidden; }
  .sug-table td, .sug-table th { padding:7px 9px; border-bottom:1px solid var(--line); text-align:left; }
  .sug-table tr:last-child td { border-bottom:0; }
  .num { text-align:right !important; font-variant-numeric:tabular-nums; }
  .muted { color:var(--muted); }
  .reason { margin-top:8px; color:var(--muted); font-size:12.5px; line-height:1.6; }
  .sug-foot { display:flex; justify-content:space-between; gap:12px; align-items:center; flex-wrap:wrap; margin-top:10px; }
  .ok { color:var(--green); font-size:12.5px; font-weight:800; }
  .warn { color:var(--danger); font-size:12.5px; font-weight:800; }
  .sug-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
  .explain { margin-top:10px; border:1px dashed var(--line); border-radius:8px; background:var(--panel); color:var(--ink); padding:10px 12px; font-size:12.5px; line-height:1.7; }
  .empty { color:var(--muted); text-align:center; padding:36px 12px; font-size:13px; }
  .summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-bottom:12px; }
  .kpi { border:1px solid var(--line); background:var(--panel-2); border-radius:10px; padding:11px 12px; font:inherit; text-align:left; cursor:pointer; transition:border-color .12s, background .12s; }
  .kpi:hover { border-color:var(--green); }
  .kpi.active { border-color:var(--green); background:rgba(20,184,166,.08); box-shadow:inset 0 0 0 1px var(--green); }
  .kpi.active .k { color:var(--green); }
  .kpi .k { color:var(--muted); font-size:11px; font-weight:850; letter-spacing:.04em; }
  .kpi .v { margin-top:3px; font-size:20px; font-weight:850; font-variant-numeric:tabular-nums; }
  .mode-panel[hidden] { display:none !important; }
  /* 第二層左側 rail 選單（建議匣 / 批次入帳），與其他頁一致 */
  .layout { display:grid; grid-template-columns:var(--tabs-w,212px) minmax(0,1fr); gap:0; align-items:start; min-height:calc(100vh - 52px); transition:grid-template-columns .16s ease; }
  .layout.tabs-railed { --tabs-w:72px; }
  .tabs { background:var(--panel); border:1px solid var(--line); border-radius:18px; box-shadow:0 10px 30px rgba(15,23,42,.10),0 2px 6px rgba(15,23,42,.05); padding:10px 8px 16px; position:sticky; top:62px; align-self:start; height:calc(100vh - 72px); margin:10px 12px 0 0; overflow-y:auto; overflow-x:hidden; box-sizing:border-box; transition:width .2s cubic-bezier(.32,.72,0,1),box-shadow .15s ease; }
  .tabs-head { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:4px 6px 8px; margin-bottom:4px; border-bottom:1px solid var(--line); }
  .tabs-title { font-size:10px; font-weight:800; letter-spacing:1.4px; text-transform:uppercase; color:var(--muted); white-space:nowrap; }
  .tabs-pin { border:0; background:transparent; color:var(--muted); width:26px; height:26px; border-radius:6px; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; }
  .tabs-pin svg { width:15px; height:15px; } .tabs-pin:hover { background:var(--line); color:var(--green); } .tabs-pin[aria-pressed="true"] { color:var(--green); }
  .tab-group { padding:1px 0; }
  .tab-main { width:100%; box-sizing:border-box; border:0; background:transparent; color:var(--ink); display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; font:inherit; font-size:14px; font-weight:700; cursor:pointer; text-align:left; }
  .tab-main .ic { width:18px; height:18px; flex-shrink:0; display:inline-flex; align-items:center; justify-content:center; color:var(--muted); } .tab-main .ic svg { width:18px; height:18px; display:block; }
  .tab-main .label { flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .tab-main:hover { background:var(--line); color:var(--ink); } .tab-main:hover .ic { color:var(--ink); }
  .tab-main.active { color:var(--green); background:rgba(20,184,166,.10); } .tab-main.active .ic { color:var(--green); }
  @media (min-width:981px){
    .tabs.rail { width:60px; overflow-x:visible; }
    .tabs.rail:not(:hover) { padding:10px 6px 16px; overflow-y:visible; }
    .tabs.rail:not(:hover) .tabs-title { display:none; }
    .tabs.rail:not(:hover) .tabs-head { justify-content:center; padding:4px 0 8px; }
    .tabs.rail:not(:hover) .tab-main { justify-content:center; padding:10px 0; gap:0; }
    .tabs.rail:not(:hover) .tab-main .label { display:none; }
    .tabs.rail:not(:hover) .tab-main .ic, .tabs.rail:not(:hover) .tab-main .ic svg { width:20px; height:20px; }
    .tabs.rail:hover { width:212px; min-width:212px; padding:10px 8px 16px; overflow-y:auto; box-shadow:0 18px 48px rgba(15,23,42,.18),0 4px 12px rgba(15,23,42,.08); z-index:60; }
  }
  @media (max-width:980px){ .layout { display:block; } .tabs { position:static; height:auto; margin:12px 12px 0; border-radius:14px; } .tabs.rail { width:auto; } .tabs.rail .tab-main { justify-content:flex-start; } .tabs.rail .tab-main .label { display:revert; } .aib-main { padding:14px 12px 40px; } }
  .batch-grid { display:grid; grid-template-columns:minmax(260px,1.15fr) minmax(240px,.85fr); gap:12px; margin-bottom:12px; }
  .batch-box { border:1px solid var(--line); background:var(--panel-2); border-radius:10px; padding:12px; }
  .batch-title { font-size:12px; font-weight:850; margin-bottom:8px; color:var(--ink); }
  .batch-box textarea { width:100%; min-height:138px; resize:vertical; border:1px solid var(--line); border-radius:8px; background:var(--panel); color:var(--ink); padding:10px; font:inherit; font-size:12.5px; line-height:1.6; box-sizing:border-box; }
  .drop-row { display:grid; gap:8px; }
  .drop-card { min-height:64px; display:flex; flex-direction:column; justify-content:center; gap:3px; border:1.5px dashed var(--line); border-radius:9px; background:var(--panel); color:var(--muted); padding:12px; cursor:pointer; }
  .drop-card:hover { border-color:var(--green); background:rgba(20,184,166,.06); }
  .drop-card b { color:var(--ink); font-size:12.5px; }
  .drop-card small { font-size:11px; line-height:1.45; }
  .batch-bar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:8px 0 12px; color:var(--muted); font-size:12.5px; }
  .draft-list { display:grid; gap:10px; }
  .draft-card { border:1px solid var(--line); border-radius:10px; background:var(--panel-2); padding:12px 13px; }
  .draft-head { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; flex-wrap:wrap; margin-bottom:8px; }
  .draft-title { display:flex; align-items:center; gap:7px; flex-wrap:wrap; font-size:13px; font-weight:850; }
  .draft-meta { color:var(--muted); font-size:11.5px; font-weight:800; }
  .draft-actions { display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap; margin-top:10px; }
  .toast { position:fixed; left:50%; bottom:26px; transform:translateX(-50%); z-index:9999; background:#0f1d31; color:#fff; padding:11px 16px; border-radius:11px; box-shadow:0 10px 28px rgba(0,0,0,.28); opacity:0; transition:opacity .18s; font-size:13px; font-weight:750; max-width:90vw; text-align:center; }
  .toast.show { opacity:1; }
  @media (max-width:760px) {
    .page { padding:16px 12px 40px; }
    .summary { grid-template-columns:1fr; }
    .batch-grid { grid-template-columns:1fr; }
    .sug-head, .sug-foot, .toolbar { align-items:stretch; }
    .head-actions, .actions, .sug-actions { width:100%; }
    .btn { flex:1 1 auto; }
  }
