/* Haninge Bilteknik – gränssnitt
   Dämpad röd + grafit. Mobil först: inköpstester görs med telefonen vid bilen. */

:root {
  --bg: #f3f2f0;
  --surface: #ffffff;
  --surface-2: #faf9f8;
  --ink: #23272b;
  --ink-2: #464c52;
  --muted: #6b7178;
  --line: #e4e1dd;
  --line-2: #d3cfca;
  --brand: #8f2d2d;
  --brand-600: #782424;
  --brand-50: #f7eded;
  --graphite: #23272b;
  --graphite-2: #2e3338;
  --side-ink: #c9c6c2;
  --ok: #2f7d4f;   --ok-50: #e9f4ee;
  --warn: #a8701a; --warn-50: #fbf3e4;
  --bad: #a3322f;  --bad-50: #f9eaea;
  --na: #6b7178;   --na-50: #efeeec;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(35, 39, 43, .06), 0 1px 1px rgba(35, 39, 43, .04);
  --shadow-lg: 0 12px 32px rgba(35, 39, 43, .18);
  --side-w: 248px;
  --side-w-min: 72px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code { font-family: var(--mono); font-size: .9em; background: var(--na-50); padding: 1px 5px; border-radius: 4px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.h2 { font-size: 20px; margin: 0; line-height: 1.25; }
.h3 { font-size: 15px; margin: 24px 0 10px; }
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; }

/* ── Skal & sidomeny ─────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  width: var(--side-w); flex: none;
  background: var(--graphite); color: var(--side-ink);
  display: flex; flex-direction: column;
  transition: width .18s ease;
  z-index: 40;
}
.sidebar-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 14px 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none !important; min-width: 0; flex: 1; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; flex: none; }
.brand-mark .icon { width: 20px; height: 20px; color: #fff; }
.brand-text { font-weight: 700; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle .when-closed { display: none; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 8px; border: 0; background: none;
  color: var(--side-ink); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
  text-decoration: none !important; white-space: nowrap; position: relative;
}
.nav-link span { overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover { background: var(--graphite-2); color: #fff; }
.nav-link.active { background: var(--graphite-2); color: #fff; font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #d0605b; }
.nav-link.active .icon { color: #e0827d; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot form { margin: 0; }
.user-line { display: flex; flex-direction: column; line-height: 1.2; }
.user-line strong { color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.user-line small { color: #9a9894; font-size: 12px; }

/* Ihopfälld meny (dator) */
@media (min-width: 900px) {
  .nav-collapsed .sidebar { width: var(--side-w-min); }
  .nav-collapsed .brand-text, .nav-collapsed .nav-link > span { display: none; }
  .nav-collapsed .sidebar-head { justify-content: center; padding: 14px 0; }
  .nav-collapsed .brand { display: flex; flex: none; }
  .nav-collapsed .user-line { display: none; }
  .nav-collapsed .nav-toggle .when-open { display: none; }
  .nav-collapsed .nav-toggle .when-closed { display: block; }
  .nav-collapsed .nav-link { justify-content: center; padding: 11px 0; }
  .nav-collapsed .nav-link.active::before { left: -10px; }
}

.nav-backdrop { display: none; }
.mobile-only { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  min-height: 64px; padding: 10px 28px;
  background: rgba(243, 242, 240, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1100px; }
.content.wide { max-width: 1280px; }

@media (max-width: 899px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; width: min(84vw, 300px); box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 22, 25, .45); z-index: 35; }
  .nav-toggle { display: none; }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 8px 12px; min-height: 56px; gap: 6px; }
  .page-title { font-size: 17px; }
  .content { padding: 16px 12px 40px; }
  .hide-sm { display: none; }
  .topbar-actions .btn { padding: 8px 10px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn span:only-child { display: inline; }
}

/* ── Knappar ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none !important;
  transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-ghost.danger, .icon-btn.danger { color: var(--bad); }
.btn-ghost.danger:hover { border-color: var(--bad); background: var(--bad-50); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: 13.5px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.loading { opacity: .7; cursor: progress; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-link:focus-visible { outline: 3px solid rgba(143, 45, 45, .35); outline-offset: 2px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  text-decoration: none !important;
}
.icon-btn:hover { background: rgba(35, 39, 43, .07); color: var(--ink); }
.icon-btn.mobile-only { display: none; }
@media (max-width: 899px) { .icon-btn.mobile-only { display: inline-grid; } }

/* ── Kort & block ────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 14px; }
.card-title .icon { color: var(--brand); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 16px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; font-size: 14.5px; }
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--ok-50); border-color: #bcdcc9; color: #1f5a37; }
.alert-error { background: var(--bad-50); border-color: #e6c0bf; color: #7d2522; }
.alert-warn { background: var(--warn-50); border-color: #ecd4a8; color: #6f4a10; }
.alert-info { background: #eef1f4; border-color: #d5dbe1; color: #33404c; }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--na-50); color: var(--ink-2); white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badge-ok, .st-ok { background: var(--ok-50); color: var(--ok); }
.badge-warn, .st-anm { background: var(--warn-50); color: var(--warn); }
.badge-bad, .st-fel { background: var(--bad-50); color: var(--bad); }
.st-na { background: var(--na-50); color: var(--na); }
.badge-brand { background: var(--brand-50); color: var(--brand); }

.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state > .icon { width: 44px; height: 44px; color: var(--line-2); margin: 0 auto 12px; }
.empty-state h2 { color: var(--ink); font-size: 18px; margin: 0 0 8px; }
.empty-state.coming { max-width: 560px; margin: 0 auto; }
.empty-state.coming > .icon { color: var(--brand); opacity: .75; }
.plan-list { list-style: none; padding: 0; margin: 16px 0 0; text-align: left; display: grid; gap: 8px; }
.plan-list li { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--ink); }
.plan-list .icon { color: var(--ok); width: 18px; height: 18px; margin-top: 2px; }

/* ── Formulär ────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field > span small { font-weight: 400; color: var(--muted); }
.field em.req { font-style: normal; font-weight: 600; color: var(--bad); font-size: 12px; margin-left: 4px; }
.field em.opt, .block-label em.opt { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.block-label em.req { font-style: normal; font-weight: 600; color: var(--bad); font-size: 12px; margin-left: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface);
  min-height: 44px; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(143, 45, 45, .14); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.form-actions .danger { margin-right: auto; }
.input-plate { text-transform: uppercase; font-weight: 700; letter-spacing: .08em; font-size: 20px !important; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; font-size: 18px; font-weight: 600; }
.input-unit span { display: grid; place-items: center; padding: 0 14px; border: 1px solid var(--line-2); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--muted); font-weight: 600; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 6px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--muted); font-size: 13px; }
.check.big, .with-extra { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.with-extra { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.with-extra > label:first-child { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; flex: 1 1 260px; }
.with-extra > label:first-child input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); }
.with-extra > label:first-child span { display: flex; flex-direction: column; }
.with-extra > label:first-child small { color: var(--muted); font-size: 13px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline input { width: 110px; } .field.inline select { width: auto; }
.dim { opacity: .45; }
.option-list { display: grid; gap: 10px; }
.field-check { align-self: end; padding-bottom: 8px; }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button, .segmented label span { display: block; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 5px; color: var(--ink-2); cursor: pointer; }
.segmented button.on, .segmented input:checked + span { background: var(--graphite); color: #fff; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented.wide { display: flex; }
.segmented.wide label { flex: 1 1 auto; text-align: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { padding-left: 38px; text-transform: uppercase; }
.search input::placeholder { text-transform: none; }

/* ── Tabeller ────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-2); }
tr.inactive td, .inactive { opacity: .55; }

@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; }
  .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .table.responsive td { border: 0; padding: 0; text-align: left !important; }
  .table.responsive td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .table.responsive td:first-child { grid-column: 1 / -1; }
  .table.responsive td:first-child::before { display: none; }
}

/* ── Regskylt ────────────────────────────────────────────────────────── */
.plate {
  display: inline-flex; align-items: center; font-family: var(--font); font-weight: 800; letter-spacing: .08em;
  color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 5px;
  padding: 1px 8px 1px 14px; font-size: 14px; line-height: 1.5; position: relative; white-space: nowrap; text-decoration: none !important;
}
.plate::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: #1f4ea3; border-radius: 2px 0 0 2px; }
.plate-lg { font-size: 22px; padding: 2px 12px 2px 20px; border-width: 2.5px; }
.plate-lg::before { width: 10px; }

/* ── Nyckeltal ───────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none !important; }
.kpi span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi strong { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi strong small { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi.bad strong { color: var(--bad); } .kpi.warn strong { color: var(--warn); }
.kpi.link:hover { border-color: var(--line-2); }

.welcome { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.welcome p { margin: 2px 0 0; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li + li { border-top: 1px solid var(--line); }
.link-list a { display: flex; align-items: center; gap: 12px; padding: 10px 2px; color: var(--ink); text-decoration: none; }
.link-list a:hover .grow { color: var(--brand); }
.link-list .grow { display: flex; flex-direction: column; }
.link-list small { color: var(--muted); font-size: 12.5px; }
.link-list .icon { color: var(--muted); width: 18px; height: 18px; }
.roadmap { margin-top: 16px; }
.roadmap p { margin: 0; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 12px; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; font-weight: 500; }
.dl.roles { grid-template-columns: 130px 1fr; }
@media (max-width: 520px) { .dl, .dl.roles { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }

/* ── Inköpstest: steg-vy ─────────────────────────────────────────────── */
.run { max-width: 720px; margin: 0 auto; padding-bottom: 90px; }
.vehicle-bar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.vehicle-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.vehicle-meta span { color: var(--muted); font-size: 13.5px; }
.progress-wrap { margin: 4px 2px 14px; }
.progress { height: 8px; background: #e2dfdb; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .3s ease; }
.progress-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }
.save-state.good { color: var(--ok); } .save-state.bad { color: var(--bad); font-weight: 600; }

.step { padding: 20px; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.step-section { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); }
.step-title { font-size: 24px; margin: 6px 0 4px; line-height: 1.2; letter-spacing: -.01em; }
.step-help { display: flex; gap: 8px; color: var(--muted); margin: 0 0 6px; font-size: 14.5px; }
.step-help .icon { width: 17px; height: 17px; margin-top: 2px; }
.block { margin-top: 18px; }
.block-label { font-size: 13.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; }
.block-label small { font-weight: 400; color: var(--muted); margin-left: 6px; }

.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.status-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 76px; padding: 10px 6px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: var(--surface); font: inherit; font-weight: 700; font-size: 14px; color: var(--ink-2); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: all .12s;
}
.status-btn .icon { width: 24px; height: 24px; }
.status-btn.st-ok, .status-btn.st-anm, .status-btn.st-fel, .status-btn.st-na { background: var(--surface); }
.status-btn.st-ok .icon { color: var(--ok); } .status-btn.st-anm .icon { color: var(--warn); } .status-btn.st-fel .icon { color: var(--bad); } .status-btn.st-na .icon { color: var(--na); }
.status-btn.st-ok.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.status-btn.st-anm.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.status-btn.st-fel.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.status-btn.st-na.on { background: var(--na); border-color: var(--na); color: #fff; }
.status-btn.on .icon { color: #fff !important; }
@media (max-width: 420px) { .status-grid { grid-template-columns: repeat(2, 1fr); } .status-btn { min-height: 60px; flex-direction: row; } }

.grade-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
@media (max-width: 560px) { .grade-grid { grid-template-columns: repeat(5, 1fr); } }
.grade-btn {
  display: grid; place-items: center; min-height: 48px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: var(--surface); font: inherit; font-size: 18px; font-weight: 800; color: var(--ink-2); cursor: pointer;
  -webkit-tap-highlight-color: transparent; position: relative;
}
.grade-btn.on, .grade-grid.radio input:checked + span { color: #fff; }
.grade-btn.g1.on, .grade-btn.g2.on, .grade-btn.g3.on { background: var(--bad); border-color: var(--bad); }
.grade-btn.g4.on, .grade-btn.g5.on, .grade-btn.g6.on { background: var(--warn); border-color: var(--warn); }
.grade-btn.g7.on, .grade-btn.g8.on, .grade-btn.g9.on, .grade-btn.g10.on { background: var(--ok); border-color: var(--ok); }
.grade-grid.radio .grade-btn { padding: 0; overflow: hidden; }
.grade-grid.radio input { position: absolute; opacity: 0; }
.grade-grid.radio span { display: grid; place-items: center; width: 100%; height: 100%; min-height: 44px; }
.grade-grid.radio .g1 input:checked + span, .grade-grid.radio .g2 input:checked + span, .grade-grid.radio .g3 input:checked + span { background: var(--bad); }
.grade-grid.radio .g4 input:checked + span, .grade-grid.radio .g5 input:checked + span, .grade-grid.radio .g6 input:checked + span { background: var(--warn); }
.grade-grid.radio .g7 input:checked + span, .grade-grid.radio .g8 input:checked + span, .grade-grid.radio .g9 input:checked + span, .grade-grid.radio .g10 input:checked + span { background: var(--ok); }
.grade-grid.radio input:focus-visible + span { outline: 3px solid rgba(143,45,45,.35); }

.grade-pill { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 99px; font-weight: 800; font-size: 13.5px; color: #fff; background: var(--na); }
.grade-pill.g1, .grade-pill.g2, .grade-pill.g3 { background: var(--bad); }
.grade-pill.g4, .grade-pill.g5, .grade-pill.g6 { background: var(--warn); }
.grade-pill.g7, .grade-pill.g8, .grade-pill.g9, .grade-pill.g10 { background: var(--ok); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; margin: 0; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--na-50); }
.photo img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-del { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 99px; border: 0; background: rgba(20,22,25,.72); color: #fff; display: grid; place-items: center; cursor: pointer; }
.photo-del .icon { width: 16px; height: 16px; }
.photo-loading { width: 100%; height: 100%; display: grid; place-items: center; }
.photo-add { aspect-ratio: 1; border: 2px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--brand); font: inherit; font-size: 13px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.photo-add .icon { width: 28px; height: 28px; }
.photo-add.alt { color: var(--ink-2); }
.photo-add:hover { border-color: var(--brand); }
.spinner { width: 24px; height: 24px; border: 3px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.step-problems { display: flex; gap: 8px; align-items: center; margin-top: 18px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-50); color: var(--bad); font-weight: 600; font-size: 14px; }
.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.step-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: 1fr auto 1.3fr; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.step-nav .btn { min-height: 52px; font-size: 15.5px; }
@media (min-width: 900px) {
  .step-nav { left: var(--side-w); }
  .nav-collapsed .step-nav { left: var(--side-w-min); }
  .step-nav { padding-left: calc((100% - 720px) / 2); padding-right: calc((100% - 720px) / 2); }
}
@media (max-width: 420px) { .step-nav #btn-overview span, .step-nav #btn-prev span { display: none; } .step-nav { grid-template-columns: auto auto 1fr; } }

/* Översiktslåda */
.drawer { position: fixed; inset: 0; z-index: 60; background: rgba(20,22,25,.45); opacity: 0; pointer-events: none; transition: opacity .18s; }
.drawer.open { opacity: 1; pointer-events: auto; }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--surface); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.drawer-body h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); margin: 18px 4px 6px; display: flex; justify-content: space-between; }
.drawer-body h3 small { color: var(--muted); }
.drawer-body ul { list-style: none; margin: 0; padding: 0; }
.drawer-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.ov-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 8px; border: 0; background: none; border-radius: 6px; font: inherit; font-size: 14.5px; color: var(--ink); text-align: left; cursor: pointer; }
.ov-item:hover { background: var(--surface-2); }
.ov-item.current { background: var(--brand-50); font-weight: 700; }
.ov-label { flex: 1; min-width: 0; }
.ov-label small { color: var(--muted); font-weight: 400; }
.ov-dot { width: 12px; height: 12px; border-radius: 99px; border: 2px solid var(--line-2); flex: none; }
.ov-item.done .ov-dot { background: var(--ok); border-color: var(--ok); }
.ov-item.missing .ov-dot { background: var(--bad); border-color: var(--bad); }
.mini { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 99px; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(10,11,12,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 6px; }
.lightbox .icon-btn { position: absolute; top: 12px; right: 12px; color: #fff; background: rgba(255,255,255,.14); }

/* ── Inköpstest: sammanställning ─────────────────────────────────────── */
.vehicle-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 16px; }
.vehicle-card-head > div:not(.plate) { flex: 1; min-width: 200px; }
.vehicle-card-head p { margin: 2px 0 0; font-size: 13.5px; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0; }
.spec-grid dt { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.spec-grid dd { margin: 2px 0 0; font-weight: 600; word-break: break-all; }
.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 14px 0 0; }

.remark-list { list-style: none; margin: 0; padding: 0; }
.remark-list li { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.remark-list li:first-child { border-top: 0; }
.remark-list .cost { font-weight: 700; white-space: nowrap; }
@media (max-width: 560px) { .remark-list li { grid-template-columns: 1fr auto; } .remark-list .badge { grid-column: 1 / -1; justify-self: start; } }

.section-card { padding: 0; overflow: hidden; }
.section-card summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.section-card summary::-webkit-details-marker { display: none; }
.section-card summary h2 { font-size: 16px; margin: 0; flex: 1; }
.section-card .chev { transition: transform .15s; color: var(--muted); }
.section-card:not([open]) .chev { transform: rotate(-90deg); }
.section-card:not([open]) summary { border-bottom: 0; }
.protocol td { vertical-align: top; }
.protocol td:first-child { width: 26%; }
.protocol tr.missing td { background: #fdf6f6; }
.protocol tr.missing td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.fix-link { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--bad); }
.fix-link .icon { width: 15px; height: 15px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 4px; }
.thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 5px; }
@media (max-width: 760px) {
  .protocol thead { display: none; }
  .protocol, .protocol tbody, .protocol tr, .protocol td { display: block; width: auto !important; }
  .protocol tr { display: grid; grid-template-columns: repeat(3, auto) 1fr; gap: 6px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; }
  .protocol td { border: 0; padding: 0; text-align: left !important; }
  .protocol td:first-child, .protocol td:nth-child(5), .protocol td:nth-child(6) { grid-column: 1 / -1; }
  .protocol td:nth-child(5):empty, .protocol td[data-label="Bilder"]:has(.thumbs:empty) { display: none; }
  .protocol td[data-label="Betyg"]::before { content: "Betyg "; color: var(--muted); font-size: 12px; }
}

.approve-card { border: 2px solid var(--graphite); }
.recipients { display: grid; gap: 4px; }
.recipients .check strong { font-weight: 600; }
.recipients .field { margin-top: 8px; max-width: 420px; }
.signature { border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); padding: 16px 18px; margin-top: 20px; display: flex; flex-direction: column; gap: 2px; background: var(--surface-2); }
.signature span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.signature strong { font-size: 22px; letter-spacing: -.01em; }
.signature small { color: var(--muted); }
.signature:not(.preview) { border-style: solid; border-color: var(--graphite); background: var(--surface); }
.log-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.log-list li { display: flex; gap: 8px; padding: 6px 0; }
.log-list .icon { color: var(--ok); width: 18px; height: 18px; margin-top: 2px; }
.log-list li.bad .icon { color: var(--bad); }

/* ── Inställningar ───────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.settings-card { display: flex; align-items: center; gap: 14px; margin: 0; color: var(--ink); text-decoration: none !important; transition: border-color .12s; }
.settings-card:hover { border-color: var(--line-2); }
.settings-card .grow { display: flex; flex-direction: column; gap: 2px; }
.settings-card .muted { font-size: 13.5px; line-height: 1.35; }
.settings-card small { color: var(--brand); font-weight: 600; font-size: 12.5px; margin-top: 4px; }
.settings-card > .icon { color: var(--muted); }
.settings-card.disabled { opacity: .6; }
.settings-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; flex: none; }

.tpl-section { padding: 0; overflow: hidden; }
.tpl-section.dragging { opacity: .5; }
.tpl-section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tpl-section-head form { margin: 0; }
.inline-rename { display: flex; align-items: center; gap: 4px; }
.inline-rename input { font-weight: 700; min-height: 38px; padding: 6px 10px; width: 360px; max-width: 60vw; font-size: 15px; border-color: transparent; background: transparent; }
.inline-rename input:hover, .inline-rename input:focus { border-color: var(--line-2); background: var(--surface); }
.drag-handle { cursor: grab; color: var(--muted); display: inline-grid; place-items: center; width: 28px; height: 36px; }
.drag-handle .icon { width: 18px; height: 18px; }
.tpl-items { list-style: none; margin: 0; padding: 4px 8px; min-height: 12px; }
.tpl-item { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tpl-item:last-child { border-bottom: 0; }
.tpl-item.dragging { opacity: .4; background: var(--brand-50); }
.tpl-item-main { display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none !important; padding: 4px 0; }
.tpl-item-main:hover strong { color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--na-50); color: var(--ink-2); }
.chip.strong { background: var(--brand-50); color: var(--brand); }
.chip.muted { background: none; border: 1px dashed var(--line-2); color: var(--muted); }
.move-btns { display: inline-flex; }
.move-btns .icon-btn { width: 32px; height: 32px; }
@media (min-width: 900px) and (pointer: fine) { .move-btns { opacity: 0; } .tpl-item:hover .move-btns { opacity: 1; } }
@media (pointer: coarse) { .drag-handle { display: none; } }
.add-item { margin: 4px 12px 12px; }
.add-section { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }

.recipient-row { display: grid; grid-template-columns: 1.2fr 1.5fr 140px auto auto; gap: 12px; align-items: end; margin: 0; padding: 14px 16px; }
.recipient-row .check { padding-bottom: 10px; }
.recipient-row.add { margin-top: 14px; border-style: dashed; grid-template-columns: 1.2fr 1.5fr 140px auto; }
.row-actions { display: flex; gap: 6px; align-items: center; padding-bottom: 2px; }
@media (max-width: 760px) { .recipient-row, .recipient-row.add { grid-template-columns: 1fr 1fr; } .recipient-row .field:nth-child(3), .recipient-row .field:nth-child(4) { grid-column: 1 / -1; } }

.temp-pw { border: 2px solid var(--ok); }
.pw-box { font-size: 26px; font-weight: 700; letter-spacing: .06em; background: var(--ok-50); color: #1f5a37; padding: 14px 18px; border-radius: var(--radius-sm); text-align: center; margin: 10px 0; user-select: all; }

/* ── Inloggning & installation ───────────────────────────────────────── */
body.bare { background: var(--graphite); min-height: 100vh; }
.bare-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.bare-wrap > .alert { width: 100%; max-width: 420px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 28px; margin: 0; }
.auth-card.wide { max-width: 640px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; margin-bottom: 22px; }
.auth-brand .icon { width: 42px; height: 42px; padding: 10px; border-radius: 10px; background: var(--brand); color: #fff; }
.auth-title { font-size: 18px; margin: 0 0 16px; color: var(--ink-2); }
.auth-card .stack { gap: 16px; }
.auth-card .btn-block { margin-top: 6px; }
.checklist { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 4px; }
.checklist li { display: flex; gap: 8px; align-items: center; font-size: 14.5px; }
.checklist li.ok .icon { color: var(--ok); } .checklist li.bad { color: var(--bad); font-weight: 600; }

/* ── Toast & dialog ──────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--graphite); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 14.5px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); }
.toast.success { background: var(--ok); }
dialog.confirm { border: 0; border-radius: 14px; padding: 24px; max-width: 440px; width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
dialog.confirm::backdrop { background: rgba(20,22,25,.55); }
dialog.confirm p { font-size: 17px; font-weight: 600; margin: 0 0 20px; line-height: 1.4; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media print {
  .sidebar, .topbar-actions, .step-nav, .nav-toggle, .form-actions { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
