/* Household Management: calm, readable, big touch targets. Light + dark via tokens. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #1a1f26;
  --muted: #5d6877;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e7eefe;
  --on-primary: #ffffff;
  --ok: #157f3b;       --ok-bg: #e6f5eb;
  --warn: #a15c07;     --warn-bg: #fff3dc;
  --bad: #b42318;      --bad-bg: #fdecea;
  --neutral-bg: #eef0f3;
  --maint: #2563eb; --repair: #dc2626; --upgrade: #9333ea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-lg: 0 20px 50px rgb(16 24 40 / .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161a21; --surface-2: #1d222b; --border: #282e38; --border-strong: #3a414d;
    --text: #e8ebef; --muted: #9aa4b1; --primary: #5b8def; --primary-hover: #7aa3f3; --primary-soft: #1a2944; --on-primary: #0b1220;
    --ok: #4ade80; --ok-bg: #12301f; --warn: #fbbf24; --warn-bg: #362a0d; --bad: #f87171; --bad-bg: #3a1717; --neutral-bg: #232933;
    --maint: #5b8def; --repair: #f87171; --upgrade: #c084fc;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 20px 50px rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
h4 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Utility */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.pre { white-space: pre-wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap { gap: 12px; } .gap-sm { gap: 6px; } .center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mt { margin-top: 12px; } .mt-sm { margin-top: 8px; } .mt-lg { margin-top: 28px; } .mb { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }
.ok-text .icon { width: 14px; height: 14px; vertical-align: -2px; }
.label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.plain { margin: 8px 0 0; padding-left: 18px; } .plain li { margin: 6px 0; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.1rem; color: var(--text); padding: 4px 8px 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: var(--on-primary); }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px; }
.brand-mark.lg .icon { width: 28px; height: 28px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.whoami { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.whoami-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 28px 36px 64px; max-width: 1240px; width: 100%; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 32px 0 12px; }
.section-title { margin: 22px 0 8px; font-size: .95rem; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 550; margin-bottom: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; color: var(--text); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { border-color: var(--bad); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: .88rem; border-radius: 8px; }
.btn.lg { min-height: 48px; font-size: 1rem; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.span-all { grid-column: 1 / -1; }

/* Pills & avatars */
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; background: var(--neutral-bg); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.soon, .pill.prio-med { background: var(--warn-bg); color: var(--warn); }
.pill.overdue, .pill.prio-high { background: var(--bad-bg); color: var(--bad); }
.pill.future, .pill.prio-low { background: var(--neutral-bg); color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--c, var(--muted)); color: #fff; font-weight: 700; font-size: .8rem; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: .65rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.avatar.empty { background: var(--neutral-bg); color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: 2px; }
.dot.bad { background: var(--bad); }
.vdot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }

/* Quick actions */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.qbtn { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); font-weight: 650; cursor: pointer; text-align: left; transition: border-color .12s, transform .12s; }
.qbtn:hover { border-color: var(--primary); transform: translateY(-1px); }
.qicon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex: none; }
.qicon.maint { background: var(--primary-soft); color: var(--maint); }
.qicon.repair { background: var(--bad-bg); color: var(--repair); }
.qicon.miles { background: var(--ok-bg); color: var(--ok); }
.qicon.add { background: var(--neutral-bg); color: var(--text); }

/* Dashboard */
.dash { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.dash h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; }
.alist { list-style: none; margin: 0; padding: 0; }
.alist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.alist li:first-child { border-top: 0; }
.all-good { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; background: var(--ok-bg); }
.all-good > .icon { color: var(--ok); width: 26px; height: 26px; }
.more-link { display: inline-block; margin-top: 8px; font-weight: 600; }
.big-num { font-size: 2rem; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 12px; }
.bars { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 96px 1fr 84px; align-items: center; gap: 10px; font-size: .9rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 99px; }
.fill.maintenance { background: var(--maint); } .fill.repair { background: var(--repair); } .fill.upgrade { background: var(--upgrade); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Vehicle cards */
.vcard { display: flex; flex-direction: column; gap: 14px; color: var(--text); border-top: 4px solid var(--accent); transition: transform .12s, box-shadow .12s; }
.vcard:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.vcard-top { display: flex; gap: 12px; align-items: center; }
.vcard h3 { margin: 0; }
.vbadge { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); flex: none; }
.vbadge.lg { width: 56px; height: 56px; border-radius: 16px; }
.vbadge.lg .icon { width: 28px; height: 28px; }
.vstats { display: grid; grid-template-columns: 1fr .8fr 1fr; gap: 10px; }
.vstats strong { font-size: .98rem; }
.vnext { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .9rem; }

/* Vehicle detail */
.vhead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat strong { font-size: 1.2rem; }
.stat .hint { font-size: .8rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.dl { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; font-weight: 550; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--primary-soft); margin-bottom: 16px; font-size: .93rem; }
.callout > .icon { color: var(--primary); margin-top: 2px; }

/* Schedule rows */
.slist { display: flex; flex-direction: column; gap: 8px; }
.srow { display: grid; grid-template-columns: 2.2fr 1.1fr 1.2fr 1.6fr auto auto; gap: 14px; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 14px; }
.srow.overdue { border-left-color: var(--bad); }
.srow.soon { border-left-color: var(--warn); }
.srow.ok { border-left-color: var(--ok); }
.srow .label { display: none; }
.s-actions { display: flex; gap: 4px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 999px; border: 1px dashed var(--border-strong); color: var(--muted); font-size: .88rem; }
.chip-btn { border: 0; background: var(--surface-2); border-radius: 999px; padding: 2px 10px; cursor: pointer; font-weight: 600; font-size: .8rem; color: var(--primary); }

/* Jobs */
.job { padding: 14px 16px; }
.job-head { display: flex; align-items: center; gap: 12px; }
.job-cost { font-variant-numeric: tabular-nums; }
.kind-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none; }
.kind-maintenance .kind-icon { background: var(--primary-soft); color: var(--maint); }
.kind-repair .kind-icon { background: var(--bad-bg); color: var(--repair); }
.kind-upgrade .kind-icon { background: color-mix(in srgb, var(--upgrade) 15%, transparent); color: var(--upgrade); }
.job details { margin-top: 10px; }
.job summary, details.more summary, details > summary { cursor: pointer; font-weight: 600; color: var(--primary); font-size: .9rem; }
.job details[open] > summary { margin-bottom: 10px; }
.cost-line { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; color: var(--muted); margin: 10px 0; }
.cost-line strong { color: var(--text); margin-left: auto; }
.fchip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 600; cursor: pointer; }
.fchip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.fchip.active .muted { color: inherit; opacity: .8; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); }
.table tfoot td { font-weight: 650; border-bottom: 0; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.card:has(> .table) { overflow-x: auto; }

/* Upgrades */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 4px; }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.kcol h4 { padding: 2px 4px; }
.ucard { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.recall summary { list-style: none; color: var(--text); }
.recall summary::-webkit-details-marker { display: none; }
.recall p { margin-top: 10px; font-size: .92rem; }

/* Calendar */
.cal-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-title { min-width: 180px; text-align: center; }
.cal-bar select { min-height: 40px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.legend .ev { width: auto; cursor: default; border-left-width: 3px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal-dow { background: var(--surface-2); padding: 8px; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: center; }
.cal-day { background: var(--surface); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: var(--surface-2); }
.cal-day.other .cal-num { opacity: .45; }
.cal-num { font-size: .8rem; font-weight: 650; color: var(--muted); padding: 2px 4px; align-self: flex-start; border-radius: 99px; }
.cal-day.today .cal-num { background: var(--primary); color: var(--on-primary); }
.ev { display: flex; align-items: center; gap: 4px; width: 100%; border: 0; border-left: 3px solid var(--accent, var(--muted)); border-radius: 5px; padding: 2px 6px; font-size: .75rem;
  font-weight: 600; text-align: left; cursor: pointer; background: var(--neutral-bg); color: var(--text); min-width: 0; }
.ev .icon { width: 12px; height: 12px; }
.ev.due.overdue { background: var(--bad-bg); color: var(--bad); }
.ev.due.soon { background: var(--warn-bg); color: var(--warn); }
.ev.due.ok, .ev.due.future { background: var(--primary-soft); color: var(--primary); }
.ev.done { background: var(--ok-bg); color: var(--ok); }
.ev.paper { background: var(--neutral-bg); color: var(--muted); }
.ev:hover { filter: brightness(.96); }
.more-ev { font-size: .72rem; color: var(--muted); padding-left: 6px; }
.agenda { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.agenda li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.agenda li:first-child { border-top: 0; }
.agenda-date { width: 110px; font-weight: 650; font-size: .9rem; color: var(--muted); }
.agenda-date.today { color: var(--primary); }

/* Household */
.profile { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.member .row { align-items: flex-start; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); cursor: pointer; border: 3px solid transparent; box-shadow: 0 0 0 1px var(--border); }
.swatches input:checked + span { border-color: var(--surface); box-shadow: 0 0 0 2px var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Onboarding / empty */
.onboard { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.onboard-card { width: 100%; max-width: 520px; padding: 32px; text-align: center; }
.onboard-card h1 { margin-bottom: 8px; }
.onboard-card form { text-align: left; margin-top: 24px; }
.form-error { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bad-bg); color: var(--bad); font-size: .9rem; }
.invite-note { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); text-align: left; }
.invite-note.bad { background: var(--warn-bg); color: var(--warn); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 20px 0; font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.empty { text-align: center; padding: 40px 20px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 460px; margin: 0 auto 16px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .label { text-transform: none; letter-spacing: 0; font-size: .87rem; color: var(--text); }
.hint { font-size: .82rem; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }
.grid-2, .grid-3 { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check.inline { padding: 8px 0; }
.check.inline:hover { background: transparent; }
.checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; }
.checklist .check:has(input:checked) { background: var(--primary-soft); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); }
.lookup { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.lookup-head { display: flex; gap: 10px; }
.lookup-head > .icon { color: var(--primary); margin-top: 2px; }
details.more { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.parts-editor { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.parts-head, .part-row { display: grid; grid-template-columns: 2fr 1.3fr 1.3fr 70px 100px 36px; gap: 8px; width: 100%; align-items: center; }
.parts-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.parts-rows:empty + .btn { margin-top: -4px; }
.parts-rows:empty { display: none; }
.parts-rows { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.parts-editor:has(.parts-rows:empty) .parts-head { display: none; }
.total-box { display: flex; flex-direction: column; justify-content: center; align-items: flex-end; padding: 8px 14px; border-radius: 10px; background: var(--surface-2); }
.total-box strong { font-size: 1.35rem; }

/* Job form: show only the sections for the chosen kind / performer */
.jf:not(.kind-maintenance) .only-maintenance,
.jf:not(.kind-repair) .only-repair,
.jf:not(.kind-upgrade) .only-upgrade,
.jf:not(.by-shop) .only-shop,
.jf:not(.by-household) .only-household { display: none; }

/* Modal */
dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(10 14 20 / .5); backdrop-filter: blur(2px); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 22px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-body > .section-title, .modal-body section > .section-title { margin: 8px 0 -4px; }
.modal-body section { display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  font-weight: 550; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive */
@media (max-width: 1100px) {
  .srow { grid-template-columns: 1fr 1fr 1fr; }
  .srow .label { display: block; }
  .s-name { grid-column: 1 / -1; }
  .s-status, .s-actions { grid-column: auto; }
  .s-actions { justify-content: flex-end; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: auto 0 0 0; height: auto; top: auto; z-index: 20; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); }
  .brand, .whoami { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: .72rem; }
  .main { padding: 20px 16px 96px; }
  .dash { grid-template-columns: 1fr; }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-day { min-height: 76px; padding: 4px; }
  .ev span { display: none; }
  .ev { height: 8px; padding: 0; border-left-width: 0; border-radius: 99px; background: var(--accent) !important; }
  .ev .icon { display: none; }
  .legend .ev { height: auto; padding: 2px 6px; background: var(--neutral-bg) !important; }
  .legend .ev span { display: inline; }
  .kanban { grid-template-columns: repeat(4, 80%); scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
  #toast { bottom: 84px; }
}
@media (max-width: 600px) {
  h1 { font-size: 1.4rem; }
  .grid-2, .grid-3, .checklist { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .srow { grid-template-columns: 1fr 1fr; }
  .vstats { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat strong { font-size: 1.05rem; }
  .parts-head { display: none !important; }
  .part-row { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
  .part-row input[name="p_name"] { grid-column: 1 / -1; }
  .part-row .icon-btn { justify-self: end; }
  .quick .qbtn { padding: 12px; font-size: .9rem; }
  .cal-dow { font-size: .65rem; padding: 6px 2px; }
  .agenda-date { width: auto; }
  dialog, dialog.wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .modal-form { max-height: 100dvh; height: 100%; }
  .modal-body { flex: 1; }
  .modal-foot { border-radius: 0; }
}
