/* Mobile-first base styles. Wider screens only widen the content column. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #5f6b66;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --danger: #a33a2b;
  --radius: 12px;
  --tap: 48px; /* minimum touch target */
  --nav-height: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a18;
    --surface: #212724;
    --text: #e8ece9;
    --muted: #a4b0aa;
    --accent: #6fb39f;
    --accent-text: #0e1412;
    --danger: #e07a6b;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* leave room for the fixed bottom navigation */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  background: var(--accent);
  color: var(--accent-text);
}

.site-title {
  color: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
}

.content {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }

/* The vehicle's photo on the dashboard (a cut-out works best). */
.vehicle-photo {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
  margin: -0.5rem auto 1rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.muted { color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-block { width: 100%; }

.btn-quiet {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  min-height: 40px;
}

.logout { margin: 0; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { background: var(--surface); border-radius: var(--radius); padding: 0.75rem 1rem; }
.message.error { color: var(--danger); }
.message.warning { border-left: 4px solid var(--danger); }

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-around;
  min-height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--muted) 30%, transparent);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.bottom-nav a[aria-current="page"] { color: var(--accent); }

input, select, textarea { font: inherit; min-height: var(--tap); }

/* --- Lists, forms and page heads (costs and later records) --- */

h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }

a { color: var(--accent); }
a.danger, .danger { color: var(--danger); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.quick-add { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.big-number { font-size: 2rem; font-weight: 700; margin: 0 0 0.5rem; font-variant-numeric: tabular-nums; }

.btn-danger { background: var(--danger); color: var(--accent-text); }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

.form > div { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.75rem; }
.form label { font-weight: 600; }
.form input, .form select, .form textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--muted) 50%, transparent);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.form .errorlist { color: var(--danger); list-style: none; padding: 0; margin: 0; }

.filters summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }

.list { list-style: none; padding: 0; margin: 0 0 1rem; }
.list > li { margin-bottom: 0.5rem; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--tap);
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.list-main { display: flex; flex-direction: column; min-width: 0; }
.list-main .muted { font-size: 0.9rem; }
.amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- Attachments (vanlog.attachments: thumbnails and PDF links) --- */

.attachments {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.75rem;
}
.attachment { display: flex; flex-direction: column; gap: 0.25rem; }
.attachment > a { display: flex; flex-direction: column; gap: 0.25rem; text-decoration: none; }
.attachment img,
.attachment-doc {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: calc(var(--radius) / 2);
  background: var(--bg);
}
.attachment-doc { display: flex; align-items: center; justify-content: center; font-weight: 700; }
.attachment-name { font-size: 0.85rem; overflow-wrap: anywhere; }
.attachment form { margin: 0; }
.attachment .btn { width: 100%; }

/* Due status (maintenance, tasks, recurring costs): {% due_badge status %} */
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.badge-ok { border: 1px solid var(--muted); color: var(--muted); }
.badge-due_soon { background: #f3d27a; color: #3d2f00; }
.badge-overdue { background: var(--danger); color: var(--bg); }
