:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #efebe2;
  --ink: #1d2629;
  --ink-2: #5d6a6e;
  --line: #e2ddd2;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe5;
  --amber: #b26a00;
  --amber-soft: #fbecd2;
  --red: #b3372e;
  --red-soft: #f8dcd8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 38, 41, .06), 0 4px 16px rgba(29, 38, 41, .05);
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a1c;
    --surface: #1d2528;
    --surface-2: #253033;
    --ink: #eef1ef;
    --ink-2: #9fb0b2;
    --line: #2e3a3d;
    --accent: #6cc3a6;
    --accent-ink: #0f1d18;
    --accent-soft: #1f3a32;
    --amber: #f0b45c;
    --amber-soft: #3a2d17;
    --red: #f08a7f;
    --red-soft: #3d2220;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.screen {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 96px);
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h1 { font-size: 28px; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 26px 4px 8px; font-weight: 600; }
.sub { color: var(--ink-2); font-size: 14px; margin: 2px 0 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-2); text-decoration: none; font-size: 11px; font-weight: 500;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }

/* ---------- cards & lists ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.meta { color: var(--ink-2); font-size: 13px; margin-top: 1px; }
.empty { padding: 28px 18px; text-align: center; color: var(--ink-2); }

/* chore rows */
.check {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent; display: grid; place-items: center; padding: 0;
  transition: background .15s, border-color .15s;
}
.check svg { width: 16px; height: 16px; opacity: 0; color: var(--accent-ink); }
.done .check { background: var(--accent); border-color: var(--accent); }
.done .check svg { opacity: 1; }
.done .title { text-decoration: line-through; color: var(--ink-2); font-weight: 500; }
.row-btn { all: unset; display: block; flex: 1; min-width: 0; cursor: pointer; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag.overdue, .tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.green { background: var(--accent-soft); color: var(--accent); }

.who {
  flex: none; display: flex; align-items: center; gap: 6px; border: 0; background: var(--surface-2);
  border-radius: 999px; padding: 4px 10px 4px 4px; font-size: 13px; font-weight: 600; max-width: 42%;
}
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.dot.none { background: transparent; border: 2px dashed var(--line); color: var(--ink-2); }

/* week header */
.weeknav { display: flex; align-items: center; gap: 4px; }
.icon-btn { border: 0; background: var(--surface); border: 1px solid var(--line); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; margin: 8px -2px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* due badges */
.due { flex: none; text-align: right; }
.due .n { font-weight: 700; font-size: 15px; }
.due .l { font-size: 12px; color: var(--ink-2); }

/* cars */
.car { padding: 16px; margin-bottom: 12px; }
.car-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.plate { font: 700 18px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .08em; background: #f7d23b; color: #111; padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .25); }
.car-rows > div { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.small-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 600; }

/* summary */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { font-size: 13px; color: var(--ink-2); }

/* ---------- buttons, forms ---------- */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--red); }
.btn.block { width: 100%; }
.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); z-index: 9;
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.fab svg { width: 28px; height: 28px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: var(--surface); -webkit-appearance: none; appearance: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.days { grid-auto-columns: auto; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 10px; margin-top: 8px; }
.actions .btn.primary { flex: 1; }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 15, .45); z-index: 20; animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 640px; margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0; max-height: 92dvh; overflow-y: auto;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .2s ease-out;
}
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 16px; font-size: 20px; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; background: var(--surface); border-radius: 12px; margin-bottom: 8px; font-weight: 600; text-align: left; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 360px; padding: 26px; text-align: center; }
.logo { width: 64px; height: 64px; margin: 0 auto 12px; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 90px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 30;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.note { font-size: 14px; color: var(--ink-2); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }

/* steps inside a big job */
.list > li.step { min-height: 46px; padding: 8px 14px 8px 58px; border-top: 1px dashed var(--line); background: color-mix(in srgb, var(--surface-2) 35%, var(--surface)); }
.list > li.step .title { font-weight: 500; font-size: 15px; }
.list > li.step-edit { min-height: 40px; }
.check.small { width: 24px; height: 24px; }
.check.small svg { width: 13px; height: 13px; }
.step-count { color: var(--accent); font-weight: 600; }
.done .step-count { color: var(--ink-2); }
.step-input { display: flex; gap: 8px; margin-bottom: 8px; }
.step-input input { flex: 1; }
.step-input .icon-btn { flex: none; width: 46px; height: 46px; font-size: 22px; color: var(--ink-2); }

.form-section { margin: 22px 2px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.ref { font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--ink); user-select: all; -webkit-user-select: all; }

.view-switch { max-width: 220px; margin-bottom: 14px; }

.list > li.skipped .title { color: var(--ink-2); font-style: italic; }
.list > li.skipped .check { border-style: dashed; }
.chip .meta { font-size: 12px; margin-left: 4px; }

/* demo */
.demo-bar { background: var(--accent-soft); color: var(--ink); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.demo-bar b { display: block; font-size: 15px; }
.demo-actions { display: flex; gap: 8px; margin-top: 10px; }
.demo-actions .btn { padding: 8px 14px; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; }

.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
