:root {
  --bg: #f4f2ee; --surface: #ffffff; --surface-2: #ece9e3; --ink: #1d1f21; --muted: #5d6166;
  --line: #d9d5cd; --accent: #e8590c; --accent-ink: #ffffff; --accent-soft: #fde7da;
  --red: #c92a2a; --red-soft: #fde2e2; --amber: #b35c00; --amber-soft: #fff1d6;
  --green: #2b8a3e; --green-soft: #e1f5e5; --blue: #1c62b0; --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517; --surface: #1d1f22; --surface-2: #26292d; --ink: #eceae6; --muted: #a2a6ab;
    --line: #34383d; --accent: #ff7a2f; --accent-ink: #141517; --accent-soft: #3a2416;
    --red: #ff6b6b; --red-soft: #3b1d1d; --amber: #ffb347; --amber-soft: #3a2c14;
    --green: #69db7c; --green-soft: #163020; --blue: #74b3ff; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141517; --surface: #1d1f22; --surface-2: #26292d; --ink: #eceae6; --muted: #a2a6ab;
  --line: #34383d; --accent: #ff7a2f; --accent-ink: #141517; --accent-soft: #3a2416;
  --red: #ff6b6b; --red-soft: #3b1d1d; --amber: #ffb347; --amber-soft: #3a2c14;
  --green: #69db7c; --green-soft: #163020; --blue: #74b3ff; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* top bar */
.sticky { position: sticky; top: 0; z-index: 20; }
.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: 10px 16px; background: #1b1d1f; color: #f2f0ec; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 1.05rem; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; font-size: .85rem; }
.hours-form { display: flex; align-items: center; gap: 8px; }
.hours-form label { font-size: .8rem; color: #b9b6b0; }
.hours-form input { width: 110px; padding: 8px 10px; border-radius: 8px; border: 1px solid #44484d; background: #26292d; color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.hours-form button, .btn { padding: 8px 14px; border-radius: 8px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 12px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; outline: none; }
.foot { max-width: 1100px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
@media (min-width: 800px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.side { grid-template-columns: 1.6fr 1fr; align-items: start; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat.red .v { color: var(--red); } .stat.amber .v { color: var(--amber); } .stat.green .v { color: var(--green); }

.task-list { list-style: none; padding: 0; margin: 0; }
.task-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.task-row:first-child { border-top: 0; }
.task-row a.t { font-weight: 650; color: var(--ink); text-decoration: none; }
.task-row a.t:hover { text-decoration: underline; }
.task-row .meta { grid-column: 1; font-size: .85rem; color: var(--muted); }
.task-row .act { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; align-items: center; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.pill.overdue { background: var(--red-soft); color: var(--red); }
.pill.soon { background: var(--amber-soft); color: var(--amber); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.na { background: var(--surface-2); color: var(--muted); }
.pill.dealer { background: var(--surface-2); color: var(--ink); }
.pill.code { background: var(--accent-soft); color: var(--accent); }

.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 8px 0 10px; }
.empty { color: var(--muted); padding: 8px 0; }

/* task detail */
.crumbs { font-size: .85rem; margin-bottom: 8px; }
.steps { padding-left: 1.3rem; margin: 0; }
.steps li { margin: 6px 0; }
.note { border-left: 4px solid var(--amber); background: var(--amber-soft); padding: 10px 12px; border-radius: 6px; margin: 12px 0; font-size: .92rem; }
.specs { list-style: none; padding: 0; margin: 0; }
.specs li { padding: 6px 0; border-top: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.specs li:first-child { border-top: 0; }
.parts li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.parts { list-style: none; padding: 0; margin: 0; }
.parts li:first-child { border-top: 0; }
.parts .pn { font-size: .8rem; color: var(--muted); }
.amz { flex: none; padding: 5px 10px; border-radius: 6px; background: #ff9900; color: #111; font-weight: 700; font-size: .8rem; text-decoration: none; }
.links-list { list-style: none; padding: 0; margin: 0; }
.links-list li { padding: 7px 0; border-top: 1px solid var(--line); }
.links-list li:first-child { border-top: 0; }
.links-list .src { font-size: .78rem; color: var(--muted); }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb { display: block; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; text-align: left; }
.thumb img { display: block; width: 100%; height: auto; aspect-ratio: 685 / 531; object-fit: contain; background: #fff; }
.thumb.page img { aspect-ratio: 654 / 478; }
.thumb span { display: block; padding: 4px 8px; font-size: .75rem; color: #444; background: #f3f3f3; }

form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
form.inline label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 3px; }
form.inline input, form.inline textarea, form.inline select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0; }
form.inline input[type=number] { width: 110px; }
form.inline .grow { flex: 1 1 220px; }
form.inline .grow input { width: 100%; }

/* daily */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check input { width: 24px; height: 24px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.check label { flex: 1; cursor: pointer; }
.check .refs { font-size: .8rem; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 80px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .h { font-weight: 750; font-variant-numeric: tabular-nums; }
.timeline .items a { margin-right: 10px; white-space: nowrap; display: inline-block; }

/* manual */
.chapters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chapters a { padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .85rem; }
.chapters a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.viewer img { width: 100%; height: auto; display: block; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10,10,10,.94); display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lb-bar { display: flex; gap: 10px; align-items: center; padding: 10px 12px; color: #eee; }
.lb-bar span { flex: 1; font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bar button { background: #2b2d30; color: #fff; border: 0; border-radius: 8px; width: 40px; height: 40px; font-size: 1.3rem; }
.lb-bar a { color: #ffb37a; font-size: .85rem; }
.lb-img { flex: 1; overflow: auto; display: grid; place-items: center; padding: 8px; touch-action: pinch-zoom; }
.lb-img img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 4px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1b1d1f; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }

@media (max-width: 560px) {
  .hours-form label { display: none; }
  .hours-form input { width: 90px; }
  .task-row { grid-template-columns: 1fr; }
  .task-row .act { grid-column: 1; grid-row: auto; }
  h1 { font-size: 1.3rem; }
}
@media print {
  .topbar, .tabs, .foot, .btn, .amz, form { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* 3D walk-around */
.model-wrap { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .model-wrap { grid-template-columns: 1fr 340px; align-items: start; } .model-panel { max-height: 620px; overflow: auto; } }
.model-panel { margin: 0; }
.model-stage { position: relative; height: min(620px, 70vh); min-height: 380px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); touch-action: none; }
.model-stage canvas { display: block; width: 100%; height: 100%; }
.hs-layer { position: absolute; inset: 0; pointer-events: none; }
.hs { position: absolute; left: 0; top: 0; pointer-events: auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; padding: 0;
  font: 700 12px/22px system-ui, sans-serif; color: #fff; background: #5d6166; box-shadow: 0 1px 4px rgba(0,0,0,.45); transition: opacity .15s; }
.hs[data-state="overdue"], .hsn[data-state="overdue"], .dot.overdue { background: #d63b3b; }
.hs[data-state="soon"], .hsn[data-state="soon"], .dot.soon { background: #e09100; }
.hs[data-state="ok"], .hsn[data-state="ok"], .dot.ok { background: #2f9e44; }
.hs[data-state="daily"], .hsn[data-state="daily"], .dot.daily { background: #1c7ed6; }
.hs.far { opacity: .35; }
.hs.sel { outline: 3px solid var(--accent); outline-offset: 2px; z-index: 2; opacity: 1; transform-origin: center; }
.hs:hover { opacity: 1; z-index: 3; }
.model-tools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; z-index: 4; }
.model-tools select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.model-tools .views { display: flex; flex-wrap: wrap; gap: 4px; }
.legend { position: absolute; bottom: 8px; left: 10px; z-index: 4; font-size: .75rem; background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 4px 8px; border-radius: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.hs-index { columns: 2 260px; padding-left: 0; list-style: none; margin: 0; }
.hs-index li { break-inside: avoid; padding: 4px 0; }
.hs-index a { color: var(--ink); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.hs-index a:hover { text-decoration: underline; }
.hsn { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: .72rem; font-weight: 700; background: #5d6166; }
.model-panel .thumbs { grid-template-columns: 1fr 1fr; }
