/* WebSaviya Business OS — admin styles. No external fonts, CDNs or inline styles (CSP: self only). */
:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --text: #172033;
    --muted: #5f6b7f;
    --border: #e3e7ef;
    --primary: #2f5bea;
    --primary-strong: #2449c7;
    --primary-soft: #e9efff;
    --primary-text: #ffffff;
    --ok: #13804b;
    --ok-bg: #e6f6ee;
    --warn: #b35300;
    --warn-bg: #fff3e3;
    --danger: #c0262d;
    --error-bg: #fdecec;
    --error-text: #9b1c22;
    --info-bg: #e9efff;
    --info-text: #2449c7;
    --side-bg: #0f1a33;
    --side-text: #c6cfe3;
    --side-muted: #7d8aa8;
    --side-active: #ffffff;
    --side-hover: rgba(255, 255, 255, .07);
    --chart-a: #2f5bea;
    --chart-b: #1fae74;
    --chart-grid: #e8ecf3;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, .08);
    --sidebar-w: 248px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c111d;
        --surface: #151c2c;
        --surface-2: #111827;
        --text: #e7ebf3;
        --muted: #98a3b8;
        --border: #263044;
        --primary: #6c8dff;
        --primary-strong: #8aa4ff;
        --primary-soft: #1c2747;
        --primary-text: #0b1220;
        --ok: #4fd393;
        --ok-bg: #12291e;
        --warn: #f3a54e;
        --warn-bg: #33240f;
        --danger: #ff7a7f;
        --error-bg: #351a1c;
        --error-text: #ffb0b3;
        --info-bg: #1c2747;
        --info-text: #a9bcff;
        --side-bg: #0a0f1a;
        --chart-a: #6c8dff;
        --chart-b: #39c98c;
        --chart-grid: #222c3e;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, .35);
    }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 1.25rem; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 1.5rem 0 .6rem; }
code { font-size: .85em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.icon { width: 1.15em; height: 1.15em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem; z-index: 50; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Shell: dark sidebar + main column ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.1rem .75rem; text-decoration: none; color: #fff; }
.logo-mark {
    display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 10px;
    background: linear-gradient(135deg, #4f7bff, #2ec58b); color: #fff; font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.brand { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.env-badge { align-self: flex-start; font-size: .65rem; font-weight: 700; letter-spacing: .04em; padding: .05rem .45rem; border-radius: 999px; background: #e8860c; color: #fff; text-transform: uppercase; }
.nav-scroll { flex: 1; overflow-y: auto; padding: .25rem .6rem 1rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a, .nav-button {
    display: flex; align-items: center; gap: .7rem; padding: .34rem .65rem; margin: 1px 0; border-radius: 8px;
    text-decoration: none; color: var(--side-text); font-size: .92rem; font-weight: 500;
}
.sidebar a:hover, .nav-button:hover { background: var(--side-hover); color: #fff; }
.sidebar a[aria-current="page"] { background: rgba(79, 123, 255, .18); color: var(--side-active); box-shadow: inset 3px 0 0 #4f7bff; }
.sidebar a[aria-current="page"] .icon { color: #8fb0ff; }
.nav-heading { margin: .7rem .65rem .2rem; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }
.sidebar-user { display: flex; align-items: center; gap: .55rem; margin: 0 .6rem; padding: .7rem .3rem .8rem .55rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-text { flex: 1; }
.sidebar .icon-button, .icon-button {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem; padding: 0; margin: 0; border-radius: 8px; border: 0; background: none;
    color: var(--side-muted); cursor: pointer; flex: 0 0 auto;
}
.sidebar .icon-button:hover, .sidebar .icon-button[aria-current="page"] { background: var(--side-hover); color: #fff; box-shadow: none; }
.avatar { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: #23314f; color: #fff; font-weight: 700; font-size: .8rem; flex: 0 0 auto; }
.user-text { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { color: var(--side-muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { margin: 0; }
.nav-button { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: .75rem; padding: .7rem 1.75rem; background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.topbar-title { display: none; font-weight: 650; }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; }
.nav-toggle { display: none; }
.content { padding: 1.75rem; width: 100%; max-width: 1240px; }

/* ---- Buttons ---- */
.button {
    display: inline-flex; align-items: center; gap: .45rem; font: inherit; font-weight: 600; font-size: .92rem; padding: .55rem 1rem;
    border: 1px solid transparent; border-radius: 9px; background: var(--primary); color: var(--primary-text); cursor: pointer; text-decoration: none;
    box-shadow: var(--shadow); transition: background .15s, border-color .15s;
}
.button:hover { background: var(--primary-strong); }
.button-small { padding: .4rem .75rem; font-size: .85rem; }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button-secondary:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { background: #a11f25; }
.button-link { font: inherit; background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; text-decoration: underline; }
.button-link.danger, .danger { color: var(--danger); }
.form .button, .actions .button { margin-top: .5rem; }

/* ---- Cards, panels ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.big { font-size: 1.35rem; font-weight: 700; margin: .3rem 0 0; font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.card-link { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.card-link:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: var(--shadow-lg); }
.cards.compact { margin-top: 1.5rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin: 1.5rem 0; box-shadow: var(--shadow); }
.panel > h2:first-child { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
th { font-weight: 600; color: var(--muted); }
tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
th.num, td.num, input.num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
tfoot th, tfoot td { border-bottom: 0; }
tr.total td, tr.total th { border-top: 2px solid var(--border); }
tr.muted td { color: var(--muted); }
table.items td { vertical-align: top; }
table.items textarea { min-width: 14rem; }
table.items select { max-width: 11rem; }
table.report tr.section th { background: var(--surface-2); font-weight: 650; color: var(--text); }
table.report tr.total th, table.report tr.total td { font-weight: 700; border-top: 2px solid var(--border); }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: .35rem; }
.form.narrow { max-width: 440px; }
.form.narrow-wide { max-width: 760px; }
.form.narrow-wide input:not([type=file]), .form.narrow-wide select { width: 100%; }
label { font-weight: 550; font-size: .9rem; margin-top: .55rem; }
input[type=email], input[type=password], input[type=text], input[type=search], input[type=number], input[type=month],
select, textarea, input[type=date], input[type=tel], input[type=file], input:not([type]) {
    font: inherit; font-size: .93rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text); max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
textarea { width: 100%; resize: vertical; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem 1rem; align-items: start; }
.grid-form .field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.grid-form .field input, .grid-form .field select, .grid-form .field textarea { width: 100%; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: .84rem; margin: .1rem 0 0; }
.field-errors { color: var(--error-text); margin: .2rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; margin: .6rem 0; }
.input-pair { display: flex; gap: .4rem; }
.input-pair input { flex: 1; min-width: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem 1rem; margin: 1rem 0; background: var(--surface); }
legend { font-weight: 650; padding: 0 .3rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.inline-form input[type=search], .inline-form input:not([type]) { min-width: 14rem; }

/* ---- Notices and badges ---- */
.notice { padding: .7rem .95rem; border-radius: 10px; margin: 0 0 1rem; border: 1px solid transparent; }
.notice p { margin: 0; }
.notice p + p { margin-top: .25rem; }
.notice ul { margin: 0; padding-left: 1.2rem; }
.notice-error { background: var(--error-bg); color: var(--error-text); border-color: color-mix(in srgb, var(--error-text) 18%, transparent); }
.notice-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 18%, transparent); }
.notice-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 18%, transparent); }
.debug { white-space: pre-wrap; font-size: .8rem; background: var(--surface); border: 1px solid var(--border); padding: 1rem; overflow-x: auto; border-radius: 8px; }
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-accepted, .badge-won, .badge-active, .badge-paid, .badge-applied, .badge-recorded, .badge-credited, .badge-renewed, .badge-emailed, .badge-sent, .badge-imported {
    background: var(--ok-bg); color: var(--ok); border-color: transparent;
}
.badge-issued, .badge-proposal_sent, .badge-qualified, .badge-contacted, .badge-unpaid, .badge-partially_paid, .badge-open, .badge-due, .badge-queued, .badge-new, .badge-dry_run {
    background: var(--info-bg); color: var(--info-text); border-color: transparent;
}
.badge-expired, .badge-rejected, .badge-lost, .badge-withdrawn, .badge-overdue, .badge-failed, .badge-bounced, .badge-blocked, .badge-unknown {
    background: var(--error-bg); color: var(--error-text); border-color: transparent;
}
.badge-draft { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-superseded, .badge-archived, .badge-merged, .badge-void, .badge-reversed, .badge-paused, .badge-cancelled, .badge-not_renewed, .badge-dismissed, .badge-skipped, .badge-obsolete, .badge-rolled_back { color: var(--muted); }

/* ---- Details, misc ---- */
dl.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 1rem 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }
.pre { white-space: pre-wrap; }
.danger-zone { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.danger-zone summary { cursor: pointer; font-weight: 600; }
.due { color: var(--warn); font-weight: 600; }
.email-body { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; font: inherit; max-width: 60rem; }
.report-meta { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .6rem 1rem; margin: .75rem 0 1rem; font-size: .9rem; }
.report-meta p { margin: .25rem 0; }

/* ---- Guest pages (sign in, setup, errors) ---- */
body.guest { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem;
    background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent), var(--bg); }
.guest-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.75rem; box-shadow: var(--shadow-lg); }
.guest-card .brand { font-size: 1rem; }
.guest-card .button { width: 100%; justify-content: center; margin-top: 1.1rem; }
.guest-card input { width: 100%; }

/* ---- Dashboard ---- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: -0.5rem 0 1.25rem; }
.dash-head p { margin: 0; color: var(--muted); }
.quick-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { position: relative; display: flex; flex-direction: column; gap: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--kpi, var(--primary)); }
.kpi:hover { box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--kpi, var(--primary)) 40%, var(--border)); }
.kpi-label { display: flex; align-items: center; gap: .45rem; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-label .icon { color: var(--kpi, var(--primary)); }
.kpi-value { font-size: 1.55rem; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-value .cur { font-size: .8rem; font-weight: 600; color: var(--muted); margin-right: .25rem; letter-spacing: 0; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.kpi-owed { --kpi: #2f5bea; }
.kpi-overdue { --kpi: #e0533a; }
.kpi-revenue { --kpi: #7a4cf0; }
.kpi-cash { --kpi: #13a06a; }
.kpi-mrr { --kpi: #e8860c; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.25rem; }
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); min-width: 0; }
.widget-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .75rem; }
.widget-head h2 { margin: 0; font-size: 1rem; }
.widget-head a { font-size: .85rem; text-decoration: none; white-space: nowrap; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin: .25rem 0 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-a, .swatch-a { fill: var(--chart-a); background: var(--chart-a); }
.chart-b, .swatch-b { fill: var(--chart-b); background: var(--chart-b); }
.chart rect:hover { opacity: .85; }
.chart-stack { height: 14px; border-radius: 7px; margin: .4rem 0 .9rem; }
.chart-empty { fill: var(--chart-grid); }
.age-current, .swatch-current { fill: #2fb37a; background: #2fb37a; }
.age-d1_30, .swatch-d1_30 { fill: #f2b233; background: #f2b233; }
.age-d31_60, .swatch-d31_60 { fill: #f08a3c; background: #f08a3c; }
.age-d61_90, .swatch-d61_90 { fill: #e65b46; background: #e65b46; }
.age-d90, .swatch-d90 { fill: #b8323a; background: #b8323a; }
.aging-rows { list-style: none; margin: 0; padding: 0; }
.aging-rows li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .32rem 0; font-size: .9rem; border-bottom: 1px dashed var(--border); }
.aging-rows li:last-child { border-bottom: 0; }
.aging-rows .name { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); }
.aging-rows .amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list li:last-child { border-bottom: 0; }
.list .primary { display: flex; flex-direction: column; min-width: 0; }
.list .primary a, .list .primary strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .secondary { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.list .value .secondary { display: block; font-weight: 400; }
.empty { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; padding: .5rem 0; }
.empty .icon { color: var(--ok); }
.actions-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.actions-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.actions-list li a { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text); font-weight: 600; flex: 1; min-width: 0; }
.actions-list .count { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 .45rem; border-radius: 8px; font-weight: 750; font-size: .9rem; background: var(--info-bg); color: var(--info-text); }
.actions-list .hint-text { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.actions-list .go { color: var(--muted); }
.actions-list li.action-urgent .count { background: var(--error-bg); color: var(--error-text); }
.actions-list li.action-high .count { background: var(--warn-bg); color: var(--warn); }
.actions-list li.action-info .count { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.actions-list li:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.all-clear { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-radius: 10px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.stat { display: flex; flex-direction: column; padding: .7rem .85rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; color: inherit; }
.stat:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.stat strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }
.health { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .84rem; color: var(--muted); margin-top: 1.25rem; padding: .75rem 1rem; border: 1px dashed var(--border); border-radius: 10px; }
.health b { color: var(--text); font-weight: 600; }
.health .ok, .health .warn { font-weight: 700; }
.currency-note { font-size: .82rem; color: var(--muted); margin: -0.5rem 0 1rem; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .shell { display: block; }
    .sidebar { display: none; position: static; width: auto; height: auto; }
    .sidebar.open { display: flex; }
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; font: inherit; width: 2.4rem; height: 2.4rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; }
    .topbar { padding: .6rem 1rem; }
    .topbar-title { display: block; }
    .topbar-actions .button span { display: none; }
    .content { padding: 1.1rem; }
    .grid-form, .two-col { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .inline-form input[type=search], .inline-form input:not([type]) { min-width: 0; width: 100%; }
    /* Quotation lines stack as cards on phones; each cell shows its own label. */
    table.items thead { display: none; }
    table.items, table.items tbody, table.items tr, table.items td { display: block; width: 100%; }
    table.items tr.item-row { border-bottom: 2px solid var(--border); padding: .5rem 0; }
    table.items td { border: 0; padding: .25rem .75rem; }
    table.items td::before { content: attr(data-label); display: block; font-size: .8rem; color: var(--muted); }
    table.items td input, table.items td select, table.items td textarea { width: 100%; max-width: none; min-width: 0; }
}
@media print {
    .sidebar, .topbar, .quick-actions { display: none !important; }
    .content { padding: 0; }
}
