/* AdvEnTally legacy component styles.
   The application design system is css/dashboard.css (loaded first). Everything below is scoped to
   .legacy - the host of pages built on PageHeader / CrudPage / DataGrid - so that neither stylesheet
   leaks into the other's pages. */
:root {
    --ink-soft: var(--muted);
    --ink-faint: var(--faint);
    --surface: var(--card);
    --surface-alt: #F7FAF9;
    --primary: var(--brand);
    --primary-dark: #173d4b;
    --grid-head: #6E828A;
    --green: var(--pos);
    --orange: #D9822B;
    --red: var(--neg);
    --focus: var(--brand-2);
    --font: var(--sans);
}

/* shell hosts */
.main.main-legacy { display: flex; flex-direction: column; height: 100vh; }
.legacy { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; flex-direction: column; font-size: 14px; color: var(--ink); }
.legacy.legacy-account { display: block; min-height: 100vh; padding: 0; overflow: visible; }
.app-loading { padding: 40px; color: var(--muted); }

.legacy {
    /* undo the design-system reset and globals inside legacy pages */
    :where(p) { margin: 1em 0; }
    :where(ul, ol) { margin: 1em 0; padding-left: 40px; }
    :where(h4, h5) { margin: 1.2em 0; }
    :where(table) { font-size: inherit; width: auto; }
    :where(thead th) { letter-spacing: normal; text-transform: none; color: inherit; font-size: inherit; padding: 0; border-bottom: 0; }
    :where(tbody td) { padding: 0; border-bottom: 0; }
    :where(tbody tr:hover) { background: none; }
    :where(dd) { margin-left: 40px; }
    table.grid { display: table; }
    .card { box-shadow: none; }
    .kpi { position: static; overflow: visible; }
    .legend { display: inline-block; gap: 0; }
    .badge { position: static; min-width: 0; height: auto; border: 0; font-family: inherit; top: auto; right: auto; }
    .icon-btn { width: auto; height: auto; display: inline-block; position: static; }
    .btn-close { height: auto; }
    .period { align-items: stretch; font-size: inherit; font-weight: inherit; }
    .num { font-variant-numeric: tabular-nums; }

    * { box-sizing: border-box; }
    h1, h2, h3 { margin: 0; font-weight: 600; }
    a { color: var(--primary); }
    code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-alt); padding: 1px 5px; border-radius: 4px; }
    .grow { flex: 1; }
    .muted { color: var(--ink-soft); }
    .mono { font-family: var(--mono); }
    .right { text-align: right; }
    .center { text-align: center; }
    .icon { flex: none; vertical-align: -3px; }

    /* ---------- buttons ---------- */
    .btn {
        display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 8px;
        border: 1px solid transparent; font: 600 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
    }
    .btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
    .btn-primary { background: var(--primary); color: #fff; }
    .btn-primary:hover { background: var(--primary-dark); }
    .btn-green { background: var(--green); color: #fff; }
    .btn-green:hover { filter: brightness(.94); }
    .btn-close { background: var(--orange); color: #fff; }
    .btn-close:hover { filter: brightness(.94); }
    .btn-danger { background: var(--red); color: #fff; }
    .btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
    .btn-ghost:hover { background: var(--surface-alt); }
    .btn-sm { padding: 6px 10px; font-size: 13px; }
    .btn-block { width: 100%; }
    .btn-x { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; color: var(--ink-soft); }
    .icon-btn { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--primary); border-radius: 6px; line-height: 0; }
    .icon-btn:hover { background: #e3ecee; }
    .icon-btn.danger { color: var(--red); }
    .icon-btn.locked { color: var(--ink-faint); cursor: default; }
    .icon-btn:disabled { color: var(--ink-faint); cursor: default; background: none; }

    /* ---------- forms ---------- */
    .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
    .field > span { font-weight: 600; font-size: 13px; color: var(--ink-soft); }
    .field small, .hint { color: var(--ink-faint); font-size: 12px; }
    .req { color: var(--red); }
    input:not([type=checkbox]):not([type=radio]), select, textarea {
        font: 14px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
        padding: 9px 11px; width: 100%; min-width: 0;
    }
    input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
    input:disabled, select:disabled { background: var(--surface-alt); color: var(--ink-soft); }
    textarea { resize: vertical; min-height: 64px; }
    .check { display: flex; align-items: center; gap: 9px; font-weight: 500; margin-bottom: 10px; cursor: pointer; }
    .check input { width: 17px; height: 17px; accent-color: var(--primary); }
    .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
    .form-grid .span2 { grid-column: span 2; }
    .form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
    .form-section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
    .validation-message { color: var(--red); font-size: 12px; }
    input.invalid, select.invalid { border-color: var(--red); }

    .alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
    .alert-error { background: #fbe9e7; color: #8f2d25; border: 1px solid #f2c4bf; }
    .alert-ok { background: #e5f4ec; color: #1f6a4a; border: 1px solid #bfe2d0; }
    .alert-info { background: #e4ecef; color: var(--primary-dark); border: 1px solid #cbdade; }
    .secret { font-family: var(--mono); font-size: 16px; background: var(--surface-alt); border: 1px dashed var(--grid-head); border-radius: 8px; padding: 10px 14px; user-select: all; display: inline-block; }

    /* ---------- account pages ---------- */
    .account-shell { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 48px 16px; gap: 18px; }
    .account-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; color: var(--primary); }
    .brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 700; flex: none; }
    .account-card { background: var(--surface); border-radius: 14px; box-shadow: 0 6px 24px rgba(23, 37, 45, .08); padding: 28px; width: 100%; max-width: 420px; }
    .account-card.wide { max-width: 720px; }
    .account-card h1 { font-size: 22px; margin-bottom: 6px; }
    .account-card p.muted { margin: 0 0 18px; }
    .account-alt { text-align: center; margin: 16px 0 0; color: var(--ink-soft); }
    .account-foot { color: var(--ink-faint); font-size: 12px; margin: 0; }

    /* ---------- application shell ---------- */
    .app-loading { padding: 40px; color: var(--ink-soft); }
    .app-shell { display: grid; grid-template-columns: 224px 1fr; height: 100vh; }
    .app-shell.nav-collapsed { grid-template-columns: 60px 1fr; }
    .app-shell.nav-collapsed .nav-label { display: none; }
    .app-nav { background: var(--primary-dark); color: #cfdde2; display: flex; flex-direction: column; padding: 12px 10px; gap: 4px; overflow: hidden; }
    .nav-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 17px; font-weight: 700; text-decoration: none; padding: 4px 4px 14px; }
    .nav-brand .brand-mark { background: var(--orange); }
    .app-nav nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
    .nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8fa9b3; padding: 14px 10px 4px; min-height: 12px; }
    .nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #cfdde2; text-decoration: none; font-weight: 500; white-space: nowrap; }
    .nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
    .nav-item.active { background: rgba(255, 255, 255, .15); color: #fff; }
    .nav-toggle { align-self: flex-end; background: none; border: 0; color: #8fa9b3; cursor: pointer; padding: 6px; }
    .app-main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
    .app-top { display: flex; align-items: center; gap: 14px; padding: 8px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
    .top-company { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--primary); }
    .top-company select { width: auto; padding: 5px 8px; font-weight: 600; }
    .top-spacer { flex: 1; }
    .top-user { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
    .avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; font-size: 12px; font-weight: 700; }
    .app-content { flex: 1; min-height: 0; padding: 16px; overflow: auto; display: flex; flex-direction: column; }

    /* ---------- page header ---------- */
    .page-title { display: flex; align-items: center; gap: 10px; padding: 14px 18px; color: var(--primary); }
    .page-title h1 { font-size: 18px; color: var(--ink); }
    .page-company { color: var(--ink-faint); font-weight: 600; }
    .page-title-bar { background: var(--surface); border-radius: var(--radius); box-shadow: 0 1px 4px rgba(23, 37, 45, .08); margin-bottom: 16px; }
    .page-size { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
    .page-size select { width: auto; padding: 5px 8px; }
    .page-body { max-width: 1320px; width: 100%; margin: 0 auto; }

    /* ---------- list page: grid + side panel ---------- */
    .list-page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0; flex: 1; min-height: 0; background: var(--surface); border-radius: 14px; box-shadow: 0 2px 10px rgba(23, 37, 45, .08); overflow: hidden; }
    .grid-card { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
    .grid-scroll { flex: 1; overflow: auto; min-height: 120px; }
    table.grid { width: 100%; border-collapse: collapse; }
    table.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--grid-head); color: #fff; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 11px 12px; white-space: nowrap; }
    table.grid thead th.right { text-align: right; }
    table.grid thead th.center { text-align: center; }
    table.grid thead th.sortable { cursor: pointer; }
    .sort-mark { font-size: 9px; margin-left: 4px; }
    table.grid thead tr.filters th { top: 39px; padding: 7px 12px 9px; border-top: 2px solid rgba(255, 255, 255, .55); }
    table.grid thead tr.filters input { padding: 6px 9px; font-size: 13px; border: 0; font-weight: 400; letter-spacing: 0; }
    table.grid thead tr.filters input.eq { max-width: 130px; }
    table.grid td { padding: 9px 12px; border-bottom: 1px solid #edf1f2; vertical-align: middle; }
    table.grid tbody tr:nth-child(even) td { background: #fafcfc; }
    table.grid tbody tr:hover td { background: #eef5f6; }
    table.grid tbody tr.selected td { background: #dcebee; }
    table.grid tbody tr { cursor: pointer; }
    table.grid tr.empty td { text-align: center; color: var(--ink-faint); padding: 36px; cursor: default; background: none !important; }
    table.grid td.mono { font-size: 13.5px; white-space: nowrap; }
    .cell-strong { font-weight: 600; white-space: nowrap; }
    .cell-sub { color: var(--ink-faint); font-size: 12px; }
    .row-actions { display: flex; gap: 6px; align-items: center; }
    .grid-foot { display: flex; align-items: center; gap: 6px; padding: 9px 18px; border-top: 1px solid var(--line); color: var(--ink-soft); }
    .pg { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; font: 600 13px var(--font); color: var(--ink-soft); cursor: pointer; }
    .pg:disabled { opacity: .45; cursor: default; }
    .pg.current { background: var(--primary); color: #fff; border-color: var(--primary); cursor: default; }

    .side-panel { background: var(--surface-alt); border-left: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
    .side-panel .btn { width: 100%; }
    .side-row { display: flex; gap: 10px; }
    .side-row .btn { width: auto; }
    .side-row .btn-green { padding: 9px 12px; }
    .side-hint { color: var(--ink-faint); font-size: 12px; margin: -4px 0 0; }
    .side-label { font-weight: 600; font-size: 13px; color: var(--ink-soft); margin-bottom: -6px; }
    .side-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; text-align: center; color: var(--ink-soft); }
    .side-box strong { color: var(--ink); }
    .side-check { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
    .side-note { color: var(--ink-soft); font-size: 12px; line-height: 1.5; }

    /* ---------- badges ---------- */
    .badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #e4ecef; color: var(--primary-dark); white-space: nowrap; }
    .badge.ok { background: #dff2e8; color: #1f6a4a; }
    .badge.warn { background: #fbeedb; color: #8a5413; }
    .badge.off { background: #eceff0; color: var(--ink-soft); }
    .badge.bad { background: #fbe9e7; color: #8f2d25; }

    /* ---------- hub tiles ---------- */
    .banner { display: flex; align-items: center; gap: 12px; background: #e4ecef; border: 1px solid #cbdade; border-radius: var(--radius); padding: 13px 18px; margin-bottom: 18px; color: var(--primary-dark); }
    .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
    .tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; text-decoration: none; color: var(--ink); transition: box-shadow .15s, border-color .15s; position: relative; }
    a.tile:hover { border-color: var(--focus); box-shadow: 0 4px 16px rgba(23, 37, 45, .1); }
    .tile.planned { opacity: .62; }
    .tile-icon { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; background: #e4ecef; color: var(--primary); margin-bottom: 16px; }
    .tile h3 { font-size: 17px; margin-bottom: 8px; }
    .tile p { margin: 0; color: var(--ink-soft); line-height: 1.5; }
    .tile .badge { position: absolute; top: 22px; right: 22px; }
    .tiles-heading { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 26px 0 12px; }
    .facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 14px 0 0; }
    .facts dt { color: var(--ink-faint); }
    .facts dd { margin: 0; font-weight: 600; }

    /* ---------- modal ---------- */
    .modal-backdrop { position: fixed; inset: 0; background: rgba(23, 37, 45, .5); display: grid; place-items: center; z-index: 50; padding: 20px; }
    .modal { background: var(--surface-alt); border-radius: 14px; width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 18px 60px rgba(0, 0, 0, .3); overflow: hidden; }
    .modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--primary); }
    .modal-head h2 { font-size: 18px; color: var(--ink); }
    .modal-sub { color: var(--ink-faint); font-size: 13px; margin-top: 2px; }
    .modal-body { padding: 20px 22px 8px; overflow: auto; }
    .modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--line); }

    /* ---------- permission matrix ---------- */
    .perm-module { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 16px 0 6px; display: flex; align-items: center; gap: 12px; }
    .perm-module button { font: 600 12px var(--font); background: none; border: 0; color: var(--focus); cursor: pointer; text-transform: none; letter-spacing: 0; }
    .perm-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 7px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 5px; align-items: center; }
    .perm-entity { font-weight: 600; }
    .perm-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }
    .perm-actions label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
    .perm-actions input { accent-color: var(--primary); }
    .perm-actions .special { color: #8a5413; }

    .json { font-family: var(--mono); font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; margin: 0 0 14px; }

    .denied { margin: 60px auto; text-align: center; max-width: 460px; color: var(--ink-soft); }
    .denied h1 { color: var(--ink); margin: 10px 0; font-size: 20px; }
    .denied p { margin-bottom: 18px; }

    @media (max-width: 900px) {
        .app-shell, .app-shell.nav-collapsed { grid-template-columns: 60px 1fr; }
        .app-shell .nav-label { display: none; }
        .list-page { grid-template-columns: 1fr; overflow: visible; }
        .side-panel { border-left: 0; border-top: 1px solid var(--line); order: -1; }
        .form-grid, .form-grid.three { grid-template-columns: 1fr; }
        .form-grid .span2 { grid-column: auto; }
        .top-user span:last-child { display: none; }
    }

    /* ---------- menu sub-items, embedded lists, attachments, documents ---------- */
    .app-nav nav { overflow-y: auto; }
    .nav-sub { display: flex; flex-direction: column; margin: 2px 0 6px 20px; border-left: 1px solid rgba(255, 255, 255, .15); }
    .nav-subitem { color: #a9c0c9; text-decoration: none; padding: 5px 12px; font-size: 13px; border-radius: 0 6px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .nav-subitem:hover { color: #fff; background: rgba(255, 255, 255, .06); }
    .nav-subitem.active { color: #fff; font-weight: 600; border-left: 2px solid var(--orange); margin-left: -1px; }
    .list-page.embedded { box-shadow: none; border: 1px solid var(--line); min-height: 380px; grid-template-columns: minmax(0, 1fr) 230px; }
    .list-page.embedded .page-title { padding: 10px 14px; }
    .list-page.embedded .side-panel { padding: 12px; }
    .attach-count { font-size: 11px; color: var(--green); margin-left: 1px; vertical-align: 4px; }
    .drop-zone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px; border: 2px dashed var(--grid-head); border-radius: 12px; background: var(--surface); color: var(--ink-soft); cursor: pointer; margin-bottom: 14px; position: relative; }
    .drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
    table.grid.plain thead th { position: static; }
    table.grid.plain tbody tr { cursor: default; }
    .amount-cr, .neg { color: var(--red); }
    .fy-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; }
    .fy-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
    .fy-head h3 { font-size: 17px; }
    .period-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .period { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-alt); display: flex; flex-direction: column; gap: 4px; }
    .period.closed { background: #f3eeee; }
    .period-name { font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
    .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
    .toolbar .field { margin: 0; }
    .card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; }
    table.sheet { width: 100%; border-collapse: collapse; }
    table.sheet th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--grid-head); padding: 9px 10px; }
    table.sheet th.right, table.sheet td.right { text-align: right; }
    table.sheet td { padding: 5px 8px; border-bottom: 1px solid #edf1f2; vertical-align: middle; }
    table.sheet td input, table.sheet td select { padding: 6px 8px; font-size: 13.5px; }
    table.sheet td input.num { text-align: right; font-family: var(--mono); }
    table.sheet tfoot td { font-weight: 700; border-top: 2px solid var(--grid-head); padding: 9px 8px; }
    table.sheet tr.group td { background: var(--surface-alt); font-weight: 600; }
    .doc-totals { display: flex; justify-content: flex-end; margin-top: 16px; }
    .doc-totals dl { display: grid; grid-template-columns: auto 170px; gap: 6px 18px; margin: 0; align-items: center; }
    .doc-totals dt { color: var(--ink-soft); text-align: right; }
    .doc-totals dd { margin: 0; text-align: right; font-family: var(--mono); }
    .doc-totals dd input { padding: 5px 8px; }
    .doc-totals .grand { font-weight: 700; color: var(--ink); font-size: 15px; border-top: 2px solid var(--grid-head); padding-top: 6px; }
    .page-title-bar { flex-wrap: wrap; }
    @media print {
        .app-nav, .app-top, .no-print, .page-title .btn, .side-panel, .toolbar { display: none !important; }
        .app-shell { display: block; height: auto; }
        .app-main, .app-content { height: auto; overflow: visible; display: block; padding: 0; }
        body { background: #fff; }
        .card, .page-title-bar { box-shadow: none; border: 0; }
        select, input { border: 0 !important; background: none !important; appearance: none; padding-left: 0 !important; }
    }
    .bank-card h3 { margin-bottom: 4px; }
    .bank-head { display: flex; gap: 8px; margin-bottom: 12px; }
    .bank-head .badge { position: static; }
    .bank-balance { font: 600 24px var(--mono); margin: 12px 0 4px; }
    .bank-balance small { font: 400 12px var(--font); color: var(--ink-faint); }
    .bank-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
    .report-head { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 14px; text-align: center; }
    .report-head h2 { font-size: 19px; }
    table.sheet tr.report-total td { font-weight: 700; border-top: 1px solid var(--grid-head); background: var(--surface-alt); }
    table.sheet tr.drill { cursor: pointer; }
    table.sheet tr.drill:hover td { background: #eef5f6; }
    .kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
    .kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
    .kpi:hover { border-color: var(--focus); }
    .kpi span { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
    .kpi strong { font: 600 22px var(--mono); }
    .kpi small { color: var(--ink-faint); }
    .bars { display: flex; align-items: flex-end; gap: 10px; height: 200px; }
    .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-faint); }
    .bar-pair { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
    .bar { width: 14px; border-radius: 3px 3px 0 0; min-height: 1px; }
    .bar.rev, .legend.rev { background: var(--green); }
    .bar.exp, .legend.exp { background: var(--orange); }
    .legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
    .tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
    .tabs button { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; font: 600 13px var(--font); color: var(--ink-soft); cursor: pointer; }
    .tabs button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
    .board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; flex: 1; padding-bottom: 8px; }
    .board-col { flex: 1; min-width: 230px; background: #e4ecef; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
    .board-head { display: flex; flex-direction: column; padding: 2px 4px 6px; }
    .board-head span { color: var(--ink-soft); font-size: 12px; }
    .board-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
    .msg { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: var(--surface); }
    .msg.customer { background: #f0f6f7; }
    .msg.note { background: #fdf6e7; border-style: dashed; }
    .msg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
    .page-host { display: flex; flex-direction: column; flex: 1; min-height: 0; }

    /* ---------- module screens shown as modal popups (General Ledger) ---------- */
    .page-modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(23, 37, 45, .55); display: flex; padding: 22px; }
    .page-modal { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: auto; background: var(--bg); border-radius: 16px; padding: 16px; box-shadow: 0 18px 60px rgba(0, 0, 0, .35); }
    @media (max-width: 900px) { .page-modal-backdrop { padding: 8px; } .page-modal { padding: 10px; } }
    @media print { .page-modal-backdrop { position: static; background: none; padding: 0; } .page-modal { box-shadow: none; padding: 0; overflow: visible; } .page-host > .page-title, .page-host > .page-body { display: none; } }
}
