/* theme-v2.css — 2026-10 界面改版（对应 Claude Design「泰国财务系统 v2 界面设计」）
   放在 styles.css 之后加载，只覆盖外观，不改功能。
   设计原则：白底浅灰、一个深绿主色、数字等宽对齐；一屏多看行；按「月」工作。 */

:root {
  --primary: #0E6B46;
  --primary-hover: #0A4F34;
  --primary-light: #E7F2EC;
  --primary-glow: rgba(14, 107, 70, 0.14);
  --secondary: #16201B;
  --bg-main: #F5F6F4;
  --bg-sidebar: #FFFFFF;
  --card-bg: #FFFFFF;
  --border: #E2E5E1;
  --border-light: #EEF0ED;
  --text-main: #16201B;
  --text-muted: #5B6660;
  --text-light: #7C8580;
  --warning: #B45309;
  --danger: #B42318;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(22, 32, 27, 0.06);
  --shadow-lg: 0 8px 24px rgba(22, 32, 27, 0.10);
  --warn-bg: #FEF3C7;
  --warn-ink: #92400E;
}

body {
  font-family: Inter, "Noto Sans SC", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "PingFang SC", "Sarabun", sans-serif;
  font-size: 14px;
  background: var(--bg-main);
}

.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; }
.num, .amt, .ov-kpi-value, .data-table td { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.warn-text { color: var(--warn-ink); }
.ok-text { color: var(--primary); }
.bad-text { color: var(--danger); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 232px;
  background: #FFFFFF;
  color: var(--text-main);
  border-right: 1px solid var(--border);
  box-shadow: none;
}
.sidebar-brand { padding: 18px 16px; border-bottom: 0; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); }
.brand-title { font-size: 14px; letter-spacing: 0; color: var(--text-main); }
.brand-subtitle { font-size: 12px; opacity: 1; color: var(--text-muted); }
.sidebar-nav { padding: 4px 12px 12px; gap: 2px; }
.nav-group-label { font-size: 11px; color: var(--text-muted); padding: 14px 10px 6px; letter-spacing: 0.04em; }
.nav-item {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  padding: 9px 10px;
  border-radius: 8px;
  min-height: 40px;
}
.nav-item:hover { background: #F3F4F2; color: var(--text-main); }
.nav-item.active { background: var(--primary-light); color: var(--primary); box-shadow: none; font-weight: 600; }
.nav-item i { width: 17px; height: 17px; }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 0 8px; line-height: 20px; }
.sidebar-footer { border-top: 1px solid var(--border); padding: 14px 12px; gap: 8px; }
.btn-export-pkg { background: var(--primary); min-height: 44px; border-radius: 8px; font-size: 14px; }
.btn-export-pkg:hover { background: var(--primary-hover); }
.btn-lock-sys { background: #FFFFFF !important; color: var(--text-muted) !important; border: 1px solid var(--border) !important; border-radius: 8px; min-height: 40px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  min-height: 0;
  justify-content: flex-start;
}
.month-switch { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: #FFFFFF; }
.month-step { width: 38px; height: 38px; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-main); }
.month-step:hover { background: #F3F4F2; }
.month-step i { width: 18px; height: 18px; }
#globalMonthSelect { height: 38px; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--text-main); padding: 0 4px; cursor: pointer; }
.global-search { flex: 1 1 320px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #F9FAF8; color: var(--text-muted); }
.global-search:focus-within { border-color: var(--primary); background: #FFFFFF; box-shadow: 0 0 0 3px var(--primary-glow); }
.global-search i { width: 16px; height: 16px; }
.global-search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--text-main); outline: none; min-width: 0; }
.global-search kbd { font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; background: #FFFFFF; color: var(--text-muted); }
.btn-dark { background: var(--secondary); color: #FFFFFF; border: 0; height: 40px; padding: 0 16px; border-radius: 8px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.btn-dark:hover { background: #000; }
.btn-dark i { width: 16px; height: 16px; }
.lang-switch-wrap { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: #FFFFFF; }
.lang-btn { height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; cursor: pointer; }
.lang-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; box-shadow: none; }

.tab-content-container { padding: 24px 28px 48px; max-width: 1320px; width: 100%; }

/* ---------- 通用组件 ---------- */
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #FFFFFF; border: 1px solid var(--border); color: var(--text-main); }
.kpi-card, .chart-card, .table-card, .card { border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: none; }
.data-table { font-size: 13px; }
.data-table th { background: #F9FAF8; color: var(--text-muted); font-size: 12px; padding: 9px 12px; }
.data-table td { padding: 8px 12px; }
.data-table tr:hover td { background: #F7FAF8; }

/* ---------- 本月概览 ---------- */
.ov-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.ov-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-main); }
.ov-sub { margin: 6px 0 0; color: var(--text-muted); }
.ov-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ov-actions .btn { height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; }
.ov-actions .btn i { width: 16px; height: 16px; }
.ov-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ov-kpi { background: #FFFFFF; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.ov-kpi-label, .ov-kpi-sub { font-size: 12px; color: var(--text-muted); }
.ov-kpi-value { font-size: 20px; font-weight: 700; }
.ov-body { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.ov-card { background: #FFFFFF; border: 1px solid var(--border); border-radius: 10px; }
.ov-checklist { flex: 999 1 520px; min-width: 0; }
.ov-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.ov-card-head h2 { margin: 0; font-size: 16px; }
.ov-card-head > span { font-size: 12px; color: var(--text-muted); }
.ov-check { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 18px; min-height: 56px; border: 0; border-bottom: 1px solid var(--border-light); background: #FFFFFF; font: inherit; color: var(--text-main); text-align: left; cursor: pointer; }
.ov-check:last-child { border-bottom: 0; border-radius: 0 0 10px 10px; }
.ov-check.is-open:hover { background: #F7FAF8; }
.ov-check.is-done { cursor: default; }
.ov-check-mark { min-width: 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; padding: 0 6px; flex: none; }
.ov-check.is-open .ov-check-mark { background: var(--warn-bg); color: var(--warn-ink); }
.ov-check.is-done .ov-check-mark { background: var(--primary-light); color: var(--primary); }
.ov-check-mark i { width: 14px; height: 14px; }
.ov-check-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ov-check-text strong { font-size: 14px; font-weight: 600; }
.ov-check-text span { font-size: 12px; color: var(--text-muted); }
.ov-check-action { margin-left: auto; font-size: 13px; white-space: nowrap; color: var(--primary); }
.ov-check.is-done .ov-check-action { color: var(--text-muted); }
.ov-bank { flex: 1 1 300px; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.ov-bank h2 { margin: 0; font-size: 16px; }
.ov-bank-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; font-variant-numeric: tabular-nums; }
.ov-bank-grid div { display: flex; flex-direction: column; gap: 4px; }
.ov-bank-grid span { font-size: 12px; color: var(--text-muted); }
.ov-bank-progress-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.ov-bar { height: 8px; border-radius: 4px; background: var(--primary-light); overflow: hidden; }
.ov-bar div { height: 8px; background: var(--primary); }
.ov-detail { margin-top: 16px; background: #FFFFFF; border: 1px solid var(--border); border-radius: 10px; }
.ov-detail-hint { margin: 10px 18px; font-size: 12px; }
.table-scroll { overflow-x: auto; }
.compact-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compact-table th { text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 8px 18px; background: #F9FAF8; border-top: 1px solid var(--border); }
.compact-table td { padding: 9px 18px; border-top: 1px solid var(--border-light); }
.compact-table .num { text-align: right; white-space: nowrap; }
.compact-table tr.is-clickable { cursor: pointer; }
.compact-table tr.is-clickable:hover td { background: #F7FAF8; }

/* ---------- 收支明细：精简表格 ---------- */
#transactionsTable { min-width: 760px !important; table-layout: auto; }
#transactionsTable td { padding: 8px 12px; vertical-align: middle; }
#transactionsTable .col-date { width: 150px; white-space: nowrap; }
#transactionsTable .col-payee { max-width: 380px; }
#transactionsTable .col-net, #transactionsTable .col-wht, #transactionsTable th.col-net, #transactionsTable th.col-wht { text-align: right; white-space: nowrap; }
#transactionsTable .col-attachments { width: 170px; }
#transactionsTable .col-jev { width: 110px; }
#transactionsTable tr.tx-row { cursor: pointer; }
.cell-main { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
.cell-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
.amt { font-weight: 600; white-space: nowrap; }
.amt-in { color: var(--primary); }
.amt-out { color: var(--text-main); }
.doc-chips { display: inline-flex; gap: 4px; align-items: center; }
.doc-chip { font-size: 12px; line-height: 20px; padding: 0 6px; border-radius: 4px; border: 0; font-family: inherit; white-space: nowrap; }
.doc-chip.ok { background: var(--primary-light); color: var(--primary); }
button.doc-chip.ok { cursor: pointer; }
button.doc-chip.ok:hover { background: #D2E8DB; }
.doc-chip.miss { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.doc-chip.na { background: #F1F2F0; color: #8A928D; }
.doc-count { font-size: 12px; color: var(--text-muted); }
.jev-badge { border-radius: 12px; font-size: 12px; }

/* 快速筛选标签 */
.chip-filter { border-radius: 8px; border: 1px solid var(--border); background: #FFFFFF; color: var(--text-main); box-shadow: none; }
.chip-filter.active { background: var(--secondary); border-color: var(--secondary); color: #FFFFFF; }

/* ---------- 详情抽屉 ---------- */
.tx-drawer { border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.calc-equation-ribbon { flex-wrap: wrap; gap: 6px; background: #F9FAF8; border: 1px solid var(--border); border-radius: 10px; }
.calc-equation-ribbon .calc-item strong { font-variant-numeric: tabular-nums; }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group-label { display: none; }
  .nav-item { width: auto; }
  .topbar { padding: 10px 16px; }
  .tab-content-container { padding: 16px; }
}

/* 只读账号（代账公司）：隐藏新增/编辑/作废入口，服务器也会拒绝写操作 */
body.role-viewer #btnNewTransaction,
body.role-viewer #btnDrawerSaveTx,
body.role-viewer .btn-tx-action.btn-edit,
body.role-viewer .btn-tx-action.btn-del,
body.role-viewer [onclick*="voidWhtCert"],
body.role-viewer [onclick*="generateWhtForTx"],
body.role-viewer [onclick*="deleteTransaction"],
body.role-viewer #btnManualWht,
body.role-viewer #btnUploadWht { display: none !important; }
