/* Home jobs: wayfinding yellow for the page headers, quiet everywhere else. */
:root {
  --paper: #F4F6F8;
  --surface: #FFFFFF;
  --ink: #1C2430;
  --muted: #5B6676;
  --line: #D9DFE6;
  --signal: #FFC72C;
  --signal-ink: #1C2430;
  --focus: #1D5FA8;
  --danger: #B42318;

  /* stages */
  --st-Backlog: #7A8494;
  --st-Ready: #1D5FA8;
  --st-Scheduled: #5A4FCF;
  --st-Progress: #B45309;
  --st-Done: #0F7B6C;
  --st-Dropped: #7A8494;

  /* priorities */
  --pr-Urgent: #B42318;
  --pr-High: #B45309;
  --pr-Medium: #1D5FA8;
  --pr-Low: #7A8494;

  --wait: #A23B72;

  --radius-s: 6px;
  --radius-m: 10px;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161D;
    --surface: #1B212B;
    --ink: #E8ECF1;
    --muted: #9AA5B4;
    --line: #2E3744;
    --focus: #7FB2F0;
    --danger: #F97066;
    --st-Backlog: #8C96A6;
    --st-Ready: #6FA8EE;
    --st-Scheduled: #A39BFF;
    --st-Progress: #E8A04A;
    --st-Done: #3CC3AE;
    --st-Dropped: #8C96A6;
    --pr-Urgent: #F97066;
    --pr-High: #E8A04A;
    --pr-Medium: #6FA8EE;
    --pr-Low: #8C96A6;
    --wait: #E58BBE;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
}
body.has-sheet { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { max-width: 34rem; margin: 20vh auto; padding: 0 16px; text-align: center; }
.error { color: var(--danger); }
.spacer { flex: 1; }

.display {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.25rem, 9vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0;
}
.h1 { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1.1; margin: 0; }
.h2 { font-family: var(--display); font-weight: 600; font-size: 1.4rem; line-height: 1.2; margin: 1.5rem 0 0.25rem; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner {
  max-width: 760px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-family: var(--display); font-weight: 700; font-size: 1.35rem; }
.home { font-size: 0.875rem; color: var(--muted); text-decoration: none; padding-right: 10px; border-right: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
@media (max-width: 520px) {
  .topbar-inner { row-gap: 4px; padding-bottom: 6px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; }
  .tab { flex: 1; text-align: center; }
}
.tab { padding: 6px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--muted); white-space: nowrap; }
.tab[aria-current="page"] { color: var(--ink); background: var(--paper); font-weight: 700; }

/* ---------- the yellow band ---------- */
.band { background: var(--signal); color: var(--signal-ink); }
.band-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px 18px; }
.band-links { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.band .back { font-size: 0.875rem; text-decoration: none; opacity: 0.85; }
.band-edit { background: none; border: 1.5px solid var(--signal-ink); color: var(--signal-ink); border-radius: var(--radius-s); padding: 3px 10px; font-size: 0.875rem; font-weight: 700; cursor: pointer; }
.band .back::before { content: "‹ "; }
.band-sub { margin: 6px 0 0; font-weight: 700; }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress-text { white-space: nowrap; }
.meter { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--st-Pack); }
.meter-band { flex: 1; height: 12px; border-radius: 6px; background: rgba(28, 36, 48, 0.15); }
.meter-band > span { background: var(--signal-ink); transition: width 300ms ease; }
@media (prefers-reduced-motion: reduce) { .meter-band > span { transition: none; } }

/* ---------- pages ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; }
.page-trip { padding-top: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page > p { max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); text-decoration: none; cursor: pointer; font-weight: 700;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { border-color: var(--ink); opacity: 0.9; }
.btn-quiet { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn-big { min-height: 52px; padding: 12px 22px; font-size: 1.1rem; }
.link { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; }

/* ---------- sign-in ---------- */
.signin .band-hero { padding: 18vh 16px 28px; }
.signin .band-hero > * { max-width: 30rem; margin-left: auto; margin-right: auto; }
.signin .band-hero p { margin-top: 12px; font-size: 1.1rem; }
.signin-body { max-width: 30rem; margin: 0 auto; padding: 28px 16px; }

/* ---------- toolbars ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 6px; }
.toolbar-2 { margin-top: 4px; }
.toolbar select, .toolbar .search, .form input, .form select, .form textarea, .lk-row input, .lk-row select, .lk-add input, .lk-add select {
  min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
}
.toolbar .search { flex: 1 1 14rem; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }

/* ---------- grouped rows ---------- */
.group { margin-top: 18px; }
.group-head {
  font-family: var(--display); font-weight: 600; font-size: 1.2rem; margin: 0 0 6px;
  display: flex; gap: 8px; align-items: baseline;
}
.group-head .muted { font-family: var(--body); font-weight: 400; font-size: 0.875rem; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.row { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-open, .pick {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 10px 12px; background: none; border: 0; text-align: left; cursor: pointer;
}
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 700; }
.row-meta { font-size: 0.875rem; color: var(--muted); }
.row-note { font-size: 0.8125rem; color: var(--muted); font-style: italic; }
.pick input { width: 20px; height: 20px; flex: none; }

.is-packed .row-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.is-excluded .row-title { color: var(--muted); }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 0.875rem; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; }
.wide { grid-column: 1 / -1; }
@media (max-width: 340px) { .form { grid-template-columns: 1fr; } }

.sticky-actions {
  position: sticky; bottom: 0; margin: 20px -16px -96px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-top: 1px solid var(--line);
}

/* ---------- sheet (dialog) ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(12, 16, 22, 0.45); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: rise 180ms ease-out;
}
@media (min-width: 700px) {
  #sheet { align-items: center; }
  .sheet { border-radius: 14px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.sheet-head .h2 { margin: 0; }
.sheet-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.sheet .rows { max-height: 52vh; overflow-y: auto; }

/* ---------- settings ---------- */
.lookup { margin-top: 12px; padding: 0; }
.lookup > summary { padding: 14px 16px; cursor: pointer; display: flex; align-items: baseline; gap: 8px; }
.lookup > summary .h2 { margin: 0; }
.lookup > :not(summary) { margin-left: 16px; margin-right: 16px; }
.lookup > form { margin-bottom: 16px; }
.lk-rows { list-style: none; margin-top: 10px; margin-bottom: 10px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.lk-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.lk-row input { width: 0; }
.lk-row input { flex: 1; min-width: 0; }
.lk-row select { flex: 0 1 auto; min-width: 0; max-width: 45%; }
.lk-row input[readonly] { background: var(--paper); }
.lk-lock, .lk-row .link { flex: none; width: 4.25rem; text-align: right; }
.lk-add { display: flex; gap: 8px; flex-wrap: wrap; }
.lk-add input { flex: 1 1 10rem; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  max-width: min(92vw, 30rem); padding: 10px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--paper); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
#toast[data-kind="error"] { background: var(--danger); color: #fff; }
@media (max-width: 520px) {
  .lk-row:has(select) { flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .lk-row:has(select) input { flex: 1 1 100%; }
  .lk-row:has(select) select { flex: 1 1 auto; max-width: none; }
}

/* ---------- stage colours (shared by counters, pills and switcher) ---------- */
[data-stage="Backlog"] { --c: var(--st-Backlog); }
[data-stage="Ready"] { --c: var(--st-Ready); }
[data-stage="Scheduled"] { --c: var(--st-Scheduled); }
[data-stage="In Progress"] { --c: var(--st-Progress); }
[data-stage="Done"] { --c: var(--st-Done); }
[data-stage="Dropped"] { --c: var(--st-Dropped); }
[data-p="Urgent"] { --pc: var(--pr-Urgent); }
[data-p="High"] { --pc: var(--pr-High); }
[data-p="Medium"] { --pc: var(--pr-Medium); }
[data-p="Low"] { --pc: var(--pr-Low); }

/* ---------- band summary ---------- */
.band-figures { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; }
.band-figures strong { font-family: var(--display); font-size: 1.5rem; line-height: 1; margin-right: 4px; }
.band-num { font-family: var(--display); font-weight: 700; opacity: 0.7; }
.band-parent { display: block; margin-top: 4px; font-size: 0.9375rem; }

/* ---------- stage counters ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 8px 10px; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line));
  border-radius: var(--radius-s); background: var(--surface); cursor: pointer; text-align: left;
}
.stat[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); border-left-color: var(--c); }
.stat-n { font-family: var(--display); font-weight: 700; font-size: 1.6rem; line-height: 1; }
.stat-l { font-size: 0.8rem; }

.attention {
  display: flex; width: 100%; justify-content: space-between; gap: 12px; margin-top: 10px;
  padding: 10px 14px; border: 1px solid var(--wait); border-radius: var(--radius-s);
  background: var(--surface); color: var(--wait); cursor: pointer; text-align: left;
}
.attention span { text-decoration: underline; text-underline-offset: 3px; }
.attention[aria-pressed="true"] { background: var(--wait); color: var(--paper); }

/* ---------- job rows ---------- */
.job-row .row-open { padding-left: 10px; text-decoration: none; }
a.row-open { text-decoration: none; }
.prio-bar { flex: none; width: 6px; align-self: stretch; border-radius: 3px; background: var(--pc, var(--line)); }
.row.child .row-open { padding-left: calc(10px + 22px * var(--depth, 1)); }
.row.child .row-title::before { content: "↳ "; color: var(--muted); font-weight: 400; }
.is-closed .row-title { color: var(--muted); }
.is-done .row-title { text-decoration: line-through; text-decoration-thickness: 2px; }
.row-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.meta-bits { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }

.pill { font-size: 0.75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; border: 1.5px solid var(--c, var(--line)); color: var(--c, var(--muted)); background: var(--surface); }
.prio { font-size: 0.75rem; font-weight: 700; padding: 0 6px; border-radius: 3px; white-space: nowrap; color: var(--pc, var(--muted)); background: var(--paper); }
.flag { font-size: 0.75rem; padding: 0 6px; border-radius: 3px; white-space: nowrap; background: var(--wait); color: #fff; }
.kids { font-size: 0.75rem; padding: 0 6px; border-radius: 3px; white-space: nowrap; border: 1px dashed var(--muted); color: var(--muted); }
.money { font-variant-numeric: tabular-nums; }

/* ---------- job detail ---------- */
.switcher { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.switcher button {
  flex: 1 1 auto; min-height: 44px; padding: 6px 12px; cursor: pointer; font-weight: 700;
  border: 1.5px solid var(--c); color: var(--c); background: var(--surface); border-radius: var(--radius-s);
}
.switcher button[aria-pressed="true"] { background: var(--c); color: var(--surface); }
.switcher button:disabled { opacity: 0.45; cursor: not-allowed; }
.wait-note { margin: 6px 0 0; padding: 10px 14px; border-left: 4px solid var(--wait); background: var(--surface); border-radius: var(--radius-s); }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 12px 16px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 0.8125rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.notes-text { margin: 14px 0 0; white-space: pre-wrap; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 24px 0 8px; }
.section-head .h2 { margin: 0; }
.row-static { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; }
.row .link { flex: none; padding: 0 12px; }
.add-line { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.add-line select { flex: 1 1 12rem; min-width: 0; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

/* materials */
.mat-status {
  flex: none; width: 5.5rem; border: 0; border-right: 1px solid var(--line); background: none; cursor: pointer;
  font-size: 0.8125rem; font-weight: 700; color: var(--c);
}
.mat-status[data-ms="Needed"] { --c: var(--st-Progress); }
.mat-status[data-ms="Ordered"] { --c: var(--st-Ready); }
.mat-status[data-ms="Got"] { --c: var(--st-Done); }
.mat-got .row-title { color: var(--muted); }
.ext { color: var(--focus); font-size: 0.875rem; }
.totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; margin-top: 6px; font-size: 0.9375rem; }
