/* ระบบรายรับ-รายจ่ายเงินงบประมาณ */

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e1e6ec;
  --border-strong: #c9d1db;
  --text: #0f1b2a;
  --text-2: #475569;
  --muted: #7a8696;
  --primary: #1f5fbf;
  --primary-hover: #1a52a6;
  --primary-ink: #ffffff;
  --primary-soft: #e8f0fc;
  --budget: #1f5fbf;
  --budget-soft: #e8f0fc;
  --revenue: #0d8a5f;
  --revenue-soft: #e3f5ee;
  --series-income: #2a78d6;
  --series-expense: #eb6834;
  --grid: #e6e9ee;
  --axis: #c3c9d2;
  --success: #0b7a3b;
  --success-soft: #e3f4ea;
  --warning: #9a6200;
  --warning-soft: #fdf3dc;
  --danger: #c43333;
  --danger-soft: #fdeaea;
  --focus: rgba(31, 95, 191, 0.35);
  --shadow: 0 1px 2px rgba(15, 27, 42, 0.05), 0 2px 8px rgba(15, 27, 42, 0.04);
  --shadow-lg: 0 12px 40px rgba(15, 27, 42, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 252px;
  --font: "IBM Plex Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1b2029;
    --surface-3: #222833;
    --border: #2a313c;
    --border-strong: #3a4350;
    --text: #edf1f6;
    --text-2: #b6c0cc;
    --muted: #8893a1;
    --primary: #4a8fe7;
    --primary-hover: #64a0ec;
    --primary-ink: #0b1220;
    --primary-soft: #1a2a42;
    --budget: #6aa5ef;
    --budget-soft: #1a2a42;
    --revenue: #34c08d;
    --revenue-soft: #14302a;
    --series-income: #3987e5;
    --series-expense: #d95926;
    --grid: #262c36;
    --axis: #3a4350;
    --success: #3cc47a;
    --success-soft: #133024;
    --warning: #e2a93b;
    --warning-soft: #33280f;
    --danger: #f07070;
    --danger-soft: #3a1a1a;
    --focus: rgba(74, 143, 231, 0.45);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1b2029;
  --surface-3: #222833;
  --border: #2a313c;
  --border-strong: #3a4350;
  --text: #edf1f6;
  --text-2: #b6c0cc;
  --muted: #8893a1;
  --primary: #4a8fe7;
  --primary-hover: #64a0ec;
  --primary-ink: #0b1220;
  --primary-soft: #1a2a42;
  --budget: #6aa5ef;
  --budget-soft: #1a2a42;
  --revenue: #34c08d;
  --revenue-soft: #14302a;
  --series-income: #3987e5;
  --series-expense: #d95926;
  --grid: #262c36;
  --axis: #3a4350;
  --success: #3cc47a;
  --success-soft: #133024;
  --warning: #e2a93b;
  --warning-soft: #33280f;
  --danger: #f07070;
  --danger-soft: #3a1a1a;
  --focus: rgba(74, 143, 231, 0.45);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
.num, .table td.num, .table th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- boot / auth ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px; }
.auth-card .brand { margin-bottom: 24px; }
.auth-card h2 { font-size: 20px; margin-bottom: 4px; }
.auth-card form { display: grid; gap: 14px; margin-top: 20px; }
.auth-foot { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark { width: 40px; height: 40px; flex: none; border-radius: 11px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.brand-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }
.nav { margin-top: 22px; display: grid; gap: 2px; }
.nav-group { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 14px 10px 6px; letter-spacing: 0.02em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a svg { flex: none; }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; color: var(--text-2); flex: none; }
.user-chip .name { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role { font-size: 12px; color: var(--muted); }
.side-actions { display: flex; gap: 6px; margin-top: 8px; }
.side-actions .btn { flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; }
.topbar .spacer { flex: 1; }
.fy-pick { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.fy-pick select { width: auto; padding: 7px 34px 7px 12px; font-weight: 600; color: var(--text); }
.menu-btn { display: none; }
.view { padding: 24px 28px 48px; max-width: 1360px; width: 100%; }
.backdrop { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: min(84vw, 300px); transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.35); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 17px; }
  .fy-pick .lbl { display: none; }
  .view { padding: 16px 16px 40px; }
}

/* ---------- generic ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 16px; }
.card-head .sub { font-size: 13px; color: var(--muted); }
.card-body { padding: 20px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-form { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .grid-form { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1.3;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .seg button:focus-visible, .choice input:focus-visible + span {
  outline: none; box-shadow: 0 0 0 3px var(--focus);
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 13.5px; border-radius: 8px; }
.btn-icon { padding: 7px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }

/* forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.field .req { color: var(--danger); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--danger); }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); min-height: 40px;
}
textarea { resize: vertical; min-height: 72px; }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23778' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.invalid, input.invalid, select.invalid { border-color: var(--danger) !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; padding-top: 4px; }
.amount-input { font-size: 22px !important; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.baht-text { font-size: 13px; color: var(--text-2); min-height: 20px; text-align: right; }

/* segmented category picker */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg button {
  text-align: left; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--border-strong);
  background: var(--surface); cursor: pointer; display: grid; gap: 2px;
}
.seg button .t { font-weight: 600; }
.seg button .d { font-size: 12.5px; color: var(--muted); }
.seg button:hover { border-color: var(--primary); }
.seg button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.seg button[aria-pressed="true"] .t { color: var(--primary); }
.seg.kind button[data-v="expense"][aria-pressed="true"] { border-color: var(--series-expense); box-shadow: inset 0 0 0 1px var(--series-expense); background: color-mix(in srgb, var(--series-expense) 10%, var(--surface)); }
.seg.kind button[data-v="expense"][aria-pressed="true"] .t { color: var(--text); }

/* radio cards */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1.5px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); font-weight: 500;
}
.choice span::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; background: var(--surface);
}
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.choice input:checked + span::before { border-color: var(--primary); background: radial-gradient(circle, var(--primary) 0 4px, var(--surface) 5px); }
@media (max-width: 480px) { .seg, .choices { grid-template-columns: minmax(0, 1fr); } }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge.income { background: var(--primary-soft); color: var(--primary); }
.badge.expense { background: color-mix(in srgb, var(--series-expense) 14%, var(--surface)); color: var(--text); }
.badge.budget { background: var(--budget-soft); color: var(--budget); }
.badge.revenue { background: var(--revenue-soft); color: var(--revenue); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* tables */
.table-wrap { overflow: auto; }
.table-wrap > .table { min-width: 720px; }
.table.report-table { min-width: 900px; }
.report-table td:first-child { min-width: 280px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.group td { background: var(--surface-3); font-weight: 600; }
.table tr.subtotal td { font-weight: 600; background: var(--surface-2); }
.table tr.total td { font-weight: 700; border-top: 2px solid var(--border-strong); background: var(--surface-2); }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.table td.actions { white-space: nowrap; text-align: right; width: 1%; }
.table .desc { min-width: 200px; }
.table .desc .sub { font-size: 12.5px; color: var(--muted); }
.neg { color: var(--danger); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { color: var(--border-strong); margin-bottom: 8px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1360px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi.hero { grid-column: 1 / -1; } }
@media (max-width: 700px) { .kpis { grid-template-columns: minmax(0, 1fr); } }
.kpi { padding: 20px; min-width: 0; }
.kpi .label { font-size: 13.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 28px; font-weight: 600; margin-top: 6px; line-height: 1.2; white-space: nowrap; }
.kpi.hero .value { font-size: 40px; }
.kpi .foot { margin-top: 4px; font-size: 13px; color: var(--muted); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 14px; }
.split .k { font-size: 12.5px; color: var(--muted); }
.split .v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 480px) { .kpi.hero .value { font-size: 30px; } .kpi .value { font-size: 24px; } }

.meter { height: 8px; border-radius: 99px; background: var(--primary-soft); overflow: hidden; min-width: 80px; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.meter.warn > i { background: var(--warning); }
.meter.over > i { background: var(--danger); }
.meter-cell { display: flex; align-items: center; gap: 10px; }
.meter-cell .meter { flex: 1; }
.meter-cell span { font-size: 12.5px; color: var(--text-2); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* chart */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 4%, transparent); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; font-size: 13px; transform: translate(-50%, calc(-100% - 10px));
}
.tooltip .t { font-weight: 600; margin-bottom: 4px; }
.tooltip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* list rows */
.mini-list { display: grid; }
.mini-list .row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.mini-list .row:last-child { border-bottom: 0; }
.mini-list .row .grow { flex: 1; min-width: 0; }
.mini-list .row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .row .meta { font-size: 12.5px; color: var(--muted); }
.mini-list .row .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stat-rows { display: grid; gap: 10px; }
.stat-rows .r { display: flex; justify-content: space-between; gap: 12px; }
.stat-rows .r .k { color: var(--text-2); }
.stat-rows .r .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-rows .r.total { border-top: 1px solid var(--border); padding-top: 10px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--primary-soft); color: var(--text); font-size: 14px; }
.notice.warn { background: var(--warning-soft); }
.notice.err { background: var(--danger-soft); }
.notice svg { flex: none; margin-top: 2px; color: var(--primary); }
.notice.warn svg { color: var(--warning); }
.notice.err svg { color: var(--danger); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button { padding: 10px 14px; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-2); font-weight: 500; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* filters */
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)); gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
@media (max-width: 1100px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .filters { grid-template-columns: minmax(0, 1fr); } }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-2); }

/* import */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 14px; padding: 36px 20px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone svg { color: var(--primary); }
.dropzone .t { font-weight: 600; margin-top: 8px; }
.map-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 1100px) { .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .map-grid { grid-template-columns: minmax(0, 1fr); } }
.import-table { min-width: 1280px; }
.import-table input, .import-table select { min-height: 34px; padding: 5px 8px; font-size: 13.5px; border-radius: 7px; }
.import-table select { padding-right: 28px; background-position: right 8px center; }
.import-table td { padding: 6px 6px; vertical-align: middle; }
.import-table th { padding: 8px 6px; }
.import-table tr.off td { opacity: 0.55; }
.import-table tr.bad td { background: color-mix(in srgb, var(--danger) 5%, transparent); }
.import-table .w-date { width: 150px; }
.import-table .w-kind { width: 104px; }
.import-table .w-type { min-width: 220px; }
.import-table .w-acc { width: 140px; }
.import-table .w-amt { width: 130px; }
.import-table .w-doc { width: 120px; }
.import-table .w-desc { min-width: 220px; }
.bulkbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.bulkbar select { width: auto; min-height: 34px; padding: 5px 30px 5px 10px; font-size: 13.5px; }
.sticky-foot { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.steps span { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.steps b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12.5px; color: var(--text-2); }
.steps span.on { color: var(--text); font-weight: 500; }
.steps span.on b { background: var(--primary); color: var(--primary-ink); }
.steps .sep { width: 22px; height: 1px; background: var(--border-strong); align-self: center; }

/* settings lists */
.opt-list { display: grid; gap: 8px; }
.opt-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.opt-row input[type="number"] { text-align: center; padding: 8px 6px; }
.opt-row.inactive input[type="text"] { color: var(--muted); text-decoration: line-through; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.switch input { width: 36px; height: 20px; appearance: none; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background 0.15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }

/* modal */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(8, 12, 20, 0.45); display: grid; place-items: center; padding: 16px; animation: fade 0.12s ease; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* toasts */
.toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--text); color: var(--bg); border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise 0.18s ease; }
.toast.err { background: var(--danger); color: #fff; }
.toast svg { flex: none; margin-top: 1px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* print */
.print-head { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 12px; }
  .sidebar, .topbar, .no-print, .tabs, .toasts, .filters { display: none !important; }
  .app { display: block; }
  .view { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .card-head { padding: 0 0 8px; border: 0; }
  .card-body { padding: 0; }
  .print-head { display: block; text-align: center; margin-bottom: 12px; }
  .print-head h2 { font-size: 16px; }
  .table th { position: static; background: #f0f0f0 !important; color: #000; }
  .table th, .table td { padding: 5px 6px; border: 1px solid #999; }
  .table-wrap { overflow: visible; }
}
