:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #1d4ed8; --accent-ink: #fff; --danger: #b91c1c; --warn-bg: #fef3c7; --warn-ink: #92400e;
  --ok-bg: #dcfce7; --ok-ink: #166534; --row-hover: #f9fafb; --credit: #15803d;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 6px 12px; }
button:hover { border-color: #cbd5e1; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: var(--panel); min-width: 0; }
textarea { width: 100%; min-height: 60px; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.f > * { color: var(--ink); font-size: 14px; }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav.side { background: #0f172a; color: #cbd5e1; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
nav.side .brand { font-weight: 700; font-size: 16px; color: #fff; padding: 0 10px 16px; display: flex; gap: 8px; align-items: center; }
nav.side a { color: inherit; text-decoration: none; padding: 8px 10px; border-radius: 7px; display: flex; justify-content: space-between; }
nav.side a.on, nav.side a:hover { background: #1e3a8a; color: #fff; }
nav.side .grow { flex: 1; }
nav.side .who { font-size: 12px; color: #94a3b8; padding: 8px 10px; }
.badge { background: #f59e0b; color: #111; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 600; }
main { padding: 22px 26px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 .sp { flex: 1; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filters { margin-bottom: 12px; }
.stats { display: flex; gap: 18px; margin: 4px 0 12px; color: var(--muted); flex-wrap: wrap; }
.stats b { color: var(--ink); }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
.tablewrap { border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafafa; position: sticky; top: 0; white-space: nowrap; }
tr:hover td { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.credit { color: var(--credit); }
td select { max-width: 160px; }
.merchant { font-weight: 600; }
.desc { font-size: 12px; color: var(--muted); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; font-size: 11px; border-radius: 999px; padding: 1px 8px; background: #eef2f7; color: #374151; white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.err { background: #fee2e2; color: var(--danger); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.unset { border-color: #f59e0b; background: #fffbeb; }
.bulkbar { position: sticky; top: 0; z-index: 5; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.cards { display: grid; gap: 14px; }
.card-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.acct { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }

.report-grid td, .report-grid th { white-space: nowrap; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }

.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 12px; }
.modal .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .grid .full { grid-column: 1 / -1; }
.modal .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.receipts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.receipts .r { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.receipts img { width: 54px; height: 54px; object-fit: cover; border-radius: 5px; }

.login { max-width: 360px; margin: 14vh auto; }
.login .panel { display: grid; gap: 12px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 99; max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.swatch { width: 34px; height: 30px; padding: 2px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; position: sticky; top: 0; z-index: 10; }
  nav.side .brand, nav.side .grow, nav.side .who { display: none; }
  nav.side a { white-space: nowrap; }
  main { padding: 16px; }
  .acct { grid-template-columns: 1fr 1fr; }
  .modal .grid { grid-template-columns: 1fr; }
  .desc { max-width: 180px; }
}

/* ---- LLR additions ---- */
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.warn { border-color: #f59e0b; background: #fffbeb; }
.kpis h3 { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.alerts { display: grid; gap: 6px; }
.alert { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid var(--line); }
.alert.bad { background: #fef2f2; border-color: #fecaca; }
.alert.warn { background: #fffbeb; border-color: #fde68a; }
.alert .grow { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 14px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.vhead { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.vhead .title { flex: 1; min-width: 240px; }
.vhead .title h1 { margin: 0 0 4px; }
.pnl { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pnl .kpi .v { font-size: 17px; }
.pos { color: var(--credit); } .neg { color: var(--danger); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.formgrid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 12px; }
legend { font-size: 12px; color: var(--muted); padding: 0 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.docgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.doc { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel); display: grid; gap: 6px; }
.doc .thumb { height: 120px; border-radius: 6px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: 28px; }
.doc .thumb img { width: 100%; height: 100%; object-fit: cover; }
.status-pill { text-transform: capitalize; }
.s-purchased { background: #e0e7ff; color: #3730a3; } .s-in_repair { background: #fee2e2; color: #991b1b; }
.s-ready { background: #dcfce7; color: #166534; } .s-listed { background: #fef3c7; color: #92400e; }
.s-sold { background: #e5e7eb; color: #374151; } .s-on_turo { background: #dbeafe; color: #1e40af; }
.s-off_turo { background: #f3e8ff; color: #6b21a8; } .s-retired { background: #f3f4f6; color: #6b7280; }
.t-flip { background: #ffedd5; color: #9a3412; } .t-turo { background: #cffafe; color: #155e75; }
.clickrow { cursor: pointer; }
.modal.wide { max-width: 860px; }
.util { display: inline-block; width: 70px; height: 7px; background: #e5e7eb; border-radius: 4px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.util > i { display: block; height: 100%; background: var(--accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
pre.email { white-space: pre-wrap; max-height: 360px; overflow: auto; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }
