/* AutoLog */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --text: #1c2430;
  --muted: #667180;
  --border: #e3ded5;
  --accent: #d2601a;
  --accent-hover: #b9510f;
  --accent-soft: #fbeadf;
  --ink-on-accent: #ffffff;
  --top: #1c2430;
  --top-text: #e9ecef;
  --ok: #2c7a4b;      --ok-soft: #e3f3e9;
  --warn: #9a6400;    --warn-soft: #fbf0d6;
  --bad: #b8322a;     --bad-soft: #fbe3e1;
  --info-soft: #e6eef8; --info: #2b5c93;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 36, 48, .06), 0 4px 14px rgba(28, 36, 48, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2028;
    --surface-2: #151a21;
    --text: #e6e9ed;
    --muted: #98a2ae;
    --border: #2b333e;
    --accent: #ef8743;
    --accent-hover: #f59a5e;
    --accent-soft: #3a2619;
    --ink-on-accent: #1a1209;
    --top: #0b0e12;
    --top-text: #e6e9ed;
    --ok: #6cc893;      --ok-soft: #173325;
    --warn: #e9b44c;    --warn-soft: #382c12;
    --bad: #f1786e;     --bad-soft: #3d1c1a;
    --info-soft: #18263a; --info: #8db6e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
img { max-width: 100%; display: block; }
.ico { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, td.num, .stat b { font-variant-numeric: tabular-nums; }

/* ---------- top bar */
.topbar { background: var(--top); color: var(--top-text); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { color: var(--top-text); font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.brand .ico { color: #ef8743; width: 22px; height: 22px; }
.brand:hover { text-decoration: none; }
.mainnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.mainnav a, .mainnav .linkbtn { color: var(--top-text); opacity: .8; padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.mainnav a:hover, .mainnav .linkbtn:hover { opacity: 1; background: rgba(255, 255, 255, .08); text-decoration: none; }
.mainnav a.on { opacity: 1; background: rgba(255, 255, 255, .12); }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; }
form.inline { display: inline; margin: 0; }

/* ---------- layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.wrap.narrow { max-width: 680px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.backlink { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .92rem; margin-bottom: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.nowrap { white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
a.row-item { color: inherit; }
a.row-item:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- alerts */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; line-height: 1.2; min-height: 40px;
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink-on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.small { padding: 6px 11px; font-size: .875rem; min-height: 34px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}

/* ---------- forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; width: 100%; min-height: 42px;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input[type=file] { padding: 7px; background: var(--surface-2); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.grid2, .grid3, .grid4 { display: grid; gap: 14px; }
@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
  .grid4 { grid-template-columns: repeat(4, 1fr); }
}
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 4px; }
.form-actions .spacer { flex: 1; }

/* ---------- tags & status */
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.tag.subtle { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.overdue, .status.expired { background: var(--bad-soft); color: var(--bad); }
.status.soon { background: var(--warn-soft); color: var(--warn); }
.status.ok, .status.active { background: var(--ok-soft); color: var(--ok); }
.status.unknown, .status.none { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* License plate badge */
.plate {
  display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700; letter-spacing: .08em; font-size: .85rem; padding: 2px 8px; border-radius: 5px;
  background: #fdfdfb; color: #1b2a4a; border: 2px solid #1b2a4a; text-transform: uppercase;
}
.plate small { font-family: system-ui, sans-serif; letter-spacing: 0; font-size: .65rem; font-weight: 600; opacity: .75; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .03em; }

/* ---------- auth */
body.bare { background: linear-gradient(160deg, var(--top) 0 260px, var(--bg) 260px); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; max-width: 420px; margin: 40px auto 0; }
.auth-card.wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; color: var(--accent); margin-bottom: 18px; }
.auth-brand .ico { width: 26px; height: 26px; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 8px; font-size: .92rem; }
.checks li.ok { background: var(--ok-soft); color: var(--ok); }
.checks li.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- dashboard */
.vgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.vcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); color: inherit; display: flex; flex-direction: column; transition: transform .12s ease, box-shadow .12s ease; }
.vcard:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 22px rgba(28, 36, 48, .12); }
.vcard .ph { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.vcard .ph img { width: 100%; height: 100%; object-fit: cover; }
.vcard .ph .ico { width: 48px; height: 48px; opacity: .4; }
.vcard .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.vcard .title { font-weight: 700; font-size: 1.05rem; }
.vcard .sub { color: var(--muted); font-size: .9rem; }
.vcard .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.vcard.add { border-style: dashed; align-items: center; justify-content: center; min-height: 200px; color: var(--muted); gap: 6px; font-weight: 600; box-shadow: none; }
.vcard.add .ico { width: 32px; height: 32px; }

.attention .row-item { gap: 10px; }

/* ---------- vehicle header */
.vhead { display: grid; gap: 20px; margin-bottom: 18px; }
@media (min-width: 760px) { .vhead { grid-template-columns: 320px 1fr; align-items: start; } }
.vhead .photo { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 16 / 10; display: grid; place-items: center; border: 1px solid var(--border); }
.vhead .photo img { width: 100%; height: 100%; object-fit: cover; }
.vhead .photo .ico { width: 56px; height: 56px; opacity: .35; }
.vhead h1 { margin-bottom: 4px; }
.vmeta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); margin: 8px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 1.2rem; }

/* ---------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: .75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; color: var(--muted); }

/* ---------- tables */
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .sub { color: var(--muted); font-size: .85rem; }
@media (max-width: 700px) {
  .table.stack-sm thead { display: none; }
  .table.stack-sm tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table.stack-sm tr:last-child { border-bottom: 0; }
  .table.stack-sm td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .table.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; font-weight: 600; text-align: left; }
  .table.stack-sm td.lead { display: block; text-align: left; font-weight: 600; padding-bottom: 4px; }
  .table.stack-sm td.lead::before { content: none; }
  .table.stack-sm td:empty { display: none; }
}

/* ---------- photos */
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { width: 132px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); color: inherit; display: flex; flex-direction: column; }
.thumb:hover { text-decoration: none; border-color: var(--accent); }
.thumb .img { aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; }
.thumb .img img { width: 100%; height: 100%; object-fit: cover; }
.thumb .img .ico { width: 34px; height: 34px; color: var(--muted); }
.thumb .cap { font-size: .78rem; padding: 5px 8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-field { display: flex; gap: 12px; align-items: center; }
.photo-field .current { width: 84px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); flex: none; background: var(--surface-2); }
.photo-field .current img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- specs */
.specs { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.specs .card { margin: 0; }
.specs dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.specs dt, .specs dd { padding: 7px 0; border-bottom: 1px solid var(--border); margin: 0; font-size: .92rem; }
.specs dt { color: var(--muted); padding-right: 10px; }
.specs dd { font-weight: 600; overflow-wrap: anywhere; }
.specs dl > :nth-last-child(-n+2) { border-bottom: 0; }
.spec-edit-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.spec-edit-row:last-child { border-bottom: 0; }
.spec-edit-row .lbl { font-size: .92rem; color: var(--muted); font-weight: 600; }
@media (max-width: 560px) { .spec-edit-row { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- parts editor */
.part-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface-2); position: relative; display: grid; gap: 12px; }
.part-row + .part-row { margin-top: 12px; }
.part-row .remove { position: absolute; top: 8px; right: 8px; }
.part-row .warranty { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.part-row .warranty label:not(.check) { flex: 1 1 120px; }
.part-row .warranty label.check { padding-bottom: 10px; }
.reminder-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* ---------- dropdown menu (details) */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .15); padding: 14px; width: 280px; display: grid; gap: 12px; }

/* ---------- misc */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--text); }
.empty .ico { width: 40px; height: 40px; margin: 0 auto 10px; opacity: .5; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 320px; }
.desc { white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.split { display: grid; gap: 16px; }
@media (min-width: 860px) { .split { grid-template-columns: 1.4fr 1fr; align-items: start; } }

@media (max-width: 560px) {
  .wrap { padding-top: 16px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .topbar-in { gap: 8px; }
  .brand span { display: none; }
  .mainnav a, .mainnav .linkbtn { padding: 6px 8px; font-size: .9rem; }
}
@media print {
  .topbar, .tabs, .actions, .btn, .backlink { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
details.card > summary { cursor: pointer; }
details.card > summary h2 { margin: 0; }
details > summary.muted { cursor: pointer; }
/* Keep photos cropped to their frame regardless of the original's shape */
.vcard .ph, .vhead .photo, .thumb .img, .photo-field .current { position: relative; overflow: hidden; }
.vcard .ph img, .vhead .photo img, .thumb .img img, .photo-field .current img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.grid2, .grid3, .grid4 { align-items: end; }
.part-row { padding-top: 46px; }
.part-row .remove { top: 8px; right: 8px; }
.part-row::before { content: ""; position: absolute; top: 14px; left: 14px; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
