/* Back office styles. Plain, high contrast, big touch targets: it is used on a phone in the shop
   as much as on a desk. */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #5b6474;
  --line: #d5dbe4;
  --line-strong: #94a3b8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --brand: #1d4ed8;
  --brand-ink: #1e3a8a;
  --brand-50: #eef3ff;
  --side: #0f172a;
  --side-ink: #cbd5e1;
  --good: #047857;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 12px;
  --topbar: 56px;
  --sidebar: 236px;
  --bottombar: 64px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-family: var(--font);
  --bs-primary: #1d4ed8;
  --bs-primary-rgb: 29, 78, 216;
  --bs-link-color: #1d4ed8;
  --bs-link-color-rgb: 29, 78, 216;
  --bs-link-hover-color: #1e3a8a;
}
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; }
a { text-decoration: none; }
code { color: var(--ink-2); font-size: .9em; }
.nowrap { white-space: nowrap; }
a:hover { text-decoration: underline; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 2000; background: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-ink); --bs-btn-hover-border-color: var(--brand-ink); --bs-btn-active-bg: var(--brand-ink); }
.btn { border-radius: 10px; font-weight: 500; }
.btn-lg { padding: .7rem 1.1rem; }
.form-control, .form-select { border-color: var(--line-strong); border-radius: 9px; min-height: 42px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .18); }
.form-label { font-weight: 500; color: var(--ink-2); margin-bottom: .3rem; }
.form-text { color: var(--ink-3); }
.text-negative { color: var(--bad) !important; }
.text-good { color: var(--good) !important; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }

/* Top bar */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar); background: var(--side); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 12px; z-index: 1030; }
.brand { color: #fff; display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.brand-name { font-size: 16px; }
.topsearch { flex: 1; max-width: 520px; margin-left: auto; position: relative; }
.topsearch i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.topsearch input { width: 100%; height: 38px; border-radius: 10px; border: 1px solid #334155; background: #1e293b; color: #fff; padding: 0 12px 0 36px; }
.topsearch input::placeholder { color: #94a3b8; }
.topsearch input:focus { outline: 2px solid #60a5fa; outline-offset: 0; }
.btn-user { color: #e2e8f0; border: 1px solid #334155; }
.btn-user:hover, .btn-user:focus { color: #fff; background: #1e293b; }

/* Side navigation (desktop) */
.sidebar { position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); background: var(--side); padding: 12px 10px 24px; overflow-y: auto; display: none; z-index: 1020; }
.nav-item { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 12px; border-radius: 9px; margin-bottom: 2px; font-weight: 500; }
.nav-item i { font-size: 17px; width: 20px; text-align: center; }
.nav-item:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-item.active { background: #fff; color: var(--ink); }
.nav-count { margin-left: auto; background: #f59e0b; color: #111; border-radius: 999px; font-size: 12px; padding: 1px 8px; font-weight: 700; }
.nav-heading { color: #64748b; text-transform: uppercase; font-size: 11px; letter-spacing: .08em; margin: 18px 12px 6px; }
.snap-cta { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--brand); color: #fff; border-radius: 10px; padding: 11px; font-weight: 600; margin: 4px 2px 14px; }
.snap-cta:hover { background: #2563eb; color: #fff; text-decoration: none; }

/* Bottom bar (phone) */
.bottombar { position: fixed; inset: auto 0 0 0; height: calc(var(--bottombar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 1030; }
.bottombar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink-3); font-size: 11px; gap: 2px; position: relative; }
.bottombar a i { font-size: 21px; }
.bottombar a.active { color: var(--brand); }
.bottombar a:hover { text-decoration: none; }
.bottombar a.snap i { background: var(--brand); color: #fff; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 4px 14px rgba(29, 78, 216, .35); font-size: 24px; }
.bottombar a.snap span { color: var(--brand); font-weight: 600; }
.bottombar .dot { position: absolute; top: 6px; right: calc(50% - 22px); background: #f59e0b; color: #111; font-size: 10px; border-radius: 999px; padding: 0 6px; }

/* Content */
.content { padding: calc(var(--topbar) + 14px) 14px calc(var(--bottombar) + 28px); max-width: 1320px; }
.content-bare { padding: 0; }
.flash { margin-bottom: 12px; }
@media (min-width: 992px) {
  .sidebar { display: block; }
  .bottombar { display: none; }
  .content { margin-left: var(--sidebar); padding: calc(var(--topbar) + 22px) 28px 40px; }
}
@media (max-width: 575.98px) {
  .brand-name { display: none; }
  .topsearch { max-width: none; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--ink-3); font-size: 14px; width: 100%; margin-top: -6px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.crumb a { color: var(--ink-3); }

.card-x { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-x > h2, .card-x .card-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
.card-x > h2 .small { font-weight: 500; }
.card-x.tight { padding: 0; overflow: hidden; }
.card-x.tight > h2 { padding: 14px 16px 0; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); display: block; }
.tile:hover { border-color: var(--brand); text-decoration: none; color: var(--ink); }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; }
.tile .note { font-size: 12px; color: var(--ink-3); }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta i { font-size: 11px; }

/* Alerts list */
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li a { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--ink); }
.alert-list li:last-child a { border-bottom: 0; }
.alert-list li a:hover { text-decoration: none; background: var(--brand-50); }
.alert-list .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.alert-list .danger .ic { background: #fee2e2; color: var(--bad); }
.alert-list .warning .ic { background: #fef3c7; color: var(--warn); }
.alert-list .info .ic { background: var(--brand-50); color: var(--brand); }
.alert-list .tag { white-space: nowrap; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-left: auto; color: var(--ink-3); }

/* Tables */
.table-x { width: 100%; margin: 0; border-collapse: collapse; }
.table-x th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line-strong); background: #f8fafc; white-space: nowrap; }
.table-x td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-x tbody tr:hover { background: #f8fafc; }
.table-x tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.table-x .void td { color: var(--ink-3); text-decoration: line-through; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.row-link { cursor: pointer; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; }
.empty i { font-size: 30px; display: block; margin-bottom: 6px; color: var(--line-strong); }

/* Badges */
.badge { font-weight: 600; border-radius: 999px; padding: .35em .7em; font-size: 12px; }
.badge-recon { background: #fef3c7; color: #78350f; }
.badge-forsale { background: #dbeafe; color: #1e3a8a; }
.badge-pending { background: #ede9fe; color: #4c1d95; }
.badge-sold { background: #d1fae5; color: #064e3b; }
.badge-warn { background: #fee2e2; color: #7f1d1d; }
.badge-muted, .badge-void { background: #e2e8f0; color: #334155; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; color: var(--ink-2); background: #fff; white-space: nowrap; font-size: 14px; }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Car cards on phones */
.car-list { display: grid; gap: 10px; }
.car-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); }
.car-card:hover { text-decoration: none; border-color: var(--brand); color: var(--ink); }
.car-card .top { display: flex; align-items: center; gap: 8px; }
.car-card .stock { font-weight: 700; }
.car-card .name { font-weight: 600; }
.car-card .meta { color: var(--ink-3); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }

/* Key/value summary */
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
@media (min-width: 768px) { .kv { grid-template-columns: repeat(4, 1fr); } }
.kv .k { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .v.big { font-size: 22px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--ink-3); font-weight: 500; }
.dl dd { margin: 0; }

/* Forms */
.form-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.form-card legend { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px 16px; }
@media (min-width: 768px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .form-grid.wide { grid-template-columns: repeat(3, 1fr); } }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { position: sticky; bottom: calc(var(--bottombar) + 8px); background: rgba(244, 246, 249, .94); padding: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }
@media (min-width: 992px) { .form-actions { bottom: 0; } }
.errorlist { color: var(--bad); list-style: none; padding: 0; margin: 4px 0 0; font-size: 13px; }
.is-invalid { border-color: var(--bad) !important; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check-row .form-check-input { width: 1.3em; height: 1.3em; margin: 0; }

/* Receipts */
.snap-box { max-width: 560px; margin: 0 auto; }
.snap-drop { border: 2px dashed var(--line-strong); border-radius: 16px; background: #fff; padding: 26px 16px; text-align: center; cursor: pointer; display: block; }
.snap-drop:hover, .snap-drop.has-file { border-color: var(--brand); background: var(--brand-50); }
.snap-drop i { font-size: 46px; color: var(--brand); }
.snap-drop .big { font-size: 18px; font-weight: 700; margin-top: 6px; }
.snap-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.snap-preview { max-height: 320px; border-radius: 10px; margin-top: 12px; display: none; }
.receipt-layout { display: grid; gap: 16px; }
/* Grid items default to min-width:auto and grow to their widest content (a long car name in a
   dropdown); zero lets them shrink to the screen instead of pushing the page sideways. */
.receipt-layout > *, .alloc-row > *, .form-grid > *, .kv > *, .tiles > * { min-width: 0; }
select.form-select, .ts-wrapper { max-width: 100%; }
@media (min-width: 1100px) { .receipt-layout { grid-template-columns: minmax(320px, 42%) 1fr; align-items: start; } .receipt-pic { position: sticky; top: calc(var(--topbar) + 16px); } }
.receipt-pic img { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.receipt-pic .zoom { cursor: zoom-in; }
.flag-list { margin: 0; padding-left: 18px; }
.alloc-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fbfcfe; }
@media (min-width: 768px) { .alloc-row { grid-template-columns: 2fr 1.6fr 1fr 1.4fr auto; align-items: end; } }
.alloc-sum { font-weight: 600; }
.alloc-sum.off { color: var(--bad); }
.reading { text-align: center; padding: 40px 16px; }
.reading .spinner-border { width: 3rem; height: 3rem; color: var(--brand); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #fff; }

/* Chart */
.viz { --series-1: #2a78d6; --grid: #e5e7eb; --axis-ink: #52514e; }
.viz-canvas { position: relative; height: 240px; }
.viz-table summary { cursor: pointer; color: var(--ink-3); font-size: 13px; margin-top: 8px; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--side); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.auth-card h1 { font-size: 22px; font-weight: 700; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; }
.code-input { font-size: 26px; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.backup-codes { columns: 2; font-family: ui-monospace, Consolas, monospace; font-size: 17px; }

/* Print: reports go to paper or PDF cleanly */
@media print {
  .topbar, .sidebar, .bottombar, .no-print, .form-actions, .flash { display: none !important; }
  .content { margin: 0 !important; padding: 0 !important; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .card-x { border: 0; padding: 0; }
  a { color: inherit; }
}
