/* SimplyKnown Cars — 3 themes on one skeleton. data-theme on <html>: command | terminal | pipeline */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r: 14px; --r2: 9px;
}

[data-theme="command"] {
  --bg: #EBEEF3; --surface: #FFFFFF; --surface-2: #F6F8FB;
  --line: #E0E5EE; --line-2: #D2D9E6;
  --ink: #10131B; --ink-2: #39404F; --muted: #636C7B;
  --rail-bg: #0E1B33; --rail-ink: #C9D6EE;
  --accent: #2F5BFF; --accent-ink: #fff; --accent-soft: #E9EEFF;
  --good: #0A7D52; --good-bg: #E5F6EE; --warn: #8F6300; --warn-bg: #FBF1D8; --bad: #C13A34; --bad-bg: #FBE9E8;
  --sans: 'Plus Jakarta Sans', system-ui, sans-serif; --display: var(--sans);
  --shadow: 0 1px 2px rgba(13,20,38,.05), 0 2px 6px rgba(13,20,38,.05);
  --rail-w: 232px;
}
[data-theme="terminal"] {
  --bg: #12110f; --surface: #1a1916; --surface-2: #211f1b;
  --line: #2f2b24; --line-2: #3c372e;
  --ink: #ece7dc; --ink-2: #cfc9bb; --muted: #9a9486;
  --rail-bg: #0d0c0a; --rail-ink: #9a9486;
  --accent: #d8a657; --accent-ink: #12110f; --accent-soft: #2a2418;
  --good: #74c596; --good-bg: #1c2a22; --warn: #d8a657; --warn-bg: #2a2418; --bad: #d9695f; --bad-bg: #2b1c1a;
  --sans: 'Inter', system-ui, sans-serif; --display: 'Fraunces', serif;
  --shadow: 0 18px 50px -20px rgba(0,0,0,.7);
  --rail-w: 232px;
}
[data-theme="pipeline"] {
  --bg: #F2F4F7; --surface: #FFFFFF; --surface-2: #F7F9FB;
  --line: #E3E7EC; --line-2: #D3D9E0;
  --ink: #16202B; --ink-2: #3A4756; --muted: #66727F;
  --rail-bg: #14243A; --rail-ink: #B9C7DB;
  --accent: #1E6FE0; --accent-ink: #fff; --accent-soft: #E7F0FD;
  --good: #17804D; --good-bg: #E4F5EC; --warn: #92650A; --warn-bg: #FAF0D7; --bad: #C03E38; --bad-bg: #FAEAE9;
  --sans: 'Plus Jakarta Sans', system-ui, sans-serif; --display: var(--sans);
  --shadow: 0 1px 3px rgba(20,30,45,.07);
  --rail-w: 176px; --r: 10px; --r2: 8px;
}

body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.5; display: flex; min-height: 100vh; }

/* rail */
#rail { width: var(--rail-w); background: var(--rail-bg); color: var(--rail-ink); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 14px 10px; z-index: 5;
  background-image: linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px); background-size: 22px 22px; }
.logo { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; }
.logo-block { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 16px; flex: none; }
.logo-name { font-family: var(--display); font-weight: 700; font-size: 14px; color: #fff; letter-spacing: .01em; }
[data-theme="terminal"] .logo-name { color: var(--accent); letter-spacing: .09em; font-size: 13px; }
#nav a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; color: var(--rail-ink); text-decoration: none; font-size: 13px; font-weight: 500; margin-bottom: 1px; }
#nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#nav a.active { background: rgba(255,255,255,.1); color: #fff; }
#nav a .badge { margin-left: auto; font-family: var(--mono); font-size: 10.5px; opacity: .7; }
#nav .nav-sep { text-transform: uppercase; font-size: 10px; letter-spacing: .09em; opacity: .5; padding: 12px 10px 4px; }
.rail-foot { margin-top: auto; font-size: 10.5px; opacity: .45; padding: 8px 10px; font-family: var(--mono); }

/* shell */
#shell { flex: 1; margin-left: var(--rail-w); display: flex; flex-direction: column; min-width: 0; }
#topbar { display: flex; gap: 10px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 4; }
#search { flex: 1; max-width: 430px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
#search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-toggle { margin-left: auto; display: flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.theme-toggle button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; cursor: pointer; font: inherit; font-weight: 700; font-size: 12px; }
.theme-toggle button.active { background: var(--accent); color: var(--accent-ink); }
#view { padding: 18px; max-width: 1320px; width: 100%; }

/* primitives */
.btn { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 7px 13px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--muted); transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; }
[data-theme="terminal"] .card { background: linear-gradient(180deg, var(--surface), #161512); }
.micro { text-transform: uppercase; font-size: 10.5px; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.vin { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.s-listed, .pill.s-won { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.pill.s-recon, .pill.s-photos-pricing, .pill.s-in-transit, .pill.s-negotiating, .pill.s-appointment, .pill.s-test-drive { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pill.s-sale-pending, .pill.s-new, .pill.s-contacted { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
[data-theme="terminal"] .pill.s-sale-pending { color: var(--accent); }
.pill.s-sold, .pill.s-wholesaled { background: var(--surface-2); color: var(--muted); }
.pill.s-appraisal, .pill.s-purchase-pending, .pill.s-at-auction, .pill.s-lost { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.days { font-family: var(--mono); font-weight: 600; }
.days.ok { color: var(--good); } .days.warn { color: var(--warn); } .days.bad { color: var(--bad); }
.verdict { font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: 2px 7px; border-radius: 4px; }
.verdict.HOLD { color: var(--good); background: var(--good-bg); }
.verdict.WATCH { color: var(--warn); background: var(--warn-bg); }
.verdict.DROP { color: var(--bad); background: var(--bad-bg); }
.dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; background: var(--line-2); }
.dot.live { background: var(--good); } .dot.pending { background: var(--warn); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { font-family: var(--mono); font-size: 11px; opacity: .75; margin-left: 4px; }

h1.page { font-family: var(--display); font-size: 21px; font-weight: 700; margin-bottom: 14px; }
[data-theme="terminal"] h1.page { font-weight: 600; letter-spacing: .02em; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi .v { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -0.03em; margin-top: 3px; }
.kpi .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.bar-row { display: grid; grid-template-columns: 64px 1fr 120px; align-items: center; gap: 10px; padding: 6px 0; font-size: 12.5px; }
.bar-track { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--bad); } .bar-fill.good { background: var(--good); }
.stage-chain { display: flex; gap: 6px; flex-wrap: wrap; }
.stage-chip { flex: 1; min-width: 92px; text-align: center; padding: 9px 6px; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); cursor: pointer; border-top: 3px solid var(--stage, var(--line-2)); }
.stage-chip .n { font-family: var(--mono); font-size: 19px; font-weight: 600; }
.stage-chip .l { font-size: 10.5px; color: var(--muted); }
.attention li { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; list-style: none; cursor: pointer; }
.attention li:last-child { border-bottom: 0; }
.view-toggle { display: flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; margin-left: auto; }
.view-toggle button { border: 0; background: transparent; color: var(--muted); padding: 5px 14px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.view-toggle button.active { background: var(--accent); color: var(--accent-ink); }

/* board */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.col { min-width: 205px; width: 205px; flex: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); border-top: 3px solid var(--stage, var(--accent)); }
.col-h { padding: 9px 11px; display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); }
.col-h .t { font-size: 12px; font-weight: 700; }
.col-h .m { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.col-body { padding: 8px; display: flex; flex-direction: column; gap: 7px; max-height: 60vh; overflow-y: auto; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 8px 9px; cursor: pointer; font-size: 12px; }
.vcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.vcard .t { font-weight: 700; font-size: 12.5px; }
.vcard .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 3px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; text-transform: uppercase; font-size: 10.5px; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.thumb { width: 44px; height: 32px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.tbl-wrap { overflow-x: auto; }

/* vehicle page */
.vhead { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.vhead .title { font-family: var(--display); font-size: 24px; font-weight: 700; }
.vhead .vin { font-size: 14px; color: var(--ink-2); }
.vhead .price { margin-left: auto; text-align: right; }
.vhead .price .v { font-family: var(--mono); font-size: 27px; font-weight: 600; letter-spacing: -0.03em; }
.vgrid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 1000px) { .vgrid { grid-template-columns: 1fr; } }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.spec .micro { margin-bottom: 1px; }
/* % of market meter — 80..120% scale, green target band at 91-101% (vAuto-style) */
.meter { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: 18px 0 6px; }
.meter .band { position: absolute; inset: 0 auto 0 27.5%; width: 25%; background: var(--good-bg); border-inline: 2px solid var(--good); }
.meter .pin { position: absolute; top: -5px; width: 3px; height: 22px; background: var(--ink); border-radius: 2px; z-index: 1; }
.gauge-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.gauge-box { border: 1px solid var(--line); border-radius: var(--r2); padding: 9px 11px; background: var(--surface-2); }
.gauge-box .v { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.gauge-box .sub { font-size: 11px; color: var(--muted); }
.compset .comp-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.compset .comp-row:last-child { border-bottom: 0; }
.compset .comp-row .r { text-align: right; white-space: nowrap; }
.compset .comp-row .sub { font-size: 11.5px; color: var(--muted); }
.compset .comp-row.own { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: var(--r2); }
/* org chart */
.org { overflow-x: auto; }
.org-node { padding-left: 0; }
.org-kids { margin-left: 26px; padding-left: 14px; border-left: 2px solid var(--line-2); margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.org-card { display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r2); padding: 7px 11px; font-size: 13px; }
.org-card .sub { color: var(--muted); font-size: 11.5px; }
.org-node.inactive .org-card { opacity: .45; }
#user-switch { margin-left: auto; font: inherit; font-size: 12.5px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink); max-width: 240px; }
.synd-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.synd-row:last-child { border-bottom: 0; }
.switch { width: 34px; height: 19px; border-radius: 999px; background: var(--line-2); border: 0; position: relative; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 999px; background: #fff; transition: left .15s; }
.switch.on { background: var(--good); } .switch.on::after { left: 17px; }
.stack > * + * { margin-top: 12px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select, input[type="number"], input[type="text"] { font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--r2); background: var(--surface); color: var(--ink); }

/* modal + toast */
#modal-root:not(:empty) { position: fixed; inset: 0; background: rgba(10,12,18,.5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 18px 50px rgba(0,0,0,.3); width: min(480px, 92vw); padding: 18px; animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal h2 { font-family: var(--display); font-size: 17px; margin-bottom: 12px; }
.modal .frm { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.modal .frm label { font-size: 11px; color: var(--muted); display: block; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.modal .frm .full { grid-column: 1 / -1; }
.modal .frm input, .modal .frm select { width: 100%; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#toast { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast-item { background: var(--rail-bg); color: #fff; padding: 10px 15px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: pop .2s ease; }

#menu-btn { display: none; }
#bottomnav { display: none; }
#plus-btn { display: none; }
@media (max-width: 760px) {
  #search, #receive-btn { display: none; }
  #plus-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 999px; font-size: 22px; font-weight: 700; line-height: 1; }
  #topbar { justify-content: space-between; }
  #rail { left: calc(-1 * var(--rail-w) - 20px); transition: left .25s cubic-bezier(.22,.61,.36,1); box-shadow: 0 0 40px rgba(0,0,0,.35); }
  #rail.open { left: 0; }
  #shell { margin-left: 0; }
  #menu-btn { display: inline-flex; padding: 7px 11px; }
  #search { min-width: 0; }
  #view { padding-bottom: 76px; }
  /* ERP-style mobile bottom tab bar */
  #bottomnav { display: flex; position: fixed; inset: auto 0 0 0; z-index: 30; background: var(--rail-bg); border-top: 1px solid rgba(255,255,255,.08); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  #bottomnav a, #bottomnav button { flex: 1; text-align: center; background: none; border: 0; color: var(--rail-ink); font: inherit; font-size: 11px; font-weight: 600; text-decoration: none; padding: 8px 2px; border-radius: 8px; min-height: 44px; }
  #bottomnav .active { background: rgba(255,255,255,.12); color: #fff; }
}
