/* ============================================================
   Auto-Tally UI — design system v2 (sidebar app shell)
   ============================================================ */
:root {
  /* Light theme v3 — teal/emerald accent on warm-cool neutrals */
  --bg:        #f3f6f8;
  --bg-2:      #e9eef2;
  --panel:     #ffffff;
  --ink:       #0f2230;
  --ink-soft:  #45586a;
  --muted:     #7c8b99;
  --line:      #e2e9ef;
  --line-2:    #eef3f7;

  --brand:     #0d9488;     /* teal-600 */
  --brand-2:   #11b3a3;     /* teal-500 */
  --brand-3:   #5eead4;     /* teal-300 */
  --brand-ink: #ffffff;
  --brand-soft:#d8f3ef;

  --side-1:    #ffffff;     /* light sidebar */
  --side-2:    #f1f5f8;
  --side-ink:  #44586a;

  --good:      #15803d;  --good-bg: #e6f7ec;
  --warn:      #b45309;  --warn-bg: #fdf3e2;
  --bad:       #dc2626;  --bad-bg:  #fdebeb;
  --info:      #0d9488;  --info-bg: #e3f6f3;
  --violet:    #7c3aed;  --violet-bg: #f3e8ff;
  --accent:    #f97316;  /* warm accent (orange) for highlights */

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(15,34,48,.05), 0 12px 30px rgba(15,34,48,.08);
  --shadow-sm: 0 1px 3px rgba(15,34,48,.07);
  --ring:      rgba(13,148,136,.18);
  --sidebar-w: 248px;
}

/* ---------- Dark mode (toggled via [data-theme="dark"] on <html>) ---------- */
html[data-theme="dark"] {
  --bg: #0c1518; --bg-2: #11201f; --panel: #11201f;
  --ink: #e4efec; --ink-soft: #a7bcb6; --muted: #7a908a;
  --line: #1f3330; --line-2: #18302c;
  --brand: #14b8a6; --brand-2: #2dd4bf; --brand-3: #5eead4; --brand-soft: #103b35;
  --side-1: #0a1413; --side-2: #11201f; --side-ink: #a7bcb6;
  --good-bg: #0e2a1c; --warn-bg: #2c2410; --bad-bg: #341a1a; --info-bg: #0e2e2a; --violet-bg: #241a3a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
  --ring: rgba(20,184,166,.25);
}
html[data-theme="dark"] .topbar { background: rgba(17,32,31,.85); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: #0c1518; color: var(--ink); }
html[data-theme="dark"] .grid thead th, html[data-theme="dark"] .grid tr:first-child th { background: #15302c; }
html[data-theme="dark"] .grid tbody tr:hover { background: #15302c; }
html[data-theme="dark"] .btn { background: #15302c; color: var(--ink); }
html[data-theme="dark"] .btn.ghost { background: #15302c; }
html[data-theme="dark"] pre.xml { background: #060d0c; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ============================================================
   App shell : sidebar + main column
   ============================================================ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--side-1), var(--side-2));
  color: var(--side-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; gap: 6px;
  border-right: 1px solid var(--line); z-index: 60;
}
.sidebar .brand { color: var(--ink); font-weight: 800; font-size: 19px; letter-spacing: .2px;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 16px; }
.sidebar .brand .logo { font-size: 22px; filter: drop-shadow(0 3px 8px rgba(13,148,136,.35)); }
/* ZeroLag wordmark — two-tone, with optional subtitle under it */
.wordmark { font-weight: 800; letter-spacing: -.2px; }
.wordmark > span { color: var(--brand); }
.brand-name { display: inline-flex; flex-direction: column; line-height: 1.12; }
.brand-name small { font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); }
.brand-tag { margin: -8px 0 18px; font-size: 12px; color: var(--muted); text-align: center; }

.nav-group { text-transform: uppercase; font-size: 10.5px; letter-spacing: .8px;
  color: var(--muted); font-weight: 700; padding: 14px 12px 6px; }

.tabs { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.tabs::-webkit-scrollbar { width: 6px; } .tabs::-webkit-scrollbar-thumb { background: rgba(15,34,48,.14); border-radius: 3px; }
.tab {
  display: flex; align-items: center; gap: 11px; width: 100%;
  border: none; background: transparent; color: var(--ink-soft);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px;
  text-align: left; transition: background .15s, color .15s;
}
/* clean line icons — the SYMBOL is coloured (per tab), no background tile */
.tab .ic { flex: 0 0 22px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.tab .ic::before { content: ""; width: 20px; height: 20px; background: var(--c, #64748b);
  -webkit-mask: var(--glyph) center/contain no-repeat; mask: var(--glyph) center/contain no-repeat; }
.tab .lbl { flex: 1; }
.tab .step { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%;
  font-size: 11px; background: var(--bg-2); color: var(--ink-soft); font-weight: 700; }
.tab:hover { background: var(--bg-2); color: var(--ink); }
.tab.active { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff;
  box-shadow: 0 6px 16px rgba(13,148,136,.32); }
.tab.active .step { background: rgba(255,255,255,.3); color: #fff; }
.tab.active .ic::before { background: #fff; }   /* white symbol on the active gradient */

/* per-tab symbol colour + glyph (Lucide-style line icons via mask) */
.tab[data-view="dashboard"] .ic { --c:#14b8a6;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3C/svg%3E"); }
.tab[data-view="clients"] .ic { --c:#3b82f6;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='3' width='14' height='18' rx='1'/%3E%3Cpath d='M9 7h2M13 7h2M9 11h2M13 11h2M9 15h6'/%3E%3C/svg%3E"); }
.tab[data-view="ledgers"] .ic { --c:#8b5cf6;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4h11a1 1 0 0 1 1 1v15H7a1 1 0 0 1-1-1z'/%3E%3Cpath d='M10 4v16'/%3E%3C/svg%3E"); }
.tab[data-view="upload"] .ic { --c:#06b6d4;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15V4'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3Cpath d='M5 19h14'/%3E%3C/svg%3E"); }
.tab[data-view="review"] .ic { --c:#22c55e;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.tab[data-view="mis"] .ic { --c:#f59e0b;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4v16h16'/%3E%3Cpath d='m7 14 3-3 3 3 4-6'/%3E%3C/svg%3E"); }
.tab[data-view="financials"] .ic { --c:#6366f1;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 3h7l4 4v14H7z'/%3E%3Cpath d='M10 13h6M10 17h6M10 9h3'/%3E%3C/svg%3E"); }
.tab[data-view="portfolio"] .ic { --c:#f97316;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7a2 2 0 0 1 2-2h3l2 2h7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.tab[data-view="rp"] .ic { --c:#0d9488;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='6' width='20' height='12' rx='2'/%3E%3Ccircle cx='12' cy='12' r='2.5'/%3E%3Cpath d='M5.5 12h.01M18.5 12h.01'/%3E%3C/svg%3E"); }
.tab[data-view="rules"] .ic { --c:#ec4899;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h7M17 7h3M4 12h3M13 12h7M4 17h9M19 17h1'/%3E%3Ccircle cx='14' cy='7' r='2'/%3E%3Ccircle cx='10' cy='12' r='2'/%3E%3Ccircle cx='16' cy='17' r='2'/%3E%3C/svg%3E"); }
.tab[data-view="gstr1"] .ic { --c:#10b981;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h12v18l-3-2-3 2-3-2-3 2z'/%3E%3Cpath d='M9 8h6M9 12h6'/%3E%3C/svg%3E"); }
.tab[data-view="gstr2"] .ic { --c:#0ea5e9;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E"); }
.tab[data-view="r26as"] .ic { --c:#64748b;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 3h7l4 4v14H7z'/%3E%3Cpath d='M14 3v4h4'/%3E%3C/svg%3E"); }
.tab[data-view="reports"] .ic { --c:#f43f5e;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 20V12M10 20V6M15 20V9M20 20V4'/%3E%3C/svg%3E"); }
.tab[data-view="settings"] .ic { --c:#475569;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2'/%3E%3C/svg%3E"); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0 22px; height: 60px; position: sticky; top: 0; z-index: 50;
}
.hamburger { display: none; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  font-size: 18px; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.brand-mobile { display: none; font-weight: 800; color: var(--brand); align-items: center; gap: 8px; }

.conn-badge { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--bg-2); color: var(--ink-soft); white-space: nowrap; transition: background .15s; user-select: none; }
.conn-badge:hover { background: var(--line); }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #c2c8d0; transition: background .2s, box-shadow .2s; }
.conn-badge.ok  { color: var(--good); } .conn-badge.ok .conn-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); animation: conn-pulse 2s infinite; }
.conn-badge.warn { color: var(--warn); } .conn-badge.warn .conn-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.conn-badge.bad { color: var(--bad); } .conn-badge.bad .conn-dot { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
@keyframes conn-pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.25); } 50% { box-shadow: 0 0 0 6px rgba(34,197,94,.06); } }

.ctx { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ctx-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.ctx select { padding: 8px 11px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font-weight: 600; max-width: 200px; }

/* ---------- Main content ---------- */
/* Fill the available width next to the sidebar (no centered gutters); a high
   cap only kicks in on ultra-wide monitors to keep line lengths sane. */
main { padding: 26px 32px; max-width: 1700px; width: 100%; margin: 0; }
.view.hidden { display: none !important; }
.page-head { margin-bottom: 20px; }
h1 { font-size: 24px; font-weight: 800; margin: 0 0 5px; letter-spacing: -.3px; }
.sub { color: var(--muted); margin: 0; max-width: 760px; }
.section-title { font-size: 15px; font-weight: 800; margin: 28px 0 12px; color: var(--ink); }

/* ---------- Panels & cards ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card h3, .panel h3 { margin: 8px 0 8px; font-size: 16.5px; font-weight: 800; }
.card-tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--brand); background: var(--info-bg); padding: 4px 10px; border-radius: 999px; }
.settings { display: flex; flex-direction: column; gap: 14px; max-width: 660px; }

/* ---------- KPI stat cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 13px; box-shadow: var(--shadow-sm); min-width: 0; }
.kpi .k-label { font-size: 11px; color: var(--ink-soft); font-weight: 800; text-transform: uppercase; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-value { font-size: clamp(14px, 1.45vw, 19px); font-weight: 800; margin-top: 4px; letter-spacing: -.3px;
  font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* master-data table item (symbol + bold label) */
.md-item { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
/* segmented control (Debtors/Creditors, Group/Party toggles) */
.recv-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-btn { border: none; background: transparent; color: var(--ink-soft); font-weight: 700; font-size: 12.5px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; transition: all .15s; }
.seg-btn.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
/* table total row — stays inside the columns so the figure aligns with Count */
.grid tfoot .grid-tot td { border-top: 2px solid var(--line); font-weight: 800; background: var(--line-2); }

/* ---------- Card colour symbols (same masked-glyph technique as the sidebar) ---------- */
.kpi-head { display: flex; align-items: center; gap: 9px; margin-bottom: 2px; min-width: 0; }
.kpi-head .k-label { margin: 0; flex: 1; }
.sym { width: 22px; height: 22px; flex: 0 0 22px; display: inline-flex; align-items: center; justify-content: center; }
.sym::before { content: ""; width: 20px; height: 20px; background: var(--c, #64748b);
  -webkit-mask: var(--glyph) center/contain no-repeat; mask: var(--glyph) center/contain no-repeat; }
/* per-symbol colour + glyph */
.sym-tx      { --c:#14b8a6; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13'/%3E%3Cpath d='M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E"); }
.sym-posted  { --c:#22c55e; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.sym-rate    { --c:#f59e0b; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2 4 14h7l-1 8 9-12h-7z'/%3E%3C/svg%3E"); }
.sym-in      { --c:#15803d; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v10'/%3E%3Cpath d='m7 11 5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E"); }
.sym-out     { --c:#dc2626; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20V10'/%3E%3Cpath d='m7 13 5-5 5 5'/%3E%3Cpath d='M5 4h14'/%3E%3C/svg%3E"); }
.sym-net     { --c:#0d9488; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v18'/%3E%3Cpath d='M5 7h14'/%3E%3Cpath d='m5 7-2 6h4z'/%3E%3Cpath d='m19 7-2 6h4z'/%3E%3C/svg%3E"); }
.sym-time    { --c:#6366f1; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.sym-ledger  { --c:#8b5cf6; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4h11a1 1 0 0 1 1 1v15H7a1 1 0 0 1-1-1z'/%3E%3Cpath d='M10 4v16'/%3E%3C/svg%3E"); }
.sym-group   { --c:#14b8a6; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 9 5-9 5-9-5z'/%3E%3Cpath d='m3 12 9 5 9-5'/%3E%3C/svg%3E"); }
.sym-bank    { --c:#0ea5e9; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 9 12 4l9 5'/%3E%3Cpath d='M5 9v9M9 9v9M15 9v9M19 9v9'/%3E%3Cpath d='M3 20h18'/%3E%3C/svg%3E"); }
.sym-voucher { --c:#f97316; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h12v18l-2-1.5L14 21l-2-1.5L10 21l-2-1.5L6 21z'/%3E%3Cpath d='M9 8h6M9 12h6'/%3E%3C/svg%3E"); }
.sym-debtors   { --c:#3b82f6; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='3.5'/%3E%3Cpath d='M5 20a7 7 0 0 1 14 0'/%3E%3C/svg%3E"); }
.sym-creditors { --c:#b45309; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3 10h18'/%3E%3C/svg%3E"); }
.sym-tax       { --c:#7c3aed; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 5 5 19'/%3E%3Ccircle cx='6.5' cy='6.5' r='2.5'/%3E%3Ccircle cx='17.5' cy='17.5' r='2.5'/%3E%3C/svg%3E"); }
.sym-clients   { --c:#6366f1; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M3 20a6 6 0 0 1 12 0'/%3E%3Cpath d='M16 6a3 3 0 0 1 0 6'/%3E%3Cpath d='M18 14a6 6 0 0 1 3 5'/%3E%3C/svg%3E"); }
.sym-pending   { --c:#b45309; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.sym-missing   { --c:#dc2626; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E"); }
.sym-alert     { --c:#b45309; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20z'/%3E%3Cpath d='M12 10v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }

/* ---------- Forms ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.row:last-child { margin-bottom: 0; }
input, select, textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px; background: #fff; color: var(--ink); font-family: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: #9aa6ba; }
textarea { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; }
.field { display: inline-flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field.block { display: flex; }
.field input, .field select { font-weight: 400; color: var(--ink); }
.chk, .switch { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }
.switch em { color: var(--muted); font-style: normal; }

/* ---------- Table search ---------- */
.searchbar { position: relative; display: inline-flex; align-items: center; flex: 1 1 240px;
  min-width: 180px; margin-bottom: 10px; }
.searchbar > .ic { position: absolute; left: 11px; font-size: 13px; opacity: .55; pointer-events: none; }
.searchbar input { width: 100%; padding-left: 32px; padding-right: 58px; }
.searchbar input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.search-count { position: absolute; right: 12px; font-size: 11.5px; font-weight: 700;
  color: var(--muted); pointer-events: none; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn { padding: 10px 16px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 13.5px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: all .15s; white-space: nowrap; }
.btn:hover { background: var(--bg-2); border-color: #d6deeb; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(13,148,136,.30); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { background: #b9bdf0; box-shadow: none; cursor: not-allowed; filter: none; }
.btn.ghost { background: var(--bg-2); }
.btn.block { width: 100%; justify-content: center; margin-top: 18px; padding: 12px; font-size: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.report-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.report-btns.live { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); align-items: center; }
.live-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--warn); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--panel); padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 14px; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); background: var(--panel); margin-top: 4px; }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.grid th, .grid td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.grid thead th, .grid tr:first-child th { background: #f7f9fd; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); position: sticky; top: 0; font-weight: 800; }
.grid tbody tr:hover, .grid tr:hover { background: #f8faff; }
.grid tr:last-child td { border-bottom: none; }
/* selectable rows (e.g. the Clients table — click a row to make it active) */
.grid tr.selectable { cursor: pointer; }
.grid tr.row-active, .grid tbody tr.row-active:hover { background: var(--info-bg); }
.grid tr.row-active td { font-weight: 600; }
.grid tr.row-active td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
/* soft, light-coloured table variant (e.g. Voucher type-wise count) */
.grid.soft { min-width: 0; }
.grid.soft thead th { background: var(--brand-soft); color: var(--brand); }
.grid.soft tbody tr:nth-child(even) { background: color-mix(in srgb, var(--brand-soft) 38%, transparent); }
.grid.soft tbody tr:hover { background: var(--info-bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* `.grid th/td` sets text-align:left (specificity 0,1,1) which beat a bare .num
   (0,1,0) — so numeric columns were left-aligned. This higher-specificity rule
   right-aligns every numeric column across all grid tables. */
.grid th.num, .grid td.num { text-align: right; }
.debit { color: var(--bad); font-weight: 700; }
.credit { color: var(--good); font-weight: 700; }
.led-input { width: 100%; min-width: 170px; }
.btn.tiny { padding: 4px 9px; font-size: 11.5px; margin-top: 5px; background: var(--info-bg); color: var(--brand); border-color: transparent; }

/* Review table columns (1=checkbox, 2=date, 3=narration, 4=amount, 5=ledger). */
.grid.review .chkcol { width: 34px; text-align: center; }
.grid.review td:nth-child(3), .grid.review th:nth-child(3) {
  max-width: 300px; white-space: normal; overflow-wrap: anywhere; word-break: break-word;
  font-size: 12.5px; color: var(--ink-soft);
}
.grid.review td:nth-child(2), .grid.review th:nth-child(2) {
  width: 86px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.grid.review td:nth-child(5), .grid.review th:nth-child(5) { width: 30%; min-width: 220px; }
.grid.review .led-input { min-width: 200px; }

/* Bulk action bar */
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
  background: var(--info-bg); border: 1px solid #c7d2fe; border-radius: var(--radius); padding: 10px 14px; }
.bulkbar input { min-width: 200px; }

/* ---------- Chips / pills / confidence ---------- */
.chip { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.chip.unmapped { background: var(--bad-bg); color: var(--bad); }
.chip.needs_review { background: var(--warn-bg); color: var(--warn); }
.chip.mapped, .chip.approved { background: var(--good-bg); color: var(--good); }
.chip.posted, .chip.posting { background: var(--info-bg); color: var(--brand); }
.chip.duplicate { background: var(--violet-bg); color: var(--violet); }
.chip.error { background: var(--bad-bg); color: var(--bad); }
.chip.skipped { background: #eceff3; color: var(--muted); }
.chip.extracted, .chip.uploaded, .chip.ready { background: var(--info-bg); color: var(--brand); }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--bg-2); color: var(--ink-soft); font-weight: 600; font-size: 12.5px; }
.conf { font-weight: 800; }
.conf.hi { color: var(--good); } .conf.mid { color: var(--warn); } .conf.lo { color: var(--bad); }

/* ---------- Banners ---------- */
.banner { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; font-weight: 600; border: 1px solid transparent; }
.banner.ok { background: var(--good-bg); color: var(--good); border-color: #bfe6cd; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: #f3c4c4; }

/* ---------- Bank reconciliation card ---------- */
.recon { max-width: 560px; margin-top: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.recon-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.recon-head.ok  { background: linear-gradient(180deg, #effaf2, var(--good-bg)); }
.recon-head.bad { background: linear-gradient(180deg, #fdf1f1, var(--bad-bg)); }
.recon-badge { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 21px; font-weight: 800; background: #fff;
  box-shadow: var(--shadow-sm); }
.recon-head.ok  .recon-badge { color: var(--good); }
.recon-head.bad .recon-badge { color: var(--bad); }
.recon-title { font-weight: 800; font-size: 15.5px; letter-spacing: -.2px; }
.recon-head.ok  .recon-title { color: var(--good); }
.recon-head.bad .recon-title { color: var(--bad); }
.recon-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.recon-diff { margin-left: auto; font-weight: 800; font-size: 15px; padding: 7px 14px;
  border-radius: 999px; background: #fff; box-shadow: var(--shadow-sm); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.recon-diff.ok  { color: var(--good); }
.recon-diff.bad { color: var(--bad); }
.recon-rows { padding: 4px 18px 8px; }
.recon-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.recon-row .lbl { color: var(--ink-soft); display: inline-flex; align-items: center; gap: 9px; }
.recon-row .lbl .ic { font-size: 15px; opacity: .85; }
.recon-row .val { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.recon-row.total { border-bottom: none; border-top: 2px solid var(--line-2); margin-top: 2px; padding-top: 14px; }
.recon-row.total .lbl { font-weight: 800; color: var(--ink); }
.recon-row.total .val { font-size: 16px; }
.recon-row.total.ok  .val { color: var(--good); }
.recon-row.total.bad .val { color: var(--bad); }
.recon-pills { display: inline-flex; gap: 6px; }
.recon-note { margin: 0; padding: 2px 18px 16px; color: var(--muted); font-size: 12.5px;
  display: flex; align-items: center; gap: 7px; }

/* ---------- Agents / connectivity ---------- */
.agents .agent { padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; background: #fbfcfe; }
.agents .agent .btn { margin-top: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(21,128,61,.18); }
.dot.off { background: #c2c8d0; }
.howto { margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.howto code, .field code { background: var(--bg-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.howto ol { margin: 10px 0 0; padding-left: 20px; color: var(--ink-soft); }
.howto li { margin-bottom: 6px; }

#reportArea .cards { margin-bottom: 18px; }
#reportArea h3 { margin: 18px 0 10px; font-size: 15px; }

/* Reports tab: two grouped cards with a tidy button grid */
.report-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 16px; }
@media (max-width: 820px) { .report-cards { grid-template-columns: 1fr; } }
.card-tag.warn-tag { color: var(--warn); background: var(--warn-bg); }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.rbtn { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--ink); border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 600; font-size: 13.5px; text-align: left; transition: all .14s; }
.rbtn .ic { font-size: 16px; }
.rbtn:hover { background: #fff; border-color: var(--brand-2); color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.rbtn:active { transform: translateY(0); }

/* Day Book column picker */
.colpick { margin: 6px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); padding: 8px 12px; }
.colpick summary { cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--ink-soft); }
.colchips { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.colchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; font-weight: 600; }
.colchip input { width: 15px; height: 15px; accent-color: var(--brand); }
pre.xml { background: #0f172a; color: #d7e3f4; padding: 16px; border-radius: var(--radius-sm); overflow: auto; max-height: 360px; font-size: 12px; line-height: 1.55; margin-top: 12px; }
.flagbox { font-size: 11.5px; color: var(--warn); margin-top: 3px; }

/* ---------- Auth overlay ---------- */
.auth-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: linear-gradient(135deg, #0f766e, var(--brand) 55%, var(--brand-3)); padding: 20px; }
.auth-card { background: #fff; border-radius: 18px; padding: 34px; width: 100%; max-width: 410px; box-shadow: 0 24px 70px rgba(0,0,0,.35); animation: pop .25s ease; }
.auth-brand { font-weight: 800; font-size: 23px; display: flex; align-items: center; gap: 9px; color: var(--brand); margin-bottom: 20px; }
.auth-brand .logo { font-size: 28px; }
.auth-form h2 { margin: 0 0 4px; font-size: 21px; }
.auth-form label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-top: 14px; }
.auth-form input { width: 100%; margin-top: 5px; }
.auth-error { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; font-weight: 600; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- User menu ---------- */
.usermenu { position: relative; }
.user-btn { width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-3)); box-shadow: 0 2px 8px rgba(13,148,136,.38); }
.user-btn:hover { filter: brightness(1.08); }
.user-dropdown { position: absolute; right: 0; top: 48px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); min-width: 230px; padding: 8px; z-index: 70; }
.user-info { padding: 10px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.role-chip { display: inline-block; width: fit-content; margin-top: 4px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; color: var(--brand); background: var(--info-bg); padding: 2px 8px; border-radius: 999px; }
.menu-item { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 10px 12px;
  border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink); font-weight: 600; }
.menu-item:hover { background: var(--bg-2); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: rgba(16,24,40,.55); padding: 20px; }
.modal-card { background: #fff; border-radius: 16px; padding: 26px; width: 100%; max-width: 390px; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.modal-card h3 { margin: 0 0 14px; }
.modal-card .field { width: 100%; margin-bottom: 12px; }

/* ---------- Bar charts (dashboard) ---------- */
.chart-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .chart-cols { grid-template-columns: 1fr; } }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); font-weight: 600; }
.bar-track { background: var(--bg-2); border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.bar-val .pos { color: var(--good); } .bar-val .neg { color: var(--bad); }
/* barChart() layout: wider label (text) column, narrower bar, value + % of total */
.bars.chart .bar-row { grid-template-columns: minmax(140px, 1.7fr) minmax(56px, 1fr) 118px 46px; }
.bar-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }
.bars.chart .bar-total { margin-top: 4px; padding-top: 7px; border-top: 1.5px solid var(--line); }
.bars.chart .bar-total .bar-label, .bars.chart .bar-total .bar-val, .bars.chart .bar-total .bar-pct { font-weight: 800; color: var(--ink); }

/* ---------- Month-on-month P&L chart ---------- */
.mchart { display: flex; gap: 10px; align-items: flex-end; overflow-x: auto; padding: 10px 2px 4px; }
.mcol { display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.mbars { display: flex; gap: 3px; align-items: flex-end; height: 124px; }
.mbar { width: 14px; border-radius: 4px 4px 0 0; }
.mbar.inc { background: linear-gradient(180deg, var(--good), color-mix(in srgb, var(--good) 60%, #fff)); }
.mbar.exp { background: linear-gradient(180deg, var(--bad), color-mix(in srgb, var(--bad) 60%, #fff)); }
.mx { font-size: 11px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.mx.pos { color: var(--good); } .mx.neg { color: var(--bad); }
.mlbl { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.legend { display: flex; gap: 14px; align-items: center; margin-top: 8px; font-size: 12px; }
.legend .lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .lg.inc::before { background: var(--good); } .legend .lg.exp::before { background: var(--bad); }
.auth-credit { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line, #e2e8f0);
  text-align: center; font-size: 11px; line-height: 1.6; color: var(--muted); }
.auth-credit b { color: var(--brand); }

/* dashboard connection summary — full-width horizontal strip (no empty space) */
.conn-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 18px;
}
.conn-strip-main { min-width: 0; flex: 1 1 280px; }
.conn-strip-main h3 { margin: 2px 0 6px; }
.conn-strip-actions { display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
@media (max-width: 560px) {
  .conn-strip { align-items: stretch; }
  .conn-strip-actions { width: 100%; }
  .conn-strip-actions .btn { flex: 1; }
}
/* dashboard stat rows: stretch to fill the last row instead of leaving gaps */
#kpiArea .kpis, #masterArea .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }


/* identifiable report header (company · address · period) */
.rpt-head { border-left: 4px solid var(--brand); background: color-mix(in srgb, var(--brand) 5%, var(--bg));
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.rpt-head .rpt-co { font-size: 17px; font-weight: 800; color: var(--ink); letter-spacing: -.2px; }
.rpt-head .rpt-addr { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.rpt-head .rpt-meta { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 600; }

/* ---------- Sidebar credit ---------- */
.sidebar-credit { margin-top: auto; padding: 14px 16px 16px; font-size: 10.5px; line-height: 1.5;
  color: var(--muted); border-top: 1px solid var(--line, rgba(255,255,255,.12)); text-align: center; }
.sidebar-credit b { color: var(--brand); font-size: 11px; letter-spacing: .2px; }
.sidebar-credit .muted { opacity: .8; }

/* ---------- Bulk action bar (review) ---------- */
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin: 8px 0;
  background: color-mix(in srgb, var(--brand) 8%, var(--bg)); border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--bg-2)); border-radius: 10px; }
.bulkbar input { font: inherit; padding: 6px 9px; border: 1px solid var(--bg-2); border-radius: 8px; min-width: 220px; }

/* ---------- Financial statements ---------- */
/* These tables live inside fixed-width panels, so cancel the .grid 560px min-width
   (meant for the big scrollable data grids) — otherwise amounts clip off the edge. */
table.stmt { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.stmt th { text-align: left; background: color-mix(in srgb, var(--brand) 12%, var(--bg)); color: var(--brand); font-weight: 800; padding: 7px 9px; }
table.stmt td { padding: 5px 9px; border-bottom: 1px solid var(--bg-2); }
table.stmt td:first-child, table.stmt th:first-child { overflow-wrap: anywhere; }
table.stmt th:nth-child(2), table.stmt td:nth-child(2) { width: 13%; }
table.stmt th:nth-child(3), table.stmt td:nth-child(3) { width: 30%; }
table.stmt tr.tot td { border-top: 2px solid color-mix(in srgb, var(--brand) 40%, var(--bg-2)); border-bottom: none; }
/* numbers always flush right */
table.stmt td.num, table.stmt th.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.sched-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.sched-grid h4 { margin: 0 0 8px; color: var(--brand); font-size: 13px; }
/* Financials: colour the Balance Sheet & P&L headings only (not the data) */
#finArea .chart-cols .panel h3 { color: var(--brand); }
/* group-wise schedule (expandable) */
.sched { font-size: 12.5px; }
.srow, .sgrp > summary { display: flex; align-items: baseline; gap: 10px; padding: 5px 4px; border-bottom: 1px solid var(--bg-2); }
.srow .s-name, .sgrp > summary .s-name { flex: 1 1 auto; overflow-wrap: anywhere; }
.s-amt { flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; min-width: 96px; }
.sgrp > summary { cursor: pointer; list-style: none; font-weight: 600; }
.sgrp > summary::-webkit-details-marker { display: none; }
.sgrp > summary::before { content: "▸"; color: var(--brand); margin-right: 4px; font-size: 11px; }
.sgrp[open] > summary::before { content: "▾"; }
.sgrp .srow.sub { padding-left: 22px; background: color-mix(in srgb, var(--brand) 4%, var(--bg)); font-size: 12px; }
.sgrp .srow.sub .s-name { color: var(--ink-soft); }
.srow.tot { border-bottom: none; border-top: 1.5px solid color-mix(in srgb, var(--brand) 35%, var(--bg-2)); font-weight: 700; margin-top: 2px; }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fld { display: inline-flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.fld select, .fld input { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line, var(--bg-2)); border-radius: 8px; padding: 6px 8px; font-weight: 500; }
.budget-grid .fld { font-size: 12.5px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 38px 18px; color: var(--muted); }
.empty .emoji { font-size: 36px; display: block; margin-bottom: 8px; opacity: .8; }
.empty b { color: var(--ink-soft); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 13px 19px; border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,.28); z-index: 250; font-weight: 600; animation: pop .2s ease; }
.toast.bad { background: var(--bad); } .toast.good { background: var(--good); }

/* ---------- Mobile drawer ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 55; }
.scrim.show { display: block; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: inline-block; }
  .brand-mobile { display: inline-flex; }
  main { padding: 18px; }
}
@media (max-width: 560px) {
  .ctx-label { display: none; }
  .ctx select { max-width: 140px; }
  h1 { font-size: 20px; }
  .panel, .card { padding: 16px; }
  .row > input, .row > select { flex: 1 1 100%; }
  .btn { flex: 1 1 auto; justify-content: center; }
  .conn-badge .conn-text { display: none; }
}

/* ============================================================
   Advanced design system additions
   ============================================================ */
.icon-btn { border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-soft);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 700;
  display: inline-grid; place-items: center; transition: background .15s, color .15s; position: relative; }
.icon-btn:hover { background: var(--line); color: var(--ink); }
#cmdkBtn { font-size: 12px; }

.bell { position: relative; }
.bell-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.bell-panel { position: absolute; right: 0; top: 46px; width: 320px; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 80; padding: 8px; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; font-weight: 700; border-bottom: 1px solid var(--line-2); }
.activity-list { display: flex; flex-direction: column; }
.activity-item { padding: 9px 10px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-item .when { color: var(--muted); font-size: 11.5px; }
.activity-item.good { border-left: 3px solid var(--good); padding-left: 8px; }
.activity-item.bad { border-left: 3px solid var(--bad); padding-left: 8px; }
.link { background: none; border: none; color: var(--brand); cursor: pointer; font-weight: 600; font-size: 12.5px; }

.palette-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(10,14,23,.45); display: grid; place-items: start center; padding-top: 12vh; }
.palette { width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.4); overflow: hidden; }
.palette input { width: 100%; border: none; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 16px; border-radius: 0; }
.palette input:focus { box-shadow: none; }
.palette-list { max-height: 50vh; overflow: auto; }
.palette-item { padding: 11px 18px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.palette-item .ic { width: 20px; text-align: center; }
.palette-item.active, .palette-item:hover { background: var(--info-bg); color: var(--brand); }
.palette-item .hint { margin-left: auto; color: var(--muted); font-size: 11.5px; }

.wizard-overlay { position: fixed; inset: 0; z-index: 220; background: rgba(10,14,23,.55); display: grid; place-items: center; padding: 20px; }
.wizard { background: var(--panel); border-radius: 18px; width: 100%; max-width: 600px; box-shadow: 0 24px 70px rgba(0,0,0,.4); overflow: hidden; }
.wizard-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; font-size: 17px; border-bottom: 1px solid var(--line-2); }
.stepper { display: flex; gap: 10px; list-style: none; margin: 0; padding: 14px 22px; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stepper li .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--bg-2); border: 2px solid var(--line); display: inline-grid; place-items: center; font-size: 10px; }
.stepper li.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.stepper li.active .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.stepper li.active { color: var(--ink); }
.wizard-body { padding: 10px 22px 18px; min-height: 140px; }
.wizard-body h3 { margin: 6px 0 8px; }
.wizard-foot { display: flex; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line-2); }

.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, var(--line) 37%, var(--bg-2) 63%);
  background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: 6px; height: 14px; margin: 8px 0; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.conf-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 64px; }
.conf-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.conf-bar > span { display: block; height: 100%; border-radius: 999px; }
.conf-bar.hi > span { background: var(--good); } .conf-bar.mid > span { background: var(--warn); } .conf-bar.lo > span { background: var(--bad); }
.src-pill { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }

.grid.review td:first-child { border-left: 3px solid transparent; }
.grid.review tr.st-mapped td:first-child, .grid.review tr.st-approved td:first-child { border-left-color: var(--good); }
.grid.review tr.st-needs_review td:first-child { border-left-color: var(--warn); }
.grid.review tr.st-unmapped td:first-child { border-left-color: var(--bad); }
.grid.review tr.st-posted td:first-child { border-left-color: var(--brand); }
.grid.review tr.st-duplicate td:first-child { border-left-color: var(--violet); }
.grid.review tr.sel-row { background: var(--info-bg) !important; }

.review-split { display: flex; gap: 14px; align-items: flex-start; }
.review-split .table-wrap { flex: 1; min-width: 0; }
.voucher-panel { width: 340px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; position: sticky; top: 76px; }
.voucher-panel h4 { margin: 0 0 10px; }
.vp-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.vp-dr { color: var(--bad); } .vp-cr { color: var(--good); }
@media (max-width: 1100px) { .voucher-panel { display: none; } }

.spark { display: block; width: 100%; height: 36px; margin-top: 6px; }
.linechart { width: 100%; height: 220px; }

.inbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; margin: 4px 0 18px; }
.inbox-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.inbox-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.inbox-card.warn { border-left-color: var(--warn); } .inbox-card.bad { border-left-color: var(--bad); } .inbox-card.good { border-left-color: var(--good); }
.inbox-card .big { font-size: 26px; font-weight: 800; }

:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 720px) {
  .grid.review thead { display: none; }
  .grid.review, .grid.review tbody, .grid.review tr, .grid.review td { display: block; width: 100%; }
  .grid.review tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px; }
  .grid.review td { border: none; padding: 6px 10px; }
  .grid.review td.chkcol { display: inline-block; width: auto; }
  .review-split { flex-direction: column; }
}

@media print {
  .sidebar, .topbar, .toolbar, .bulkbar, .report-cards, .colpick, #postBtn { display: none !important; }
  .main-col, main { padding: 0; max-width: none; }
  .panel, .table-wrap, .card { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* ---------- Diagnostics checklist ---------- */
.diag-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.diag-row {
  display: grid; grid-template-columns: 22px 150px 1fr; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); font-size: 13px;
}
.diag-row.ok  { border-left: 3px solid var(--good); }
.diag-row.bad { border-left: 3px solid var(--bad); }
.diag-ic { font-weight: 700; text-align: center; }
.diag-row.ok  .diag-ic { color: var(--good); }
.diag-row.bad .diag-ic { color: var(--bad); }
.diag-name { font-weight: 600; color: var(--ink); }
.diag-detail { color: var(--ink-soft); }
@media (max-width: 560px) {
  .diag-row { grid-template-columns: 22px 1fr; }
  .diag-detail { grid-column: 2; }
}

/* ---------- Receipts & Payments (Bank → R&P) summary ---------- */
.rp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 4px 0 8px; }
.rp-card { min-width: 0; display: flex; flex-direction: column; }
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.rp-total { font-size: 19px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink); }
.rp-list { display: flex; flex-direction: column; max-height: 330px; overflow-y: auto; }
.rp-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 6px; border-bottom: 1px solid var(--line-2); border-radius: 8px;
  cursor: pointer; min-width: 0;
}
.rp-row:hover { background: var(--brand-soft); }
.rp-row:last-child { border-bottom: none; }
.rp-row.static { cursor: default; }
.rp-row.static:hover { background: transparent; }
.rp-cat {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; color: var(--ink-soft); font-size: 13.5px;
}
.rp-cat em {
  font-style: normal; font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--bg-2); border-radius: 9px; padding: 1px 7px; margin-left: 6px;
}
.rp-amt { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; color: var(--ink); }
.rp-arrow { color: var(--muted); font-weight: 400; }
.rp-net { border-top: 2px solid var(--line); margin-top: 4px; padding-top: 10px; }
html[data-theme="dark"] .rp-row:hover { background: rgba(45, 212, 191, .12); }
html[data-theme="dark"] .rp-cat em { background: rgba(255, 255, 255, .08); }

/* ---------- R&P transactions table ----------
   Columns: 1 ☑ · 2 date · 3 narration (gets ALL the spare width) · 4 party ·
   5 amount · 6 group · 7 ★. The generic .grid.review nth-child rules (built for
   the Tally review table) would garble this table — the #id selectors below
   out-rank and reset them. */
#rpTxnsTable { table-layout: fixed; width: 100%; }
#rpTxnsTable th:nth-child(1), #rpTxnsTable td:nth-child(1) { width: 36px; text-align: center; }
#rpTxnsTable th:nth-child(2), #rpTxnsTable td:nth-child(2) {
  width: 96px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
/* bank-wise section heading row (a <th> so the search filter never hides it) */
#rpTxnsTable tr.rp-bankhead th {
  width: auto; white-space: normal; text-align: left;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12.5px; font-weight: 800; letter-spacing: .3px;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
}
#rpTxnsTable tr.rp-bankhead th em {
  font-style: normal; font-weight: 600; color: var(--ink-soft); margin-left: 8px; font-size: 11.5px;
}
html[data-theme="dark"] #rpTxnsTable tr.rp-bankhead th { background: #15302c; color: var(--brand-3); }
#rpTxnsTable th:nth-child(3), #rpTxnsTable td:nth-child(3) {
  width: 34%; max-width: none; white-space: normal;
  overflow-wrap: anywhere; word-break: break-word;
  font-size: 12px; color: var(--ink-soft); line-height: 1.45;
}
#rpTxnsTable th:nth-child(4), #rpTxnsTable td:nth-child(4) {
  width: 150px; max-width: none; white-space: normal; overflow-wrap: break-word;
  font-weight: 600; font-size: 13px; color: var(--ink);
}
#rpTxnsTable th:nth-child(5), #rpTxnsTable td:nth-child(5) {
  width: 116px; min-width: 0; white-space: nowrap; text-align: right;
}
#rpTxnsTable th:nth-child(6), #rpTxnsTable td:nth-child(6) { width: 235px; min-width: 0; }
#rpTxnsTable th:nth-child(7), #rpTxnsTable td:nth-child(7) { width: 48px; }
#rpTxnsTable .led-input { width: 100%; min-width: 0; box-sizing: border-box; display: block; margin-bottom: 5px; }
@media (max-width: 900px) { #rpTxnsTable { table-layout: auto; } }

/* ---------- R&P tool cards (cash book / 26AS) — compact aligned forms ---------- */
.rp-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; margin: 14px 0 4px; }
.rp-tool { min-width: 0; }
.rp-form-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.rp-form-row .btn { margin-bottom: 1px; white-space: nowrap; }
.rp-fld { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase; color: var(--muted); min-width: 0; }
.rp-fld input, .rp-fld select { font-size: 13.5px; min-width: 0; }
.rp-fld input[type="date"] { width: 142px; }
.rp-fld input[type="number"] { width: 130px; }
.rp-fld input[type="file"] { font-size: 12.5px; }
.rp-fld.grow { flex: 1; min-width: 170px; }
.rp-fld.grow input { width: 100%; box-sizing: border-box; }
.rp-form-foot { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 14px; }

/* ---------- R&P bank-wise / consolidated scope selector ---------- */
.rp-scope { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 12px; }
.rp-scope .seg { display: flex; flex-wrap: wrap; }

/* ---------- standard on-screen report heading (client · report · period) ---------- */
.rp-report-head { margin: 16px 0 10px; padding-left: 12px; border-left: 4px solid var(--brand); }
.rp-report-head h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--ink); }
.rp-report-head .muted { font-size: 12.5px; }

/* ---------- R&P season dashboard strip ---------- */
.rp-season { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rp-season .pill { font-weight: 700; }
