:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e9ebf0;
  --muted: #8b92a1;
  --accent: #ff5a36;
  --accent-2: #ff7a59;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, .9);
  backdrop-filter: blur(8px);
  flex: none;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 4px 0;
  font-size: 17px; letter-spacing: -.01em;
}
.brand b { color: var(--accent); }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #c0392b);
  color: #fff;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); flex: 1; min-width: 0; }
.crumbs button { background: none; border: 0; color: var(--muted); padding: 0; }
.crumbs button:hover { color: var(--text); }
.crumbs .current { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 6px; }

.view { flex: 1; overflow-y: auto; padding: 28px 32px 60px; }
.view-inner { max-width: 1240px; margin: 0 auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel-2);
  font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #3a4150; background: #252a35; }
a.btn { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: #fca5a5; }
.btn.danger:hover { background: rgba(239, 68, 68, .15); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn svg { width: 16px; height: 16px; }
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 700; }

/* ---------- garage ---------- */
.garage-stats { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; min-width: 170px;
}
.stat b { display: block; font-size: 22px; letter-spacing: -.01em; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.car-card {
  position: relative; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; padding: 0;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.car-card:hover { transform: translateY(-3px); border-color: #3a4150; box-shadow: var(--shadow); }
.car-card .cover { aspect-ratio: 16 / 10; background: var(--panel-2); position: relative; overflow: hidden; }
.car-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.car-card .cover .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #3a4150; }
.car-card .cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(15,17,21,.85), transparent 55%);
}
.car-card .overlay { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 1; }
.car-card h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.car-card .meta { color: #c3c8d2; font-size: 13px; }
.car-card .foot { display: flex; justify-content: space-between; padding: 12px 16px; color: var(--muted); font-size: 13px; }
.car-card .foot b { color: var(--text); font-size: 15px; }
.car-card .card-menu { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.car-card:hover .card-menu { opacity: 1; }
.card-menu .icon-btn { background: rgba(15,17,21,.75); color: #d6dae2; }
.card-menu .icon-btn:hover { background: rgba(15,17,21,.95); }

.add-card {
  border: 2px dashed var(--line); border-radius: 14px; background: transparent;
  min-height: 250px; display: grid; place-items: center; color: var(--muted);
  transition: border-color .15s, color .15s;
}
.add-card:hover { border-color: var(--accent); color: var(--text); }
.add-card .plus { font-size: 34px; line-height: 1; margin-bottom: 6px; color: var(--accent); }

.empty {
  text-align: center; padding: 70px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 16px;
}
.empty h2 { color: var(--text); margin: 10px 0 6px; }
.empty .btn { margin-top: 16px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- car view ---------- */
.car-hero {
  display: grid; grid-template-columns: 360px 1fr; gap: 26px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; margin-bottom: 24px;
}
.car-hero .cover { aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; color: #3a4150; }
.car-hero .cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.car-hero h1 { margin: 2px 0 0; font-size: 30px; letter-spacing: -.02em; }
.car-hero .sub { color: var(--muted); font-size: 15px; }
.car-hero .notes { color: #c3c8d2; margin: 10px 0 0; white-space: pre-wrap; max-height: 64px; overflow: auto; }
.hero-stats { display: flex; gap: 28px; margin: 16px 0; }
.hero-stats b { display: block; font-size: 24px; letter-spacing: -.01em; }
.hero-stats span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.hero-body { display: flex; flex-direction: column; min-width: 0; }
.hero-body .actions { margin-top: auto; }

.breakdown { display: flex; height: 8px; border-radius: 6px; overflow: hidden; background: var(--panel-2); margin-top: 4px; }
.breakdown i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { margin: 0 auto 0 0; font-size: 18px; }
.search { position: relative; }
/* Higher specificity than the generic input[type=search] rule further down. */
.search input[type=search] { padding-left: 34px; width: 220px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; z-index: 1; }

.mod-list { display: flex; flex-direction: column; gap: 10px; }
.mod-row {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; text-align: left; width: 100%;
  transition: border-color .15s, background .15s;
}
.mod-row:hover { border-color: #3a4150; background: #1a1d25; }
.mod-thumb { position: relative; width: 96px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; color: #3a4150; }
/* Pinned to the frame (a plain grid item would grow to the photo's own height, so the photo
   could never be repositioned inside it). */
.mod-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mod-row h3 { margin: 0; font-size: 16px; }
.mod-row .meta { display: flex; gap: 12px; color: var(--muted); font-size: 12.5px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.mod-row .meta svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.mod-row .right { display: flex; align-items: center; gap: 10px; }
.mod-row .price { font-size: 17px; font-weight: 700; white-space: nowrap; min-width: 100px; text-align: right; }
.mod-row .row-actions { display: flex; opacity: 0; transition: opacity .15s; }
.mod-row:hover .row-actions { opacity: 1; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: rgba(255, 90, 54, .12); color: var(--accent-2);
}

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
.row { display: grid; gap: 12px; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.row.c3 { grid-template-columns: 2fr 1fr 1fr; }
.row.c4 { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], textarea, select {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 90, 54, .18); }
textarea { resize: vertical; min-height: 80px; }
.price-input { position: relative; }
.price-input span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.price-input input { padding-right: 48px; }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 10px;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: rgba(255, 90, 54, .06); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.7); border: 0; color: #fff; display: grid; place-items: center; font-size: 14px; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.thumb:hover .x { opacity: 1; }
.thumb .pos {
  position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.7); border: 0; color: #fff; display: grid; place-items: center; padding: 0;
  opacity: 0; transition: opacity .15s;
}
.thumb:hover .pos { opacity: 1; }
.thumb .pos:hover { background: var(--accent); }

/* "Adjust preview" editor */
.pos-pick {
  display: grid; place-items: center; background: var(--panel-2); border-radius: 10px; padding: 8px;
}
.pos-pick-inner {
  position: relative; display: inline-block; line-height: 0; cursor: crosshair;
  touch-action: none; user-select: none;
}
.pos-pick-inner img { max-width: 100%; max-height: min(46vh, 380px); display: block; border-radius: 6px; pointer-events: none; }
.pos-dot {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 2.5px solid #fff; background: rgba(255, 90, 54, .55);
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.5); pointer-events: none;
}
.pos-zoom { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.pos-zoom input { flex: 1; accent-color: var(--accent); }
.pos-zoom b { color: var(--text); min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.pos-frame { position: relative; overflow: hidden; border-radius: 8px; background: var(--panel-2); outline: 1px solid var(--line); }
.pos-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pos-frame.cover { aspect-ratio: 16 / 10; width: 128px; }
.pos-frame.list { aspect-ratio: 4 / 3; width: 96px; }   /* same shape as the modification list */
.pos-frame.square { aspect-ratio: 1; width: 72px; }
.pos-previews { display: flex; gap: 14px; margin-top: 14px; align-items: flex-end; flex-wrap: wrap; }
.pos-previews > div { display: flex; flex-direction: column; gap: 4px; }
.pos-previews span { font-size: 12px; color: var(--muted); }

.car-hero .cover { position: relative; }
.cover-adjust {
  position: absolute; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 0; background: rgba(0,0,0,.65); color: #fff;
  font-size: 12px; font-weight: 600; opacity: 0; transition: opacity .15s;
}
.car-hero .cover:hover .cover-adjust, .cover-adjust:focus-visible { opacity: 1; }
.cover-adjust:hover { background: var(--accent); }
.thumb .x:hover { background: var(--danger); }
.add-thumb {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 12px;
}
.add-thumb:hover { color: var(--text); border-color: var(--accent); }
.add-thumb b { font-size: 22px; color: var(--accent); line-height: 1; }
.drop-hint { color: var(--muted); font-size: 12px; margin-top: 8px; text-align: center; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 6, 9, .7);
  display: grid; place-items: center; padding: 30px; z-index: 50;
  animation: fade .15s ease-out;
}
.modal {
  width: min(640px, 100%); max-height: calc(100vh - 60px);
  min-width: 0; max-width: 100%; /* never wider than the screen, whatever is inside */
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  animation: pop .18s ease-out;
}
.modal.wide { width: min(920px, 100%); }
.modal.small { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* mod detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.detail-head h2 { margin: 2px 0 0; font-size: 24px; }
.detail-price { font-size: 26px; font-weight: 800; white-space: nowrap; }
.detail-desc { white-space: pre-wrap; color: #c9cdd6; margin: 14px 0 0; }
.tabs { display: flex; gap: 4px; margin: 20px 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.gallery button { padding: 0; border: 0; background: var(--panel-2); border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.gallery button:hover img { transform: scale(1.04); }
.gallery-empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.94);
  display: grid; place-items: center; animation: fade .15s;
}
.lightbox img { max-width: calc(100vw - 140px); max-height: calc(100vh - 90px); object-fit: contain; border-radius: 4px; }
.lightbox .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #fff; font-size: 22px;
}
.lightbox .nav:hover { background: rgba(255,255,255,.18); }
.lightbox .prev { left: 24px; }
.lightbox .next { right: 24px; }
.lightbox .close { position: absolute; top: 16px; right: 20px; }
.lightbox .counter { position: absolute; bottom: 18px; color: #aaa; font-size: 13px; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #262b36; border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100;
  animation: pop .18s ease-out;
}

/* car page tabs + plan */
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 7px; font-weight: 600; }
.seg button span { font-size: 12px; opacity: .7; margin-left: 4px; }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* Modifications / Maintenance sub-tabs */
.subtabs { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.subtabs button {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
}
.subtabs button svg { width: 15px; height: 15px; }
.subtabs button span { font-weight: 500; font-size: 12px; opacity: .75; }
.subtabs button:hover { color: var(--text); border-color: #3a4150; }
.subtabs button.active { color: var(--text); border-color: var(--accent); background: rgba(255, 90, 54, .1); }
.subtabs button.active svg { color: var(--accent); }
.plan-note { font-size: 12.5px; }
.plan-row { grid-template-columns: 4px 1fr auto; padding-left: 0; overflow: hidden; }
.prio-bar { align-self: stretch; border-radius: 0 3px 3px 0; margin: -10px 0; }
.plan-notes { color: #b4bac6; font-size: 13px; margin-top: 6px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { background: none; border: 0; padding: 0; color: #7aa7ff; font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }
.done-btn { padding: 6px 12px; font-size: 13px; }
.done-btn:hover { border-color: #22c55e; color: #86efac; background: rgba(34, 197, 94, .12); }
.plan-total { display: flex; justify-content: flex-end; gap: 14px; align-items: baseline; padding: 14px 12px 0; color: var(--muted); }
.plan-total b { color: var(--text); font-size: 18px; }
.hero-stats .planned-stat b { color: var(--muted); }

.muted { color: var(--muted); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2f3a; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1050px) {
  .car-hero { grid-template-columns: 1fr; }
}

/* Touch screens: hover-revealed controls would be invisible but still tappable. */
@media (hover: none) {
  .car-card .card-menu, .mod-row .row-actions { display: none; }
  .car-card:hover { transform: none; box-shadow: none; }
  .thumb .x, .thumb .pos, .cover-adjust { opacity: 1; }
}

/* "New version available" bar (website / installed web app) */
.update-bar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 200; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 24px);
  padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--panel-2);
  border: 1px solid var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: 14px;
}
.update-bar .btn { flex-shrink: 0; }

/* Timeline tab */
.tl-stats { margin-bottom: 16px; }
.tl-charts { display: grid; gap: 14px; }
.tl-chart { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tl-chart figcaption { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.tl-chart figcaption b { font-size: 15px; }
.tl-chart figcaption span { color: var(--muted); font-size: 12.5px; }
.tl-plot { position: relative; }
.tl-plot svg { display: block; max-width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.tl-grid line { stroke: var(--line); stroke-width: 1; }
.tl-axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tl-dots circle, .tl-focus { stroke: var(--panel); stroke-width: 2; }
.tl-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tl-hit { cursor: crosshair; }
.tl-tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 120px; max-width: 240px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); font-size: 12.5px; display: grid; gap: 2px;
}
.tl-tip b { font-size: 15px; font-variant-numeric: tabular-nums; }
.tl-tip span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-tip .tl-tip-date { color: var(--text); font-weight: 600; }
.tl-note { margin-top: 10px; font-size: 13px; }
.tl-list { margin-top: 22px; display: grid; gap: 18px; }
.tl-month h3 {
  display: flex; justify-content: space-between; gap: 12px; margin: 0 0 6px; font-size: 14px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.tl-month h3 span { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.tl-item {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 6px; border-radius: 8px; cursor: pointer;
}
.tl-item:hover { background: var(--panel); }
.tl-item > i { width: 10px; height: 10px; border-radius: 50%; }
.tl-item b { font-size: 14.5px; font-weight: 600; }
.tl-item .meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-price { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Share window */
.share-body { display: grid; gap: 14px; }
.share-body > .check { margin: 0; }
.share-option {
  display: grid; grid-template-columns: 40px 1fr; gap: 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
}
.share-ico {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(255, 90, 54, .14); color: var(--accent);
}
.share-main { min-width: 0; }
.share-main h3 { margin: 2px 0 4px; font-size: 15px; }
.share-main p { margin: 0 0 10px; font-size: 13px; }
.share-link { display: flex; gap: 8px; }
.share-link input { flex: 1; min-width: 0; font-size: 13px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.share-body .check { margin: 0 0 10px; font-size: 13.5px; }
.share-card { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.share-card-actions { display: flex; flex-direction: column; gap: 8px; }
.card-preview, .cd-preview {
  aspect-ratio: 9 / 16; width: 130px; border-radius: 10px; overflow: hidden; background: var(--panel);
  display: grid; place-items: center; border: 1px solid var(--line); flex-shrink: 0;
}
.card-preview img, .cd-preview img { width: 100%; height: 100%; display: block; }

/* Build card designer */
.card-designer { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.cd-preview { width: 100%; }
.cd-controls { min-width: 0; }
/* contain: inline-size — the strip's width never depends on how many photos it holds, so a long
   strip scrolls instead of stretching the whole window (it made the window 40 photos wide). */
.cd-photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; contain: inline-size; }
.card-designer > *, .card-designer .field { min-width: 0; }
.cd-photos button {
  position: relative; flex: 0 0 64px; height: 64px; padding: 0; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; background: var(--panel-2); cursor: pointer;
}
.cd-photos button img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cd-photos button.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255, 90, 54, .3); }
.cd-mods { max-height: 290px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
.field .cd-mods label.check { font-size: 14px; color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 500; }
.cd-count { text-transform: none; letter-spacing: 0; }
.cd-mods .check { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cd-mods .check:last-child { border-bottom: 0; }
.cd-mods .check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-mods .check b { font-weight: 600; color: var(--muted); font-size: 13px; }
.cd-mods .check.disabled { opacity: .45; cursor: default; }
.cd-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cd-styles button {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer;
}
.cd-styles button i { width: 22px; height: 30px; border-radius: 5px; border: 1.5px solid rgba(255,255,255,.25); flex-shrink: 0; }
.cd-styles button.on { border-color: var(--accent); background: rgba(255, 90, 54, .1); }
.cd-colours { display: flex; gap: 10px; flex-wrap: wrap; }
.cd-colours button {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); cursor: pointer; padding: 0;
}
.cd-colours button.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px #fff; }
.cd-colour-field.off { opacity: .4; pointer-events: none; }
.cd-colour-field.off label::after { content: ' — this style has its own colours'; text-transform: none; letter-spacing: 0; font-weight: 400; }
.pos-frame.card-tall { aspect-ratio: 932 / 1592; width: 110px; }
.pos-frame.card-wide { aspect-ratio: 880 / 620; width: 190px; }

/* Public build page (shared link) */
body.public .topbar-actions { display: none; }
.public-cta {
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; margin-top: 28px;
  padding: 20px; border-radius: 14px; border: 1px solid rgba(255, 90, 54, .4);
  background: linear-gradient(135deg, rgba(255, 90, 54, .12), rgba(255, 90, 54, .03));
}
.public-cta h2 { margin: 0 0 4px; font-size: 18px; }
.public-cta p { margin: 0; font-size: 13.5px; }
.brand-mark.big { width: 48px; height: 48px; border-radius: 12px; }
.brand-mark.big svg { width: 28px; height: 28px; }

/* Admin dashboard */
.admin-link { gap: 6px; padding: 6px 12px; color: var(--accent); }
.admin-link svg { width: 16px; height: 16px; }
.user-list { display: grid; gap: 8px; }
.user-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.user-row:hover { border-color: #3a4150; background: #1a1d25; }
.user-row h3 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.user-row .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.user-row .avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 90, 54, .14); color: var(--accent); font-weight: 700;
}
.user-row .counts { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.user-row .counts b { color: var(--text); font-size: 14px; }
.admin-chip { background: rgba(255, 90, 54, .15); color: var(--accent); vertical-align: 2px; }
.admin-h2 { font-size: 16px; margin: 26px 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.admin-plan { display: grid; gap: 6px; }
.admin-plan > div {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}

/* Phones */
@media (max-width: 640px) {
  .public-cta { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  /* Stacked, with the preview's height set outright: a 9:16 box whose height only comes from
     aspect-ratio got a too-short row here, and the controls slid underneath it. */
  .garage-stats.tl-stats { grid-template-columns: 1fr 1fr; }
  .tl-chart { padding: 12px 10px; }
  .card-designer { display: flex; flex-direction: column; gap: 18px; }
  .cd-preview { width: min(240px, 62vw); height: calc(min(240px, 62vw) * 16 / 9); align-self: center; }
  .share-link { flex-direction: column; }
  .user-row { grid-template-columns: 36px 1fr; }
  .user-row .counts { grid-column: 1 / -1; gap: 14px; flex-wrap: wrap; }
  .admin-link span { display: none; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; gap: 10px; }
  .brand > span:last-child { display: none; }
  .view { padding: 16px 14px calc(48px + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 24px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 40%; justify-content: center; padding: 9px 10px; }
  .garage-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
  .stat { min-width: 0; padding: 10px 12px; }
  .stat b { font-size: 16px; }
  .stat span { font-size: 10px; }
  .car-grid { grid-template-columns: 1fr; gap: 12px; }
  .add-card { min-height: 90px; }

  .car-hero { padding: 12px; gap: 14px; margin-bottom: 16px; }
  .car-hero h1 { font-size: 24px; }
  .hero-stats { gap: 10px 18px; flex-wrap: wrap; margin: 12px 0; }
  .hero-stats b { font-size: 17px; }
  .hero-body .actions .btn { flex: 1 1 auto; justify-content: center; }

  .toolbar { gap: 8px; }
  .toolbar .spacer { display: none; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .search { flex: 1; min-width: 0; }
  .search input[type=search] { width: 100%; }
  .plan-note { width: 100%; font-size: 12px; }

  .mod-row { grid-template-columns: 64px 1fr auto; gap: 10px; padding: 8px; }
  .mod-thumb { width: 64px; height: 56px; }
  .mod-row h3 { font-size: 15px; }
  .mod-row .meta { gap: 4px 10px; }
  .mod-row .price { font-size: 15px; min-width: 0; }
  .plan-row { grid-template-columns: 4px 1fr auto; padding-left: 0; }
  .plan-row .right { flex-direction: column; align-items: flex-end; gap: 6px; }

  /* Modals become bottom sheets. */
  .modal-backdrop { padding: 0; align-items: end; justify-items: stretch; }
  .modal, .modal.wide, .modal.small {
    width: 100%; max-height: calc(100vh - env(safe-area-inset-top) - 16px);
    border-radius: 18px 18px 0 0; border-bottom: 0;
  }
  .modal-head { padding: 16px 16px 0; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .row.c2, .row.c3, .row.c4 { grid-template-columns: 1fr 1fr; }
  .row.c3 > :first-child, .row.c4 > :first-child { grid-column: 1 / -1; }
  #mod-form .row.c2 { grid-template-columns: 1fr; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .detail-head h2 { font-size: 20px; }
  .detail-price { font-size: 20px; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .lightbox img { max-width: 100vw; max-height: calc(100vh - 140px); border-radius: 0; }
  .lightbox .nav { top: auto; bottom: calc(20px + env(safe-area-inset-bottom)); transform: none; }
  .lightbox .close { top: calc(12px + env(safe-area-inset-top)); }
  .lightbox .counter { bottom: calc(34px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); text-align: center; }
}

/* Sign-in screen (web version) */
.auth {
  position: fixed; inset: 0; z-index: 120; overflow-y: auto;
  display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(255, 90, 54, .18), transparent 60%), var(--bg);
}
.auth-card {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); animation: pop .2s ease-out;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 22px; }
.auth-brand b { color: var(--accent); }
.auth-card h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.auth-card > .muted { margin: 4px 0 20px; }
.auth-submit { width: 100%; justify-content: center; padding: 11px 16px; margin-top: 4px; }
.auth-submit:disabled { opacity: .6; cursor: default; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.auth-links button { background: none; border: 0; padding: 0; color: var(--accent-2); font-size: 13.5px; }
.auth-links button:hover { text-decoration: underline; }
.auth-notice, .auth-error { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.auth-notice { background: rgba(34, 197, 94, .12); color: #86efac; border: 1px solid rgba(34, 197, 94, .3); }
.auth-error { background: rgba(239, 68, 68, .12); color: #fca5a5; border: 1px solid rgba(239, 68, 68, .3); }
.auth input[type=password], .auth input[type=text] { width: 100%; }

/* Bottom-sheet chooser used by the Android build (camera / gallery). */
.sheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(5, 6, 9, .6); display: flex; align-items: flex-end; animation: fade .15s; }
.sheet { width: 100%; background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); animation: pop .18s ease-out; }
.sheet h3 { margin: 6px 10px 10px; font-size: 15px; color: var(--muted); font-weight: 600; }
.sheet button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 12px; background: none; border: 0; border-radius: 10px; font-size: 16px; text-align: left; }
.sheet button:active { background: var(--panel-2); }
.sheet button svg { width: 22px; height: 22px; color: var(--accent); }
