/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:           #f8f9fa;
  --color-surface:      #ffffff;
  --color-primary:      #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-text:         #111827;
  --color-muted:        #6b7280;
  --color-border:       #e5e7eb;
  --color-error:        #dc2626;
  --color-success:      #16a34a;
  --color-info:         #2563eb;
  --radius:             8px;
  --shadow:             0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-primary);
  text-decoration: none;
}

.site-header nav { display: flex; gap: 1.25rem; }
.site-header nav a { color: var(--color-muted); text-decoration: none; font-size: .9rem; }
.site-header nav a:hover { color: var(--color-text); }

/* ── Layout ───────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Alerts ───────────────────────────────────────────────── */
.messages { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  border-left: 4px solid transparent;
}

.alert-success { background: #f0fdf4; border-color: var(--color-success); color: #166534; }
.alert-error   { background: #fef2f2; border-color: var(--color-error);   color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: var(--color-info);    color: #1e40af; }

/* ── Auth card ────────────────────────────────────────────── */
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  margin-top: 2rem;
}

.auth-card h1 { font-size: 1.4rem; margin-bottom: 1.25rem; }
.auth-alt { margin-top: 1.25rem; font-size: .9rem; color: var(--color-muted); }
.auth-alt a { color: var(--color-primary); }

/* ── Forms ────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: 1rem;
}

.field label { font-size: .9rem; font-weight: 500; }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color .15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.field-error { color: var(--color-error); font-size: .8rem; }

.field-checkbox { flex-direction: row; align-items: center; gap: .5rem; }
.field-checkbox label { font-weight: 400; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background .15s;
  min-height: 44px;
  white-space: nowrap;
}

.btn-primary { background: var(--color-primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-danger { background: var(--color-error); color: #fff; }

/* ── Dashboard ────────────────────────────────────────────── */
.dashboard h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.muted { color: var(--color-muted); font-size: .95rem; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 1.4rem; }
.header-actions { display: flex; gap: .5rem; }

/* ── Card (generic surface) ───────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

/* ── License plate badge ──────────────────────────────────── */
.plate {
  display: inline-block;
  font-family: monospace;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .05em;
  background: #fef9c3;
  border: 1px solid #fbbf24;
  border-radius: 4px;
  padding: .15rem .5rem;
}
.plate-lg { font-size: 1.1rem; }
.car-name { color: var(--color-muted); font-size: .9rem; margin-left: .5rem; }

/* ── Car cards (dashboard) ────────────────────────────────── */
.car-cards { display: flex; flex-direction: column; gap: 1rem; }

.car-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.car-card-top {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.car-edit-link { margin-left: auto; font-size: .8rem; color: var(--color-muted); }
.car-card-meta { font-size: .85rem; color: var(--color-muted); margin-bottom: .75rem; }
.car-card-actions { display: flex; gap: .5rem; }

/* ── Car list (manage page) ───────────────────────────────── */
.section-title { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }

.car-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.car-list-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.car-list-actions { margin-left: auto; display: flex; gap: .75rem; font-size: .875rem; }
.car-list-actions a { color: var(--color-primary); text-decoration: none; }

/* ── Fill-up table ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

.fillup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.fillup-table th {
  text-align: left;
  padding: .6rem .75rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
}
.fillup-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.fillup-table tbody tr:last-child td { border-bottom: none; }
.table-link { color: var(--color-primary); text-decoration: none; font-size: .85rem; }

/* ── Form hints ───────────────────────────────────────────── */
.field-hint { font-size: .8rem; color: var(--color-muted); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-muted);
}
.empty-state p { margin-bottom: 1rem; }

/* ── Danger zone ──────────────────────────────────────────── */
.danger-zone {
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fff5f5;
}
.danger-zone h2 { font-size: 1rem; color: var(--color-error); margin-bottom: .4rem; }
.danger-zone p { font-size: .875rem; color: var(--color-muted); margin-bottom: .75rem; }

/* ── Button sizes ─────────────────────────────────────────── */
.btn-sm { padding: .4rem .85rem; font-size: .875rem; min-height: 36px; }

/* ── OCR section ──────────────────────────────────────────── */
.ocr-section {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
  background: var(--color-bg);
}

.ocr-title { font-size: .9rem; font-weight: 600; margin-bottom: .6rem; }
.ocr-optional { font-weight: 400; color: var(--color-muted); }

.ocr-type { display: flex; gap: 1.25rem; margin-bottom: .6rem; font-size: .875rem; }
.ocr-type-label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }

.ocr-controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.ocr-controls input[type="file"] { font-size: .85rem; flex: 1 1 auto; }

.ocr-status {
  margin-top: .5rem;
  font-size: .82rem;
  padding: .35rem .6rem;
  border-radius: 4px;
  min-height: 1.5rem;
}
.ocr-success { background: #f0fdf4; color: #166534; }
.ocr-error   { background: #fef2f2; color: #991b1b; }
.ocr-warn    { background: #fffbeb; color: #92400e; }

.ocr-existing-photo { margin-bottom: .6rem; font-size: .85rem; }
.ocr-existing-photo a { color: var(--color-primary); }

/* OCR-detected field highlight — amber until manually edited */
.ocr-detected {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
  box-shadow: 0 0 0 3px rgba(245,158,11,.15) !important;
}

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .85rem .75rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: .7rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .2rem;
}

/* ── Dashboard inline stats ───────────────────────────────── */
.car-card-stats { margin-bottom: .4rem; }
.stat-inline { font-size: .9rem; margin-right: .75rem; }

/* ── Trend chart ───────────────────────────────────────────── */
.chart-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

/* ── Desktop ──────────────────────────────────────────────── */
@media (min-width: 640px) {
  .container { padding: 2rem 1.5rem; }
  .auth-card { padding: 2.5rem 2rem; }
  .btn-primary { width: auto; }
  .car-cards { flex-direction: row; flex-wrap: wrap; }
  .car-card { flex: 1 1 280px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
