/* ───────── Tokens ───────── */
:root {
    --bg: #f5f6f3;
    --surface: #ffffff;
    --surface-2: #f0f2ee;
    --border: #e1e4dd;
    --text: #1c2119;
    --muted: #667062;
    --primary: #2f6f3e;
    --primary-hover: #275d34;
    --primary-soft: #e6f0e7;
    --on-primary: #ffffff;
    --sidebar: #1d2b20;
    --sidebar-text: #c9d3c8;
    --sidebar-active: #2f4a34;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --warn: #8a5a00;
    --warn-soft: #fff4dc;
    --info: #1f5fa8;
    --info-soft: #e7f0fb;
    --gray-soft: #eceeea;
    --shadow: 0 1px 2px rgba(20, 30, 20, .06), 0 4px 16px rgba(20, 30, 20, .06);
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121612;
        --surface: #1a201a;
        --surface-2: #222a22;
        --border: #2f382f;
        --text: #e6ebe4;
        --muted: #98a395;
        --primary: #5aa86c;
        --primary-hover: #6dbb7f;
        --primary-soft: #1f3324;
        --on-primary: #0d150e;
        --sidebar: #0e130f;
        --sidebar-text: #b4bfb2;
        --sidebar-active: #22352a;
        --danger: #f0776c;
        --danger-soft: #3a1d1a;
        --warn: #e8b54a;
        --warn-soft: #3a2d10;
        --info: #78aef0;
        --info-soft: #182a40;
        --gray-soft: #2a312a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
h1:focus { outline: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 24px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ───────── Shell ───────── */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; flex: none; }
.brand-name { font-size: 15px; line-height: 1.2; }
.nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 1px; flex: 1; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7f8c7d; padding: 14px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--sidebar-text); font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { flex: none; opacity: .85; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.user-meta { flex: 1; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-roles { font-size: 11.5px; color: #8c998a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .icon-btn { color: var(--sidebar-text); }
.user-card form { margin: 0; }

.content { min-width: 0; }
.topbar { display: none; }
.page { padding: 28px 32px 48px; max-width: 1280px; }
.scrim { display: none; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    .nav-open .sidebar { transform: none; }
    .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
    .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
    .topbar-title { font-weight: 600; }
    .page { padding: 20px 16px 40px; }
}

/* ───────── Page header ───────── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header p { margin: 0; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }

/* ───────── Buttons ───────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; height: auto; cursor: pointer; font: inherit; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.btn-google { width: 100%; height: 42px; font-weight: 600; }

/* ───────── Cards & stats ───────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-header h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-sub { font-size: 12px; color: var(--muted); }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }

/* ───────── Tables ───────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: none; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.empty-state { max-width: 460px; margin: 60px auto; text-align: center; }

/* ───────── Toolbar / filters ───────── */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.tab { border: none; background: none; padding: 5px 12px; border-radius: 6px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ───────── Forms ───────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.input, .select, .textarea, input.form-control, select.form-control, textarea.form-control {
    width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
.textarea, textarea.form-control { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus, .form-control:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.check-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.check-card input { margin-top: 3px; accent-color: var(--primary); }
.check-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.validation-message { color: var(--danger); font-size: 12.5px; }
.validation-errors { color: var(--danger); margin: 0 0 12px; padding-left: 18px; }
.invalid { border-color: var(--danger) !important; }

/* ───────── Badges & alerts ───────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-neutral, .badge-gray { background: var(--gray-soft); color: var(--muted); }
.badge-green { background: var(--primary-soft); color: var(--primary); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-amber { background: var(--warn-soft); color: var(--warn); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); display: block; }
.alert-ok { background: var(--primary-soft); color: var(--primary); }

/* ───────── Modal ───────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 10, .45); z-index: 100; }
.modal {
    position: fixed; z-index: 101; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
    background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-body { padding: 18px 20px 20px; }

/* ───────── Timeline (CRM interactions) ───────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 8px; align-items: center; }
.timeline .body { white-space: pre-wrap; }

/* ───────── Schedule week ───────── */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 180px; display: flex; flex-direction: column; }
.day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.day-head { padding: 8px 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; }
.day-name { font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.day-num { font-weight: 700; font-size: 16px; }
.day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.job-chip { display: block; text-align: left; width: 100%; border: 1px solid var(--border); border-left: 3px solid var(--info); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 12.5px; color: var(--text); cursor: pointer; }
.job-chip:hover { border-color: var(--primary); text-decoration: none; }
.job-chip.s-InProgress { border-left-color: var(--warn); }
.job-chip.s-Completed { border-left-color: var(--primary); opacity: .8; }
.job-chip.s-Cancelled { border-left-color: var(--muted); opacity: .55; text-decoration: line-through; }
.job-chip .t { font-weight: 600; }
.job-chip .c { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1000px) { .week { grid-template-columns: 1fr; } .day { min-height: 0; } }

.job-card { display: flex; gap: 14px; align-items: flex-start; }
.job-card .when { min-width: 92px; font-weight: 600; }
.job-card .when .d { color: var(--muted); font-weight: 500; font-size: 12.5px; }

/* ───────── Login ───────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--primary-soft), var(--bg) 60%); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.login-card .brand { color: var(--text); padding: 0 0 8px; }
.login-card h1 { margin-bottom: 0; }
.login-card p { margin: 0; }
.dev-login { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 12px; }
.dev-login summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.dev-login form { margin-top: 10px; }

/* ───────── Invoice editor & print ───────── */
.lines .input { height: 32px; }
.lines td { padding: 6px 8px; }
.totals { margin-left: auto; width: min(320px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 12px 14px 4px; }
.totals .grand { font-size: 16px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; }

.print-page { max-width: 820px; margin: 0 auto; padding: 40px 32px; background: #fff; color: #1c2119; min-height: 100vh; }
.print-page .muted { color: #667062; }
.print-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.print-title { font-size: 30px; font-weight: 700; color: #2f6f3e; margin: 0; }
.print-page .table th { background: #f0f2ee; color: #667062; }
.print-page .table td, .print-page .table th { border-color: #e1e4dd; }
.print-toolbar { display: flex; gap: 8px; justify-content: flex-end; max-width: 820px; margin: 16px auto 0; padding: 0 32px; }
@media print {
    .print-toolbar, #blazor-error-ui, #components-reconnect-modal { display: none !important; }
    body { background: #fff; }
    .print-page { padding: 0; }
}

/* ───────── Blazor ───────── */
.blazor-error-boundary { background: var(--danger-soft); color: var(--danger); padding: 1rem; border-radius: 8px; }
.blazor-error-boundary::after { content: "An error has occurred." }

/* ───────── Files ───────── */
.file-picker { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 4px; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; }
.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-list.compact { margin: 0; }
.file-list.compact li { padding: 0; background: none; border: none; }
.file-list.compact .file-name { font-weight: 400; font-size: 12.5px; }

/* ───────── Leave ───────── */
.balance-bar { height: 6px; border-radius: 999px; background: var(--gray-soft); overflow: hidden; margin-top: 8px; }
.balance-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.callout { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.callout strong { font-variant-numeric: tabular-nums; }
.section-title { margin: 24px 0 10px; }

/* ───────── Compliance ───────── */
.alert-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--border); background: var(--surface); border-left-width: 4px; }
.alert-row.level-Critical { border-left-color: var(--danger); background: var(--danger-soft); }
.alert-row.level-Warning { border-left-color: var(--warn); background: var(--warn-soft); }
.alert-row.level-Info { border-left-color: var(--info); }
.alert-row .alert-text { flex: 1; min-width: 0; }
.alert-row .alert-icon { font-size: 16px; }
.day-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; font-weight: 500; color: var(--muted); user-select: none; }
.day-toggle input { display: none; }
.day-toggle.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
fieldset:disabled .day-toggle { cursor: default; opacity: .8; }
.doc-block { padding: 12px; border: 1px dashed var(--border); border-radius: 8px; min-width: 0; }

/* ───────── Quotation signature block ───────── */
.signature-block { margin-top: 40px; padding-top: 20px; border-top: 1px solid #e1e4dd; break-inside: avoid; }
.signature-grid { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 24px; }
.sig-line { border-bottom: 1px solid #1c2119; height: 40px; margin-bottom: 4px; }

/* Blazor's error bar: hidden until the framework shows it. Global (not layout-scoped) so pages
   using EmptyLayout (login, print views) hide it too. */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ───────── Charts (dataviz reference palette, validated light + dark) ───────── */
.viz { --series-1: #2a78d6; --series-2: #eb6834; --viz-grid: #e8e9e4; --viz-tip-bg: #1c2119; --viz-tip-fg: #ffffff; }
@media (prefers-color-scheme: dark) {
    .viz { --series-1: #3987e5; --series-2: #d95926; --viz-grid: #2c332c; --viz-tip-bg: #f0f2ee; --viz-tip-fg: #121612; }
}
.viz-mark { position: relative; outline: none; transition: filter .12s; }
.viz-mark:hover, .viz-mark:focus-visible { filter: brightness(1.12); }
.viz-mark:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.viz-tip {
    display: none; position: absolute; z-index: 20; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: var(--viz-tip-bg); color: var(--viz-tip-fg); border-radius: 6px; padding: 6px 9px; white-space: nowrap;
    font-size: 12px; line-height: 1.35; pointer-events: none; box-shadow: var(--shadow);
}
.viz-tip strong { display: block; font-size: 13px; }
.viz-tip span { opacity: .8; }
.viz-mark:hover .viz-tip, .viz-mark:focus-visible .viz-tip { display: block; }
.viz-table { margin-top: 10px; font-size: 12.5px; }
.viz-table summary { cursor: pointer; color: var(--muted); }
.viz-table .table td, .viz-table .table th { padding: 6px 10px; }

/* Single-series horizontal bars */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bl-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr; gap: 12px; align-items: center; }
.bl-label { color: var(--muted); font-size: 12.5px; text-align: right; }
.bl-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bl-bar { display: block; height: 18px; min-width: 2px; border-radius: 0 4px 4px 0; cursor: default; flex: none; max-width: calc(100% - 90px); }
.bl-bar .viz-tip { left: 100%; transform: translateX(-50%); }
.bl-value { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Grouped columns */
.cc-legend { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }
.cc-key { display: inline-flex; align-items: center; gap: 6px; }
.cc-swatch { width: 10px; height: 10px; border-radius: 2px; }
.cc-plot { display: grid; grid-template-columns: 44px 1fr; height: 220px; }
.cc-axis { position: relative; margin-bottom: 22px; }
.cc-axis span { position: absolute; right: 8px; transform: translateY(50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cc-area { position: relative; }
.cc-grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--viz-grid); }
.cc-groups { position: absolute; inset: 0; display: flex; }
.cc-group { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cc-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; margin-bottom: 0; }
.cc-bar { display: block; width: min(24px, 40%); border-radius: 4px 4px 0 0; }
.cc-cat { height: 22px; line-height: 22px; text-align: center; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Statement of account */
.statement-toolbar { flex-wrap: wrap; align-items: center; }
.soa-due { text-align: right; padding: 10px 14px; border: 1px solid #e1e4dd; border-radius: 8px; }
.soa-due-value { font-size: 22px; font-weight: 700; }
.soa-opening td { color: #667062; font-style: italic; }

/* Header cells follow their column's alignment (the generic th rule used to override .num). */
.table th.num { text-align: right; }
.center, .table th.center { text-align: center; }

/* ───────── How to pay (printed invoices & statements) ───────── */
.how-to-pay { margin-top: 28px; padding: 14px 16px; border: 1px solid #e1e4dd; border-radius: 8px; break-inside: avoid; }
.how-to-pay h3 { margin: 0 0 10px; }
.htp-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.htp-paynow { display: flex; gap: 12px; align-items: center; }
.htp-paynow img { display: block; border: 1px solid #e1e4dd; border-radius: 6px; background: #fff; }
.htp-bank { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.htp-bank dt { color: #667062; }
.htp-bank dt:first-child { color: inherit; font-weight: 700; grid-column: 1 / -1; }
.htp-bank dd { margin: 0; }
.htp-bank dd:empty { display: none; }
.print-preview { background: #fff; color: #1c2119; border-radius: 8px; padding: 4px 12px 12px; }
.print-preview .muted { color: #667062; }
.qr-preview { border: 1px solid var(--border); border-radius: 6px; background: #fff; }

/* CSV import preview */
.import-preview { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.import-preview tr.import-Rejected td { background: var(--danger-soft); }
.import-preview tr.import-Warning td { background: var(--warn-soft); }

/* ───────── Payroll ───────── */
.pay-doc { font-size: 13px; }
.pay-doc .print-head { margin-bottom: 18px; }
.pay-who { grid-template-columns: 110px 1fr; margin-bottom: 16px; }
.pay-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pay-table td, .pay-table th { padding: 6px 10px; }
.pay-net { display: flex; justify-content: space-between; align-items: center; margin: 16px 0; padding: 12px 16px; border: 2px solid #2f6f3e; border-radius: 8px; font-size: 16px; }
.pay-net strong { font-size: 22px; }
.pay-employer { margin-top: 4px; }
.voucher-sign { margin-top: 28px; padding-top: 16px; border-top: 1px solid #e1e4dd; break-inside: avoid; }
.voucher-sign-grid { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: end; }
.thumb-box { height: 110px; border: 1px dashed #667062; border-radius: 6px; margin-bottom: 4px; }
.voucher-preview { position: sticky; top: 16px; }
.voucher-preview .print-page { padding: 24px; min-height: 0; border: 1px solid var(--border); border-radius: 10px; }
.inline-num { width: 64px; height: 26px; display: inline-block; padding: 0 6px; }
@media (max-width: 1000px) { .pay-cols { grid-template-columns: 1fr; } .voucher-preview { position: static; } }
@media print { .page-break { break-after: page; } .page-break:last-child { break-after: auto; } }

/* Salary vouchers and payslips are printed: black on white only, no colour or tints. */
.pay-doc, .pay-doc .muted, .pay-doc .print-title, .pay-doc .table th, .pay-doc .table td, .pay-doc .dl dt { color: #000; }
.pay-doc .print-title { letter-spacing: .02em; }
.pay-doc .table th { background: none; border-bottom: 1px solid #000; }
.pay-doc .table td { border-color: #bbb; }
.pay-doc .table tfoot td { border-top: 1px solid #000; }
.pay-doc .pay-net { border-color: #000; }
.pay-doc .thumb-box { border-color: #000; }
.pay-doc .sig-line { border-color: #000; }
.pay-doc .voucher-sign { border-color: #000; }
/* Any remaining border inside a voucher/payslip is neutral grey (the app's default border is green-tinted). */
.pay-doc, .pay-doc * { border-color: #bbb; }
.pay-doc .table th, .pay-doc .table td { border-color: #bbb; }
.pay-doc .table th { border-bottom-color: #000; }
.pay-doc .table tfoot td { border-top-color: #000; }
.pay-advance { margin: 16px 0 0; }
.pay-advance + .pay-net { margin-top: 8px; }

/* Paging & customer notes */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.card-flush .pager, .table-wrap + .pager { padding: 10px 14px 0; }
.timeline .meta .spacer { flex: 1; }
.timeline .meta .btn-link { font-size: 12px; }
.special-note { border-left: 4px solid var(--warn); }
.over-limit { color: var(--danger); font-weight: 600; }

/* Confirmation dialog & toasts */
.confirm-backdrop { z-index: 150; }
.confirm-dialog { max-width: 440px; z-index: 151; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.08); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: 10px; background: var(--surface, #fff); border: 1px solid var(--border);
         box-shadow: 0 6px 20px rgba(0,0,0,.14); font-size: 14px; animation: toast-in .18s ease-out; }
.toast-ok { border-left: 4px solid var(--primary); }
.toast-ok > span:first-child { color: var(--primary); font-weight: 700; }
.toast-error { border-left: 4px solid var(--danger); }
.toast-error > span:first-child { color: var(--danger); font-weight: 700; }
.toast-msg { flex: 1; }
.toast .icon-btn { width: 26px; height: 26px; font-size: 12px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) { .toasts { left: 16px; right: 16px; bottom: 16px; max-width: none; } }
@media print { .toasts { display: none; } }

/* Service addresses */
.site-list { list-style: none; margin: 0; padding: 0; }
.site-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.site-list li:last-child { border-bottom: none; }
.card-flush > .pager { padding: 10px 16px 12px; margin-top: 0; }

/* Printable reports (payroll summary, expense summary) */
.report-doc { font-size: 13px; }
.report-doc h3 { font-size: 14px; }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.report-table { width: 100%; }
.report-table td, .report-table th { padding: 6px 8px; }
.report-table tfoot td { font-weight: 700; border-top: 2px solid #1c2119; }
.report-subtotal td { font-weight: 600; border-top: 1px solid #1c2119; }
@media (max-width: 640px) { .report-cols { grid-template-columns: 1fr; } }
@media print { .report-table tr { break-inside: avoid; } .report-doc h3 { break-after: avoid; } }

/* Customer search box */
.customer-picker { position: relative; }
.customer-picker .picked { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.picker-results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: 320px; overflow-y: auto;
                  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.picker-option { display: block; width: 100%; text-align: left; padding: 8px 12px; background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; font: inherit; color: inherit; }
.picker-option:last-child { border-bottom: 0; }
.picker-option:hover, .picker-option:focus { background: var(--surface-2); }
.pad-sm { padding: 8px 12px; }

/* Business details: letterhead, logos and accreditation badges */
.company-header { display: flex; gap: 14px; align-items: flex-start; }
.company-logo { max-height: 64px; max-width: 160px; object-fit: contain; }
.accreditations { margin-top: 36px; padding-top: 12px; border-top: 1px solid #e1e4dd; break-inside: avoid; }
.accreditations-title { text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.accreditation-logos { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-end; }
.accreditation-logos figure { margin: 0; text-align: center; width: 110px; }
.accreditation-logos img { max-height: 54px; max-width: 110px; object-fit: contain; display: block; margin: 0 auto 4px; }
.accreditation-logos figcaption { font-size: 10.5px; color: #667062; line-height: 1.3; }
.brand-logo { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: #fff; overflow: hidden; flex: none; }
.brand-logo img { max-width: 30px; max-height: 30px; object-fit: contain; }
.badge-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.badge-slot { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.logo-box { display: flex; align-items: center; justify-content: center; height: 80px; border: 1px dashed var(--border); border-radius: 8px; background: #fff; }
.logo-box img { max-height: 70px; max-width: 90%; object-fit: contain; }
.logo-box-lg { height: 120px; }
.logo-box-lg img { max-height: 108px; }
.biz-preview { background: #fff; color: #1c2119; border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.biz-preview .muted { color: #667062; }
.biz-preview .accreditations { margin-top: 16px; }

/* Price list toolbar: compact supplier search */
.toolbar-picker { margin: 0; min-width: 220px; }
.toolbar-picker > label:empty { display: none; }
