:root {
  --ink: #17211f;
  --muted: #63706d;
  --line: #d9e0de;
  --surface: #ffffff;
  --surface-soft: #f4f6f5;
  --canvas: #edf1ef;
  --sidebar: #152723;
  --sidebar-muted: #a9bbb6;
  --accent: #087c68;
  --accent-dark: #076455;
  --orange: #d97706;
  --danger: #b42318;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(22, 38, 34, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); color: var(--ink); font-family: Inter, "Segoe UI", Helvetica, Arial, sans-serif; }
button, input, select { font: inherit; }
button { letter-spacing: 0; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(8, 124, 104, .2); outline-offset: 1px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; margin-bottom: 0; }
h2 { font-size: 19px; margin-bottom: 0; }
h3 { font-size: 16px; margin-bottom: 0; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; background: var(--surface); }
.login-brand { min-height: 100vh; padding: 42px; background: var(--sidebar); color: white; display: flex; flex-direction: column; justify-content: space-between; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup div { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 15px; }
.brand-lockup span:not(.brand-symbol) { font-size: 12px; color: var(--sidebar-muted); }
.brand-symbol { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; color: #fff; font-weight: 800; }
.login-statement { max-width: 520px; }
.login-statement h1 { font-size: 50px; line-height: 1.04; max-width: 10ch; margin-bottom: 18px; }
.login-statement > p:last-child { color: #bfd0cc; line-height: 1.7; max-width: 48ch; }
.login-source { color: var(--sidebar-muted); font-size: 12px; margin-bottom: 0; }
.login-form-wrap { display: grid; place-items: center; padding: 28px; }
.login-form { width: min(400px, 100%); }
.login-form h2 { font-size: 30px; margin-bottom: 28px; }
.overline { margin-bottom: 6px; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.login-brand .overline { color: #68c9b6; }

.field { display: grid; gap: 7px; margin-bottom: 16px; min-width: 0; }
.field > span, .field legend { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea, .search-field input { width: 100%; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); }
.field textarea { height: auto; min-height: 90px; padding-top: 10px; resize: vertical; font: inherit; }
.field input[readonly] { background: var(--surface-soft); color: var(--muted); }
.field input[type="file"] { height: auto; min-height: 42px; padding: 8px; }
fieldset.field { border: 0; padding: 0; }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin: 4px 0 8px; }
#vehicleError { font-weight: 800; }
.vehicle-form-alert { min-height: 0; margin: 0; }
.vehicle-form-alert:empty { display: none; }
.vehicle-form-alert:not(:empty) { padding: 11px 20px; border-bottom: 1px solid #efb9b4; background: #fff0ee; }
.vehicle-form-alert:not(:empty) + .modal-body { max-height: calc(100vh - 222px); }
.button { min-height: 38px; border: 1px solid transparent; border-radius: 6px; padding: 0 15px; cursor: pointer; font-weight: 750; }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { background: white; border-color: var(--line); color: var(--ink); }
.button.secondary:hover { border-color: #a9b8b4; }
.button.full { width: 100%; height: 44px; }
.button.compact { min-height: 30px; padding: 0 10px; font-size: .86rem; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--accent); cursor: pointer; font-weight: 750; }

.workspace { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.workspace[hidden] { display: none; }
.sidebar { min-height: 100vh; position: sticky; top: 0; height: 100vh; padding: 22px 16px; background: var(--sidebar); color: white; display: flex; flex-direction: column; }
.brand-lockup.compact { padding: 0 7px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.nav { display: grid; gap: 4px; margin-top: 22px; }
.nav-button { width: 100%; height: 42px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: #c8d5d2; text-align: left; cursor: pointer; font-weight: 650; }
.nav-button:hover, .nav-button.active { background: rgba(255,255,255,.1); color: white; }
.nav-group { display: grid; gap: 4px; margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.nav-group-label { padding: 0 12px 5px; color: var(--sidebar-muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-group.active .nav-group-label { color: #68c9b6; }
.nav-group-items { display: grid; gap: 4px; }
.nav-group .nav-button { padding-left: 22px; }
.sidebar-session { margin-top: auto; padding: 18px 8px 4px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 4px; }
.sidebar-session strong { font-size: 13px; }
.sidebar-session span { color: var(--sidebar-muted); font-size: 12px; }
.sidebar-session .text-button { text-align: left; margin-top: 10px; color: #68c9b6; font-size: 12px; }

.main { min-width: 0; padding: 24px 28px 40px; }
.topbar { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.view { display: none; }
.view.active { display: block; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stats-grid { min-width: 0; display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { min-width: 0; min-height: 112px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat span { display: block; min-height: 30px; color: var(--muted); font-size: 12px; font-weight: 650; }
.stat strong { display: block; margin-top: 10px; font-size: 23px; }
.stat.accent { border-top: 3px solid var(--accent); }
.stat.orange { border-top: 3px solid var(--orange); }
.dashboard-grid { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.section-heading { min-height: 78px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.section-heading .overline { margin-bottom: 4px; }

.toolbar { min-height: 54px; margin-bottom: 12px; display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.search-field { display: grid; gap: 5px; width: min(420px, 100%); }
.search-field span { color: var(--muted); font-size: 11px; font-weight: 750; }
.toolbar-select { display: grid; gap: 5px; width: min(230px, 100%); }
.toolbar-select span { color: var(--muted); font-size: 11px; font-weight: 750; }
.toolbar-select select { width: 100%; min-width: 0; height: 40px; padding: 0 32px 0 10px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); }
.toolbar-filter { display: grid; gap: 5px; }
.toolbar-filter > span { color: var(--muted); font-size: 11px; font-weight: 750; }
.result-count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.segmented button, .segmented label span { min-height: 32px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.segmented button.active, .segmented label:has(input:checked) span { background: var(--sidebar); color: white; }
.segmented.radio input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }

.master-detail { display: grid; grid-template-columns: minmax(520px, 1.08fr) minmax(390px, .92fr); gap: 14px; align-items: start; }
.list-panel { min-width: 0; }
.detail-panel { min-height: 640px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.empty-state { min-height: 360px; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 7px; }
.empty-state strong { color: var(--ink); }
.client-head { padding: 20px; border-bottom: 1px solid var(--line); }
.client-head-row { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.client-head h2 { font-size: 22px; margin: 3px 0 7px; }
.client-subline { color: var(--muted); font-size: 13px; }
.client-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.detail-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.detail-tab { height: 42px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 750; white-space: nowrap; }
.detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.detail-content { padding: 18px 20px 24px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.detail-item { min-width: 0; }
.detail-item span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.detail-item strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.client-summary-layout { display: grid; grid-template-columns: 1fr 190px; gap: 24px; align-items: start; }
.client-identity-photo { margin: 0; }
.client-identity-photo img { display: block; width: 100%; aspect-ratio: 1.58; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.client-identity-photo figcaption { margin-top: 7px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.summary-band { display: grid; grid-template-columns: repeat(3, 1fr); margin: -18px -20px 18px; border-bottom: 1px solid var(--line); }
.summary-band div { padding: 16px 20px; border-right: 1px solid var(--line); }
.summary-band div:last-child { border-right: 0; }
.summary-band span { color: var(--muted); font-size: 11px; }
.summary-band strong { display: block; margin-top: 5px; font-size: 18px; }
.account-stats { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.accounts-master { grid-template-columns: minmax(720px, 1.25fr) minmax(390px, .75fr); }
.account-vehicle-cell { min-width: 210px; max-width: 300px; line-height: 1.35; }
.account-detail-summary { display: grid; grid-template-columns: 1fr 1fr; margin: -18px -20px 18px; border-bottom: 1px solid var(--line); }
.account-detail-summary div { min-width: 0; padding: 14px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.account-detail-summary div:nth-child(even) { border-right: 0; }
.account-detail-summary span { display: block; color: var(--muted); font-size: 10px; }
.account-detail-summary strong { display: block; margin-top: 5px; font-size: 16px; overflow-wrap: anywhere; }
.account-detail-summary .account-total-due { background: var(--surface-soft); }
.account-detail-summary .account-total-due strong { color: var(--accent-dark); }
.account-detail-section { margin-top: 20px; }
.account-detail-section h3 { margin-bottom: 9px; font-size: 13px; }
.account-plan { max-height: 300px; border: 1px solid var(--line); border-radius: 6px; }
.account-plan th { position: sticky; }
.account-plan td { height: 38px; padding: 6px 8px; }
.account-vehicle-list { display: grid; gap: 8px; }
.account-vehicle-row { min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-vehicle-row strong, .account-vehicle-row span { display: block; overflow-wrap: anywhere; }
.account-vehicle-row span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.account-report-table { font-size: 8.5px; }
.account-report-table th { position: static; height: 31px; padding: 5px 7px; font-size: 7.5px; }
.account-report-table td { height: auto; padding: 6px 7px; vertical-align: top; }

.table-wrap { width: 100%; overflow: auto; }
.table-wrap.tall { max-height: calc(100vh - 204px); min-height: 500px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; height: 39px; padding: 0 13px; background: #f5f7f6; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
th[data-sortable="true"] { cursor: pointer; user-select: none; }
th[data-sortable="true"]::after { content: "↕"; display: inline-block; width: 12px; margin-left: 6px; color: #91a09c; text-align: center; font-size: 11px; }
th[data-sortable="true"][aria-sort="ascending"]::after { content: "↑"; color: var(--accent); }
th[data-sortable="true"][aria-sort="descending"]::after { content: "↓"; color: var(--accent); }
th[data-sortable="true"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
td { height: 48px; padding: 7px 13px; border-bottom: 1px solid #e9edec; vertical-align: middle; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.2; }
tbody tr:last-child td { border-bottom: 0; }
.selectable tbody tr { cursor: pointer; }
.selectable tbody tr:hover, .selectable tbody tr.selected { background: #edf7f4; }
.number { text-align: right; white-space: nowrap; }
.cell-main { display: block; max-width: 260px; color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.concept-cell { min-width: 220px; max-width: 360px; white-space: normal; line-height: 1.35; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; background: #edf2f1; color: #4c5c58; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status.good { background: #dff3ed; color: #086a59; }
.status.warn { background: #fff0d9; color: #99570b; }
.status.bad { background: #fee8e6; color: #9f291f; }
.pagination { min-height: 48px; padding: 8px 12px; display: flex; align-items: center; justify-content: center; gap: 7px; border-top: 1px solid var(--line); }
.pagination button { min-width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 5px; background: white; cursor: pointer; }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination span { color: var(--muted); font-size: 11px; }

.modal { width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.modal.wide { width: min(1040px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(15, 26, 23, .58); }
.modal-shell { background: white; }
.modal-header { min-height: 72px; padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.modal-header .overline { margin-bottom: 3px; }
.modal-header > div:last-child { display: flex; align-items: center; gap: 8px; }
.close-button { width: 36px; height: 36px; border: 0; border-radius: 5px; background: var(--surface-soft); color: var(--ink); cursor: pointer; font-size: 24px; line-height: 1; }
.modal-body { max-height: calc(100vh - 180px); overflow: auto; padding: 20px; }
.modal-footer { min-height: 64px; padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; gap: 0 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.vin-lookup-control .button { min-height: 42px; }
.vin-lookup-control small { min-height: 14px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.vin-decode-panel { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 2px 0 16px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.vin-decode-panel[hidden] { display: none; }
.vin-decode-copy { min-width: 0; padding-left: 14px; }
.vin-decode-copy .overline { margin-bottom: 4px; }
.vin-decode-copy > strong { display: block; font-size: 16px; }
.vin-decode-copy > p { margin: 3px 0 0; color: var(--muted); }
.vin-decode-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; color: var(--ink); font-size: 11px; }
.vin-decode-facts span { white-space: nowrap; }
.vin-decode-warning { color: #8b5b14 !important; font-size: 10px; font-weight: 700; }
.vin-decode-panel > .button { flex: 0 0 auto; margin-right: 14px; }
.form-section-heading { margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.form-section-heading h3 { font-size: 14px; }
.checkbox-field { min-height: 42px; margin: 20px 0 16px; display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 12px; font-weight: 700; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.identity-upload { display: grid; grid-template-columns: minmax(260px, 1fr) 220px; gap: 18px; align-items: start; padding-top: 4px; }
.identity-preview { min-height: 132px; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 11px; text-align: center; }
.identity-preview img { display: block; width: 100%; aspect-ratio: 1.58; object-fit: cover; }
.vehicle-picker { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; padding: 14px; margin-bottom: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.vehicle-picker .field { margin-bottom: 0; }
.line-entry { display: flex; gap: 9px; align-items: end; margin-bottom: 12px; }
.line-entry .field { margin-bottom: 0; }
.line-entry .grow { flex: 1 1 260px; }
.line-entry .small { width: 86px; }
.line-entry .medium { width: 126px; }
.align-end { flex: 0 0 auto; }
.invoice-lines { min-height: 120px; border: 1px solid var(--line); border-radius: 6px; }
.invoice-lines td { height: 42px; }
.remove-line { width: 28px; height: 28px; border: 0; background: transparent; color: var(--danger); cursor: pointer; font-weight: 800; }
.invoice-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 16px; margin-top: 16px; }
.invoice-total span { color: var(--muted); font-size: 12px; font-weight: 750; }
.invoice-total strong { min-width: 160px; text-align: right; font-size: 24px; }
.promissory-card { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.promissory-card .field { margin-bottom: 12px; }
.promissory-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.promissory-summary div { min-width: 0; padding: 11px 12px; border-right: 1px solid var(--line); }
.promissory-summary div:last-child { border-right: 0; }
.promissory-summary span { display: block; color: var(--muted); font-size: 10px; }
.promissory-summary strong { display: block; margin-top: 4px; font-size: 13px; overflow-wrap: anywhere; }
.promissory-preview { max-height: 210px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.promissory-preview th { position: sticky; }
.promissory-preview td { height: 38px; }
.application-list { margin: 4px 0 16px; border: 1px solid var(--line); border-radius: 6px; max-height: 270px; overflow: auto; }
.application-row { display: grid; grid-template-columns: 1fr 130px; gap: 14px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.application-row:last-child { border-bottom: 0; }
.application-row strong, .application-row span { display: block; }
.application-row span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.application-row input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 5px; padding: 0 9px; text-align: right; }

.statement-client { display: grid; gap: 4px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.statement-client strong { font-size: 16px; }
.statement-client span { color: var(--muted); font-size: 12px; }

.document-modal { width: min(1180px, calc(100vw - 28px)); }
.document-sheet { width: min(760px, 100%); min-height: 760px; margin: 24px auto; padding: 44px; border: 1px solid var(--line); background: white; color: #111; }
.document-sheet.statement-sheet { width: min(1080px, 100%); padding: 34px; }
.document-brand { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 20px; border-bottom: 2px solid #111; }
.document-company { display: flex; flex-direction: column; align-items: flex-start; min-width: 210px; }
.document-logo { display: block; width: 180px; height: auto; margin: -8px 0 8px; }
.document-brand h2 { font-size: 25px; margin-bottom: 5px; }
.document-brand p { margin-bottom: 3px; font-size: 12px; }
.document-number { text-align: right; }
.document-number strong { display: block; font-size: 22px; }
.document-client { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 30px; margin: 24px 0; font-size: 12px; }
.document-client > div { display: grid; gap: 2px; }
.document-client span { color: #555; }
.document-summary { margin-left: auto; width: 310px; margin-top: 22px; }
.document-summary div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #ddd; }
.document-summary div:last-child { font-size: 17px; font-weight: 800; border-bottom-color: #111; }
.document-installments { margin-top: 24px; }
.document-installments h3 { margin-bottom: 10px; font-size: 13px; }
.document-installments table { font-size: 9px; }
.document-installments th { position: static; height: 30px; padding: 5px 7px; font-size: 8px; }
.document-installments td { height: auto; padding: 6px 7px; }
.document-income td small { display: block; margin-top: 3px; color: #555; font-size: 8px; }
.document-footer { margin-top: 70px; padding-top: 20px; border-top: 1px solid #aaa; font-size: 11px; color: #555; }

.statement-brand .document-number { max-width: 470px; }
.statement-brand .document-number strong { margin: 4px 0; font-size: 19px; }
.statement-client-grid { grid-template-columns: 1.45fr 1fr 1.45fr; gap: 10px 24px; margin: 20px 0; }
.statement-table-wrap { width: 100%; overflow-x: auto; }
.statement-table { font-size: 9px; }
.statement-table th { position: static; height: 34px; padding: 5px 7px; font-size: 8px; }
.statement-table td { height: auto; min-height: 38px; padding: 7px; vertical-align: top; }
.statement-table td small { margin-top: 3px; }
.statement-table .statement-description { min-width: 170px; line-height: 1.35; }
.statement-table tfoot th { border-top: 2px solid #111; border-bottom: 0; background: white; color: #111; }
.statement-empty { height: 70px !important; text-align: center; color: #555; }
.statement-analysis { margin-top: 24px; }
.statement-analysis h3, .statement-vehicles h3 { margin-bottom: 10px; font-size: 13px; }
.aging-grid { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid #bbb; }
.aging-grid div { min-width: 0; padding: 9px; border-right: 1px solid #bbb; text-align: right; }
.aging-grid div:last-child { border-right: 0; }
.aging-grid span { display: block; color: #555; font-size: 9px; }
.aging-grid strong { display: block; margin-top: 5px; font-size: 11px; }
.statement-balance { width: 360px; margin: 16px 0 0 auto; display: grid; grid-template-columns: 1fr auto; border-top: 1px solid #bbb; }
.statement-balance span, .statement-balance strong { padding: 6px 0; border-bottom: 1px solid #ddd; font-size: 11px; }
.statement-balance strong { min-width: 130px; text-align: right; }
.statement-balance span:last-of-type, .statement-balance strong:last-child { border-bottom: 2px solid #111; font-size: 13px; }
.statement-vehicles { margin-top: 24px; }
.statement-vehicles table { font-size: 9px; }
.statement-vehicles th { position: static; height: 30px; padding: 5px 8px; font-size: 8px; }
.statement-vehicles td { height: auto; padding: 6px 8px; }
.statement-sheet .document-footer { margin-top: 32px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 360px; padding: 13px 16px; border-radius: 6px; background: var(--sidebar); color: white; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .account-stats { grid-template-columns: repeat(2, 1fr); }
  .master-detail { grid-template-columns: 1fr; }
  .detail-panel { min-height: 500px; }
  .table-wrap.tall { max-height: 560px; min-height: 420px; }
}

@media (max-width: 820px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { min-height: 280px; padding: 26px; }
  .login-statement h1 { font-size: 38px; }
  .login-source { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { width: 100%; min-width: 0; min-height: auto; height: auto; position: static; padding: 12px; overflow: hidden; }
  .brand-lockup.compact { display: none; }
  .nav { width: 100%; min-width: 0; grid-template-columns: repeat(3, minmax(82px, 1fr)); margin-top: 0; }
  .nav-button { text-align: center; padding: 0 7px; font-size: 11px; }
  .nav-group { grid-column: 1 / -1; margin-top: 4px; padding-top: 8px; }
  .nav-group-label { padding: 0 7px 3px; }
  .nav-group-items { grid-template-columns: repeat(3, minmax(82px, 1fr)); }
  .nav-group .nav-button { padding: 0 7px; }
  .sidebar-session { display: none; }
  .main { padding: 18px 14px 30px; }
  .topbar { align-items: start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .account-stats { grid-template-columns: repeat(2, 1fr); }
  .accounts-master { grid-template-columns: 1fr; }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .line-entry { flex-wrap: wrap; }
  .line-entry .grow { flex-basis: 100%; }
}

@media (max-width: 540px) {
  .login-brand { min-height: 240px; }
  .login-form-wrap { padding: 28px 20px; }
  .nav, .nav-group-items { grid-template-columns: repeat(3, minmax(76px, 1fr)); }
  .topbar { display: grid; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat { min-height: 96px; padding: 14px; }
  .stat strong { font-size: 16px; overflow-wrap: anywhere; }
  .result-count { width: 100%; margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .client-summary-layout { grid-template-columns: 1fr; }
  .client-identity-photo { width: min(260px, 100%); }
  .summary-band { grid-template-columns: 1fr; }
  .summary-band div { border-right: 0; border-bottom: 1px solid var(--line); }
  .client-head-row { display: grid; }
  .client-actions { justify-content: start; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .vin-decode-panel { align-items: stretch; flex-direction: column; }
  .vin-decode-panel > .button { margin: 0 14px 14px; }
  .promissory-summary { grid-template-columns: 1fr 1fr; }
  .promissory-summary div:nth-child(2) { border-right: 0; }
  .promissory-summary div { border-bottom: 1px solid var(--line); }
  .promissory-summary div:nth-last-child(-n+2) { border-bottom: 0; }
  .identity-upload { grid-template-columns: 1fr; }
  .vehicle-picker { grid-template-columns: 1fr; }
  .application-row { grid-template-columns: 1fr; }
  .document-sheet { padding: 24px 18px; }
  .document-sheet.statement-sheet { padding: 22px 14px; }
  .statement-brand { display: grid; }
  .statement-brand .document-number { max-width: none; text-align: left; }
  .statement-brand .document-number strong { font-size: 16px; }
  .statement-brand .document-logo { width: 130px; }
  .statement-client-grid { grid-template-columns: 1fr; }
  .statement-table thead { display: none; }
  .statement-table, .statement-table tbody, .statement-table tfoot { display: block; }
  .statement-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; padding: 9px 0; border-bottom: 1px solid #bbb; }
  .statement-table tbody td { min-width: 0; height: auto; padding: 5px 8px; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .statement-table tbody td::before { display: block; margin-bottom: 3px; color: #666; font-size: 8px; font-weight: 800; text-transform: uppercase; }
  .statement-table tbody td:nth-child(1)::before { content: "Fecha"; }
  .statement-table tbody td:nth-child(2)::before { content: "Descripción"; }
  .statement-table tbody td:nth-child(3)::before { content: "Documento origen"; }
  .statement-table tbody td:nth-child(4)::before { content: "Referencia"; }
  .statement-table tbody td:nth-child(5)::before { content: "Vence"; }
  .statement-table tbody td:nth-child(6)::before { content: "Débito"; }
  .statement-table tbody td:nth-child(7)::before { content: "Crédito"; }
  .statement-table tbody td:nth-child(8)::before { content: "Pendiente"; }
  .statement-table tbody td:nth-child(9)::before { content: "Balance"; }
  .statement-table tbody .statement-description { grid-column: 1 / -1; min-width: 0; }
  .statement-table tfoot tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 2px solid #111; }
  .statement-table tfoot th { min-width: 0; height: auto; padding: 7px 8px; border: 0; white-space: normal; }
  .statement-table tfoot th:first-child { grid-column: 1 / -1; border-bottom: 1px solid #bbb; text-align: left; }
  .statement-table tfoot th:nth-child(2)::before { content: "Débito: "; }
  .statement-table tfoot th:nth-child(3)::before { content: "Crédito: "; }
  .statement-table tfoot th:nth-child(4)::before { content: "Capital: "; }
  .statement-table tfoot th:nth-child(5)::before { content: "Balance: "; }
  .aging-grid { grid-template-columns: 1fr 1fr; }
  .aging-grid div { border-bottom: 1px solid #bbb; }
  .statement-balance { width: 100%; }
}

@media print {
  th[data-sortable="true"]::after { display: none; }
  body * { visibility: hidden !important; }
  #documentSheet, #documentSheet * { visibility: visible !important; }
  #documentSheet { position: absolute; inset: 0; width: 100%; min-height: 0; margin: 0; padding: 20mm 15mm; border: 0; }
  #documentSheet.statement-sheet { padding: 10mm; }
  .statement-table { font-size: 7.5pt; }
  .statement-table th { font-size: 6.5pt; }
  .statement-table tr, .statement-vehicles tr { break-inside: avoid; }
}
