/* Garage — dark automotive theme. One file: tokens, base, components, views. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0c0e11;            /* asphalt */
  --bg-raise: #14171c;      /* panel */
  --bg-raise-2: #1b1f26;    /* panel hover / inputs */
  --line: #262b34;          /* hairline */
  --line-soft: #1d2129;
  --text: #eef1f5;
  --text-2: #aab2bf;
  --text-3: #717a88;
  --accent: #ffb020;        /* racing amber */
  --accent-ink: #1a1200;
  --ok: #37d183;
  --warn: #ffb020;
  --danger: #ff5c5c;
  --info: #5aa9ff;
  --radius: 14px;
  --fs-h1: 22px; --fs-h2: 18px; --fs-body: 15.5px; --fs-sec: 13.5px; --fs-tiny: 12px;
  --pad: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

/* iOS UA reset — every tappable is a <button>; make them inherit cleanly */
button {
  font: inherit; color: inherit; background: none; border: 0;
  text-align: inherit; cursor: pointer; touch-action: manipulation;
}
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg-raise-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: var(--fs-sec); color: var(--text-2);
  margin: 14px 0 6px; font-weight: 600; }

/* ---- app bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--sat)) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.appbar .brand {
  font-weight: 800; font-size: 17px; letter-spacing: 0.14em;
  display: flex; align-items: center; gap: 9px;
}
.brand .mark { color: var(--accent); display: flex; }
.appbar .spacer { flex: 1; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 19px;
}
.iconbtn:active { background: var(--bg-raise-2); }
.backbtn { display: flex; align-items: center; gap: 4px; color: var(--text-2);
  font-weight: 600; font-size: var(--fs-sec); padding: 8px 10px 8px 4px; }

.page { padding: var(--pad) var(--pad) calc(40px + var(--sab)); max-width: 640px; margin: 0 auto; }

/* ---- buttons ---- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 16px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; border-radius: 12px; font-size: var(--fs-body);
}
.btn:active { filter: brightness(0.92); }
.btn.secondary { background: var(--bg-raise-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.small { width: auto; padding: 8px 14px; font-size: var(--fs-sec); border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ---- vehicle card (garage view) ---- */
.vcard {
  display: block; width: 100%;
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px;
}
.vcard:active { border-color: var(--line); }
.vcard .photo {
  position: relative; aspect-ratio: 16/8.5; background:
    radial-gradient(120% 100% at 20% 0%, #232936 0%, #141920 55%, #0e1116 100%);
  display: flex; align-items: center; justify-content: center;
}
.vcard .photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vcard .photo .placeholder { color: #39414e; }
.vcard .photo::after {   /* legibility gradient for the odometer overlay */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(5,6,8,.72), transparent 42%);
}
.vcard .odo {
  position: absolute; right: 12px; bottom: 10px; z-index: 2;
}
.vcard .meta { padding: 13px 15px 14px; }
.vcard .vname { font-weight: 750; font-size: var(--fs-h2); letter-spacing: -0.01em; }
.vcard .vsub { color: var(--text-3); font-size: var(--fs-sec); margin-top: 1px; }
.vcard .chips { margin-top: 10px; }

/* odometer readout — tabular digits on a dark plate, like a dash cluster */
.odo {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: rgba(8,9,12,.78); border: 1px solid rgba(255,255,255,.09);
  border-radius: 9px; padding: 4px 10px;
  font-variant-numeric: tabular-nums; letter-spacing: 0.08em;
  font-weight: 700; font-size: 15px;
}
.odo .unit { font-size: 10.5px; color: var(--text-3); letter-spacing: 0.12em; font-weight: 600; }
.odo.big { font-size: 21px; padding: 6px 14px; }

/* ---- status chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-tiny); font-weight: 650;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-raise-2); color: var(--text-2);
  border: 1px solid var(--line-soft);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.chip.ok .dot { background: var(--ok); }
.chip.soon { color: #ffd27a; border-color: #4d3c14; background: #211a09; }
.chip.soon .dot { background: var(--warn); }
.chip.overdue { color: #ff9d9d; border-color: #572222; background: #250e0e; }
.chip.overdue .dot { background: var(--danger); }
.chip.unknown .dot { background: var(--info); }

/* ---- section cards ---- */
.card {
  background: var(--bg-raise); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 15px; margin-bottom: 14px;
}
.card h3 { font-size: var(--fs-sec); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); font-weight: 700; margin-bottom: 10px; }
.row-title { font-weight: 650; }
.row-sub { color: var(--text-3); font-size: var(--fs-sec); margin-top: 1px; }

/* list rows (service items, parts, records) */
.rows { display: flex; flex-direction: column; }
.rows > * + * { border-top: 1px solid var(--line-soft); }
.itemrow { display: flex; align-items: center; gap: 12px; padding: 12px 2px; width: 100%; }
.itemrow .grow { flex: 1; min-width: 0; }
.statusdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.statusdot.ok { background: var(--ok); }
.statusdot.soon { background: var(--warn); box-shadow: 0 0 10px color-mix(in srgb, var(--warn) 55%, transparent); }
.statusdot.overdue { background: var(--danger); box-shadow: 0 0 10px color-mix(in srgb, var(--danger) 55%, transparent); }
.statusdot.unknown { background: var(--info); }

/* ---- gauge ring ---- */
.gauge-wrap { display: flex; align-items: center; gap: 16px; }
.gauge { width: 108px; height: 108px; flex: none; }
.gauge .track { stroke: var(--bg-raise-2); }
.gauge .arc.ok { stroke: var(--ok); }
.gauge .arc.soon { stroke: var(--warn); }
.gauge .arc.overdue { stroke: var(--danger); }
.gauge text { fill: var(--text); font-weight: 800; font-size: 17px; }
.gauge .glabel { fill: var(--text-3); font-size: 8.5px; font-weight: 600; letter-spacing: .08em; }

/* ---- tabs ---- */
.tabs {
  display: flex; gap: 2px; margin: 16px 0 14px;
  background: var(--bg-raise); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 3px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; padding: 8px 12px; border-radius: 9px; text-align: center;
  font-size: var(--fs-sec); font-weight: 650; color: var(--text-3); white-space: nowrap;
}
.tab.active { background: var(--bg-raise-2); color: var(--text); }

/* ---- hero (vehicle view) ---- */
.hero {
  position: relative; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16/9; background:
    radial-gradient(120% 100% at 20% 0%, #232936 0%, #141920 55%, #0e1116 100%);
  border: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center;
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(5,6,8,.75), transparent 40%); }
.hero .odo { position: absolute; left: 12px; bottom: 12px; z-index: 2; }
.hero .heroact { position: absolute; right: 12px; bottom: 12px; z-index: 2; }
.hero .placeholder { color: #39414e; }

/* ---- history timeline ---- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line-soft); border-radius: 2px; }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content: ""; position: absolute; left: -21px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent); }
.tl-item.kind-repair::before { border-color: var(--danger); }
.tl-item.kind-upgrade::before { border-color: var(--info); }
.tl-item.kind-inspection::before,
.tl-item.kind-other::before { border-color: var(--text-3); }
.tl-date { font-size: var(--fs-tiny); color: var(--text-3); font-weight: 650;
  letter-spacing: .05em; text-transform: uppercase; }
.tl-card { display: block; width: 100%; background: var(--bg-raise);
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; margin-top: 6px; }
.tl-card:active { border-color: var(--line); }
.tl-title { font-weight: 700; }
.tl-sub { color: var(--text-3); font-size: var(--fs-sec); margin-top: 2px; }
.tl-thumbs { display: flex; gap: 8px; margin-top: 10px; }
.tl-thumbs img, .doc-thumb {
  width: 54px; height: 54px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line);
}
.doc-thumb { display: flex; align-items: center; justify-content: center;
  background: var(--bg-raise-2); font-size: 20px; }

/* ---- parts ---- */
.pn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13.5px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 2px 8px; border-radius: 7px; letter-spacing: 0.04em;
}
.copybtn { color: var(--text-3); font-size: 16px; padding: 8px; border-radius: 8px; flex: none; }
.copybtn:active { background: var(--bg-raise-2); color: var(--text); }

/* ---- photo grid ---- */
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pgrid button { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line-soft); background: var(--bg-raise-2); }
.pgrid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pgrid .tag { position: absolute; left: 5px; bottom: 5px; font-size: 10px;
  background: rgba(0,0,0,.65); padding: 2px 6px; border-radius: 6px; color: var(--text-2); }

/* ---- sheets ---- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 90;
  opacity: 0; transition: opacity .18s; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: #171b21; border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 10px var(--pad) calc(22px + var(--sab));
  max-height: 88dvh; overflow-y: auto;
  transform: translateY(102%); transition: transform .22s cubic-bezier(.3,.9,.3,1);
  max-width: 640px; margin: 0 auto;
}
.sheet.show { transform: none; }
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line);
  margin: 2px auto 12px; }
.sheet h2 { font-size: var(--fs-h1); font-weight: 750; letter-spacing: -0.01em; margin-bottom: 4px; }
.sheet .btn { margin-top: 20px; }
.formrow { display: flex; gap: 10px; }
.formrow > * { flex: 1; }

/* full-screen photo viewer */
.viewer { position: fixed; inset: 0; z-index: 120; background: rgba(3,4,6,.96);
  display: flex; flex-direction: column; }
.viewer .vtop { display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + var(--sat)) 14px 8px; }
.viewer .vimg { flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 0 8px; }
.viewer .vimg img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer .vactions { display: flex; gap: 10px; padding: 12px 16px calc(16px + var(--sab)); }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(30px + var(--sab)); transform: translateX(-50%) translateY(8px);
  background: #21262e; color: var(--text); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 12px; font-size: var(--fs-sec); font-weight: 600;
  z-index: 150; opacity: 0; transition: all .2s; pointer-events: none;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.empty { text-align: center; color: var(--text-3); padding: 26px 10px; font-size: var(--fs-sec); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.section-head h3 { font-size: var(--fs-sec); text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-3); font-weight: 700; }
.linkbtn { color: var(--accent); font-weight: 700; font-size: var(--fs-sec); padding: 6px 8px; }
.muted { color: var(--text-3); font-size: var(--fs-sec); }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }
