:root {
  --primary: #17a05d;
  --primary-dark: #0e8a4c;
  --primary-soft: #e7f6ee;
  --primary-line: #bfe6d0;
  --sidebar: #23272e;
  --sidebar-2: #2d323a;
  --sidebar-text: #d4d8de;
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --text: #1f2329;
  --text-2: #5b6370;
  --text-3: #8a929e;
  --border: #dfe3e8;
  --border-2: #eceef1;
  --th: #dcefe4;
  --row-hover: #f1f8f4;
  --row-sel: #dff2e7;
  --blue: #1e6fd9;
  --orange: #f2852a;
  --red: #e0383e;
  --purple: #7b4ddb;
  --yellow: #f5b400;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 13.5px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.green { color: var(--primary); }
.orange { color: var(--orange); }
.red { color: var(--red); }
.blue { color: var(--blue); }
.bold { font-weight: 600; }
.mt { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
svg.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Layout ---------- */
#app { height: 100%; }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: 52px 1fr; height: 100%; }
.shell.collapsed { grid-template-columns: 60px minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; min-width: 190px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: conic-gradient(from 200deg, #17a05d, #1e6fd9, #f2852a, #e0383e, #17a05d); display: grid; place-items: center; }
.brand-logo span { width: 18px; height: 18px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--primary); }
.brand-img { height: 34px; width: auto; display: block; }
.brand-name { font-weight: 800; letter-spacing: 1.5px; color: #2c4a5c; font-size: 18px; }
.login-logo { background: #fff; border-radius: 16px; padding: 14px 18px; display: inline-block; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.login-logo img { height: 110px; display: block; }
.logo-preview { width: 120px; height: 120px; border: 1px dashed var(--border); border-radius: 10px; display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 110px; max-height: 110px; object-fit: contain; }
.company-name { font-weight: 600; font-size: 14px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.year-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; font-size: 13px; white-space: nowrap; }
.year-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.top-search { position: relative; width: 260px; }
.top-search input { width: 100%; height: 30px; border: 1.5px solid #8b6cf0; border-radius: 6px; padding: 0 10px 0 30px; font-size: 13px; outline: none; }
.top-search svg { position: absolute; left: 8px; top: 7px; width: 16px; height: 16px; color: #6a55e0; }
.top-search .results { position: absolute; top: 34px; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; z-index: 50; }
.top-search .results div { padding: 8px 12px; cursor: pointer; display: flex; gap: 8px; }
.top-search .results svg { position: static; flex: none; margin-top: 2px; }
.top-search .results { min-width: 380px; left: auto; }
.top-search .results div:hover, .top-search .results div.active { background: var(--row-hover); }
.top-icons { display: flex; align-items: center; gap: 4px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--text-2); position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .badge { position: absolute; top: 3px; right: 3px; background: var(--red); color: #fff; font-size: 10px; border-radius: 9px; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #8bc34a; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 2px #8bc34a; }

.sidebar { background: var(--sidebar); color: var(--sidebar-text); overflow-y: auto; padding: 14px 12px 60px; position: relative; }
.sidebar .quick-add { width: 100%; height: 34px; border-radius: 6px; border: 1px solid #4b525c; background: var(--sidebar-2); color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; margin-bottom: 18px; }
.sidebar .quick-add svg { color: var(--primary); }
.sidebar .quick-add:hover { background: #363c45; }
.side-label { font-size: 12.5px; color: #8d95a1; text-transform: uppercase; letter-spacing: .3px; padding: 6px 4px 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; color: var(--sidebar-text); text-decoration: none; margin-bottom: 4px; font-size: 13.5px; white-space: nowrap; }
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.shell.collapsed .nav a span, .shell.collapsed .side-label, .shell.collapsed .quick-add span { display: none; }
.shell.collapsed .nav a { justify-content: center; padding: 10px 0; }
.collapse-btn { position: fixed; bottom: 0; left: 176px; width: 44px; height: 40px; background: #3a4049; border: 0; color: #c8ced6; cursor: pointer; border-radius: 6px 0 0 0; display: grid; place-items: center; }
.shell.collapsed .collapse-btn { left: 16px; transform: scaleX(-1); }

.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.tabs-bar { display: flex; align-items: center; gap: 2px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 12px; min-height: 42px; overflow-x: auto; flex: none; }
.tabs-bar a { padding: 12px 12px 10px; color: var(--text); white-space: nowrap; border-bottom: 2px solid transparent; text-decoration: none; font-size: 13.5px; }
.tabs-bar a:hover { color: var(--primary); }
.tabs-bar a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: var(--primary-soft); border-radius: 4px 4px 0 0; }
.tabs-bar .new-tag { background: var(--orange); color: #fff; font-size: 10px; border-radius: 3px; padding: 1px 4px; margin-left: 4px; }
.page { flex: 1; overflow: auto; padding: 14px 16px 24px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }

/* ---------- Buttons & inputs ---------- */
.btn { height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: #c4cad2; background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.dark { background: #165c3a; border-color: #165c3a; color: #fff; }
.btn.ai { background: linear-gradient(90deg, #5b6cf7, #8a4cf0); border: 0; color: #fff; }
.btn.outline-green { border-color: var(--primary); color: var(--primary); }
.btn.outline-blue { border-color: var(--blue); color: var(--blue); }
.btn.danger { color: var(--red); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn-group { display: inline-flex; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; border-left: 1px solid rgba(255,255,255,.35); padding: 0 8px; }

.input, select.input, textarea.input { height: 32px; width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 160, 93, .12); }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--text-2); }
.input.num { text-align: right; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; color: var(--text); font-weight: 500; }
.field > label .req { color: var(--red); }
.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-right: 34px; }
.input-wrap .addon { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 30px; border: 0; border-left: 1px solid var(--border); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--text-2); border-radius: 0 6px 6px 0; }
.input-wrap .addon.plus { right: 31px; border-left: 0; color: var(--primary); }
.input-wrap.has-plus .input { padding-right: 62px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; white-space: nowrap; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.search-box { position: relative; }
.search-box input { padding-left: 32px; }
.search-box svg { position: absolute; left: 9px; top: 8px; width: 16px; height: 16px; color: var(--text-3); }

.grid-form { display: grid; gap: 12px 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; margin: 0; }
.card-sub { font-size: 12px; color: var(--text-3); }
.dash-grid { display: grid; grid-template-columns: 1.55fr 1fr 1fr; gap: 14px; }
.dash-grid .wide { grid-column: span 1; }
.dash-row2 { display: grid; grid-template-columns: 1.55fr 2fr; gap: 14px; margin-top: 14px; }
.dash-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 14px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); gap: 10px; }
.kv.sub { padding-left: 20px; color: var(--text-2); }
.kv .v { color: var(--blue); font-variant-numeric: tabular-nums; }
.big-num { font-size: 26px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 13px; color: var(--text-3); font-weight: 500; text-decoration: underline; margin-left: 4px; }
.debt-bar { height: 18px; border-radius: 2px; background: #e8ebef; overflow: hidden; display: flex; margin: 14px 0; }
.debt-bar span { display: block; height: 100%; }
.stamp { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.list-rows { display: flex; flex-direction: column; }
.list-rows .lr { display: grid; grid-template-columns: 1fr 110px 130px; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); align-items: center; }
.list-rows .lr.head { font-weight: 600; border-bottom: 0; }
.lr .nm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lr .nm span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insights { background: linear-gradient(110deg, #fdf6ef, #f6f0fe 60%, #eef4ff); border: 1px solid #c9b8f5; border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.insights-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.insight { background: #fff; border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.5; }
.insight b { display: block; font-size: 13.5px; margin-bottom: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 12px; padding: 2px 9px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.green { background: var(--primary-soft); color: var(--primary-dark); }
.chip.orange { background: #fff1e5; color: #c25e0c; }
.chip.red { background: #fde8e8; color: #c22a2f; }
.chip.blue { background: #e6f0fd; color: #1859b0; }
.chip.gray { background: #eef0f3; color: var(--text-2); }

/* ---------- Data grid ---------- */
.grid-card { background: #fff; border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px; flex-wrap: wrap; }
.toolbar .search-box { width: 200px; }
.period-select { display: inline-flex; align-items: center; gap: 6px; }
.grid-wrap { overflow: auto; position: relative; border-top: 1px solid var(--border); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th { position: sticky; top: 0; background: var(--th); font-weight: 600; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--primary-line); border-right: 1px solid #cfe5d8; white-space: nowrap; z-index: 2; user-select: none; }
table.grid th.sortable { cursor: pointer; }
table.grid th .sort { color: var(--text-3); font-size: 10px; margin-left: 4px; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--border-2); border-right: 1px dashed #edf0f2; white-space: nowrap; max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
table.grid td.wrap { white-space: normal; }
table.grid tbody tr:hover td { background: var(--row-hover); }
table.grid tbody tr.selected td { background: var(--row-sel); }
table.grid tbody tr { cursor: default; }
table.grid tfoot td { position: sticky; bottom: 0; background: #f0f2f4; font-weight: 700; border-top: 1px solid var(--border); padding: 9px 10px; z-index: 1; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid .chk { width: 36px; text-align: center; }
table.grid .chk input { accent-color: var(--primary); width: 15px; height: 15px; }
table.grid td.link a { font-weight: 500; }
table.grid tr.group-row td { background: #f3f5f7; font-weight: 600; }
table.grid tr.open-row td { background: #fbfbf3; font-style: italic; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.row-actions a { cursor: pointer; }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border-2); font-size: 13px; }
.pager .pg-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 7px; color: var(--text-2); border-radius: 4px; }
.pager .pg-btn:hover:not(:disabled) { background: var(--surface-2); }
.pager .pg-btn:disabled { opacity: .35; cursor: default; }
.pager select { height: 30px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; }
.empty { padding: 50px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 64px; height: 64px; stroke: #c8ced6; stroke-width: 1.2; margin-bottom: 10px; }
.split { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.split .top { flex: 1 1 60%; min-height: 220px; }
.split .bottom { flex: 0 0 auto; max-height: 40%; min-height: 150px; }
.detail-head { display: flex; align-items: center; padding: 10px 16px; font-weight: 600; gap: 10px; }

/* ---------- Modal / voucher form ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 30, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); width: min(720px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .14s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal.lg { width: min(1040px, 100%); }
.modal.xl { width: min(1240px, 100%); }
.modal.sm { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; padding: 16px 20px 10px; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.modal-body { padding: 8px 20px 16px; overflow: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border-2); justify-content: flex-end; }

.vform { position: fixed; inset: 0; background: var(--bg); z-index: 90; display: flex; flex-direction: column; animation: fade .12s; }
.vform-head { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.vform-head h2 { margin: 0; font-size: 21px; font-weight: 700; white-space: nowrap; }
.vform-head .from-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 6px; height: 32px; padding: 0 12px; background: #fff; color: var(--blue); font-style: italic; cursor: pointer; position: relative; }
.dropdown { position: absolute; top: calc(100% + 4px); left: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 6px 0; min-width: 260px; z-index: 30; font-style: normal; color: var(--text); }
.dropdown .dd-item { padding: 8px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; white-space: nowrap; }
.dropdown .dd-item:hover { background: var(--row-hover); }
.dropdown .dd-item.active { background: var(--row-sel); }
.dropdown .dd-sep { height: 1px; background: var(--border-2); margin: 4px 0; }
.vform-body { flex: 1; overflow: auto; padding: 14px 18px; }
.vform-top { display: grid; grid-template-columns: minmax(0, 1fr) 260px 200px; gap: 18px; background: #fff; border-radius: 8px; padding: 14px 18px; box-shadow: var(--shadow); }
.opt-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-2); margin-bottom: 12px; }
.subtabs a { padding: 8px 12px; color: var(--text); text-decoration: none; border-bottom: 2px solid transparent; cursor: pointer; }
.subtabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.total-box { text-align: right; }
.total-box .lbl { color: var(--text-2); font-size: 13px; }
.total-box .val { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lines-card { background: #fff; border-radius: 8px; box-shadow: var(--shadow); margin-top: 14px; }
.lines-card .lines-tools { display: flex; align-items: center; gap: 10px; padding: 8px 14px; flex-wrap: wrap; }
table.lines { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.lines th { background: var(--th); padding: 8px 8px; text-align: left; font-weight: 600; border-right: 1px solid #cfe5d8; white-space: nowrap; position: sticky; top: 0; z-index: 2; }
table.lines td { border-bottom: 1px solid var(--border-2); border-right: 1px solid var(--border-2); padding: 0; height: 34px; }
table.lines td.idx { text-align: center; color: var(--text-2); width: 36px; padding: 0 6px; }
table.lines td.ro { padding: 0 8px; background: #fafbfc; color: var(--text-2); white-space: nowrap; }
table.lines td input, table.lines td select { width: 100%; height: 33px; border: 0; padding: 0 8px; background: transparent; outline: none; }
table.lines td input:focus, table.lines td select:focus { background: #fffbe6; box-shadow: inset 0 0 0 1.5px var(--primary); }
table.lines td input.num { text-align: right; }
table.lines tfoot td { background: #f0f2f4; font-weight: 700; padding: 8px; height: auto; }
table.lines .del { border: 0; background: transparent; color: var(--red); cursor: pointer; width: 30px; height: 30px; border-radius: 4px; }
table.lines .del:hover { background: #fde8e8; }
.stock-hint { font-size: 11px; color: var(--text-3); display: block; text-align: right; padding: 0 8px; margin-top: -6px; }
.stock-hint.low { color: var(--red); }
.vform-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; padding: 12px 14px 16px; }
.sum-table { width: 100%; font-size: 13.5px; }
.sum-table td { padding: 6px 0; }
.sum-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.sum-table tr.strong td { font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; }
.vform-foot { display: flex; align-items: center; gap: 8px; padding: 10px 18px; background: #fff; border-top: 1px solid var(--border); }

/* combo / autocomplete */
.combo-pop { position: fixed; z-index: 300; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 300px; overflow: auto; min-width: 420px; }
.combo-pop table { width: 100%; border-collapse: collapse; font-size: 13px; }
.combo-pop th { position: sticky; top: 0; background: #f3f5f7; text-align: left; padding: 7px 10px; font-weight: 600; white-space: nowrap; }
.combo-pop td { padding: 7px 10px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.combo-pop tr.active td, .combo-pop tbody tr:hover td { background: var(--row-sel); cursor: pointer; }
.combo-pop .combo-add { padding: 8px 12px; border-top: 1px solid var(--border-2); color: var(--primary); cursor: pointer; display: flex; gap: 6px; align-items: center; position: sticky; bottom: 0; background: #fff; }

/* toast */
#toasts { position: fixed; top: 64px; right: 18px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #fff; border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg); border-radius: 6px; padding: 11px 16px; min-width: 260px; max-width: 420px; animation: pop .15s; font-size: 13.5px; }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--orange); }

/* upload */
.drop { border: 1.5px dashed var(--primary); border-radius: 8px; padding: 26px; text-align: center; color: var(--text-2); cursor: pointer; background: #fbfefc; }
.drop.over { background: var(--primary-soft); }
.drop b { color: var(--blue); font-weight: 500; }

/* reports */
.rpt-group { background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 4px 18px 10px; margin-bottom: 12px; }
.rpt-group-head { display: flex; align-items: center; background: #eef0f3; margin: 10px -8px 6px; padding: 10px 16px; border-radius: 4px; font-weight: 600; cursor: pointer; }
.rpt-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 26px; }
.rpt-item { display: flex; align-items: center; gap: 8px; padding: 9px 4px 9px 12px; border-bottom: 1px solid var(--border-2); }
.rpt-item a { flex: 1; color: var(--text); cursor: pointer; }
.rpt-item a:hover { color: var(--primary); }
.star-btn { width: 28px; height: 28px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: pointer; display: grid; place-items: center; color: var(--text-3); }
.star-btn.on { color: var(--primary); border-color: var(--primary); }
.star-btn.on svg { fill: var(--primary); }
.rpt-params { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px; }
.rpt-params .field { min-width: 150px; }
.rpt-title { text-align: center; padding: 6px 0 12px; }
.rpt-title h2 { margin: 0; font-size: 18px; text-transform: uppercase; }
.rpt-title div { color: var(--text-2); font-style: italic; margin-top: 4px; }

/* process */
.process { display: flex; flex-wrap: wrap; align-items: center; gap: 0; padding: 30px 10px; justify-content: center; }
.proc-node { width: 170px; text-align: center; cursor: pointer; padding: 16px 10px; border-radius: 10px; transition: background .15s; }
.proc-node:hover { background: var(--primary-soft); }
.proc-node .pi { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 10px; display: grid; place-items: center; color: #fff; }
.proc-node .pi svg { width: 30px; height: 30px; }
.proc-node b { display: block; font-size: 14px; }
.proc-node span { font-size: 12px; color: var(--text-3); }
.proc-arrow { color: #b5bcc6; font-size: 26px; padding: 0 2px; }

/* login */
.login-wrap { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-art { background: linear-gradient(145deg, #0f8b50, #17a05d 45%, #1e6fd9); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 34px; margin: 0 0 14px; line-height: 1.2; }
.login-art ul { padding: 0; list-style: none; margin: 28px 0 0; }
.login-art li { padding: 8px 0; display: flex; gap: 10px; align-items: center; font-size: 15px; }
.login-box { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-box h2 { margin: 0 0 4px; font-size: 24px; }
.login-box .input { height: 40px; }
.login-box .btn { height: 40px; justify-content: center; }
.err-box { background: #fde8e8; color: #a4161a; border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.info-box { background: #e6f0fd; color: #12407e; border-radius: 6px; padding: 10px 12px; font-size: 13px; line-height: 1.5; }
code.inline { background: #f1f3f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-3); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #d7efe2; border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, #eef0f3, #f6f7f9, #eef0f3); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 4px; height: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid > :first-child { grid-column: 1 / -1; }
  .dash-row2, .dash-row3 { grid-template-columns: 1fr; }
  .vform-top { grid-template-columns: 1fr 220px; }
  .vform-top .total-col { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: 52px 1fr; }
  .topbar { overflow: hidden; gap: 6px; padding: 0 8px; }
  .top-icons .icon-btn:not([data-act="alerts"]) { display: none; }
  .brand { font-size: 16px; }
  [data-fin-body] { grid-template-columns: 1fr !important; }
  .page-head .btn { display: none; }
  .toolbar .search-box { width: 100%; }
  .modal-back { padding: 8px; }
  .modal .grid-form { grid-template-columns: 1fr !important; }
  .modal .grid-form > * { grid-column: auto !important; }
  .vform-head h2 { font-size: 17px; }
  .vform-head select, .vform-head .btn { display: none; }
  .shell .sidebar { display: none; }
  .shell.mobile-nav .sidebar { display: block; position: fixed; top: 52px; bottom: 0; left: 0; width: 240px; z-index: 80; }
  .collapse-btn { display: none; }
  .company-name, .year-pill, .top-search { display: none; }
  .brand { min-width: 0; }
  .dash-grid, .insights-grid, .cols-3, .cols-4, .rpt-list { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .vform-top, .vform-bottom { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .page { padding: 10px; }
}
.menu-btn { display: none; }
@media (max-width: 860px) { .menu-btn { display: grid; } }

@media print {
  body { background: #fff; }
}
