/* =============================================================================
   Dealer: app styles on top of Bootstrap 5.3
   Tokens first; components below. Signature element: the number-plate chip.
   ============================================================================= */

:root {
    --asphalt: #1F2A30;
    --asphalt-2: #2C3A42;
    --asphalt-3: #3A4A53;
    --yard: #F5F6F4;
    --surface: #FFFFFF;
    --surface-2: #FAFBFA;
    --line: #DADFDC;
    --line-strong: #C3CAC6;
    --ink: #1F2A30;
    --muted: #55626A;
    --plate: #F2C230;
    --plate-ink: #111A1F;

    --ok-ink: #1F6B41;     --ok-bg: #E4F1E9;     --ok-solid: #2E7D4F;
    --warn-ink: #7A4F0E;   --warn-bg: #FBF0D9;   --warn-solid: #C99A2E;
    --fail-ink: #A61E14;   --fail-bg: #FBE7E4;   --fail-solid: #B42318;
    --info-ink: #1D4F7A;   --info-bg: #E3EEF7;   --info-solid: #2F6EA3;
    --violet-ink: #4F3F8C; --violet-bg: #ECE8F7;
    --neutral-ink: #4A565D; --neutral-bg: #ECEFED; --neutral-solid: #8A969C;

    /* One family (Archivo, variable width) in three roles. Change here to swap. */
    --font-ui: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-plate: var(--font-ui);
    --stretch-display: 112.5%;
    --stretch-plate: 75%;

    --radius-sm: 6px;
    --radius: 10px;
    --sidebar-w: 248px;
    --topbar-h: 64px;
    --bottom-nav-h: 64px;
    --ease: cubic-bezier(.2, .7, .2, 1);

    /* Bootstrap hooks */
    --bs-body-font-family: var(--font-ui);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--yard);
    --bs-border-color: var(--line);
    --bs-link-color: var(--asphalt);
    --bs-link-color-rgb: 31, 42, 48;
    --bs-link-hover-color: var(--asphalt-3);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
}

/* ---------- Base ---------------------------------------------------------- */

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.55;
    background: var(--yard);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { font-weight: 700; font-stretch: var(--stretch-display); letter-spacing: -.01em; color: var(--ink); text-wrap: balance; }
h1 { font-weight: 800; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.text-muted, .muted { color: var(--muted) !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.small, small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }

:focus-visible {
    outline: 3px solid var(--plate);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--asphalt) !important;
    border-radius: 4px;
}

.skip-link {
    position: absolute; left: 1rem; top: -100px; z-index: 2000;
    background: var(--plate); color: var(--plate-ink); padding: .6rem 1rem;
    font-weight: 700; border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---------- Plate chip (signature) ---------------------------------------- */

.plate {
    display: inline-flex;
    align-items: center;
    padding: .12em .5em .08em;
    background: var(--plate);
    color: var(--plate-ink);
    border: 2px solid var(--plate-ink);
    border-radius: 5px;
    box-shadow: inset 0 0 0 1.5px var(--plate), inset 0 0 0 2.5px rgba(17, 26, 31, .3);
    font: 700 1.05rem/1.15 var(--font-plate);
    font-stretch: var(--stretch-plate);
    letter-spacing: .05em;
    white-space: nowrap;
    vertical-align: middle;
}
.plate-sm { font-size: .9rem; padding: .08em .4em .04em; border-width: 1.5px; }
.plate-lg { font-size: 1.6rem; border-width: 2.5px; padding: .1em .55em .05em; }
.plate-unreg {
    background: var(--surface);
    border-style: dashed;
    color: var(--muted);
    box-shadow: none;
}
a .plate { text-decoration: none; }

/* ---------- Status pills (icon + word, never colour alone) ---------------- */

.st {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .16rem .55rem .16rem .42rem;
    border-radius: 999px;
    font-size: .8125rem; font-weight: 700; line-height: 1.35;
    white-space: nowrap;
}
.st .ph { font-size: 1em; }
.st-ok      { color: var(--ok-ink);      background: var(--ok-bg); }
.st-warn    { color: var(--warn-ink);    background: var(--warn-bg); }
.st-fail    { color: var(--fail-ink);    background: var(--fail-bg); }
.st-info    { color: var(--info-ink);    background: var(--info-bg); }
.st-violet  { color: var(--violet-ink);  background: var(--violet-bg); }
.st-neutral { color: var(--neutral-ink); background: var(--neutral-bg); }

/* ---------- App shell ------------------------------------------------------ */

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1030;
    width: var(--sidebar-w);
    background: var(--asphalt);
    color: #D5DCDF;
    display: none;
    flex-direction: column;
    padding: 1.1rem .85rem 1rem;
    overflow-y: auto;
    /* Still scrolls with wheel / touch on short screens, but no visible bar. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar,
.nav-sheet .offcanvas-body::-webkit-scrollbar { display: none; }
.nav-sheet .offcanvas-body { scrollbar-width: none; }

.brand {
    display: flex; flex-direction: column; align-items: flex-start; gap: .55rem;
    padding: .25rem .5rem 1.25rem;
    color: #fff; text-decoration: none;
}
.brand .plate { font-size: 1rem; }
.brand-name { font-weight: 700; line-height: 1.2; font-size: .95rem; min-width: 0; overflow-wrap: anywhere; }
.brand-name span { display: block; font-weight: 400; color: #AEB9BE; font-size: .8125rem; }

.nav-group-label {
    color: #96A3A9; font-size: .8125rem; font-weight: 600;
    padding: 1rem .75rem .35rem;
}
.side-nav { list-style: none; margin: 0; padding: 0; }
.side-nav a {
    position: relative;
    display: flex; align-items: center; gap: .7rem;
    min-height: 44px;
    padding: .55rem .75rem;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    color: #D5DCDF;
    text-decoration: none;
    font-weight: 600;
}
.side-nav a .ph { font-size: 1.25rem; opacity: .85; }
.side-nav a:hover { background: var(--asphalt-2); color: #fff; }
.side-nav a[aria-current="page"] { background: var(--asphalt-2); color: #fff; }
.side-nav a[aria-current="page"]::before {
    content: ""; position: absolute; left: -.85rem; top: 8px; bottom: 8px;
    width: 4px; border-radius: 0 3px 3px 0; background: var(--plate);
}
.side-nav .count {
    margin-left: auto; background: var(--fail-solid); color: #fff;
    font-size: .75rem; padding: .05rem .45rem; border-radius: 999px;
}
.sidebar-cta { margin-top: auto; padding-top: 1rem; }
.btn-plate {
    --bs-btn-bg: var(--plate); --bs-btn-color: var(--plate-ink); --bs-btn-border-color: var(--plate);
    --bs-btn-hover-bg: #F5CE52; --bs-btn-hover-color: var(--plate-ink); --bs-btn-hover-border-color: #F5CE52;
    --bs-btn-active-bg: #E0B21F; --bs-btn-active-color: var(--plate-ink); --bs-btn-active-border-color: #E0B21F;
    font-weight: 700;
}

.main-col { min-height: 100dvh; display: flex; flex-direction: column; min-width: 0; overflow-x: clip; }

.topbar {
    position: sticky; top: 0; z-index: 1020;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar .brand-mobile { display: flex; align-items: center; text-decoration: none; }
.topbar-search { flex: 1; max-width: 34rem; position: relative; }
.topbar-search .ph {
    position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
    color: var(--muted); pointer-events: none; font-size: 1.1rem;
}
.topbar-search input { padding-left: 2.4rem; background: var(--yard); border-color: transparent; }
.topbar-search input:focus { background: var(--surface); border-color: var(--line-strong); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .25rem; }

.icon-btn {
    position: relative;
    display: inline-grid; place-items: center;
    width: 44px; height: 44px;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--ink);
    font-size: 1.35rem;
}
.icon-btn:hover { background: var(--yard); }
.bell-count {
    position: absolute; top: 5px; right: 3px;
    min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 999px; border: 2px solid var(--surface);
    background: var(--fail-solid); color: #fff;
    font-size: .6875rem; font-weight: 700; line-height: 15px; text-align: center;
}
.bell-count[hidden] { display: none; }

.avatar {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--asphalt); color: #fff;
    font-weight: 700; font-size: .875rem;
}
.user-btn { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; padding: .25rem .4rem; border-radius: 999px; min-height: 44px; }
.user-btn:hover { background: var(--yard); }

.notif-menu { width: min(380px, calc(100vw - 2rem)); padding: 0; overflow: hidden; }
.notif-menu-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 420px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.notif-item form { margin: 0; }
.notif-item button {
    display: grid; grid-template-columns: 28px 1fr; gap: .6rem;
    width: 100%; text-align: left; border: 0; background: transparent;
    padding: .7rem 1rem; border-bottom: 1px solid var(--line);
}
.notif-item button:hover { background: var(--yard); }
.notif-item.unread button { background: #FFFBEB; }
.notif-item .ph { font-size: 1.25rem; margin-top: .1rem; }
.notif-title { font-weight: 700; font-size: .9375rem; }
.notif-msg { color: var(--muted); font-size: .875rem; }
.notif-time { color: var(--muted); font-size: .75rem; }
.notif-empty { padding: 1.5rem 1rem; color: var(--muted); text-align: center; }

.content { flex: 1; padding: 1.25rem 1rem calc(var(--bottom-nav-h) + 1.5rem); width: 100%; max-width: 1320px; }

.bottom-nav {
    position: fixed; inset: auto 0 0 0; z-index: 1030;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface); border-top: 1px solid var(--line);
}
.bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: transparent; color: var(--muted);
    font-size: .75rem; font-weight: 600; text-decoration: none;
}
.bottom-nav .ph { font-size: 1.4rem; }
.bottom-nav [aria-current="page"] { color: var(--ink); }
.bottom-nav [aria-current="page"] .ph { color: var(--ink); }
.bottom-nav .pay .ph {
    background: var(--plate); color: var(--plate-ink);
    width: 40px; height: 30px; border-radius: 8px; display: grid; place-items: center;
}

.offcanvas.nav-sheet { background: var(--asphalt); color: #D5DCDF; }
.offcanvas.nav-sheet .btn-close { filter: invert(1); }

@media (min-width: 992px) {
    .sidebar { display: flex; }
    .main-col { margin-left: var(--sidebar-w); }
    .topbar { padding: 0 1.75rem; }
    .topbar .brand-mobile { display: none; }
    .bottom-nav { display: none; }
    .content { padding: 1.75rem 1.75rem 3rem; }
}

/* ---------- Page structure ------------------------------------------------- */

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem;
}
.page-head .sub { color: var(--muted); margin: .3rem 0 0; }
.page-head .crumb { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); text-decoration: none; font-size: .875rem; margin-bottom: .35rem; }
.page-head .crumb:hover { color: var(--ink); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; justify-content: flex-end; }
/* The title and description give way, so the buttons stay on the right */
.page-head > div:first-child { flex: 1 1 22rem; min-width: 0; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--line);
}
.panel-head .sub { color: var(--muted); font-size: .875rem; margin: .1rem 0 0; }
.panel-body { padding: 1.1rem; }
.panel-foot { padding: .75rem 1.1rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.panel-danger { border-color: #F0C4BE; }
.panel-danger .panel-head { background: #FFF7F6; border-radius: var(--radius) var(--radius) 0 0; }

/* minmax(0, 1fr): a single column must never grow wider than the screen. */
.grid-main { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
.grid-main > * { min-width: 0; }
@media (min-width: 1100px) {
    .grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
}

/* Key facts */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: .8125rem; font-weight: 600; color: var(--muted); margin-bottom: .1rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts-list { margin: 0; }
.facts-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.facts-list div:last-child { border-bottom: 0; }
.facts-list dt { color: var(--muted); font-weight: 400; }
.facts-list dd { margin: 0; font-weight: 700; text-align: right; }
.facts-list .total dt, .facts-list .total dd { color: var(--ink); font-weight: 700; font-size: 1.05rem; }

/* Money headline in a panel */
.balance-figure { font-size: 1.75rem; font-weight: 700; line-height: 1.15; }
.balance-figure small { display: block; font-size: .875rem; font-weight: 400; color: var(--muted); margin-bottom: .2rem; }

/* ---------- Buttons & forms (Bootstrap overrides) ------------------------- */

.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-weight: 600; border-radius: var(--radius-sm); padding: .5rem 1rem; }
.btn .ph { font-size: 1.15em; }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .875rem; }
.btn-primary {
    --bs-btn-bg: var(--asphalt); --bs-btn-border-color: var(--asphalt);
    --bs-btn-hover-bg: var(--asphalt-2); --bs-btn-hover-border-color: var(--asphalt-2);
    --bs-btn-active-bg: var(--asphalt-3); --bs-btn-active-border-color: var(--asphalt-3);
    --bs-btn-disabled-bg: var(--asphalt); --bs-btn-disabled-border-color: var(--asphalt);
}
.btn-outline-secondary {
    --bs-btn-color: var(--ink); --bs-btn-border-color: var(--line-strong);
    --bs-btn-hover-bg: var(--yard); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: var(--line-strong);
    --bs-btn-active-bg: var(--line); --bs-btn-active-color: var(--ink); --bs-btn-active-border-color: var(--line-strong);
    background: var(--surface);
}
.btn-link { color: var(--ink); }
.btn[aria-busy="true"] { pointer-events: none; opacity: .7; }

.form-label { font-weight: 600; margin-bottom: .3rem; }
.form-label .req { color: var(--fail-ink); margin-left: .15rem; }
legend.form-label { font-size: 1rem; float: none; width: auto; }
.form-text { color: var(--muted); font-size: .8125rem; }
.form-control, .form-select { min-height: 44px; border-color: var(--line-strong); font-size: 1rem; }
textarea.form-control { min-height: 88px; }
.form-control:focus, .form-select:focus { border-color: var(--asphalt); box-shadow: 0 0 0 3px rgba(242, 194, 48, .55); }
.form-check-input { width: 1.25em; height: 1.25em; margin-top: .15em; border-color: var(--line-strong); }
.form-check-input:checked { background-color: var(--asphalt); border-color: var(--asphalt); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(242, 194, 48, .55); border-color: var(--asphalt); }
.input-group-text { background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); font-weight: 600; }
.invalid-feedback { font-weight: 600; font-size: .875rem; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--fail-solid); }
.form-section + .form-section { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.form-section > h2 { margin-bottom: .2rem; }
.form-section > .sub { color: var(--muted); margin-bottom: 1rem; font-size: .9375rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1.5rem; }

/* ---------- Tables -------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.tbl { margin: 0; --bs-table-bg: transparent; }
.tbl > :not(caption) > * > * { padding: .7rem .9rem; border-bottom-color: var(--line); vertical-align: middle; }
.tbl thead th {
    font-size: .8125rem; font-weight: 700; color: var(--muted);
    background: var(--surface-2); white-space: nowrap;
}
.tbl tbody tr:hover > * { background: #FBFBF9; }
.tbl .money, .tbl th.money { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.tbl .row-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.tbl .row-link:hover { text-decoration: underline; }
.tbl .sub-line { display: block; color: var(--muted); font-size: .8125rem; font-weight: 400; }
.tbl tr.is-void > * { color: var(--muted); }
.tbl tr.is-next > * { background: #FFF8E1; }
.tbl tr.is-next .primary-cell, .tbl tr.is-next td:first-child { box-shadow: inset 4px 0 0 var(--plate); }
.tbl tr.is-void .money { text-decoration: line-through; }

@media (max-width: 767.98px) {
    .tbl-stack thead { display: none; }
    .tbl-stack, .tbl-stack tbody, .tbl-stack tr, .tbl-stack td { display: block; width: 100%; }
    .tbl-stack tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
    .tbl-stack > :not(caption) > * > * { padding: .2rem 0; border: 0; }
    .tbl-stack td[data-label] { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; text-align: right; }
    .tbl-stack td[data-label] .sub-line { flex-basis: 100%; }
    .tbl-stack tr.is-next { background: #FFF8E1; }
    .tbl-stack tr.is-next > * { background: transparent !important; }
    .tbl-stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; }
    .tbl-stack td.primary-cell { font-size: 1.05rem; margin-bottom: .2rem; }
    .tbl-stack tfoot tr { background: var(--surface-2); }
}

/* ---------- Filters ------------------------------------------------------- */

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .f-grow { flex: 1 1 220px; }
.filters .form-label { font-size: .8125rem; color: var(--muted); }
.seg-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.seg-tabs a {
    display: inline-flex; align-items: center; gap: .4rem; min-height: 40px;
    padding: .35rem .85rem; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9375rem;
}
.seg-tabs a .n { color: var(--muted); font-weight: 400; }
.seg-tabs a[aria-current="page"] { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
.seg-tabs a[aria-current="page"] .n { color: #C9D1D5; }

/* ---------- Empty state, flash ------------------------------------------- */

.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); }
.empty .ph { font-size: 2.25rem; color: var(--line-strong); display: block; margin: 0 auto .5rem; }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .25rem; }
.empty .btn { margin-top: 1rem; }

.flash {
    display: flex; gap: .7rem; align-items: flex-start;
    padding: .85rem 1rem; margin-bottom: 1.25rem;
    border-radius: var(--radius); border: 1px solid;
    font-weight: 600;
}
.flash .ph { font-size: 1.3rem; flex: none; margin-top: .05rem; }
.flash p { margin: 0; flex: 1; }
.flash .btn-close { flex: none; }
.flash-success { background: var(--ok-bg);   border-color: #BFDCCB; color: var(--ok-ink); }
.flash-error   { background: var(--fail-bg); border-color: #F0C4BE; color: var(--fail-ink); }
.flash-warning { background: var(--warn-bg); border-color: #EBD3A0; color: var(--warn-ink); }
.flash-info    { background: var(--info-bg); border-color: #BCD3E6; color: var(--info-ink); }

/* ---------- Dashboard ----------------------------------------------------- */

.today-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.today-head .date { color: var(--muted); font-weight: 600; }

.collect {
    display: grid; gap: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-bottom: 1px solid var(--line);
}
.collect > div { padding: 1rem 1.1rem; }
.collect > div + div { border-left: 1px solid var(--line); }
.collect .label { color: var(--muted); font-size: .875rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.collect > div { min-width: 0; }
.collect .value { font-size: clamp(1.15rem, .6rem + 1.1vw, 1.5rem); font-weight: 700; line-height: 1.2; margin-top: .15rem; overflow-wrap: anywhere; }
.collect .value .cur, .cur { font-size: .62em; font-weight: 600; color: var(--muted); margin-right: .15em; letter-spacing: .02em; }
.collect .meta { color: var(--muted); font-size: .8125rem; }
.collect .is-overdue .value { color: var(--fail-ink); }
@media (max-width: 575.98px) {
    /* Phones: a compact list, label on the left and amount on the right. */
    .collect { grid-template-columns: 1fr; }
    .collect > div {
        display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "meta value";
        column-gap: 1rem; align-items: center; padding: .7rem 1.1rem;
    }
    .collect > div + div { border-left: 0; border-top: 1px solid var(--line); }
    .collect .label { grid-area: label; }
    .collect .meta  { grid-area: meta; }
    .collect .value { grid-area: value; margin: 0; font-size: 1.15rem; text-align: right; overflow-wrap: normal; white-space: nowrap; }
}

.worklist { list-style: none; margin: 0; padding: 0; }
.work-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: .4rem 1rem; align-items: center;
    padding: .8rem 1.1rem; border-bottom: 1px solid var(--line);
}
.work-row:last-child { border-bottom: 0; }
.work-who { min-width: 0; }
.work-who a { font-weight: 700; color: var(--ink); text-decoration: none; }
.work-who a:hover { text-decoration: underline; }
.work-who .sub-line { display: block; color: var(--muted); font-size: .8125rem; }
.work-when { font-size: .875rem; font-weight: 700; white-space: nowrap; }
.work-when.late { color: var(--fail-ink); }
.work-amount { font-weight: 700; text-align: right; white-space: nowrap; }
.work-actions { display: flex; gap: .35rem; }
@media (max-width: 767.98px) {
    /* Phones: plate and name on the left, amount on the right, buttons below. */
    .work-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "plate money" "who money" "actions actions";
        gap: .3rem .75rem; align-items: start;
    }
    .work-row > .plate { grid-area: plate; justify-self: start; }
    .work-row > .work-who { grid-area: who; }
    .work-row > .text-end { grid-area: money; }
    .work-row > .work-actions { grid-area: actions; justify-content: flex-end; margin-top: .25rem; }
}

.pay-list { list-style: none; margin: 0; padding: 0; }
.pay-list a { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 1.1rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.pay-list li:last-child a { border-bottom: 0; }
.pay-list a:hover { background: var(--surface-2); }
.pay-list a:hover .pay-who { text-decoration: underline; }
.pay-who { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.pay-who .sub-line, .pay-amt .sub-line { display: block; color: var(--muted); font-size: .8125rem; font-weight: 400; }
.pay-amt { font-weight: 700; text-align: right; white-space: nowrap; }

.fleet-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--neutral-bg); margin: .25rem 0 1rem; }
.fleet-bar span { display: block; height: 100%; }
.fleet-bar span + span { box-shadow: -2px 0 0 var(--surface); }
.seg-available     { background: var(--ok-solid); }
.seg-reserved      { background: #7B6BC0; }
.seg-sold          { background: var(--neutral-solid); }
.fleet-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }
.fleet-legend li a { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; padding: .2rem 0; }
.fleet-legend li a:hover .lbl { text-decoration: underline; }
.fleet-legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.fleet-legend .n { margin-left: auto; font-weight: 700; }

.stat-line { list-style: none; margin: 0; padding: 0; }
.stat-line li { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.stat-line li:last-child { border-bottom: 0; }
.stat-line a { color: var(--ink); }
.stat-line strong { font-weight: 700; }

.progress-line { height: 8px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress-line span { display: block; height: 100%; background: var(--ok-solid); }

/* ---------- Vehicles ------------------------------------------------------ */

.vehicle-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.v-card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--ink); text-decoration: none; overflow: hidden;
    transition: border-color .15s var(--ease);
}
.v-card:hover { border-color: var(--line-strong); color: var(--ink); }
.v-card:hover .v-title { text-decoration: underline; }
.v-photo { aspect-ratio: 4 / 3; background: var(--neutral-bg); position: relative; }
.v-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.v-photo .no-photo { position: absolute; inset: 0; display: grid; place-items: center; color: var(--neutral-solid); font-size: 2.5rem; }
.v-photo .plate { position: absolute; left: .6rem; bottom: .6rem; }
.v-photo .st { position: absolute; right: .6rem; top: .6rem; box-shadow: 0 0 0 2px var(--surface); }
.v-body { padding: .8rem .95rem .95rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.v-title { font-weight: 700; font-size: 1.05rem; }
.v-meta { color: var(--muted); font-size: .875rem; }
.v-price { margin-top: auto; padding-top: .5rem; font-weight: 700; font-size: 1.1rem; }

.gallery-main { aspect-ratio: 16 / 10; background: var(--neutral-bg); border-radius: var(--radius-sm); overflow: hidden; display: grid; place-items: center; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-main .ph { font-size: 3rem; color: var(--neutral-solid); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem; margin-top: .75rem; }
.thumb { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; background: var(--neutral-bg); }
.thumb.is-primary { border-color: var(--plate); }
.thumb button.view { display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; background: transparent; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-actions { display: flex; gap: 2px; background: var(--surface); }
.thumb .thumb-actions form { flex: 1; margin: 0; }
.thumb .thumb-actions button { width: 100%; min-height: 32px; border: 0; background: var(--surface-2); font-size: .75rem; font-weight: 600; color: var(--ink); }
.thumb .thumb-actions button:hover { background: var(--yard); }
.thumb .primary-tag { position: absolute; top: 4px; left: 4px; background: var(--plate); color: var(--plate-ink); font-size: .6875rem; font-weight: 700; padding: 0 .35rem; border-radius: 3px; }

.spec-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem 1.25rem; margin: 0; }
.spec-list dt { font-size: .8125rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: .3rem; }
.spec-list dd { margin: 0; font-weight: 700; }

/* ---------- Receipt ------------------------------------------------------- */

.receipt { max-width: 720px; }
.receipt-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.25rem 1.25rem 1rem; border-bottom: 2px solid var(--ink); }
.receipt-head .biz { font-weight: 700; font-size: 1.2rem; }
.receipt-amount { font-size: 2rem; font-weight: 700; }
.void-stamp {
    display: inline-block; border: 3px solid var(--fail-solid); color: var(--fail-solid);
    font: 800 1.5rem/1 var(--font-plate); font-stretch: var(--stretch-plate); letter-spacing: .12em; padding: .3rem .8rem; border-radius: 6px; transform: rotate(-4deg);
}

/* ---------- Auth ---------------------------------------------------------- */

.auth-page { min-height: 100dvh; display: grid; background: var(--yard); }
@media (min-width: 992px) {
    .auth-page { grid-template-columns: minmax(0, 1fr) minmax(420px, 520px); }
}
.auth-side {
    display: none;
    background: var(--asphalt);
    color: #D5DCDF;
    padding: 3rem;
    position: relative; overflow: hidden;
}
@media (min-width: 992px) { .auth-side { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-side .plate-hero { font-size: clamp(3rem, 6vw, 5.5rem); }
.auth-side h2 { color: #fff; font-size: 1.75rem; margin: 2rem 0 .75rem; max-width: 22ch; }
.auth-side p { max-width: 46ch; color: #AEB9BE; }
.auth-side .road {
    position: absolute; left: 0; right: 0; bottom: 5.5rem; height: 6px;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 48px, transparent 48px 84px);
}
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.625rem; margin-bottom: .35rem; }
.auth-card .lede { color: var(--muted); margin-bottom: 1.75rem; }
.auth-brand-mobile { margin-bottom: 2rem; }
@media (min-width: 992px) { .auth-brand-mobile { display: none; } }

/* ---------- Search results ---------------------------------------------- */

.result-group + .result-group { margin-top: 1.25rem; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li a { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.result-list li:last-child a { border-bottom: 0; }
.result-list li a:hover { background: var(--yard); }
.result-list .sub-line { color: var(--muted); font-size: .875rem; }

/* ---------- Settings ----------------------------------------------------- */

.settings-nav { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.settings-nav a { display: block; padding: .45rem .75rem; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 600; }
.settings-nav a:hover { background: var(--surface); }
.tpl-preview { background: var(--yard); border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .875rem; color: var(--muted); margin-top: .4rem; }
.tpl-preview strong { color: var(--ink); }

/* ---------- Pagination --------------------------------------------------- */

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1.1rem; border-top: 1px solid var(--line); }
.pager .info { color: var(--muted); font-size: .875rem; }
.pager nav { display: flex; gap: .35rem; }

/* ---------- Modal tweaks -------------------------------------------------- */

.modal-content { border-radius: var(--radius); border: 0; }
.modal-header, .modal-footer { border-color: var(--line); }

/* ---------- Motion & print ----------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Costing and profit -------------------------------------------- */

.profit-pos { color: var(--ok-ink); }
.profit-neg { color: var(--fail-ink); }
.note-warn {
    display: flex; gap: .5rem; align-items: flex-start; padding: .7rem .9rem;
    border-radius: var(--radius-sm); border: 1px solid #EBD3A0;
    background: var(--warn-bg); color: var(--warn-ink);
}
.note-warn .ph { font-size: 1.15rem; flex: none; }
.collect .is-profit .value { color: var(--ok-ink); }
@media (min-width: 576px) {
    .collect-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .collect-4 > div:nth-child(3) { border-left: 0; }
    .collect-4 > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (min-width: 992px) {
    .collect-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .collect-4 > div:nth-child(3) { border-left: 1px solid var(--line); }
    .collect-4 > div:nth-child(n+3) { border-top: 0; }
}
.tbl tr.cat-row > * { background: var(--surface-2); font-weight: 700; }
.tbl tfoot td { font-weight: 700; }
.profit-result {
    display: grid; gap: .1rem; margin-top: 1rem; padding: .9rem 1rem;
    border-radius: var(--radius-sm); border: 1px solid;
}
.profit-result .label { display: flex; align-items: center; gap: .35rem; font-weight: 700; }
.profit-result .value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.profit-result .value .cur { font-size: .55em; color: inherit; opacity: .75; }
.profit-result .meta { font-size: .875rem; }
.profit-result.is-profit { background: var(--ok-bg); border-color: #BFDCCB; color: var(--ok-ink); }
.profit-result.is-loss { background: var(--fail-bg); border-color: #F0C4BE; color: var(--fail-ink); }
@media (min-width: 768px) {
    .costing-table { min-width: 1180px; }
    .costing-table td, .costing-table th { font-size: .875rem; white-space: nowrap; }
    .costing-table .sub-line { display: block; }
}

/* ---------- Sourcing: imports and suppliers ------------------------------- */

.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .02em; }

/* Source chooser on the vehicle and supplier forms */
.source-choice { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); border: 0; padding: 0; margin: 0; }
.source-card { position: relative; cursor: pointer; }
.source-card input { position: absolute; opacity: 0; inset: 0; }
.source-card > span {
    display: grid; grid-template-columns: auto 1fr; column-gap: .7rem; align-items: center; height: 100%;
    padding: .85rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
.source-card .ph { grid-row: span 2; font-size: 1.6rem; color: var(--muted); }
.source-card strong { line-height: 1.25; }
.source-card small { color: var(--muted); line-height: 1.35; }
.source-card:hover > span { border-color: var(--asphalt-3); }
.source-card input:checked + span { border-color: var(--asphalt); box-shadow: inset 0 0 0 1px var(--asphalt); background: var(--surface-2); }
.source-card input:checked + span .ph { color: var(--asphalt); }
.source-card input:focus-visible + span { outline: 3px solid var(--plate); outline-offset: 2px; }

/* Stage picker when adding an import */
.stage-choice { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stage-pill { position: relative; cursor: pointer; }
.stage-pill input { position: absolute; opacity: 0; inset: 0; }
.stage-pill > span {
    display: flex; flex-direction: column; height: 100%; padding: .6rem .8rem;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.stage-pill small { color: var(--muted); font-size: .8125rem; }
.stage-pill input:checked + span { border-color: var(--asphalt); background: var(--asphalt); color: #fff; }
.stage-pill input:checked + span small { color: #C9D1D5; }
.stage-pill input:focus-visible + span { outline: 3px solid var(--plate); outline-offset: 2px; }

/* Stage tracker on the vehicle page */
.stage-track { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; counter-reset: stage; }
.stage-track li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem; padding-top: .1rem; }
.stage-track li::before {
    content: ""; position: absolute; top: 1.15rem; right: 50%; width: 100%; height: 3px; background: var(--line);
}
.stage-track li:first-child::before { display: none; }
.stage-track li.is-done::before, .stage-track li.is-current::before { background: var(--asphalt); }
.stage-track .dot {
    position: relative; z-index: 1; display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted); font-size: 1.1rem;
}
.stage-track .is-done .dot { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
.stage-track .is-current .dot { background: var(--plate); border-color: var(--plate-ink); color: var(--plate-ink); box-shadow: 0 0 0 4px rgba(242, 194, 48, .3); }
.stage-track strong { font-size: .875rem; line-height: 1.2; margin-top: .25rem; }
.stage-track small { color: var(--muted); font-size: .75rem; }
.stage-track li:not(.is-done):not(.is-current) strong { color: var(--muted); font-weight: 600; }
@media (max-width: 420px) {
    .stage-track strong { font-size: .75rem; }
    .stage-track small { font-size: .6875rem; }
}
.stage-form { padding-top: 1rem; border-top: 1px dashed var(--line); }

/* Pipeline counts on the imports page */
.pipeline { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pipeline a {
    position: relative; display: flex; align-items: center; gap: .75rem; height: 100%; padding: .8rem 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none;
}
.pipeline a:hover { border-color: var(--line-strong); }
.pipeline li.is-on a { border-color: var(--asphalt); box-shadow: inset 0 0 0 1px var(--asphalt); }
.pipeline .n { font-size: 1.6rem; font-weight: 700; line-height: 1; min-width: 1.6ch; }
.pipeline span:last-child { font-weight: 600; line-height: 1.2; }
.pipeline small { display: block; color: var(--muted); font-weight: 400; font-size: .75rem; }
@media (min-width: 768px) {
    .pipeline li + li a::before {
        content: ""; position: absolute; left: -.5rem; top: 50%; width: .5rem; height: 2px; background: var(--line-strong);
    }
}

/* Dashboard link to imports */
.on-the-way {
    display: flex; align-items: center; gap: .65rem; padding: .7rem .85rem; border-radius: var(--radius-sm);
    background: var(--info-bg); color: var(--info-ink); text-decoration: none; line-height: 1.25;
}
.on-the-way > .ph:first-child { font-size: 1.5rem; }
.on-the-way small { display: block; font-size: .8125rem; opacity: .9; }
.on-the-way:hover { color: var(--info-ink); text-decoration: underline; }

/* Purchase summary: 2 x 2 at any width (it sits in the narrower main column) */
@media (min-width: 576px) {
    .collect-2x2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .collect-2x2 > div:nth-child(3) { border-left: 0; }
    .collect-2x2 > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* Finance: kinds of money, car lookup */
.record-types { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.record-types a {
    display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; align-items: start; padding: .7rem .85rem;
    border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none;
}
.record-types a .ph { font-size: 1.4rem; color: var(--muted); grid-row: span 2; margin-top: .1rem; }
.record-types a small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; margin-top: .1rem; }
.record-types a:hover { border-color: var(--asphalt-3); }
.record-types a[aria-current="page"] { border-color: var(--asphalt); box-shadow: inset 0 0 0 1px var(--asphalt); background: var(--surface-2); }
.record-types a[aria-current="page"] .ph { color: var(--asphalt); }
.car-lookup { position: relative; }
.car-lookup .car-clear { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); }
.car-results {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .25rem; list-style: none;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(31, 42, 48, .12);
    max-height: 320px; overflow-y: auto;
}
.car-option { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .45rem .55rem; border-radius: var(--radius-sm); color: var(--ink); }
.car-option:hover, .car-option.is-active { background: var(--neutral-bg); }
.car-none { padding: .5rem .6rem; color: var(--muted); }
@media (min-width: 992px) { .car-context { position: sticky; top: calc(var(--topbar-h) + 1rem); } }
.cash-book td.money { white-space: nowrap; }

/* Receivables aging */
.aging-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; align-items: end; height: 64px; margin-top: .3rem; }
.aging-bars div { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; }
.aging-bars span { display: block; background: var(--fail-solid); border-radius: 3px 3px 0 0; min-height: 0; }
.aging-bars small { font-size: .68rem; color: var(--muted); text-align: center; margin-top: .15rem; white-space: nowrap; }
.aging-table td, .aging-table th { font-size: .875rem; }

/* Finance documents */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: .6rem; padding: .6rem 1.1rem; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list .ph { color: var(--muted); }
.min-w-0 { min-width: 0; }

/* Vehicle reference number */
.ref-chip { display: inline-block; margin-right: .4rem; padding: .05rem .45rem; border-radius: var(--radius-sm); background: var(--asphalt); color: #fff; font-weight: 700; font-size: .875rem; letter-spacing: .02em; }

/* Installment plan builder */
.plan-summary { display: grid; gap: .5rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plan-summary > div { padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.plan-summary span { display: block; color: var(--muted); font-size: .8125rem; }
.plan-summary strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.plan-summary .is-off { border-color: #EBD3A0; background: var(--warn-bg); color: var(--warn-ink); }
.plan-summary .is-ok { border-color: #BFDCCB; background: var(--ok-bg); color: var(--ok-ink); }
.plan-summary .is-off span, .plan-summary .is-ok span { color: inherit; }
@media (max-width: 575.98px) { .plan-summary { grid-template-columns: 1fr; } }
.plan-table { table-layout: fixed; width: 100%; }
.plan-table th, .plan-table td { vertical-align: middle; padding-left: .3rem; padding-right: .3rem; }
.plan-table th:first-child, .plan-table td.n { width: 2.2rem; color: var(--muted); font-weight: 600; }
.plan-table th.rm, .plan-table td:last-child { width: 2.4rem; }
.plan-table input { min-width: 0; width: 100%; }
/* Installment states on the sale page */
.tbl tr.inst-paid td { color: var(--muted); }
.tbl tr.inst-overdue td.primary-cell { box-shadow: inset 3px 0 0 var(--fail-solid); }

/* Live UGX value of a supplier payment */
.fx-result {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem;
    padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
}
.fx-result span { color: var(--muted); }
.fx-result strong { font-size: 1.25rem; }

@media print {
    .sidebar, .topbar, .bottom-nav, .no-print, .flash, .page-actions { display: none !important; }
    .main-col { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none; }
    body { background: #fff; }
    .panel { border: 0; }
    .plate { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Short screens (most laptops): tighten the menu so it fits without scrolling. */
@media (max-height: 820px) {
    .sidebar { padding-top: .8rem; padding-bottom: .75rem; }
    .brand { padding-bottom: .75rem; gap: .4rem; }
    .side-nav a { min-height: 34px; padding: .3rem .75rem; font-size: .9375rem; }
    .side-nav a .ph { font-size: 1.15rem; }
    .brand-name span { display: none; }
    .side-nav a[aria-current="page"]::before { top: 6px; bottom: 6px; }
    .nav-group-label { padding-top: .6rem; }
    .sidebar-cta { padding-top: .6rem; }
}

/* Finance dashboard and reports ------------------------------------------ */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-bottom: 1px solid var(--line); }
.kpi-grid > div { padding: .8rem 1.1rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.kpi-grid > div:nth-child(-n+2) { border-top: 0; }
.kpi-grid > div:nth-child(even) { border-left: 1px solid var(--line); }
.kpi-grid span { color: var(--muted); font-size: .8rem; }
.kpi-grid strong { font-size: 1.05rem; overflow-wrap: anywhere; }
@media (min-width: 992px) {
    .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .kpi-grid > div:nth-child(-n+4) { border-top: 0; }
    .kpi-grid > div:nth-child(even) { border-left: 0; }
    .kpi-grid > div:not(:nth-child(4n+1)) { border-left: 1px solid var(--line); }
}
.chart-pair { display: grid; gap: 1.25rem; padding: 1.1rem; }
@media (min-width: 992px) { .chart-pair { grid-template-columns: 1fr 1fr; } }
.bar-chart { margin: 0; min-width: 0; }
.bar-chart svg { display: block; width: 100%; height: 200px; }
.bar-chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; font-size: .9rem; }
.bar-chart .legend { display: flex; gap: .9rem; color: var(--muted); font-size: .8rem; }
.bar-chart .legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.pl-table th, .pl-table td { padding-top: .5rem; padding-bottom: .5rem; }
.pl-table .pl-sub th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding-top: 1rem; }
.pl-table .pl-head th, .pl-table .pl-head td { font-weight: 700; }
.pl-table .pl-total th, .pl-table .pl-total td { font-weight: 700; border-top: 1px solid var(--line-strong); }
.pl-table .pl-net th, .pl-table .pl-net td { font-weight: 800; font-size: 1.1rem; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
@media print { .bar-chart svg { height: 160px; } }
.rec-strip { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; align-items: center; padding: .7rem 1.1rem; border-top: 1px solid var(--line); background: var(--surface-2); font-size: .9rem; }
.rec-strip .ph, .rec-strip i { margin-right: .3rem; }
.rec-bulk { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: flex-end; padding: .6rem 1.1rem; border-top: 1px solid var(--line); }

/* Costing: what the business holds in cars */
.worth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.worth-grid > * { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1.1rem; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-width: 0; }
.worth-grid > *:nth-child(-n+2) { border-top: 0; }
.worth-grid > *:nth-child(even) { border-left: 1px solid var(--line); }
.worth-grid a:hover { background: var(--surface-2); }
.worth-grid .label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.worth-grid strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.worth-grid .meta { color: var(--muted); font-size: .8rem; }
.worth-grid .worth-total { grid-column: 1 / -1; border-left: 0 !important; border-top: 2px solid var(--ink); background: var(--surface-2); }
.worth-grid .worth-total strong { font-size: 1.35rem; }
@media (min-width: 992px) {
    .worth-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .worth-grid > *:nth-child(-n+4) { border-top: 0; }
    .worth-grid > *:nth-child(even) { border-left: 0; }
    .worth-grid > a:not(:first-child) { border-left: 1px solid var(--line); }
}

/* Sourced vehicle: deal position */
.deal-sides { display: grid; grid-template-columns: 1fr; border-bottom: 1px solid var(--line); }
.deal-sides > div { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.1rem; border-left: 4px solid var(--line); }
.deal-sides > div + div { border-top: 1px solid var(--line); }
.deal-sides .label { color: var(--muted); font-weight: 600; font-size: .85rem; }
.deal-sides strong { font-size: 1.6rem; line-height: 1.15; }
.deal-sides .meta { color: var(--muted); font-size: .85rem; }
.deal-sides .is-open { border-left-color: var(--warn-solid); }
.deal-sides .is-clear { border-left-color: var(--ok-solid); }
@media (min-width: 768px) {
    .deal-sides { grid-template-columns: 1fr 1fr; }
    .deal-sides > div + div { border-top: 0; }
}
.deal-split { display: grid; gap: 1.25rem; padding: 1.1rem; }
.deal-split h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 .4rem; }
@media (min-width: 992px) { .deal-split { grid-template-columns: 1fr 1fr; } }
.trail .trail-sale td, .trail .trail-agreed td { background: var(--surface-2); font-weight: 600; }
.funding-fields { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: .6rem .9rem; background: var(--surface-2); }
.funding-fields summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

/* Reports: a grid of cards, grouped */
.report-group { margin-bottom: 1.75rem; }
.report-group-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .6rem; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); gap: .75rem; }
.report-card { display: flex; flex-direction: column; gap: .35rem; padding: 1rem 1.1rem; min-height: 8.5rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .15s; }
.report-card:hover, .report-card:focus-visible { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(31, 42, 48, .08); transform: translateY(-1px); color: var(--ink); }
.report-card:focus-visible { outline: 3px solid var(--plate); outline-offset: 2px; }
.report-card-icon { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 8px; background: var(--surface-2); font-size: 1.25rem; margin-bottom: .2rem; }
.report-card strong { font-size: 1rem; line-height: 1.25; }
.report-card-text { color: var(--muted); font-size: .85rem; line-height: 1.4; }
@media (prefers-reduced-motion: reduce) { .report-card { transition: none; } .report-card:hover { transform: none; } }

/* Report summaries: figures as tiles; any sentence wraps */
/* Report summaries: one card per figure */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.summary-card { display: flex; flex-direction: column; gap: .2rem; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.summary-card span { color: var(--muted); font-size: .8rem; font-weight: 600; }
.summary-card strong { font-size: 1.15rem; overflow-wrap: anywhere; white-space: normal; }
.summary-card small { color: var(--muted); font-size: .75rem; }
.summary-card.is-neg strong { color: var(--fail-solid); }

/* Report tables: compact, figures on one line, words wrap within a sensible width */
.tbl-report { font-size: .875rem; }
.tbl-report > :not(caption) > * > * { padding: .55rem .65rem; }
.tbl-report thead th { font-size: .75rem; white-space: normal; vertical-align: bottom; line-height: 1.25; }
.tbl-report thead th.money { white-space: normal; }
.tbl-report .c-tight { white-space: nowrap; }
.tbl-report .c-text { min-width: 6rem; max-width: 18rem; }
.tbl-report tbody tr:nth-child(even) > * { background: #FAFAF8; }
.tbl-report tbody tr:hover > * { background: #F3F4F1; }
@media (min-width: 768px) {
    .tbl-report .primary-cell { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: inset -1px 0 0 var(--line); }
    .tbl-report thead .primary-cell, .tbl-report tfoot .primary-cell { background: var(--surface-2); }
}
@media (max-width: 767.98px) {
    .tbl-report .c-text { min-width: 0; max-width: none; }
    .summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .summary-card { padding: .75rem .85rem; }
    .summary-card strong { font-size: .95rem; }
    .tbl-report tbody tr:nth-child(even) > * { background: transparent; }
}
.summary-notes li { font-weight: 600; overflow-wrap: anywhere; }

/* Activity log */
.activity-tbl .activity-day > td { font-size: .8rem; letter-spacing: .02em; color: var(--muted); padding-top: .7rem; }
.activity-tbl tbody tr.activity-day:hover > * { background: var(--surface-2); }
.activity-tbl .activity-what { min-width: 13rem; }
.activity-tbl .activity-details { min-width: 14rem; max-width: 32rem; color: var(--muted); }
.activity-details ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.activity-details li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .05rem .45rem; font-size: .8rem; color: var(--ink); overflow-wrap: anywhere; }
.activity-ip { display: block; font-size: .72rem; margin-top: .25rem; }
.activity-tbl tr.is-warn .activity-what strong { color: var(--fail-solid); }
.activity-tbl tr.is-muted .activity-what strong { font-weight: 600; color: var(--muted); }
@media (max-width: 767.98px) {
    .activity-tbl .activity-day { padding: .5rem 1rem; background: var(--surface-2); }
    .activity-tbl .activity-day > td { padding: 0; }
    .activity-tbl td.activity-details { display: block; text-align: left; }
    .activity-tbl td.activity-details::before { display: none; }
    .activity-tbl .activity-what, .activity-tbl .activity-details { min-width: 0; max-width: none; }
}

/* Fleet cards: labelled lines in two aligned columns, price under a divider */
.v-body { gap: .5rem; }
.v-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: .9rem; row-gap: .15rem; margin: 0; font-size: .875rem; }
.v-facts dt { font-weight: 400; color: var(--muted); }
.v-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.v-card .v-price { margin-top: auto; padding-top: .6rem; border-top: 1px solid var(--line); }
.v-meta .ph { margin-right: .3rem; }
/* Staff account page: the two forms side by side */
.staff-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.staff-forms .panel { margin: 0; }
.staff-forms h2 .ph { margin-right: .3rem; }

/* Supplier page: what is owed and paid, then one row per currency */
.sm-figures { display: grid; grid-template-columns: 1.4fr 1fr 1fr; border-bottom: 1px solid var(--line); }
.sm-figures > div { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.2rem; min-width: 0; }
.sm-figures > div + div { border-left: 1px solid var(--line); }
.sm-label { color: var(--muted); font-size: .8125rem; font-weight: 600; }
.sm-value { font-size: 1.45rem; line-height: 1.2; white-space: nowrap; }
.sm-main.is-owed .sm-value { color: var(--fail-ink); }
.sm-note { color: var(--muted); font-size: .8125rem; }
.sm-table { margin: 0; }

.sm-table .sub-line { font-weight: 400; }
@media (max-width: 767.98px) {
    .sm-figures { grid-template-columns: 1fr; }
    .sm-figures > div + div { border-left: 0; border-top: 1px solid var(--line); }
    .sm-value { font-size: 1.25rem; }
    .sm-table tfoot, .sm-table tfoot tr, .sm-table tfoot td { display: block; width: 100%; }
    .sm-table tfoot td[data-label] { display: flex; justify-content: space-between; }
}
/* Menu dropdown (Finance): a details element, sub-links in small sections */
.nav-drop details > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: .7rem;
    min-height: 44px; padding: .55rem .75rem; margin: 1px 0;
    border-radius: var(--radius-sm); color: #D5DCDF; font-weight: 600;
}
.nav-drop details > summary::-webkit-details-marker { display: none; }
.nav-drop summary .ph { font-size: 1.25rem; opacity: .85; }
.nav-drop summary .caret { margin-left: auto; font-size: .9rem; transition: transform .15s ease; }
.nav-drop details[open] > summary .caret { transform: rotate(180deg); }
.nav-drop summary:hover, .nav-drop summary.is-here { background: var(--asphalt-2); color: #fff; }
.nav-drop summary:focus-visible { outline: 2px solid var(--plate); outline-offset: 2px; }
.side-sub { display: flex; flex-direction: column; padding-bottom: .25rem; }
/* Same size as the main menu items; text lines up with "Finance" (icon 1.25rem + gap .7rem + padding .75rem) */
.side-sub a {
    position: relative; display: flex; align-items: center;
    min-height: 44px; padding: .55rem .75rem .55rem 2.7rem; margin: 1px 0;
    border-radius: var(--radius-sm); color: #D5DCDF; text-decoration: none; font-weight: 600;
}
.side-sub a:hover { background: var(--asphalt-2); color: #fff; }
.side-sub a[aria-current="page"] { background: var(--asphalt-2); color: #fff; }
.side-sub a[aria-current="page"]::before { content: ""; position: absolute; left: -.85rem; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--plate); }
@media (max-height: 820px) {
    .side-sub a { min-height: 34px; padding-top: .3rem; padding-bottom: .3rem; padding-left: 2.6rem; font-size: .9375rem; }
    .nav-drop details > summary { min-height: 34px; padding: .3rem .75rem; font-size: .9375rem; }
    .nav-drop summary .ph:first-child { font-size: 1.15rem; }
    .side-sub a[aria-current="page"]::before { top: 6px; bottom: 6px; }
}
/* Correct balances */
.correct-input { max-width: 15rem; margin-left: auto; }

/* Tabs between the pages of a Finance group, above the page heading */
.section-tabs { display: flex; gap: .25rem; margin: -.25rem 0 1.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs a { flex: 0 0 auto; padding: .55rem .85rem; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.section-tabs a:hover { color: var(--ink); }
.section-tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--plate); }

/* Imports list: room for the car's name, balance under the price */
.imports-tbl .primary-cell { min-width: 12rem; }
.imports-tbl .balance-left { color: var(--warn-ink); font-weight: 600; }
.imports-tbl .balance-paid { color: var(--ok-ink); font-weight: 600; }
.imports-tbl .balance-paid .ph { margin-right: .2rem; }
/* Small icon actions at the end of a table row, with a label on hover */
.row-actions { display: inline-flex; align-items: center; gap: .3rem; }
.row-actions form { margin: 0; }
.act-btn {
    position: relative; display: inline-grid; place-items: center;
    width: 32px; height: 32px; padding: 0;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface); color: var(--ink); font-size: 1rem; text-decoration: none; cursor: pointer;
}
.act-btn:hover { background: var(--surface-2); border-color: var(--ink); color: var(--ink); }
.act-btn:focus-visible { outline: 2px solid var(--plate); outline-offset: 2px; }
.act-btn.act-go { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
.act-btn.act-go:hover { background: var(--asphalt-2); color: #fff; }
.act-btn[data-tip]:hover::after, .act-btn[data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5;
    padding: .25rem .5rem; border-radius: 6px; background: var(--asphalt); color: #fff;
    font-size: .75rem; font-weight: 600; white-space: nowrap; pointer-events: none;
}
/* Edit account: what the system says, before correcting it */
.correct-now { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.correct-now span { color: var(--muted); font-weight: 600; font-size: .875rem; }
.correct-now strong { font-size: 1.25rem; }

/* Imports: on wide screens the vehicle gets the most room and the other columns share the rest
   evenly; on narrower ones the columns size to what they hold. Amounts never break mid-number. */
.imports-tbl .imp-price { text-align: left; white-space: nowrap; }
.imports-tbl .imp-price .sub-line { text-align: left; }
/* Words (stage, delivery, exporter) wrap; amounts do not */
.imports-tbl td:not(.imp-price), .imports-tbl th { white-space: normal; overflow-wrap: break-word; }
.imports-tbl .c-tight { white-space: normal; }
.imports-tbl .st { white-space: normal; max-width: 100%; }
@media (min-width: 1200px) {
    .imports-tbl { table-layout: fixed; width: 100%; }
    .imports-tbl col.c-vehicle { width: 22%; }
    .imports-tbl col.c-act { width: 56px; }
    .imports-tbl .primary-cell { min-width: 0; }
    .imports-tbl > :not(caption) > * > * { padding-right: 1.1rem; }
}

/* Costing: the business's own share, under the total held in cars */

/* Proforma form: the running total */
.pf-total { display: flex; justify-content: space-between; align-items: baseline; height: 100%; padding: .75rem 1rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; margin-top: 1.6rem; }
.pf-total span { color: var(--muted); font-weight: 600; }
.pf-total strong { font-size: 1.25rem; }

/* Costing: "Total held in cars" and "Business's own share" as two cards side by side */
.worth-grid .worth-pair { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; padding: 1rem; border-top: 2px solid var(--ink); border-left: 0 !important; background: var(--surface-2); }
.worth-grid .worth-pair.is-single { grid-template-columns: minmax(0, 1fr); }
.worth-card { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.15rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.worth-card .label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.worth-card strong { font-size: 1.45rem; line-height: 1.2; }
.worth-card .worth-usd { font-size: 1rem; font-weight: 700; color: var(--muted); }
.worth-card .meta { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.worth-card.worth-own { background: #FFF8E1; border-color: #F0DC9A; }
.worth-card a { color: inherit; }
.worth-rate { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .75rem; }
@media (max-width: 767.98px) {
    .worth-grid .worth-pair { grid-template-columns: minmax(0, 1fr); }
}
.worth-card.worth-inv { background: #EEF4FB; border-color: #C9DAEE; }
@media (min-width: 768px) and (max-width: 1099.98px) { .worth-grid .worth-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } .worth-grid .worth-pair .worth-card:first-child { grid-column: 1 / -1; } }

/* ---------- Receipt prompt (send the SMS after checking it) ----------- */
.rcpt-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; border: 0; border-radius: var(--radius); padding: 1.4rem 1.5rem 1.25rem; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(17, 26, 31, .28); }
.rcpt-dialog::backdrop { background: rgba(17, 26, 31, .55); }
.rcpt-dialog[open] { animation: rcpt-in .18s var(--ease); }
@keyframes rcpt-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rcpt-dialog h2 { font-size: 1.2rem; margin: 0 2rem .2rem 0; }
.rcpt-dialog .sub { color: var(--muted); font-size: .875rem; margin-bottom: 1rem; }
.rcpt-x { position: absolute; top: 1rem; right: 1rem; }
.rcpt-sum { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .2rem .9rem .3rem; margin-bottom: 1rem; }
.rcpt-amt { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .7rem 0 .6rem; border-bottom: 1px solid var(--line); }
.rcpt-amt span { color: var(--muted); font-size: .875rem; }
.rcpt-amt strong { font-size: 1.45rem; font-weight: 800; }
.rcpt-sum .facts-list div { padding: .4rem 0; }
.rcpt-bal dd { font-size: 1rem; }
.rcpt-sms { background: var(--info-bg); border-radius: var(--radius-sm); padding: .75rem .9rem; margin-bottom: .75rem; }
.rcpt-sms-to { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .875rem; color: var(--info-ink); margin-bottom: .35rem; }
.rcpt-sms-to span { margin-left: auto; font-size: .78rem; }
.rcpt-sms p { margin: 0; font-size: .92rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.rcpt-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.rcpt-actions form { margin: 0; }
@media (max-width: 575.98px) {
    .rcpt-dialog { padding: 1.2rem 1rem 1rem; }
    .rcpt-actions, .rcpt-actions form, .rcpt-actions .btn { width: 100%; }
}
@media print { .rcpt-dialog { display: none !important; } }

/* ---------- Receipt layout (matches the PDF) --------------------------- */
.receipt .doc-title { font-weight: 800; font-size: 1.15rem; letter-spacing: .05em; text-transform: uppercase; margin-bottom: .2rem; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.doc-party { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .75rem .9rem .85rem; }
.doc-party h2 { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .3rem; }
.doc-party .name { display: block; font-size: 1.05rem; margin-bottom: .35rem; }
.doc-rows { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; margin: 0; font-size: .875rem; }
.doc-rows dt { font-weight: 400; color: var(--muted); }
.doc-rows dd { margin: 0; overflow-wrap: anywhere; }
.doc-lines { width: 100%; border-collapse: collapse; margin-bottom: .4rem; }
.doc-lines th { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .35rem .5rem; border-bottom: 2px solid var(--ink); text-align: left; }
.doc-lines td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-lines .amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-lines .sub { display: block; font-size: .8rem; color: var(--muted); }
.doc-lines tfoot td { font-weight: 800; font-size: 1.1rem; border-top: 2px solid var(--ink); border-bottom: 0; }
.doc-balance, .doc-next { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .5rem; }
.doc-balance { background: var(--neutral-bg); border-radius: var(--radius-sm); font-weight: 700; }
.doc-next { color: var(--muted); font-size: .9rem; }
.doc-next strong { color: var(--ink); }
.doc-balance strong, .doc-next strong { white-space: nowrap; }
.doc-words { font-style: italic; font-size: .85rem; color: var(--muted); margin: 1rem 0 .4rem; }
@media (max-width: 575.98px) {
    .doc-parties { grid-template-columns: 1fr; }
    .receipt-head { flex-direction: column; }
    .receipt-head .text-end { text-align: left !important; }
}

/* ---------- Dropdown with a search box inside (select[data-searchable]) -- */
.ss { position: relative; }
.ss-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.ss-toggle { display: block; width: 100%; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-toggle.ss-placeholder { color: var(--muted); }
.ss-panel { position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 14px 34px rgba(17, 26, 31, .18); padding: .5rem; }
.ss-search { margin-bottom: .35rem; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.ss-opt { padding: .5rem .6rem; border-radius: 4px; cursor: pointer; line-height: 1.3; }
.ss-opt.active { background: var(--neutral-bg); }
.ss-opt[aria-selected="true"] { font-weight: 700; }
.ss-opt[aria-selected="true"]::after { content: " ✓"; color: var(--ok-solid); }
.ss-empty { padding: .5rem .6rem; color: var(--muted); font-size: .875rem; }
