/* ---------------------------------------------------------------------------
   EV Registry — shared styles (responsive UI + one-page print layout)
--------------------------------------------------------------------------- */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2230;
  --muted: #62707f;
  --border: #e2e8ef;
  --primary: #0b6e4f;
  --primary-dark: #08573f;
  --primary-contrast: #ffffff;
  --accent: #eef7f2;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.25; }

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ---------------------------------- Nav ---------------------------------- */

header#app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  margin-right: auto;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand-icon { color: var(--primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-links a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 4px;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--primary); }

.nav-links a.nav-cta {
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 8px 16px;
  border-radius: 999px;
}
.nav-links a.nav-cta:hover { background: var(--primary-dark); }
.nav-links a.nav-cta.active { background: var(--primary-dark); color: var(--primary-contrast); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 18px;
  margin: 0 auto;
  background: var(--text);
}

.demo-banner {
  background: #fff8e6;
  color: #7a5b00;
  font-size: 0.82rem;
  text-align: center;
  padding: 6px 12px;
  border-top: 1px solid #f0e0a8;
}
.demo-banner code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 20px 16px;
    gap: 4px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 4px; }
  .nav-links a.nav-cta { text-align: center; }
}

/* The browser's own [hidden] rule is display:none, but ANY author rule that sets
   display beats it - .btn below sets display:inline-flex, which silently
   un-hides every hidden button. This must stay above the component styles. */
[hidden] {
  display: none !important;
}

/* -------------------------------- Buttons -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--accent); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f1c6c0; }
.btn-danger:hover { background: #fdecea; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* --------------------------------- Toolbar -------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.toolbar .spacer { flex: 1 1 auto; }

.search-input, select.select-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.92rem;
  color: var(--text);
}
.search-input { flex: 1 1 220px; min-width: 160px; }

/* -------------------------------- Vehicle grid ----------------------------- */

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.vehicle-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }

/* No image tile - see the note in js/app.js card(). Cards are text only, so the
   body carries even padding and the grid can pack tighter. */
.vehicle-card-body { padding: 16px; color: var(--text); }
.vehicle-card-title { font-weight: 700; font-size: 1.02rem; margin-bottom: 2px; }
.vehicle-card-sub { color: var(--muted); font-size: 0.86rem; margin-bottom: 10px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--accent);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* --------------------------------- Forms ---------------------------------- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.field-group { margin-bottom: 26px; }
.field-group h3 {
  font-size: 0.98rem;
  color: var(--primary-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.94rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.12);
}

.field-unit { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

/* Photo uploader */

.photo-uploader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.photo-slot {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-slot .remove-photo {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.photo-add-btn {
  aspect-ratio: 4 / 3;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.photo-add-btn:hover { background: var(--accent); }
.photo-hint { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.form-message {
  font-size: 0.88rem;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.form-message.error { background: #fdecea; color: var(--danger); }
.form-message.success { background: var(--accent); color: var(--primary-dark); }

/* ----------------------------- Vehicle spec sheet -------------------------- */

.sheet-wrap {
  max-width: 210mm;
  margin: 0 auto;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16mm 14mm;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.sheet-title { font-size: 1.5rem; font-weight: 800; }
.sheet-subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 2px; }
.sheet-badge {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.sheet-meta { color: var(--muted); font-size: 0.75rem; margin-bottom: 14px; }

.spec-group { margin-bottom: 12px; }
.spec-group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-dark);
  font-weight: 700;
  margin-bottom: 6px;
}
.spec-table {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 14px;
}
.spec-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  padding: 3px 0;
  border-bottom: 1px dotted var(--border);
}
.spec-item .k { color: var(--muted); }
.spec-item .v { font-weight: 600; text-align: right; }

.photo-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-dark);
  font-weight: 700;
  margin: 14px 0 6px;
}
.photo-grid-print {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.photo-grid-print .photo-box {
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--accent);
}
.photo-grid-print img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid-print .photo-box.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ---------------------------------- Misc ----------------------------------- */

.loading { text-align: center; color: var(--muted); padding: 40px; }

@media (max-width: 640px) {
  .spec-table { grid-template-columns: repeat(2, 1fr); }
  .sheet { padding: 20px 16px; }
  .sheet-header { flex-direction: column; }
}

/* --------------------------------- Print ------------------------------------
   Goal: the vehicle spec sheet fits on exactly one portrait page, with the
   photos (max 4, two per row) at the bottom.
------------------------------------------------------------------------------ */

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  .no-print { display: none !important; }

  html, body {
    background: #fff;
  }

  .page-container, .sheet-wrap {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .sheet {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  .sheet-header { padding-bottom: 8px; margin-bottom: 8px; }
  .sheet-title { font-size: 18pt; }
  .sheet-subtitle { font-size: 10pt; }
  .sheet-badge { font-size: 9pt; padding: 3px 10px; }
  .sheet-meta { font-size: 7.5pt; margin-bottom: 8px; }

  .spec-group { margin-bottom: 6px; }
  .spec-group-title { font-size: 7.5pt; margin-bottom: 4px; }
  .spec-table { gap: 1px 14px; }
  .spec-item { font-size: 8.5pt; padding: 1.5px 0; }

  .photo-section-title { font-size: 7.5pt; margin: 8px 0 4px; }
  .photo-grid-print { gap: 6px; }
  .photo-grid-print .photo-box { aspect-ratio: 4 / 3; }

  .spec-group, .photo-grid-print { page-break-inside: avoid; }
}

/* ------------------------- Read-only register additions -------------------- */
/* Added when the app switched from a Supabase CRUD app to a read-only viewer
   over the register spreadsheet. See README.md. */

.banner {
  padding: 10px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.banner-warn { background: #fff8e1; color: #6b5310; border-bottom-color: #f0e0a8; }
.banner code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.results-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.data-meta { color: var(--muted); }

.import-error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f1c6c0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.86rem;
  margin: 0 0 12px;
}

.chip-ok     { background: #e6f4ec; color: #0b6e4f; }
.chip-warn   { background: #fdf3d8; color: #8a6d1a; }
.chip-alert  { background: #fdecea; color: #a5342a; }
.chip-muted  { background: #eceff2; color: #62707f; }

/* A blank spec means "not published in Australia", so mute it rather than
   letting an em dash read like a real value. */
.spec-item.is-blank .v { color: #a8b2bd; }

.photo-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 6px;
}
.photo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.photo-link:hover { background: var(--accent); text-decoration: none; }
.photo-link-icon { opacity: 0.7; }

.record-notes {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.sheet-footnote {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--muted);
}

@media print {
  .banner, .results-bar, .import-error { display: none !important; }
  .record-notes { font-size: 8pt; }
  .sheet-footnote { font-size: 7pt; margin-top: 8px; padding-top: 6px; }
}

/* ------------------------------- Dashboard --------------------------------- */
/* Every figure is counted in the browser from data/vehicles.json - see the note
   at the top of js/dashboard.js. Bars are plain CSS on purpose: the site has no
   runtime dependencies and a charting library is not worth breaking that for
   six bars. */

.page-title {
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: var(--text);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); line-height: 1.2; }
.stat-note  { font-size: 0.72rem; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel-title { font-size: 1.05rem; margin: 0 0 4px; color: var(--text); }
.panel-note  { font-size: 0.8rem; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }

.year-chart { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.year-row {
  display: grid;
  grid-template-columns: 48px 1fr 44px;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--text);
}
.year-row:hover { background: var(--accent); text-decoration: none; }
.year-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.year-total { font-size: 0.85rem; font-weight: 700; text-align: right; }
.year-bar {
  display: flex;
  height: 22px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}
.bar-seg { display: block; height: 100%; }
.bar-bev  { background: var(--primary); }
.bar-phev { background: #7fbfa6; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { color: var(--muted); font-size: 0.78rem; text-transform: none; }
.data-table tfoot td { font-weight: 700; border-bottom: none; border-top: 2px solid var(--border); }

/* --------------------------------- About ---------------------------------- */

.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px 32px;
  max-width: 780px;
}
.prose h2 {
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.prose p { line-height: 1.65; margin: 0 0 12px; font-size: 0.95rem; }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose li { line-height: 1.6; margin-bottom: 8px; font-size: 0.95rem; }

.attribution {
  font-weight: 600;
  color: var(--primary-dark);
  margin: 0 0 2px !important;
}

@media (max-width: 720px) {
  .prose { padding: 20px; }
}
