/* ==========================================================================
   Drive Comfort — application styles
   A single stylesheet, no build step, no external dependencies. Tokens first,
   then layout, then components, then print.
   ========================================================================== */

:root {
    --ink: #0f172a;
    --ink-soft: #475569;
    --ink-faint: #94a3b8;

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-sunk: #f8fafc;
    --line: #e4e7ec;
    --line-strong: #cbd2dc;

    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-wash: #eff4ff;

    --positive: #15803d;
    --positive-wash: #ecfdf3;
    --negative: #b91c1c;
    --negative-wash: #fef2f2;
    --warning: #b45309;
    --warning-wash: #fffbeb;
    --info-wash: #eff6ff;

    --sidebar-bg: #101828;
    --sidebar-ink: #98a2b3;
    --sidebar-ink-bright: #f9fafb;
    --sidebar-active: #1d2939;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

    --sidebar-width: 248px;
    --topbar-height: 60px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Numbers line up in columns and never jump around while typing. */
.num, td.num, th.num, .money {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.mono { font-family: var(--font-mono); font-size: 12.5px; }

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--ink-soft); }
.muted    { color: var(--ink-soft); }
.faint    { color: var(--ink-faint); }
.small    { font-size: 12.5px; }
.tiny     { font-size: 11.5px; }
.strong   { font-weight: 600; }
.nowrap   { white-space: nowrap; }
.right    { text-align: right; }
.center   { text-align: center; }
.block    { display: block; }
.full     { width: 100%; }

/* ============================================================ app shell */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    color: var(--sidebar-ink-bright);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; color: #fff; }

.brand-mark {
    width: 30px; height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.brand-sub { display: block; font-size: 11px; font-weight: 400; color: var(--sidebar-ink); }

.nav { padding: 4px 10px 24px; flex: 1; }

.nav-group { margin-bottom: 2px; }

.nav-heading {
    padding: 14px 10px 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #667085;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-ink);
    font-size: 13.5px;
    transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--sidebar-active); color: var(--sidebar-ink-bright); text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 500; }
.nav-link.active .nav-icon { color: var(--accent); }

.nav-icon { width: 16px; height: 16px; flex: 0 0 16px; color: #667085; }

.nav-sub { margin: 2px 0 6px 26px; padding-left: 10px; border-left: 1px solid #1d2939; }
.nav-sub .nav-link { padding: 5px 10px; font-size: 13px; }

.nav-badge {
    margin-left: auto;
    background: var(--negative);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 9px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    cursor: pointer;
    color: var(--ink);
}

.search { position: relative; flex: 1; max-width: 460px; }

/* Specificity has to beat the generic input[type=search] rule further down,
   otherwise the left padding is lost and the text sits under the icon. */
.search input[type=search] {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-sunk);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
}
.search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.search-icon {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--ink-faint);
    pointer-events: none;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 9px 5px 5px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 13px;
}
.user-chip:hover { text-decoration: none; background: var(--surface-sunk); }

.avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 600;
}

.content { padding: 22px; max-width: 1500px; width: 100%; }

/* ============================================================== page head */

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-head .titles { flex: 1; min-width: 220px; }
.page-head .lede { color: var(--ink-soft); margin-top: 3px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.breadcrumb {
    font-size: 12.5px;
    color: var(--ink-faint);
    margin-bottom: 4px;
}
.breadcrumb a { color: var(--ink-soft); }

/* ================================================================ buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-sunk); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-sunk); border-color: var(--line); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-dark); z-index: 1; }

/* ================================================================== cards */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    overflow: hidden;
}

.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-head .sub { color: var(--ink-soft); font-size: 12.5px; }

.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }
.card-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    background: var(--surface-sunk);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ================================================================== stats */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.stat-value.sm { font-size: 18px; }

.stat-note { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

.stat-accent { border-left: 3px solid var(--accent); }
.stat-positive { border-left: 3px solid var(--positive); }
.stat-negative { border-left: 3px solid var(--negative); }
.stat-warning { border-left: 3px solid var(--warning); }

/* ================================================================= tables */

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data th {
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    padding: 9px 14px;
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table.data td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-sunk); }
table.data tr.void td { color: var(--ink-faint); text-decoration: line-through; }
table.data tr.subtotal td { font-weight: 600; background: var(--surface-sunk); }
table.data tr.total td {
    font-weight: 700;
    background: var(--surface-sunk);
    border-top: 2px solid var(--line-strong);
    border-bottom: none;
}
table.data tfoot td { font-weight: 600; background: var(--surface-sunk); }

table.data.compact th, table.data.compact td { padding: 6px 10px; }

.row-link { cursor: pointer; }

/* ================================================================ badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
    background: var(--surface-sunk);
    color: var(--ink-soft);
    border: 1px solid var(--line);
}
.badge-success { background: var(--positive-wash); color: var(--positive); border-color: #a7f3d0; }
.badge-danger  { background: var(--negative-wash); color: var(--negative); border-color: #fecaca; }
.badge-warning { background: var(--warning-wash); color: var(--warning); border-color: #fde68a; }
.badge-info    { background: var(--info-wash); color: var(--accent-dark); border-color: #bfdbfe; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-success { background: var(--positive); }
.dot-danger { background: var(--negative); }
.dot-warning { background: var(--warning); }
.dot-muted { background: var(--ink-faint); }

/* ================================================================== forms */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px 18px;
}
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field label, .label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-soft);
}

.field .hint { font-size: 12px; color: var(--ink-faint); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=file],
select, textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

input[readonly], input:disabled, select:disabled, textarea:disabled {
    background: var(--surface-sunk);
    color: var(--ink-soft);
}

input.money, input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }

textarea { min-height: 72px; resize: vertical; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667085' d='M6 8.5L2 4.5h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; }
.check input { width: 15px; height: 15px; margin-top: 2px; flex: 0 0 15px; }
.check label { font-size: 13.5px; color: var(--ink); font-weight: 400; }

.radio-cards { display: grid; gap: 8px; }

.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .12s, background .12s;
}
.radio-card:hover { background: var(--surface-sunk); }
.radio-card input { margin-top: 2px; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.radio-card .rc-title { font-weight: 500; font-size: 13.5px; }
.radio-card .rc-desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

.input-prefix { position: relative; }
.input-prefix > span {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--ink-faint);
    font-size: 13px;
    pointer-events: none;
}
.input-prefix input { padding-left: 34px; text-align: right; }

fieldset { border: none; margin: 0; padding: 0; }

/* =============================================================== messages */

.alert {
    display: flex;
    gap: 11px;
    padding: 12px 15px;
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: 16px;
    font-size: 13.5px;
    align-items: flex-start;
}
.alert-success { background: var(--positive-wash); border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: var(--negative-wash); border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-wash); border-color: #fde68a; color: #92400e; }
.alert-info    { background: var(--info-wash); border-color: #bfdbfe; color: #1e40af; }
.alert strong { display: block; margin-bottom: 2px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.validation-summary { }
.field-error { color: var(--negative); font-size: 12px; }
.input-validation-error { border-color: var(--negative) !important; }

/* ================================================================= alerts feed */

.alert-list { display: grid; gap: 10px; }

.alert-item {
    display: flex;
    gap: 11px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    align-items: flex-start;
}
.alert-item.sev-critical { border-left-color: var(--negative); }
.alert-item.sev-warning  { border-left-color: var(--warning); }
.alert-item.sev-info     { border-left-color: var(--accent); }
.alert-item .ai-body { flex: 1; min-width: 0; }
.alert-item .ai-title { font-weight: 600; font-size: 13.5px; }
.alert-item .ai-detail { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }

/* ================================================================== charts */

.chart { width: 100%; height: auto; display: block; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ================================================================ layouts */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }

.toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 0;
}
.toolbar .field { min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .spacer { flex: 1; }

.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--ink-soft);
}
.empty h3 { margin-bottom: 6px; color: var(--ink); }
.empty p { max-width: 420px; margin: 0 auto 14px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

.definition { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: 13.5px; }
.definition dt { color: var(--ink-soft); }
.definition dd { margin: 0; font-weight: 500; }

.kv-list { display: grid; gap: 9px; }
.kv { display: flex; justify-content: space-between; gap: 14px; font-size: 13.5px; }
.kv .k { color: var(--ink-soft); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.kv.total { border-top: 1px solid var(--line); padding-top: 9px; font-size: 14.5px; }

/* Sticky footer summary for long entry forms. */
.entry-total {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 14px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 26px;
    box-shadow: 0 -2px 8px rgba(16, 24, 40, .05);
}

/* Line item editor rows. */
.lines { width: 100%; border-collapse: collapse; }
.lines th {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
}
.lines td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines input, .lines select { padding: 6px 8px; font-size: 13px; }
.lines .col-remove { width: 36px; }

.wizard-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--ink-soft);
}
.wizard-step.done { border-color: #a7f3d0; background: var(--positive-wash); color: var(--positive); }
.wizard-step.current { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-dark); font-weight: 600; }
.wizard-step .n {
    width: 19px; height: 19px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--line);
    color: var(--ink-soft);
    font-size: 11px; font-weight: 600;
}
.wizard-step.current .n { background: var(--accent); color: #fff; }
.wizard-step.done .n { background: var(--positive); color: #fff; }

/* ================================================================ sign in */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(160deg, #101828 0%, #1d2939 60%, #101828 100%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 30px;
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { margin: 0 auto 12px; width: 44px; height: 44px; font-size: 17px; }
.auth-brand h1 { font-size: 20px; }
.auth-brand p { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }

.setup-shell { max-width: 780px; margin: 0 auto; padding: 34px 22px 60px; }

/* ============================================================== utilities */

.stack   { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 8px; }
.row     { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ============================================================= responsive */

@media (max-width: 1024px) {
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, .45);
        z-index: 50;
    }
    .menu-toggle { display: inline-flex; }
    .content { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
    .stat-value { font-size: 19px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .page-head { margin-bottom: 14px; }
}

@media (max-width: 640px) {
    .topbar { padding: 0 14px; gap: 10px; }
    .user-chip .user-name { display: none; }
    table.data th, table.data td { padding: 8px 10px; }
    .entry-total { flex-wrap: wrap; gap: 12px; justify-content: space-between; }
}

/* ================================================================== print */

@media print {
    :root { --bg: #fff; }

    .sidebar, .topbar, .page-actions, .no-print, .toolbar, .btn, .pagination { display: none !important; }
    body { background: #fff; font-size: 11pt; }
    .app { display: block; }
    .content { padding: 0; max-width: none; }
    .card {
        border: none;
        box-shadow: none;
        margin-bottom: 14pt;
        break-inside: avoid;
    }
    .card-head { border-bottom: 1px solid #000; padding: 0 0 6pt; }
    .card-body { padding: 8pt 0 0; }
    table.data th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        position: static;
    }
    table.data th, table.data td { padding: 4pt 6pt; border-bottom: 1px solid #ddd; }
    .print-only { display: block !important; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 8pt; }
    .stat { border: 1px solid #ddd; box-shadow: none; }
    a { color: #000; text-decoration: none; }
    tr { break-inside: avoid; }
    thead { display: table-header-group; }
}

.print-only { display: none; }

.print-header { display: none; }
@media print {
    .print-header {
        display: block;
        margin-bottom: 14pt;
        padding-bottom: 8pt;
        border-bottom: 2px solid #000;
    }
    .print-header h1 { font-size: 16pt; }
    .print-header .meta { font-size: 9pt; color: #444; margin-top: 3pt; }
}
