:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1d2228; --muted: #5f6b77; --border: #dde1e6;
  --accent: #2563eb; --accent-ink: #ffffff; --ok: #1e7b45; --warn: #a76100; --bad: #b3261e; --info: #1f5fa8;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --panel: #1d2127; --text: #e7eaee; --muted: #9aa5b1; --border: #313842;
    --accent: #60a5fa; --accent-ink: #0b1220; --ok: #5cc98a; --warn: #f0b155; --bad: #ff8a80; --info: #79b0f0;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--info); }
h1, h2, h3 { line-height: 1.25; }
.muted { color: var(--muted); }
.error { color: var(--bad); }

button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
button { padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--info); text-decoration: underline; }
label { display: block; margin-bottom: 10px; font-weight: 500; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }

.topbar { position: sticky; top: 0; z-index: 10; height: 56px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar .brand { margin: 0; color: var(--text); text-decoration: none; }
.topbar .tagline { font-size: 13px; font-weight: 400; margin-left: 6px; }
.auth-area { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.auth-area .who { font-size: 14px; color: var(--muted); }
a.button { display: inline-block; padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel);
  color: var(--text); text-decoration: none; }
a.button:hover { border-color: var(--muted); }
a.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.members-tag { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 4px; }
.vehicle-name { font-weight: 600; }
.vehicle-detail { font-size: 13px; }

/* ---------- Vehicle bar (under the top bar) ---------- */
.vehicle-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); border-left: 4px solid var(--accent); }
.vehicle-bar:empty { display: none; }
.vbar-current { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.vbar-current .vehicle-name { font-size: 17px; }
.vbar-current select { width: auto; max-width: 100%; font-weight: 600; }
.vbar-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.vbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.vehicle-bar.open { display: block; padding: 14px 16px 6px; }
.vbar-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.vbar-head h2 { margin: 0; font-size: 18px; }
.vbar-head .muted { font-size: 13px; }
.vbar-close { margin-left: auto; }
.vbar-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; align-items: start; }
.vbar-fields label { margin-bottom: 8px; }
.vbar-engine { grid-column: span 2; }
.vbar-submit { display: flex; gap: 6px; align-items: flex-end; padding-top: 23px; margin-bottom: 8px; }
.vbar-submit .primary { flex: 1; white-space: nowrap; }
.vbar-more { grid-column: 1 / -1; margin-bottom: 8px; }
.vbar-more summary { cursor: pointer; color: var(--info); font-size: 14px; margin-bottom: 8px; }
.step { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); font-size: 11px; font-weight: 700; margin-right: 2px; vertical-align: 1px; }
.vbar-vin { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; font-size: 14px; }
.vbar-vin .search { flex: 0 1 340px; }
.vbar-vin .search button { white-space: nowrap; }
.vbar-signin { font-size: 13px; margin: 0 0 8px; }
@media (max-width: 800px) {
  .vbar-engine { grid-column: auto; }
  .vbar-submit { padding-top: 0; }
}
.engine-hint { display: block; margin-top: 4px; font-weight: 400; font-size: 12px; }

.layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 16px; overflow-y: auto;
  max-height: calc(100vh - 56px); position: sticky; top: 56px; }
.sidebar section { margin-bottom: 20px; }
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.brand { font-weight: 700; font-size: 17px; }
.row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.search { display: flex; gap: 6px; }
.search .clear-q { padding: 7px 9px; color: var(--muted); }
.link-list { list-style: none; padding: 0; margin: 8px 0; }
.link-list li { padding: 3px 0; }
ol.link-list { list-style: decimal; padding-left: 22px; }
.link-list a.active { font-weight: 700; color: var(--accent); }
.account { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }

.main { padding: 24px; max-width: 1100px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin-top: 0; font-size: 19px; }
.card.highlight { border-left: 4px solid var(--accent); }
.card.error { border-left: 4px solid var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.tile h3 { margin: 0 0 6px; font-size: 15px; }
.results { list-style: none; padding: 0; margin: 0; }
.results li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.results li:last-child { border-bottom: 0; }
.results .domain { font-size: 13px; color: var(--ok); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.overdue { color: var(--bad); } .badge.due_soon { color: var(--warn); }
.badge.ok { color: var(--ok); } .badge.no_record { color: var(--muted); } .badge.oem { color: var(--info); }
.diagram-preview { max-width: 100%; max-height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
iframe.diagram-preview { width: 100%; height: 70vh; }
.table-wrap { overflow-x: auto; }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 400px; }
.auth-card h1 { margin-top: 0; font-size: 22px; }
.auth-card button { width: 100%; margin: 6px 0 12px; }
.helptext, .auth-card ul { font-size: 13px; color: var(--muted); }

/* ---------- Search all: right-hand price panel ---------- */
.layout { grid-template-columns: 300px minmax(0, 65fr) minmax(0, 35fr); }
.results-panel { background: var(--panel); border-right: 1px solid var(--border); padding: 16px; overflow-y: auto;
  max-height: calc(100vh - 56px); position: sticky; top: 56px; }
.results-panel h2 { font-size: 17px; margin: 0 0 4px; }
.panel-sub { margin: 0 0 10px; font-size: 13px; }
.panel-note { font-size: 12px; margin-top: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tab { border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; background: none; padding: 6px 8px;
  font-size: 13px; color: var(--muted); margin-bottom: -1px; }
.tab.active { border-color: var(--border); background: var(--panel); color: var(--text); font-weight: 600; }
.tab .count { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 999px; background: var(--bg);
  font-size: 11px; text-align: center; }
.showing { font-size: 12px; margin: 4px 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-items: end;
  padding: 10px; margin-bottom: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.filters label { margin: 0; font-size: 12px; color: var(--muted); }
.filters select, .filters input[type=number] { padding: 5px 7px; font-size: 13px; }
.filters .check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.filters .check input { width: auto; margin: 0; }
.filters .clear { justify-self: start; }
.access-summary { margin: 4px 0 8px; font-size: 14px; }
.legend { font-size: 12px; margin: -4px 0 10px; }
.chip.manual { border-style: dashed; }
.chip.manual.blocked { border-color: var(--warn); color: var(--text); }
.chip.was-opened { opacity: .75; }
.opened { font-size: 12px; color: var(--ok); white-space: nowrap; }
.lock { margin-left: 4px; font-size: 13px; cursor: help; }
.access-icon { font-size: 18px; }
a.manual-open { font-weight: 600; }
.site-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip { display: inline-block; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px;
  background: var(--panel); color: var(--text); text-decoration: none; }
.chip.priced { border-color: var(--ok); cursor: pointer; }
.chip.priced.active { background: var(--ok); color: #fff; border-color: var(--ok); }
.chip.priced.dim { opacity: .8; }
.site-filter-note { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; }
.chip.muted { color: var(--muted); }
a.chip { color: var(--info); }
.more-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.onsite-head { font-size: 14px; margin: 16px 0 4px; }
.onsite-row .price-main { color: var(--muted); }
.st-feedback { white-space: nowrap; }
.st-feedback .fb { padding: 0 7px; margin-left: 2px; }
.st-feedback .fb.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin: 4px 0 6px; }
.list-head .showing { margin: 0; }
.pager-top { margin-top: 0; }
.saved-head { justify-content: space-between; align-items: center; margin-top: 0; }
.saved-head label { margin: 0; font-size: 13px; }
.saved-head select { width: auto; }
@media (min-width: 1201px) {
  /* Two columns: price (or icon) on the left; title, details and badges stacked on the right. */
  .price-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 2px 14px; align-items: start; }
  .price-row .price-main { grid-row: 1 / span 3; flex-direction: column; gap: 0; }
  .price-row > :not(.price-main) { grid-column: 2; min-width: 0; }
  .price-row.onsite-row { grid-template-columns: 32px minmax(0, 1fr); }
}
.fresh { margin: 4px 0; font-size: 13px; }
.price-list { list-style: none; padding: 0; margin: 0; }
.price-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.price-row:last-child { border-bottom: 0; }
.price-main { display: flex; align-items: baseline; gap: 8px; }
.price { font-size: 18px; font-weight: 700; }
.core { font-size: 12px; }
.price-title { font-size: 14px; margin: 2px 0; overflow-wrap: anywhere; }
.price-meta { font-size: 12px; }
.price-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.badge.site { color: var(--text); }
.badge.fits { color: var(--ok); }
button.mini { padding: 2px 8px; font-size: 12px; }
.price-mini { margin-left: 4px; padding: 0 6px; line-height: 18px; }
.save-btn { margin-left: auto; padding: 2px 8px; font-size: 12px; }
.save-btn[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); }
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.pager .pg { padding: 3px 8px; font-size: 13px; min-width: 32px; }
.pager .pg.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.pager .pg:disabled { opacity: .45; cursor: default; }

/* ---------- Search all: live status window ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-card { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.overlay-card h2 { margin: 0 0 10px; font-size: 18px; }
.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar { height: 100%; background: var(--accent); transition: width .4s ease; }
.status-table td { padding: 6px; font-size: 14px; }
.status-table .st-icon { width: 28px; text-align: center; }
.status-table .st-msg { font-size: 12px; }
.status-table tr.st-running td { font-weight: 600; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
  .sidebar { grid-row: span 2; }
  .results-panel, .main { grid-column: 2; }
  .results-panel { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 800px) {
  .results-panel, .main { grid-column: 1; }
  .sidebar { grid-row: auto; }
  .topbar .brand .muted, .auth-area .who { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 16px; }
}
