:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #172033; --muted: #5b6577; --line: #dde3ec; --line2: #eef1f6;
  --accent: #0c78d9; --accent-ink: #ffffff; --ok: #1f9d55; --warn: #d98c0c; --bad: #d64545; --soft: #eaf2fc;
  --pill-new: #ffe1e1; --pill-new-ink: #8a1f1f; --pill-prog: #fff2c9; --pill-prog-ink: #7a5300; --pill-done: #d7f3e1; --pill-done-ink: #145c34;
  --pill-grey: #e6e9ef; --pill-grey-ink: #3d4757; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .05);
  --radius: 12px; --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1520; --panel: #182131; --ink: #e8edf5; --muted: #98a3b8; --line: #2a3446; --line2: #212b3c; --accent: #4aa3ff; --accent-ink: #061120; --soft: #1d2a3d;
    --pill-new: #4a1f1f; --pill-new-ink: #ffb3b3; --pill-prog: #4a3a10; --pill-prog-ink: #ffd88a; --pill-done: #14361f; --pill-done-ink: #9fe6bb; --pill-grey: #2a3446; --pill-grey-ink: #c9d2e0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 12px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: #101828; color: #fff; }
.top .brand { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.topnav { display: none; gap: 4px; margin-left: auto; }
.topnav a { color: #c7d2e6; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.topnav a.active { background: #223049; color: #fff; }
.timerchip { margin-left: auto; background: #d64545; color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.timerchip a { color: #fff; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); min-width: 56px; }
.bottomnav a span { font-size: 20px; line-height: 1; }
.bottomnav a.active { color: var(--accent); }
.bottomnav a.primary span { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; font-size: 24px; margin-top: -14px; box-shadow: var(--shadow); }
@media (min-width: 900px) { .topnav { display: flex; } .bottomnav { display: none; } body { padding-bottom: 40px; } .timerchip { margin-left: 12px; } }

main { max-width: 900px; margin: 0 auto; padding: 14px 16px 24px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card.compact { padding: 10px 14px; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }

label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input[type="date"] { min-height: 44px; }
input[type="checkbox"] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.stop { background: var(--bad); color: #fff; border-color: var(--bad); }

.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.seg button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg button b { font-weight: 800; margin-left: 4px; }

.search { margin: 8px 0 12px; }
.joblist { display: flex; flex-direction: column; gap: 8px; }
.job { display: block; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; color: var(--ink); }
.job .l1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.job .no { font-weight: 800; font-size: 16px; }
.job .cust { font-weight: 600; }
.job .l2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.job .note { margin-top: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.new, .pill.waiting_customer { background: var(--pill-new); color: var(--pill-new-ink); }
.pill.in_progress, .pill.waiting_parts, .pill.external { background: var(--pill-prog); color: var(--pill-prog-ink); }
.pill.done, .pill.delivered, .pill.invoiced { background: var(--pill-done); color: var(--pill-done-ink); }
.pill.scrapped, .pill.grey, .pill.none, .pill.legacy_no, .pill.legacy_yes, .pill.legacy_unknown, .pill.not_billable { background: var(--pill-grey); color: var(--pill-grey-ink); }
.pill.draft { background: var(--pill-prog); color: var(--pill-prog-ink); }
.pill.rec { background: #d64545; color: #fff; }

.checklist { display: flex; flex-direction: column; gap: 6px; }
.chk { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line2); }
.chk .lab { font-weight: 600; font-size: 14px; }
.chk .lab small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.chk .states { display: flex; gap: 4px; }
.chk .states button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; font-weight: 700; min-width: 44px; min-height: 36px; cursor: pointer; }
.chk .states button.ok.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.chk .states button.issue.on { background: var(--bad); color: #fff; border-color: var(--bad); }
.chk .states button.treg.on { background: var(--warn); color: #fff; border-color: var(--warn); }
.chk input.note { grid-column: 1 / -1; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.chk input.text { grid-column: 1 / -1; min-height: 40px; }
.chk.text { grid-template-columns: 1fr; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tag { position: absolute; left: 4px; top: 4px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 6px; }
.photo .del { position: absolute; right: 4px; top: 4px; background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }
.photo.uploading { opacity: .5; }
.camera { display: inline-flex; align-items: center; gap: 8px; }
.camera input { display: none; }

table.parts { width: 100%; border-collapse: collapse; }
table.parts td { padding: 4px 3px; vertical-align: top; }
table.parts input { min-height: 40px; padding: 8px 10px; }
table.parts .c-q { width: 64px; } table.parts .c-p { width: 96px; } table.parts .c-x { width: 40px; }
table.parts .c-pn { width: 34%; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.list td { padding: 8px 4px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.timerbox { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.timerbox .t { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timerbox .running .t { color: var(--bad); }
.timelist { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.timelist li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line2); }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #172033; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: 92vw; }
.toast.err { background: var(--bad); }
.saved { font-size: 12px; color: var(--muted); }
.dl { display: flex; gap: 8px; flex-wrap: wrap; }
.warn { color: var(--warn); } .bad { color: var(--bad); } .okc { color: var(--ok); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.head h1 { margin-bottom: 4px; }
.suggest { position: relative; }
.suggest ul { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; margin: 0; padding: 4px 0; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.suggest li { padding: 10px 12px; cursor: pointer; }
.suggest li:hover, .suggest li.hi { background: var(--soft); }
.suggest li small { display: block; color: var(--muted); }
.login { max-width: 360px; margin: 60px auto; text-align: center; }
.login img { width: 200px; margin-bottom: 20px; }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.histitem { padding: 8px 0; border-bottom: 1px solid var(--line2); font-size: 14px; }
.histitem .w { color: var(--muted); font-size: 13px; }
pre.wrap { white-space: pre-wrap; font: inherit; margin: 0; }
