/* ==========================================================================
   csv-panel — workshop manual stylesheet
   Aesthetic: gunmetal canvas, oxide-red accent, blueprint grid undertone.
   Built for long sessions. Dense, legible, intentional.
   ========================================================================== */

/* ---------- 1. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, picture, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

/* ---------- 2. Theme tokens ---------- */
:root {
  /* surfaces */
  --bg:           #0e1014;
  --bg-elev-1:    #14171d;
  --bg-elev-2:    #1a1e25;
  --bg-elev-3:    #20252e;
  --bg-row-hover: #1c2029;

  /* lines */
  --line:         #262b34;
  --line-strong: #353c47;
  --line-faint:  #1d2129;

  /* text */
  --text:       #e6e8ec;
  --text-mid:   #aab1be;
  --text-dim:   #6e7585;
  --text-faint: #4a5160;

  /* accents */
  --oxide:       #d24a1c;
  --oxide-dim:   #b03e15;
  --oxide-bg:    rgba(210, 74, 28, 0.12);
  --steel:       #4d80c4;
  --steel-dim:   #3a6aa6;
  --steel-bg:    rgba(77, 128, 196, 0.14);

  /* status */
  --st-pending:    #b8881e;
  --st-pending-bg: rgba(184, 136, 30, 0.14);
  --st-progress:    #4d80c4;
  --st-progress-bg: rgba(77, 128, 196, 0.14);
  --st-done:    #5a9b56;
  --st-done-bg: rgba(90, 155, 86, 0.14);
  --st-locked:    #c7553a;
  --st-locked-bg: rgba(199, 85, 58, 0.14);

  --danger: #c43838;

  /* fonts */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* sizes */
  --topbar-h: 52px;
  --radius: 2px;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.4), 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* ---------- 3. Base ---------- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-feature-settings: "ss01", "cv11";
}

/* faint blueprint grid in the background — present but never noisy */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 64px 64px;
  z-index: 0;
}
main, .topbar { position: relative; z-index: 1; }

::selection { background: var(--oxide); color: #fff; }

/* ---------- 4. Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}
.topbar .logo .slash { color: var(--oxide); font-weight: 400; padding: 0 1px; }
.topbar .logo .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
  align-self: center;
}
.topbar nav { display: flex; gap: 2px; margin-left: 28px; }
.topbar nav a {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-mid);
  border-radius: var(--radius);
  transition: color 80ms, background 80ms;
}
.topbar nav a:hover { color: var(--text); background: var(--bg-elev-2); }
.topbar nav a.active { color: var(--text); background: var(--bg-elev-2); }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-mid); }
.topbar .user .who { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.topbar .user .who .badge-admin {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--oxide);
  border: 1px solid var(--oxide-dim);
  padding: 1px 4px;
  margin-left: 8px;
  vertical-align: 1px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* ---------- 5. Content shell ---------- */
.content {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.page-head .crumbs {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.page-head .crumbs a:hover { color: var(--text); }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: var(--radius);
  transition: background 80ms, border-color 80ms, transform 60ms;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--bg-elev-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--oxide); border-color: var(--oxide); color: #fff; }
.btn.primary:hover { background: var(--oxide-dim); border-color: var(--oxide-dim); }
.btn.danger { color: #ff8080; border-color: rgba(196, 56, 56, 0.5); }
.btn.danger:hover { background: rgba(196, 56, 56, 0.1); color: #ffa0a0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-mid); }
.btn.ghost:hover { color: var(--text); background: var(--bg-elev-2); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 10px 22px; font-size: 14px; }

/* ---------- 7. Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.input, .select {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  transition: border-color 80ms, background 80ms;
  min-width: 180px;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--oxide);
  background: var(--bg-elev-3);
}
.input::placeholder { color: var(--text-faint); }

/* ---------- 8. Tabs (status filter) ---------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tabs .tab {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-mid);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 80ms, border-color 80ms;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--text); border-bottom-color: var(--oxide); }
.tabs .tab .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  padding: 1px 7px;
  border-radius: var(--radius);
}
.tabs .tab.active .count { color: var(--text); background: var(--bg-elev-3); }

/* ---------- 9. Status badges (inventory stamps) ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.15);
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  background: currentColor;
  display: inline-block;
}
.status.pending { color: var(--st-pending); background: var(--st-pending-bg); }
.status.in_progress, .status.progress { color: var(--st-progress); background: var(--st-progress-bg); }
.status.done { color: var(--st-done); background: var(--st-done-bg); }
.status.locked { color: var(--st-locked); background: var(--st-locked-bg); }

/* ---------- 10. Tables ---------- */
.table-wrap {
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data { font-size: 13px; }
table.data thead th {
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--line-strong);
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 9px 12px;
}
table.data tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-faint);
  vertical-align: middle;
}
table.data tbody tr { transition: background 60ms; }
table.data tbody tr:hover { background: var(--bg-row-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .right { text-align: right; }

table.data .col-year    { font-family: var(--font-mono); color: var(--text-mid); width: 64px; }
table.data .col-make    { font-weight: 500; }
table.data .col-model   { color: var(--text-mid); }
table.data .col-price   { font-family: var(--font-mono); text-align: right; width: 100px; font-feature-settings: "tnum"; }
table.data .col-mileage { font-family: var(--font-mono); color: var(--text-mid); text-align: right; width: 100px; font-feature-settings: "tnum"; }
table.data .col-status  { width: 150px; }
table.data .col-editor  { color: var(--text-dim); width: 130px; font-size: 12px; }
table.data .col-action  { width: 96px; text-align: right; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.right { text-align: right; }
.dim { color: var(--text-dim); }

/* ---------- 11. Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.pagination .pages { display: flex; gap: 6px; }

/* ---------- 12. Cards & stat cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.card {
  position: relative;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  padding: 20px;
  border-radius: var(--radius);
}
.card .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.card .value {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.025em;
  margin-top: 6px;
  font-feature-settings: "tnum";
  line-height: 1;
}
.card .pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}
.card .accent { color: var(--oxide); }

/* registration crosshair on card corners */
.card.marked::before, .card.marked::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border: 1px solid var(--line-strong);
  pointer-events: none;
}
.card.marked::before { top: -1px; left: -1px;  border-right: 0; border-bottom: 0; }
.card.marked::after  { bottom: -1px; right: -1px; border-left: 0;  border-top: 0; }

/* ---------- 13. Banners ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--bg-elev-1);
  border-left: 3px solid var(--st-locked);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.banner.flash {
  border-left-color: var(--st-done);
  background: var(--st-done-bg);
}
.banner .heading {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--st-locked);
  margin-bottom: 3px;
}
.banner.flash .heading { color: var(--st-done); }
.banner .body { color: var(--text); }
.banner .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 14. Login page ---------- */
.login-shell {
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  padding: 36px 32px;
  border-radius: var(--radius);
  position: relative;
}
.login-card::before, .login-card::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  border: 1px solid var(--line-strong);
  pointer-events: none;
}
.login-card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.login-card::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.login-card .marque {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.login-card .marque .slash { color: var(--oxide); font-weight: 400; }
.login-card .sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 28px;
}
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card .input { min-width: 0; padding: 9px 12px; }
.login-card .btn { padding: 10px; }
.login-card .error {
  background: rgba(196, 56, 56, 0.1);
  border: 1px solid rgba(196, 56, 56, 0.3);
  color: #ff7c7c;
  padding: 9px 12px;
  font-size: 13px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
}

/* ---------- 15. Edit page — header ---------- */
.edit-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.edit-head .crumbs {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.edit-head .crumbs a { color: var(--text-dim); }
.edit-head .crumbs a:hover { color: var(--text); }
.edit-head h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.edit-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 14px;
  font-size: 13px;
}
.edit-head .meta div { display: flex; flex-direction: column; gap: 2px; }
.edit-head .meta dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.edit-head .meta dd { font-family: var(--font-mono); color: var(--text); font-size: 12px; }
.edit-head .actions { display: flex; gap: 8px; }

/* ---------- 16. Mode bar (main / additional toggle) ---------- */
.mode-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.mode-bar .label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.mode-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-toggle button {
  padding: 8px 16px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mid);
  background: transparent;
  font-family: var(--font-mono);
  font-weight: 500;
  transition: background 80ms, color 80ms;
}
.mode-toggle button:hover { color: var(--text); }
.mode-toggle button[data-active="true"][data-mode="main"]       { background: var(--oxide); color: #fff; }
.mode-toggle button[data-active="true"][data-mode="additional"] { background: var(--steel); color: #fff; }
.mode-bar .spacer { flex: 1; }
.mode-bar .selection-summary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mid);
}
.mode-bar .selection-summary strong { color: var(--text); font-weight: 600; }

/* ---------- 17. Photo grid ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.photo-grid .photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  transition: transform 80ms, border-color 80ms;
  user-select: none;
}
.photo-grid .photo:hover { border-color: var(--line-strong); }
.photo-grid .photo:active { transform: scale(0.99); }
.photo-grid .photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 120ms, transform 200ms;
}
.photo-grid .photo:hover img { transform: scale(1.02); }

/* selection rings — drawn via outline so they don't shift layout */
.photo-grid .photo[data-selected="main"] {
  outline: 4px solid var(--oxide);
  outline-offset: -4px;
  z-index: 2;
}
.photo-grid .photo[data-selected="additional"] {
  outline: 3px solid var(--steel);
  outline-offset: -3px;
  z-index: 2;
}
.photo-grid .photo[data-selected="main"] img { filter: saturate(1.1); }

.photo-grid .photo .stamp {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 3;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--oxide);
  color: #fff;
  padding: 4px 7px;
  border-radius: var(--radius);
  display: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.photo-grid .photo[data-selected="main"] .stamp.main { display: inline-block; }

.photo-grid .photo .number {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 3;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  width: 30px; height: 30px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--steel);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.photo-grid .photo[data-selected="additional"] .number { display: inline-flex; }

.photo-grid .photo .index {
  position: absolute;
  bottom: 6px; right: 8px;
  z-index: 3;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.08em;
}

/* empty states */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
}
.empty-state .ico {
  font-family: var(--font-display);
  font-size: 56px;
  color: var(--text-faint);
  margin-bottom: 12px;
  line-height: 1;
}
.empty-state .text { font-size: 13px; max-width: 480px; margin: 0 auto; }
.empty-state .text a { color: var(--text-mid); text-decoration: underline; text-decoration-color: var(--line-strong); }

/* ---------- 18. Edit footer (sticky save bar) ---------- */
.edit-footer {
  position: sticky;
  bottom: 0;
  margin-top: 24px;
  padding: 18px 0 12px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 5;
}
.edit-footer .summary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mid);
}
.edit-footer .summary strong { color: var(--oxide); font-weight: 600; }
.edit-footer .actions { display: flex; gap: 8px; }

/* ---------- 19. Progress bar ---------- */
.progress {
  height: 6px;
  background: var(--bg-elev-3);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.progress > div { height: 100%; background: var(--oxide); transition: width 200ms; }

/* ---------- 20. Filter bar ---------- */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar form { display: contents; }

/* ---------- 21. Section title ---------- */
.section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- 22. Misc helpers ---------- */
.flex-row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.no-wrap { white-space: nowrap; }

.inline-form { display: inline; }

/* ---------- 23. Animations ---------- */
@keyframes flash-row {
  0%   { background: var(--oxide-bg); }
  100% { background: transparent; }
}
.row-flash { animation: flash-row 1.2s ease-out; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; animation: spin 0.9s linear infinite; }

/* ---------- 24. Responsive ---------- */
@media (max-width: 900px) {
  .topbar nav { display: none; }
  .content { padding: 16px; }
  .filter-bar { gap: 8px; }
  .edit-head { grid-template-columns: 1fr; }
  .edit-head .actions { justify-content: flex-start; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head h1 { font-size: 26px; }
  table.data .col-mileage, table.data .col-editor { display: none; }
}
