:root {
    --ink: #1D2433;
    --muted: #667085;
    --line: #E4E7EC;
    --paper: #FFFFFF;
    --canvas: #F6F7F9;
    --blue: #1F4E79;
    --blue-hover: #173B5C;
    --green: #12805C;
    --green-soft: #E7F4EF;
    --red: #C0392B;
    --red-soft: #FCEEEB;
    --orange: #D9822B;
    --orange-soft: #FFF2E2;
    --sidebar: #1F4E79;
    --sidebar-muted: #D0DDED;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05);
    --font-body: Inter, system-ui, sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand strong { font-family: Inter, system-ui, sans-serif; letter-spacing: -.035em; }
.muted { color: var(--muted); }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: .16em; margin-bottom: 9px; }
.field-hint { color: var(--muted); font-weight: 400; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; background: #fff; color: #1F4E79; font: 700 22px Inter, system-ui, sans-serif; }
.button { min-height: 43px; display: inline-flex; justify-content: center; align-items: center; gap: 12px; border: 1px solid transparent; border-radius: 8px; padding: 0 16px; font-weight: 700; transition: .18s ease; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: #1d6646; transform: translateY(-1px); }
.button-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.button-secondary:hover { border-color: #b7c4b9; }
.button-danger { background: var(--red-soft); color: var(--red); border-color: #f0d5d0; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.button-wide { width: 100%; margin-top: 7px; }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--sidebar-muted); font-size: 20px; }
.icon-button:hover { color: #fff; background: rgba(255,255,255,.08); }
.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 18px; line-height: 1.5; }
.alert-error { color: #973e35; background: #fbefed; border: 1px solid #f2d3cf; }
.alert-success { color: #236542; background: #e9f5ed; border: 1px solid #cbe8d3; }

/* Main app frame */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 246px; display: flex; flex-direction: column; background: var(--sidebar); color: #f6f7f2; padding: 26px 17px 14px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.04em; }
.brand small { display: block; margin-top: 2px; color: #aab5aa; font-size: 8px; letter-spacing: .16em; }
.workspace-label { margin: 43px 10px 12px; color: #839188; font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.company-switcher { display: grid; gap: 7px; margin: -2px 3px 18px; padding: 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; background: rgba(255,255,255,.04); }
.company-switcher label { color: #94a197; font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.company-switcher select { width: 100%; border: 0; outline: 0; background: transparent; color: #f6f7f2; font-size: 11px; }
.company-switcher select option { color: var(--ink); }
.side-nav { display: grid; gap: 4px; }
.nav-link { min-height: 42px; display: flex; align-items: center; gap: 12px; border-radius: 7px; padding: 0 11px; color: #c2cbc2; font-size: 13px; transition: .15s; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.is-active { color: #fff; background: #35463a; box-shadow: inset 2px 0 #8db797; }
.nav-icon { width: 18px; text-align: center; color: #a6b6a8; font-size: 17px; }
.nav-link.is-active .nav-icon { color: #a9d7b6; }
.nav-lower-label { margin-top: 35px; }
.sidebar-bottom { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 16px 4px 2px; border-top: 1px solid rgba(255,255,255,.1); }
.firm-avatar { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #425949; color: #dcefe0; font-weight: 700; }
.firm-logo { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 7px; background: #fff; object-fit: contain; padding: 2px; }
.firm-identity { min-width: 0; flex: 1; }
.firm-identity strong, .firm-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.firm-identity strong { font-size: 11px; }
.firm-identity small { margin-top: 4px; color: var(--sidebar-muted); font-size: 10px; }
.logout-form { margin: 0; }
.main-column { min-height: 100vh; margin-left: 246px; display: flex; flex-direction: column; }
.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 42px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.72); }
.breadcrumb { display: flex; align-items: center; gap: 11px; color: #89928a; font-size: 12px; }
.breadcrumb i { color: #c4c9c2; font-style: normal; }
.breadcrumb strong { color: var(--ink); font-weight: 600; }
.topbar-date { color: #7e8980; font-size: 11px; }
.menu-toggle { display: none; border: 0; background: none; color: var(--ink); font-size: 21px; }
.main-content { width: min(1320px, 100%); flex: 1; margin: 0 auto; padding: 36px 42px 54px; }
.app-footer { display: flex; justify-content: space-between; padding: 15px 42px 18px; border-top: 1px solid var(--line); color: #929a92; font-size: 10px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 6px; font-size: 26px; line-height: 1.2; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: 0 4px 14px rgba(34,43,36,.025); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 19px 20px 15px; }
.panel-heading h2, .panel-heading h3 { margin: 0; font-size: 14px; letter-spacing: -.02em; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.text-link { color: var(--green); font-size: 10px; font-weight: 700; }
.panel-body { padding: 18px 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-bottom: 16px; }
.stat-card { min-height: 129px; position: relative; overflow: hidden; padding: 19px 19px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.stat-label { display: flex; align-items: center; gap: 8px; color: #68736b; font-size: 11px; font-weight: 600; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; background: #8f9a91; }
.stat-card.is-green .stat-dot { background: #388562; }
.stat-card.is-red .stat-dot { background: #c96157; }
.stat-card.is-orange .stat-dot { background: #d48b39; }
.stat-value { margin-top: 17px; font: 600 23px Inter, system-ui, sans-serif; letter-spacing: 0; white-space: nowrap; }
.stat-card.is-green .stat-value { color: var(--green); }
.stat-card.is-red .stat-value { color: var(--red); }
.stat-card.is-orange .stat-value { color: var(--orange); }
.stat-sub { margin-top: 5px; color: #a0a8a0; font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(280px,.9fr); gap: 15px; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 10px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: #43835e; }
.legend-dot.is-orange { background: #d49a58; }
.chart-wrap { height: 218px; display: flex; align-items: stretch; gap: 13px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }
.chart-month { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 9px; }
.chart-bars { width: 100%; max-width: 42px; height: 174px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.chart-bar { width: min(17px, 40%); min-height: 3px; border-radius: 4px 4px 0 0; background: #43835e; }
.chart-bar.is-orange { background: #d49a58; }
.chart-month small { padding-bottom: 8px; color: #879188; font-size: 9px; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 11px 14px; border-bottom: 1px solid var(--line); color: #89938a; font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid #f0f0ec; color: #4f5a52; font-size: 11px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td strong { color: var(--ink); font-weight: 600; }
.table-empty { padding: 30px 15px !important; color: var(--muted) !important; text-align: center; }
.amount-positive { color: var(--green) !important; font-weight: 700; white-space: nowrap; }
.amount-negative { color: var(--red) !important; font-weight: 700; white-space: nowrap; }
.amount-warning { color: var(--orange) !important; font-weight: 700; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; border-radius: 20px; padding: 4px 8px; background: #f1f2ed; color: #66716a; font-size: 9px; font-weight: 700; white-space: nowrap; }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.badge-orange { color: var(--orange); background: var(--orange-soft); }
.filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 9px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters label, .form-stack label { min-width: 0; display: grid; gap: 6px; color: #5f6b62; font-size: 10px; font-weight: 600; }
.filters input, .filters select, .form-stack input, .form-stack select, .form-stack textarea { width: 100%; min-height: 39px; border: 1px solid #e1e4dd; border-radius: 7px; outline: 0; padding: 8px 10px; background: #fff; color: var(--ink); font-size: 12px; }
.filters input:focus, .filters select:focus, .form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus { border-color: #80aa8c; box-shadow: 0 0 0 3px rgba(67,131,94,.1); }
.filters .filter-wide { flex: 1 1 180px; }
.filters .filter-small { width: 148px; }
.filters .button { min-height: 39px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.pagination-links { display: flex; gap: 6px; }
.pagination-links a { min-width: 29px; min-height: 29px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination-links a:hover { border-color: #89ae93; color: var(--green); }
.content-grid { display: grid; grid-template-columns: minmax(0,1fr) 310px; align-items: start; gap: 15px; }
.form-stack { display: grid; gap: 13px; }
.form-stack textarea { min-height: 78px; resize: vertical; }
.form-stack .form-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.form-stack [data-invoice-field][hidden] { display: none; }
.form-stack [data-cash-field][hidden] { display: none; }
.inline-actions { display: flex; align-items: center; gap: 6px; }
.inline-form { display: inline; margin: 0; }
.link-payment-form { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.link-payment-form select { min-height: 30px; max-width: 190px; border: 1px solid #e1e4dd; border-radius: 6px; padding: 4px 6px; color: var(--muted); font-size: 9px; }
.form-note { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.restore-steps { display: grid; gap: 10px; margin: 0 0 15px; padding-left: 20px; color: #59645c; font-size: 11px; line-height: 1.55; }
.restore-steps strong { color: var(--green); }
.balance-box { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 13px; padding-top: 14px; color: var(--muted); font-size: 11px; }
.balance-box strong { font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.detail-item { padding: 12px; border-radius: 8px; background: #f8f8f5; }
.detail-item span { display: block; color: var(--muted); font-size: 10px; }
.detail-item strong { display: block; margin-top: 6px; font-size: 12px; }
.upload-preview { display: flex; align-items: center; gap: 12px; }
.upload-preview img { max-width: 96px; max-height: 56px; object-fit: contain; }
.logo-placeholder { width: 84px; height: 48px; display: grid; place-items: center; border-radius: 7px; background: #f2f3ef; color: #879188; font-size: 10px; }
.overdue-row { background: #fffbf4; }
.overdue-label { color: var(--orange); font-size: 9px; font-weight: 700; }
.print-only { display: none; }

/* Installer and login */
.install-page { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; background: #f2f3ee; }
.install-shell { width: min(600px, 100%); }
.install-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.install-heading h1 { margin: 0; font-size: 21px; }
.install-heading .eyebrow { margin: 0 0 3px; font-size: 8px; }
.install-steps { display: grid; grid-template-columns: repeat(4,1fr); margin-bottom: 14px; }
.install-step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; color: #a0a8a0; font-size: 9px; }
.install-step:not(:last-child)::after { position: absolute; content: ''; height: 1px; width: calc(100% - 40px); top: 14px; left: calc(50% + 20px); background: #dfe2dc; }
.install-step b { z-index: 1; width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid #dfe2dc; border-radius: 50%; background: #f2f3ee; font-size: 10px; }
.install-step.is-current { color: var(--green); font-weight: 700; }
.install-step.is-current b, .install-step.is-done b { border-color: var(--green); color: white; background: var(--green); }
.install-step.is-done { color: #64766a; }
.install-card { padding: 27px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.install-card h2 { margin-bottom: 7px; font-size: 20px; }
.install-card > .muted { margin-bottom: 20px; font-size: 12px; line-height: 1.5; }
.install-card code { padding: 2px 5px; border-radius: 4px; background: #f2f3ef; }
.install-card .button { margin-top: 18px; }
.requirement-list { list-style: none; margin: 0 0 20px; padding: 0; border-top: 1px solid var(--line); }
.requirement-list li { display: flex; justify-content: space-between; padding: 13px 2px; border-bottom: 1px solid var(--line); font-size: 12px; }
.status-ok { color: var(--green); }
.status-error { color: var(--red); }
.form-stack .button-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; }
.form-stack .button-row .button { margin-top: 0; }
.install-footnote { margin: 14px 0 0; color: #8c958d; text-align: center; font-size: 10px; }
.login-page { min-height: 100vh; background: #fff; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .92fr) minmax(420px,1.08fr); }
.login-intro { position: relative; min-height: 100vh; overflow: hidden; display: flex; flex-direction: column; padding: 38px 54px 29px; background: #e9eee7; }
.login-brand { padding: 0; }
.login-brand small { color: #819083; }
.intro-copy { position: relative; z-index: 2; margin: auto 0; padding-bottom: 60px; }
.intro-copy .eyebrow { margin-bottom: 14px; }
.intro-copy h1 { margin-bottom: 15px; font-size: clamp(33px,4vw,49px); line-height: 1.14; }
.intro-copy > p:last-child { max-width: 315px; margin: 0; color: #748078; font-size: 13px; line-height: 1.7; }
.login-copyright { position: relative; z-index: 2; color: #849087; font-size: 10px; }
.login-decoration { position: absolute; right: -74px; bottom: 64px; width: 290px; height: 190px; display: flex; align-items: flex-end; gap: 9px; transform: rotate(-16deg); opacity: .68; }
.login-decoration span { width: 13px; border-radius: 9px; background: #cad9c9; }
.login-decoration span:nth-child(3n+1) { height: 50%; }
.login-decoration span:nth-child(3n+2) { height: 76%; background: #d6e1d3; }
.login-decoration span:nth-child(3n) { height: 100%; background: #bfd2c1; }
.login-panel { display: grid; place-items: center; padding: 36px; }
.login-form-wrap { width: min(365px,100%); }
.login-form-wrap h2 { margin-bottom: 7px; font-size: 24px; }
.login-form-wrap > .muted { margin-bottom: 25px; font-size: 12px; }
.login-form { gap: 16px; }
.login-form label { font-size: 11px; }
.login-form input { min-height: 45px; padding: 10px 12px; font-size: 13px; }
.login-help { margin: 19px 0 0; color: #8a938b; text-align: center; font-size: 10px; }
.login-help a { color: var(--green); font-weight: 700; }

@media (max-width: 1100px) {
    .sidebar { width: 218px; }
    .main-column { margin-left: 218px; }
    .main-content { padding-right: 26px; padding-left: 26px; }
    .topbar { padding-right: 26px; padding-left: 26px; }
    .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .content-grid { grid-template-columns: minmax(0,1fr) 285px; }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-scrim { position: fixed; z-index: 19; inset: 0; display: none; background: rgba(20,28,23,.35); }
    .menu-open .sidebar-scrim { display: block; }
    .main-column { margin-left: 0; }
    .topbar { height: 57px; justify-content: flex-start; gap: 13px; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .topbar-date { margin-left: auto; }
    .content-grid { grid-template-columns: 1fr; }
    .dashboard-grid, .cash-management-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .login-shell { grid-template-columns: minmax(280px,.8fr) minmax(360px,1.2fr); }
    .login-intro { padding-right: 30px; padding-left: 30px; }
}
@media (max-width: 600px) {
    .main-content { padding: 25px 15px 35px; }
    .topbar { padding: 0 15px; }
    .app-footer { padding: 13px 15px; }
    .app-footer span:last-child { display: none; }
    .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
    .page-heading h1 { font-size: 23px; }
    .stats-grid { gap: 9px; }
    .stat-card { min-height: 111px; padding: 14px 12px; }
    .stat-value { margin-top: 14px; font-size: 18px; }
    .stat-label { font-size: 10px; }
    .panel-heading { padding: 15px 14px 12px; }
    .panel-body { padding: 14px; }
    .filters { align-items: stretch; }
    .filters .filter-small { width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); }
    .filters .filter-wide { flex-basis: 100%; }
    .filters .button { flex: 1; }
    .form-stack .form-row { grid-template-columns: 1fr; }
    .data-table td, .data-table th { padding-right: 10px; padding-left: 10px; }
    .chart-legend { gap: 8px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-intro { min-height: 200px; padding: 24px 23px; }
    .intro-copy { margin: 28px 0 0; padding: 0 0 22px; }
    .intro-copy h1 { font-size: 29px; }
    .intro-copy > p:last-child, .login-copyright, .login-decoration { display: none; }
    .login-panel { padding: 40px 23px; }
    .login-form-wrap h2 { font-size: 21px; }
    .install-card { padding: 20px 17px; }
    .install-step { font-size: 8px; }
    .install-step:not(:last-child)::after { width: calc(100% - 30px); left: calc(50% + 15px); top: 13px; }
    .install-step b { width: 27px; height: 27px; }
    .install-card .form-stack .button-row { align-items: stretch; flex-direction: column; }
}
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .app-footer, .filters, .heading-actions, .menu-toggle, .sidebar-scrim, .no-print { display: none !important; }
    .main-column { margin: 0; }
    .main-content { width: 100%; padding: 0; }
    .panel, .stat-card { box-shadow: none; border-color: #ddd; }
    .print-only { display: block; }
    .page-heading { margin-bottom: 12px; }
    .data-table th, .data-table td { padding: 7px; }
}

/* Finance-first palette and accessible system theme */
:root {
    color-scheme: light;
    --ink: #1D2433;
    --muted: #667085;
    --line: #E4E7EC;
    --paper: #FFFFFF;
    --canvas: #F6F7F9;
    --blue: #1F4E79;
    --blue-hover: #173B5C;
    --green: #12805C;
    --green-soft: #E7F4EF;
    --red: #C0392B;
    --red-soft: #FCEEEB;
    --orange: #D9822B;
    --orange-soft: #FFF2E2;
    --sidebar: #1F4E79;
    --sidebar-muted: #D0DDED;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05);
    --font-body: Inter, system-ui, sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    font-family: var(--font-body);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    background: var(--canvas);
    text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #E6EAF0;
    --muted: #A4ADBA;
    --line: #343D4A;
    --paper: #202833;
    --canvas: #161C24;
    --blue: #83B4E0;
    --blue-hover: #A4CDF0;
    --green: #54C99A;
    --green-soft: #203B34;
    --red: #F07868;
    --red-soft: #402B2B;
    --orange: #F1A44F;
    --orange-soft: #413222;
    --sidebar: #111B28;
    --sidebar-muted: #ABB8C7;
    --shadow: 0 1px 2px rgba(0, 0, 0, .2);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --ink: #E6EAF0;
        --muted: #A4ADBA;
        --line: #343D4A;
        --paper: #202833;
        --canvas: #161C24;
        --blue: #83B4E0;
        --blue-hover: #A4CDF0;
        --green: #54C99A;
        --green-soft: #203B34;
        --red: #F07868;
        --red-soft: #402B2B;
        --orange: #F1A44F;
        --orange-soft: #413222;
        --sidebar: #111B28;
        --sidebar-muted: #ABB8C7;
        --shadow: 0 1px 2px rgba(0, 0, 0, .2);
    }
}

* { box-sizing: border-box; }
html { font-family: var(--font-body); }
body { background: var(--canvas); color: var(--ink); font: 400 14px/1.5 var(--font-body); }
button, input, select, textarea { font-family: inherit; }
h1, h2, h3, .brand strong { font-family: inherit; letter-spacing: 0; }
h1 { font-size: 24px !important; font-weight: 600 !important; }
h2, .panel-heading h2, .panel-heading h3 { font-size: 16px !important; font-weight: 600 !important; }
.eyebrow, .workspace-label, .install-step, .install-heading .eyebrow { font-size: 12px; letter-spacing: .06em; }
.muted, .page-heading p, .panel-heading p, .form-note { color: var(--muted); }
.brand-mark { border-radius: 8px; background: #fff; color: #1F4E79; }

/* Compact, predictable controls */
.button { min-height: 40px; border-radius: 6px; padding: 0 14px; font-size: 14px; font-weight: 600; transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-hover); transform: none; }
.button-secondary { border-color: var(--line); background: var(--paper); color: var(--ink); }
.button-secondary:hover { border-color: var(--blue); color: var(--blue); }
.button-danger { border-color: transparent; background: var(--red-soft); color: var(--red); }
.button-danger:hover { border-color: var(--red); }
.button-small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.icon-button { border-radius: 6px; }
.alert { border-radius: 6px; font-size: 13px; }
.alert-error { color: var(--red); background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-success { color: var(--green); background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 28%, transparent); }

/* Navigation and content surfaces */
.sidebar { width: 240px; padding: 24px 16px 12px; background: var(--sidebar); }
.workspace-label { margin: 20px 10px 8px; color: var(--sidebar-muted); }
.nav-lower-label { margin-top: 24px; }
.side-nav { gap: 4px; }
.nav-link { min-height: 40px; border-radius: 6px; padding: 0 10px; color: #E1EAF4; transition: background-color 120ms ease, color 120ms ease; }
.nav-link:hover { background: rgba(255,255,255,.11); color: #fff; }
.nav-link.is-active { background: rgba(255,255,255,.17); box-shadow: inset 3px 0 #fff; color: #fff; }
.nav-icon { color: #D3E0ED; font-size: 15px; }
.nav-icon svg { display: block; }
.nav-link.is-active .nav-icon { color: #fff; }
.main-column { margin-left: 240px; }
.topbar { position: sticky; top: 0; z-index: 10; height: 56px; border-color: var(--line); background: var(--paper); padding: 0 32px; }
.breadcrumb { color: var(--muted); }
.breadcrumb i { color: var(--line); }
.breadcrumb strong { color: var(--ink); }
.main-content { max-width: 1440px; padding: 28px 32px 40px; }
.app-footer { padding: 12px 32px; border-color: var(--line); color: var(--muted); }
.page-heading { margin-bottom: 20px; }
.page-heading h1 { margin-bottom: 4px; line-height: 1.35; }
.page-heading p { font-size: 14px; }
.heading-actions { gap: 8px; }
.panel, .stat-card { border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { padding: 16px; }
.panel-heading h2, .panel-heading h3 { margin: 0; }
.panel-heading p { font-size: 12px; }
.panel-body { padding: 16px; }
.stats-grid { gap: 12px; margin-bottom: 16px; }
.stat-card { min-height: 116px; padding: 16px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 12px; font: 600 22px/1.3 var(--font-body); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; }
.dashboard-grid { grid-template-columns: minmax(0,1.3fr) minmax(300px,.9fr); gap: 16px; }
.stat-card-link { display: block; color: inherit; transition: border-color 120ms ease, background-color 120ms ease; }
.stat-card-link:hover { border-color: var(--orange); background: var(--orange-soft); }
.dashboard-detail-grid { margin-top: 16px; }
.cash-account-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cash-account-name { overflow: hidden; margin-top: 10px; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.cash-management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.cash-transfers { margin-top: 16px; }
.dashboard-cash-panel { grid-column: 1 / -1; }
.cash-total { display: block; margin-bottom: 12px; color: var(--green); font-size: 23px; font-variant-numeric: tabular-nums; }
.cash-balance-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.cash-balance-list li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.cash-balance-list strong { font-variant-numeric: tabular-nums; }
.document-lines { display: grid; gap: 12px; }
.document-line { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); }
.document-line-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.document-line-heading .button { min-height: 28px; }
.checkbox-label { display: flex !important; align-items: center; gap: 9px !important; }
.checkbox-label input { min-height: auto !important; width: 16px; height: 16px; }
.module-settings { margin-top: 16px; }
.profile-link { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-top: 8px; padding: 0 10px; border-radius: 6px; color: #E1EAF4; font-size: 13px; }
.profile-link:hover { background: rgba(255,255,255,.11); color: #fff; }
.print-document { display: none; }
.print-mode .app-shell { display: none; }
.print-mode .print-document { display: block; }
.document-print-header { display: flex; justify-content: space-between; gap: 32px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.document-print-header h1 { margin-bottom: 8px; color: var(--blue); }
.document-print-header p { color: var(--muted); }
.document-totals { width: min(360px, 100%); margin: 18px 0 0 auto; }
.document-totals p { display: flex; justify-content: space-between; gap: 16px; margin: 8px 0; }

/* Tables: fixed header, 44px rows, no striping */
.table-wrap { max-width: 100%; overflow: auto; }
.data-table { color: var(--ink); }
.data-table thead { position: sticky; top: 0; z-index: 1; background: var(--paper); }
.data-table th { height: 40px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.data-table td { height: 44px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 13px; }
.data-table tbody tr { transition: background-color 120ms ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--blue) 5%, var(--paper)); }
.data-table td strong { color: var(--ink); }
.data-table td:nth-last-child(1), .data-table td.amount-positive, .data-table td.amount-negative, .data-table td.amount-warning { font-variant-numeric: tabular-nums; }
.numeric-cell { text-align: right !important; font-variant-numeric: tabular-nums; }
.data-table td.numeric-cell, .data-table th.numeric-cell { text-align: right; }
.data-table td.amount-positive, .data-table td.amount-negative, .data-table td.amount-warning { text-align: right; }
.badge-gray { color: #475467; background: #F2F4F7; }
.amount-positive { color: var(--green) !important; font-weight: 600; white-space: nowrap; }
.amount-negative { color: var(--red) !important; font-weight: 600; white-space: nowrap; }
.amount-warning { color: #8C4A0B !important; font-weight: 600; white-space: nowrap; }
.badge { border-radius: 4px; padding: 3px 7px; background: #F2F4F7; color: #475467; font-size: 12px; font-weight: 500; }
.badge-green { color: #086647; background: #E7F4EF; }
.badge-red { color: #A93226; background: #FCEEEB; }
.badge-orange { color: #8C4A0B; background: #FFF2E2; }
.chart-legend { font-size: 12px; }
.chart-wrap { border-color: var(--line); }
.chart-month small { color: var(--muted); font-size: 12px; }

/* Inputs, keyboard focus, and validation */
.filters { gap: 8px; padding: 12px 16px; border-color: var(--line); }
.filters label, .form-stack label { gap: 5px; color: var(--ink); font-size: 12px; font-weight: 500; }
.filters input, .filters select, .form-stack input, .form-stack select, .form-stack textarea,
.link-payment-form select, .company-switcher select {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    color: var(--ink);
    font: 400 14px/1.4 var(--font-body);
}
.filters input, .filters select, .form-stack input, .form-stack select, .form-stack textarea { padding: 8px 10px; }
.filters input::placeholder, .form-stack input::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 48%, transparent); outline-offset: 2px; }
.filters input:focus, .filters select:focus, .form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.form-stack { gap: 12px; }
.form-stack button[aria-busy="true"] { cursor: wait; opacity: .8; }
.form-stack textarea { min-height: 72px; }
.content-grid { gap: 16px; grid-template-columns: minmax(0,1fr) 320px; }
.detail-item, .logo-placeholder { border-radius: 6px; background: var(--canvas); }
.overdue-row { background: color-mix(in srgb, var(--orange) 7%, var(--paper)); }
.link-payment-form select { min-height: 32px; padding: 4px 6px; font-size: 12px; }
.restore-steps { color: var(--ink); font-size: 13px; }

/* Installer and login surfaces follow the same restrained system */
.install-page { background: var(--canvas); }
.install-card { border-color: var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.install-card h2 { font-size: 20px !important; }
.install-card code { background: var(--canvas); }
.install-step { color: var(--muted); font-size: 12px; }
.install-step b { border-color: var(--line); background: var(--canvas); }
.install-step.is-current b, .install-step.is-done b { border-color: var(--blue); background: var(--blue); }
.install-step.is-current { color: var(--blue); }
.install-step.is-done { color: var(--muted); }
.requirement-list, .requirement-list li { border-color: var(--line); }
.login-page, .login-panel { background: var(--paper); }
.login-intro { background: var(--canvas); }
.login-brand small, .intro-copy > p:last-child, .login-copyright { color: var(--muted); }
.intro-copy h1 { font-size: 40px !important; }
.firm-avatar { border-radius: 6px; background: rgba(255,255,255,.18); color: #fff; }
.company-switcher { border-radius: 6px; background: rgba(255,255,255,.07); }
.company-switcher select { min-height: 32px; border: 0; background: transparent; color: #fff; font-size: 12px; }
.company-switcher select option { color: #1D2433; }

/* Theme switch, non-blocking feedback, and one-handed mobile action */
.theme-switch { display: flex; align-items: center; gap: 9px; width: 100%; margin-top: 16px; padding: 12px 10px; border: 0; border-top: 1px solid rgba(255,255,255,.2); background: transparent; color: #fff; text-align: left; font: 500 13px var(--font-body); }
.theme-switch::before { width: 30px; height: 17px; content: ""; border: 1px solid rgba(255,255,255,.7); border-radius: 10px; background: linear-gradient(to right, #fff 0 50%, transparent 50%); }
:root[data-theme="dark"] .theme-switch::before { background: linear-gradient(to right, transparent 0 50%, #fff 50%); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-switch::before { background: linear-gradient(to right, transparent 0 50%, #fff 50%); }
}
.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 32px)); margin: 0; box-shadow: var(--shadow); animation: toast-in 120ms ease-out; }
.toast-dismiss { margin-left: 12px; border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.mobile-quick-action { display: none; }
.dashboard-grid:not(.dashboard-detail-grid) > .panel:first-child { order: 2; }
.dashboard-grid:not(.dashboard-detail-grid) > .panel:nth-child(2) { order: 1; }
.recent-movements { margin-top: 16px; }
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 8px; }
.empty-state strong { color: var(--ink); font-size: 14px; }
.empty-state span { max-width: 330px; color: var(--muted); font-size: 12px; }
.empty-state .button { margin-top: 4px; }
.nav-icon { font-size: 11px; font-weight: 700; }
.sidebar-bottom { margin-top: auto; }

.sidebar { transition: transform 150ms ease; }
.nav-link, .button, .stat-card, .data-table tbody tr { transition-duration: 120ms; }
.theme-switch { cursor: pointer; }
.theme-switch:hover { background: rgba(255,255,255,.08); }
.theme-switch:focus-visible { outline-color: #fff; }
#new-movement, #new-account { scroll-margin-top: 70px; }
.empty-state .button { white-space: nowrap; }
.loading-state { min-height: 44px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.loading-state::before { width: 14px; height: 14px; content: ""; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: loading-spin 700ms linear infinite; }
.form-stack .checkbox-label input { min-height: 0; width: 16px; height: 16px; padding: 0; }
.cheque-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.cheque-list { margin-top: 16px; }
.inline-status-form { display: flex; align-items: center; gap: 6px; min-width: 210px; }
.inline-status-form select { min-height: 32px; max-width: 150px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: 400 12px/1.4 var(--font-body); }
.inline-status-form .button { min-height: 32px; padding: 0 8px; font-size: 12px; }
.data-table td small { display: block; margin-top: 3px; font-size: 11px; }
.pagination > div { display: flex; gap: 6px; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
:root[data-theme="dark"] .amount-warning { color: #F1A44F !important; }
:root[data-theme="dark"] .badge-gray { color: #E6EAF0; background: #36414E; }
:root[data-theme="dark"] .button-primary { color: #111820; }
:root[data-theme="dark"] .intro-copy .eyebrow { color: var(--blue); }
:root[data-theme="dark"] .login-intro { color: var(--ink); }
:root[data-theme="dark"] .install-step.is-current b, :root[data-theme="dark"] .install-step.is-done b { color: #111820; }
@media (max-width: 1100px) {
    .sidebar { width: 240px; }
    .main-column { margin-left: 240px; }
    .main-content { padding-right: 24px; padding-left: 24px; }
    .topbar { padding-right: 24px; padding-left: 24px; }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); }
    .main-column { margin-left: 0; }
    .topbar { justify-content: flex-start; gap: 12px; padding: 0 16px; }
    .menu-toggle { display: inline-grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: 17px; }
    .dashboard-grid, .cash-management-grid { grid-template-columns: 1fr; }
    .cheque-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid > .panel:first-child, .dashboard-grid > .panel:nth-child(2) { order: initial; }
    .content-grid { grid-template-columns: minmax(0,1fr) 300px; }
}
@media (max-width: 600px) {
    .cheque-form { grid-template-columns: 1fr; }
    body.app-page { padding-bottom: 74px; }
    .main-content { padding: 20px 12px 28px; }
    .topbar { padding: 0 12px; }
    .app-footer { padding: 12px; }
    .page-heading h1 { font-size: 22px !important; }
    .stats-grid { gap: 8px; }
    .stat-card { min-height: 104px; padding: 12px; }
    .stat-value { font-size: 18px; }
    .content-grid { grid-template-columns: 1fr; }
    .data-table th { height: 38px; }
    .data-table td { height: 44px; }
    .numeric-cell { text-align: right !important; }
    .mobile-quick-action { position: fixed; z-index: 18; right: 16px; bottom: 16px; display: inline-flex; min-height: 48px; align-items: center; gap: 8px; border: 0; border-radius: 8px; padding: 0 16px; background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18); font-size: 14px; font-weight: 600; }
    .mobile-quick-action:hover { background: var(--blue-hover); }
    .toast { right: 12px; bottom: 76px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-intro { min-height: 200px; }
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .amount-warning { color: #F1A44F !important; }
    :root:not([data-theme="light"]) .badge-gray { color: #E6EAF0; background: #36414E; }
    :root:not([data-theme="light"]) .button-primary { color: #111820; }
    :root:not([data-theme="light"]) .intro-copy .eyebrow { color: var(--blue); }
    :root:not([data-theme="light"]) .login-intro { color: var(--ink); }
    :root:not([data-theme="light"]) .install-step.is-current b,
    :root:not([data-theme="light"]) .install-step.is-done b { color: #111820; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
    :root { color-scheme: light; }
    body { background: #fff; color: #1D2433; }
    .document-print-header { color: #111; }
}
