/* Wexus ERP. Dense, keyboard-first screens for bookkeepers on Windows desktops.
   One deliberate signature: grids striped like green-bar ledger paper. Everything else stays quiet. */
:root {
    --paper: #f5f6f3;
    --surface: #ffffff;
    --ink: #1e2b32;
    --ink-soft: #5a6970;
    --rule: #d5dad3;
    --greenbar: #eef5f0;
    --accent: #1e6b5c;
    --accent-ink: #ffffff;
    --select: #d9ebe3;
    --neg: #a4262c;
    --warn: #8a5a00;
    --warn-bg: #fff4d6;
    --ok-bg: #e3f2e8;
    --err-bg: #fbe9ea;
    --nav: #1e2b32;
    --nav-ink: #dfe7e4;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --row: 1.9rem;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #141b1f;
        --surface: #1b2428;
        --ink: #e3e9e6;
        --ink-soft: #9fb0b6;
        --rule: #2f3c41;
        --greenbar: #1f2b2a;
        --accent: #4fae98;
        --accent-ink: #0d1517;
        --select: #23443b;
        --neg: #ff8a8f;
        --warn: #f0c060;
        --warn-bg: #3a3018;
        --ok-bg: #1d3a2c;
        --err-bg: #43211f;
        --nav: #0e1416;
        --nav-ink: #c9d5d1;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 var(--font); color: var(--ink); background: var(--paper); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 0.75rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 13rem 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; padding: 0.4rem 1rem; background: var(--nav); color: var(--nav-ink); }
.topbar .brand { color: var(--nav-ink); font-weight: 600; text-decoration: none; margin-right: auto; }
.topbar .user { opacity: 0.85; }
.topbar .link, .topbar .company-name { color: var(--nav-ink); }
.topbar select { background: transparent; color: var(--nav-ink); border: 1px solid #4a5a60; border-radius: 3px; padding: 0.2rem 0.4rem; font: inherit; }
.topbar select option { color: #1e2b32; }
.sidenav { background: var(--surface); border-right: 1px solid var(--rule); padding: 0.75rem 0; }
.sidenav a { display: block; padding: 0.35rem 1rem; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.sidenav a:hover { background: var(--greenbar); }
.sidenav a.active { border-left-color: var(--accent); background: var(--select); font-weight: 600; }
.nav-group { margin: 0.9rem 1rem 0.2rem; font-size: 0.8rem; color: var(--ink-soft); }
.content { padding: 1rem 1.25rem 3rem; min-width: 0; }
.inline { display: inline; margin: 0; }

/* Pages */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-bottom: 0.75rem; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-left: auto; }
.narrow { max-width: 36rem; }
.help { color: var(--ink-soft); font-size: 0.9em; }
.spacer { flex: 1; }

/* Controls */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; padding: 0.25rem 0.4rem; min-height: 1.8rem; }
input:disabled, select:disabled { background: var(--paper); color: var(--ink-soft); }
button, .button { font: inherit; display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.85rem; min-height: 1.9rem; border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--neg); }
button.link { border: 0; background: none; padding: 0 0.25rem; min-height: 0; color: var(--accent); text-decoration: underline; }
label.check { display: inline-flex; align-items: center; gap: 0.35rem; }
input.amt { text-align: right; }

.msg { padding: 0.5rem 0.75rem; border-radius: 3px; margin: 0 0 0.75rem; }
.msg.error { background: var(--err-bg); color: var(--neg); }
.msg.ok { background: var(--ok-bg); }
.tag { display: inline-block; margin-left: 0.4rem; padding: 0 0.35rem; font-size: 0.78em; border: 1px solid var(--rule); border-radius: 3px; color: var(--ink-soft); }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag.muted { opacity: 0.7; }
.neg { color: var(--neg); }

/* Grids: green-bar ledger paper */
.grid-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 600; font-size: 0.85rem; color: var(--ink-soft); padding: 0.35rem 0.6rem; border-bottom: 2px solid var(--rule); white-space: nowrap; }
.grid td { padding: 0 0.6rem; height: var(--row); border-bottom: 1px solid transparent; white-space: nowrap; }
.grid tbody tr:nth-child(4n + 3) td, .grid tbody tr:nth-child(4n + 4) td { background: var(--greenbar); }
.grid tbody tr.selected td { background: var(--select); }
.grid tbody tr.inactive td { color: var(--ink-soft); }
.grid tbody tr.clickable { cursor: pointer; }
.grid tbody tr.clickable:hover td { background: var(--select); }
.grid tfoot th { position: static; border-top: 2px solid var(--ink); border-bottom: 0; color: var(--ink); }
.grid .amt { text-align: right; width: 8.5rem; }
.grid .num-col { width: 6rem; }
.grid .actions { width: 1%; text-align: right; }
.grid .empty-row { text-align: center; color: var(--ink-soft); padding: 1.5rem; height: auto; }
.grid tr.opening td { font-style: italic; color: var(--ink-soft); }
.grid-wrap:focus-visible { outline-offset: 2px; }

/* Journal entry */
.entry-head { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: end; margin-bottom: 0.75rem; }
.entry-head > div { display: flex; flex-direction: column; gap: 0.2rem; }
.entry-head .grow { flex: 1; min-width: 14rem; }
.entry-head label { font-size: 0.85rem; color: var(--ink-soft); }
.readout { min-height: 1.8rem; display: flex; align-items: center; color: var(--ink-soft); }
.grid.lines td { padding: 0; }
.grid.lines td > input, .grid.lines td .picker-input { width: 100%; border: 0; border-radius: 0; background: transparent; height: var(--row); }
.grid.lines td > input:focus, .grid.lines td .picker-input:focus { background: var(--surface); outline: 2px solid var(--accent); outline-offset: -2px; }
.grid.lines .col-account { width: 26%; }
.grid.lines .col-name { width: 16%; }
.grid.lines .col-class { width: 11%; }
.grid.lines tr.row-error td { background: var(--err-bg) !important; }
.out-of-balance { color: var(--neg); font-weight: 600; }
.posted-banner { background: var(--ok-bg); padding: 0.5rem 0.75rem; border-radius: 3px; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
fieldset.reverse { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; border: 1px solid var(--rule); border-radius: 3px; padding: 0.6rem 0.9rem; background: var(--surface); }
fieldset.reverse input:not([type=date]) { min-width: 18rem; }
.inline-field { display: flex; align-items: center; gap: 0.5rem; }
.inline-field input { min-width: 22rem; }
.ending { text-align: right; margin: 0.5rem 0; }

/* Lookup picker */
.picker { position: relative; }
.picker-input { width: 100%; }
.picker-list { position: absolute; z-index: 20; left: 0; top: 100%; min-width: 100%; max-width: 32rem; max-height: 18rem; overflow-y: auto; margin: 0; padding: 0.2rem 0; list-style: none; background: var(--surface); border: 1px solid var(--accent); border-radius: 0 0 3px 3px; box-shadow: 0 6px 16px rgb(0 0 0 / 0.18); }
.picker-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0.5rem; cursor: pointer; white-space: nowrap; }
.picker-list li.active { background: var(--select); }
.picker-list .hint { color: var(--ink-soft); font-size: 0.85em; }

/* Dialog */
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgb(15 22 25 / 0.45); padding: 1rem; }
.dialog { width: min(40rem, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: 4px; padding: 1.25rem; box-shadow: 0 12px 40px rgb(0 0 0 / 0.3); }
.form-grid { display: grid; grid-template-columns: 10rem 1fr; gap: 0.55rem 0.75rem; align-items: center; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* Home, sign-in, empty states */
.home-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.tile { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 3px; color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile span { color: var(--ink-soft); font-size: 0.88em; }
.bare { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.signin { width: min(24rem, 100%); background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--accent); border-radius: 3px; padding: 1.5rem; }
.signin form { display: flex; flex-direction: column; gap: 0.35rem; }
.signin label { margin-top: 0.5rem; font-weight: 600; }
.signin button { margin-top: 1rem; justify-content: center; }
.lede { color: var(--ink-soft); margin: 0.4rem 0 0.5rem; }
.validation-message { color: var(--neg); font-size: 0.9em; }
.company-list { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.company-list button { width: 100%; flex-direction: column; align-items: flex-start; padding: 0.7rem 1rem; }
.company-list span { color: var(--ink-soft); font-size: 0.88em; }
.empty { max-width: 34rem; margin: 3rem auto; text-align: center; }
.ref { font-family: Consolas, monospace; color: var(--ink-soft); }
.report-sub { color: var(--ink-soft); margin: 0 0 0.75rem; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding: 0.6rem 1rem; background: var(--warn-bg); color: var(--warn); }
#blazor-error-ui .reload { margin-left: 0.5rem; }

@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .sidenav { border-right: 0; border-bottom: 1px solid var(--rule); display: flex; flex-wrap: wrap; padding: 0.25rem; }
    .nav-group { display: none; }
    .tools { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
}

@media print {
    .topbar, .sidenav, .no-print, #blazor-error-ui { display: none !important; }
    .shell { display: block; }
    body { background: #fff; color: #000; }
    .grid-wrap { border: 0; overflow: visible; }
    .grid th { position: static; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
.journal .grid-wrap { overflow: visible; } /* let account and name pickers drop below the grid */

/* Phase 2 */
.dialog.wide { width: min(56rem, 100%); }
.form-grid.two { grid-template-columns: 10rem 1fr 10rem 1fr; }
.form-grid.two textarea { grid-column: span 3; }
.form-grid.two .stack { grid-column: span 3; display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.form-grid.two .stack textarea { width: 100%; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.radio-row { display: flex; gap: 1rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 0.3rem 1rem; max-height: 50vh; overflow-y: auto; padding: 0.25rem; border: 1px solid var(--rule); border-radius: 3px; }
.perm-grid .check { align-items: flex-start; }
.perm-grid small { display: block; color: var(--ink-soft); }
.perm-group { grid-column: 1 / -1; margin: 0.5rem 0 0; font-weight: 600; color: var(--ink-soft); }
.check-list { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.detail-cell { white-space: normal; max-width: 28rem; color: var(--ink-soft); }
@media (max-width: 760px) { .form-grid.two { grid-template-columns: 1fr; } .form-grid.two textarea, .form-grid.two .stack { grid-column: auto; } }
h3 { font-size: 0.95rem; font-weight: 600; margin: 1rem 0 0.5rem; }

/* Phase 3 */
.form-grid.two .span3 { grid-column: span 2; align-self: center; margin: 0; }
.grid-wrap.components { overflow: visible; margin-bottom: 0.35rem; }
.summary-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0.5rem 0; }
.summary-row strong { font-size: 1.05rem; }
.count-input { width: 7rem; text-align: right; }
@media print { .count-input { border: 0; border-bottom: 1px solid #000; border-radius: 0; } } .print-line { display: inline-block; width: 6rem; border-bottom: 1px solid var(--ink-soft); }
.tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.75rem 0 0.5rem; } .grid-wrap.tall { max-height: 45vh; overflow-y: auto; }

/* Phase 4 */
.sales-bottom { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; margin-top: 0.75rem; }
.sales-bottom .grow { flex: 1; min-width: 16rem; display: flex; flex-direction: column; gap: 0.25rem; }
.sales-bottom label { font-size: 0.85rem; color: var(--ink-soft); }
table.totals { border-collapse: collapse; min-width: 20rem; }
table.totals th { text-align: left; font-weight: normal; padding: 0.25rem 0.75rem 0.25rem 0; }
table.totals td { padding: 0.25rem 0; }
table.totals tr.grand th, table.totals tr.grand td { font-weight: 600; border-top: 2px solid var(--ink); }
.grid tr.subtotal-row td { font-weight: 600; }
.balance-chip { font-weight: 600; }
.portal-hero { display: flex; flex-wrap: wrap; gap: 2rem; padding: 1rem 1.25rem; margin: 0.5rem 0 1rem; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 3px; }
.portal-hero strong { display: block; font-size: 1.5rem; }
@media print { .sales-form .entry-head input, .sales-form .entry-head select, .sales-form textarea { border: 0; } }
.statement-head { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 0.75rem; }
pre.address { font: inherit; margin: 0.25rem 0 0; white-space: pre-wrap; }
table.aging { margin-top: 0.75rem; }
table.totals.right { margin: 0.75rem 0 0 auto; }
.grid tbody tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--neg); }

/* Phase 5 */
.grid tr.linked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tracker { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.tracker-tile { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.8rem 1rem; border-radius: 3px; color: #fff; text-decoration: none; background: #2f5d8a; }
.tracker-tile strong { font-size: 1.4rem; }
.tracker-tile small { opacity: 0.9; }
.tracker-tile.unpaid { background: #c58a00; }
.tracker-tile.overdue { background: #b23a2a; }
.tracker-tile.paid { background: #3f8a3a; }
.check-page { break-after: page; max-width: 8.5in; margin: 0 auto 2rem; }
.check { position: relative; height: 3.5in; padding: 0.4in 0.5in; border: 1px dashed var(--rule); display: flex; flex-direction: column; justify-content: space-between; }
.check-row { display: flex; justify-content: space-between; gap: 1rem; }
.check-row.payee { border-bottom: 1px solid var(--ink); padding-bottom: 0.2rem; }
.check-amount { font-weight: 600; border: 1px solid var(--ink); padding: 0 0.5rem; }
.check-words { border-bottom: 1px solid var(--ink); font-variant: small-caps; }
.check-no { font-weight: 600; }
.signature { border-top: 1px solid var(--ink); min-width: 2.5in; text-align: center; font-size: 0.8rem; }
.void-stamp { position: absolute; inset: 0; display: grid; place-items: center; font-size: 4rem; font-weight: 700; color: var(--neg); opacity: 0.35; transform: rotate(-12deg); }
.stub { height: 3.5in; padding: 0.3in 0.5in; border: 1px dashed var(--rule); border-top: 0; overflow: hidden; }
@media print { .no-print-chrome .check, .no-print-chrome .stub { border: 0; } .check-page { margin: 0; } }

/* Phase 6 */
.check-form.is-check { background: color-mix(in srgb, var(--ok-bg) 60%, var(--surface)); border: 1px solid var(--rule); border-radius: 3px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.amount-box { font-weight: 600; border: 1px solid var(--ink); padding: 0 0.6rem; min-width: 8rem; justify-content: flex-end; }
.check-words-preview { font-variant: small-caps; margin: 0 0 0.5rem; color: var(--ink-soft); }
.recon-summary { display: flex; flex-wrap: wrap; gap: 1.5rem; padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; }
.recon-summary .ok strong { color: var(--accent); }
.recon-grids { display: grid; grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr)); gap: 0.75rem; }
.inline-pickers { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.inline-pickers > * { flex: 1; }
.quick-entry input { min-width: 0; }

/* Phase 7: reports */
.report-center { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.report-group h3 { margin: 0.5rem 0; }
.report-card { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.5rem 0.7rem; margin-bottom: 0.4rem; border: 1px solid var(--rule); border-radius: 3px; text-decoration: none; color: var(--ink); background: var(--surface); }
.report-card:hover, .report-card:focus { border-color: var(--accent); }
.report-card span { font-size: 0.85rem; color: var(--ink-soft); }
.report-title { text-align: center; margin: 0.5rem 0; }
.report-title h2 { margin: 0; }
.report-grid .grid td, .report-grid .grid th { white-space: nowrap; }
.report-grid tr.rpt-header td { font-weight: 600; }
.report-grid tr.rpt-subtotal td { font-weight: 600; border-top: 1px solid var(--rule); }
.report-grid tr.rpt-total td { font-weight: 700; border-top: 1px solid var(--ink); }
.report-grid tr.rpt-grand td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
.email-dialog { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
@media print { .report-params, .report-center { display: none; } .report-grid .grid { font-size: 10pt; } }

/* QuickBooks history documents */
.tabs { display: flex; gap: 0.25rem; }
.tabs a { padding: 0.3rem 0.8rem; border: 1px solid var(--rule); border-radius: 3px 3px 0 0; text-decoration: none; color: var(--ink); }
.tabs a.active { background: var(--surface); border-bottom-color: var(--surface); font-weight: 600; }
.qb-doc-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.qb-doc-head h2 { margin: 0; }
.qb-doc-head dl { display: grid; grid-template-columns: auto auto; gap: 0.1rem 0.75rem; margin: 0; }
.qb-doc-head dt { color: var(--ink-soft); }
.qb-doc-head dd { margin: 0; }
.signin-links { margin: 0.9rem 0 0; text-align: center; font-size: 0.92rem; }
.signin .msg.ok { margin: 0.5rem 0; }
