/* CleanVINUSA operator panel.
 *
 * Mobile first, because §6.3 of the spec is literal: part of the ticking-off
 * happens from a phone. Everything here is one column until 640px and only then
 * spreads out; the queue is built from cards rather than tables for the same
 * reason - a table with five columns and two buttons cannot be made to work on
 * a 375px screen, it can only be made to scroll.
 *
 * Served as a file, not a <style> block, so the CSP can forbid 'unsafe-inline'
 * outright instead of carving an exception for our own markup. There is no
 * script-src at all: the panel has no JavaScript.
 */

:root {
  --bg: #0f1115;
  --panel: #171b22;
  --panel-2: #1e2531;
  --line: #2b323e;
  --fg: #e6e9ef;
  --muted: #98a2b3;
  --accent: #60a5fa;
  --ok: #16a34a;
  --ok-2: #15803d;
  --bad: #b91c1c;
  --warn: #fbbf24;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 .9rem; }

/* --- chrome ---------------------------------------------------------------- */

header.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  padding-top: .55rem;
  padding-bottom: .55rem;
}
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.topbar nav { display: flex; gap: .9rem; margin-right: auto; }
.topbar nav a {
  text-decoration: none;
  font-size: .9rem;
  color: var(--muted);
  padding: .2rem 0;
  border-bottom: 2px solid transparent;
}
.topbar nav a.on { color: var(--fg); border-bottom-color: var(--accent); }
.who { font-size: .8rem; color: var(--muted); }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }

main.wrap { padding-bottom: 3rem; }

h1 { font-size: 1.25rem; margin: 1.2rem 0 .6rem; }
h3 { font-size: .9rem; margin: 1.2rem 0 .4rem; color: var(--accent); }

.lead { margin: 0 0 1rem; color: var(--muted); font-size: .92rem; }
.lead b, .note b { color: var(--fg); }
.note { font-size: .82rem; color: var(--muted); line-height: 1.5; margin: .5rem 0; }
.empty { color: var(--muted); font-style: italic; }
.warn { color: var(--warn); }

.flash {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .7rem .9rem;
  margin: 1rem 0 0;
  font-size: .9rem;
}
.alert {
  background: #2a1f14;
  border: 1px solid #7c4a12;
  border-radius: var(--radius);
  padding: .8rem .9rem;
  margin: 1rem 0;
  font-size: .88rem;
  line-height: 1.55;
}

/* --- buttons --------------------------------------------------------------- */

button, .btn {
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  min-height: 38px;
  padding: .4rem .8rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #334155;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.ok { background: var(--ok); }
button.bad { background: var(--bad); }
button.ghost, .btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
button.big, .btn.big { font-size: .95rem; min-height: 46px; padding: .5rem 1.4rem; }

/* --- the one thing to act on ---------------------------------------------- */

.todo {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  text-decoration: none;
  color: var(--fg);
}
.todo b { font-size: 1.9rem; line-height: 1; }
.todo span { font-size: .82rem; color: var(--muted); }

/* --- kpi cards ------------------------------------------------------------- */

.cards { display: grid; gap: .7rem; margin: 1rem 0; }
.cards .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem 1rem;
}
.cards .card h3 {
  margin: 0 0 .2rem;
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.cards .card b { font-size: 1.5rem; }
.cards .card span { display: block; font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* --- collapsible sections -------------------------------------------------- */

details {
  border-top: 1px solid var(--line);
  padding: .2rem 0;
}
details > summary {
  cursor: pointer;
  padding: .75rem .2rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "\25B8\00a0"; color: var(--muted); }
details[open] > summary::before { content: "\25BE\00a0"; }

/* --- tables (statistics only; the queue does not use them) ----------------- */

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: .38rem .55rem; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; }
.vin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95em; }

/* --- queue groups ---------------------------------------------------------- */

.grp {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: .8rem 0;
  overflow: hidden;
}
.grp.muted { opacity: .72; }
.grp > header {
  padding: .7rem .85rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.grp-id { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.ord { font-weight: 700; }
.grp-id .vin { font-size: .88rem; color: var(--muted); }
.grp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .8rem;
  margin-top: .3rem;
  font-size: .75rem;
  color: var(--muted);
}
.grp-meta .wait { color: var(--warn); font-weight: 600; }
.grp-meta .sum { color: var(--fg); }

.lines { list-style: none; margin: 0; padding: 0; }
.line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .7rem;
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--line);
}
.line:last-child { border-bottom: 0; }
.site { flex: 1 1 14rem; font-size: .86rem; word-break: break-word; }
.price { font-size: .82rem; color: var(--muted); }
.tag {
  font-size: .68rem;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .05rem .5rem;
}
.acts { display: flex; flex-wrap: wrap; gap: .35rem; width: 100%; }

/* --- one VIN inside an order ----------------------------------------------- */

.vinblock { border-bottom: 1px solid var(--line); padding: .1rem 0 .5rem; }
.vinblock:last-of-type { border-bottom: 0; }
.vinhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .7rem;
  padding: .6rem .85rem .2rem;
}
.vinhead .vin { font-weight: 600; }
.counts { font-size: .78rem; color: var(--muted); flex: 1 1 12rem; }
.counts b { color: var(--fg); }
.src { opacity: .75; }

.miss { padding: 0 .85rem .3rem; }
.miss h4 {
  margin: .5rem 0 .1rem;
  font-size: .8rem;
  color: var(--warn);
  font-weight: 600;
}
.miss .line { padding-left: 0; padding-right: 0; border-bottom: 0; }
.miss .price { color: var(--fg); }

.draft { border-top: 1px solid var(--line); padding: 0 .85rem .6rem; }
.draft summary { padding-left: 0; }
textarea {
  width: 100%;
  font: .78rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0d1015;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .6rem;
  resize: vertical;
}

/* --- confirmation ---------------------------------------------------------- */

.what { font-size: .88rem; line-height: 1.6; padding-left: 1.1rem; }
.what .loud { color: var(--warn); }
.confirm-acts { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.2rem 0; }

/* --- login / enrolment ----------------------------------------------------- */

body.auth {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  width: min(380px, 100%);
}
.auth h1 { font-size: 1.05rem; margin: 0 0 .8rem; }
.auth label { display: block; margin: .8rem 0; font-size: .82rem; color: var(--muted); }
.auth input {
  width: 100%;
  margin-top: .3rem;
  padding: .6rem;
  font: inherit;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0d1015;
  color: var(--fg);
}
.auth button { width: 100%; margin-top: 1.1rem; background: var(--accent); color: #08111f; }
.auth img { display: block; margin: 1rem auto; background: #fff; padding: 8px; border-radius: 8px; max-width: 100%; height: auto; }
.msg { color: #f87171; font-size: .82rem; min-height: 1.2em; margin: 0; }
.hint { font-size: .8rem; color: var(--muted); line-height: 1.45; margin: .5rem 0; }
code { font-size: .78rem; word-break: break-all; color: #cbd5e1; }

/* --- wider screens --------------------------------------------------------- */

@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .acts { width: auto; margin-left: auto; }
  .grp > header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
  .grp-meta { margin-top: 0; justify-content: flex-end; }
  h1 { font-size: 1.45rem; }
}
