/* Design v2 (docs/DESIGN.md). Tokens first, then shared pieces. */
:root {
  color-scheme: light;
  /* surfaces and text */
  /* Marigold Field brand (docs/brand/BRAND.md). Marigold and sunrise are fills and accents only, never text on white. */
  --mf-navy: #14284B; --mf-marigold: #F2A23A; --mf-sunrise: #D9741A; --mf-cloud: #EEF0F4; --mf-white: #FFFFFF; --mf-slate: #4E5A70;
  --accent: var(--mf-marigold); --accent-ink: var(--mf-navy);
  --bg: var(--mf-cloud);  --card: #ffffff;  --sheet: #ffffff;
  --ink: #14284B; --muted: var(--mf-slate);
  --line: #e5e7eb; --divider: #eef0f3;
  --field: #ffffff; --field-line: #868f9c;
  /* brand */
  --brand: var(--mf-navy); --brand-ink: #ffffff; --brand-text: var(--mf-navy); --brand-soft: #E1E7F1;
  --header: var(--mf-navy); --header-ink: #ffffff; --header-sub: #C9D3E8;
  --seg: #eef0f3; --seg-on: #ffffff;
  --danger: #b91c1c; --skeleton: #e5e7eb; --backdrop: rgba(17,24,39,.45);
  --toast: #111827; --toast-ink: #ffffff;
  /* status tones: background / text */
  --red-bg: #fee2e2;    --red-fg: #991b1b;
  --orange-bg: #ffedd5; --orange-fg: #9a3412;
  --amber-bg: #fef3c7;  --amber-fg: #92400e;
  --green-bg: #dcfce7;  --green-fg: #166534;
  --blue-bg: #dbeafe;   --blue-fg: #1e40af;
  --purple-bg: #ede9fe; --purple-fg: #5b21b6;
  --teal-bg: #ccfbf1;   --teal-fg: #115e59;
  --grey-bg: #eef0f3;   --grey-fg: #374151;
  --overdue-bg: #b91c1c; --overdue-fg: #ffffff;
  /* legacy aliases so old rules still work: remove once style.css is migrated */
  --red: var(--red-fg); --red-soft: var(--red-bg); --amber: var(--amber-fg); --amber-soft: var(--amber-bg);
  --green: var(--green-fg); --green-soft: var(--green-bg); --blue: var(--blue-fg); --blue-soft: var(--blue-bg);
  /* shape and space */
  --radius: 14px; --radius-control: 12px; --radius-sheet: 20px; --pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --shadow-card: 0 1px 2px rgba(16,24,40,.06);
  --shadow-raised: 0 4px 14px rgba(16,24,40,.10);
  --tap: 44px; --tab-h: 84px;
  /* type (rem so iPhone larger text and zoom work) */
  --font: "Figtree", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif; /* Figtree is used when installed; self-hosting the font files is a separate step */
  --font-head: "Sora", "Helvetica Neue", Arial, sans-serif;
  --fs-screen: 1.875rem;  /* 30 */
  --fs-title: 1.625rem;   /* 26 */
  --fs-card: 1.125rem;    /* 18 */
  --fs-section: 1.0625rem;/* 17 */
  --fs-body: 1rem;        /* 16 */
  --fs-sub: .9375rem;     /* 15 */
  --fs-small: .8125rem;   /* 13 */
  --fs-tab: .6875rem;     /* 11 */
  --fs-input: 1.0625rem;  /* 17: stops iOS zoom on focus */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f14; --card: #161b22; --sheet: #1b2129;
    --ink: #f3f4f6; --muted: #a8b1bd;
    --line: #2a313b; --divider: #232a33;
    --field: #0f141a; --field-line: #6b7684;
    --brand: #F2A23A; --brand-ink: #14284B; --brand-text: #F2A23A; --brand-soft: #1C2D4F;
    --header: #0F1E3A; --header-sub: #A9B9D9; --ink: #f3f4f6; --muted: #AEB8C9; --bg: #0b0f14;
    --seg: #232a33; --seg-on: #3a4350;
    --danger: #f87171; --skeleton: #252c35; --backdrop: rgba(0,0,0,.6);
    --toast: #f3f4f6; --toast-ink: #111827;
    --red-bg: #4c1515;    --red-fg: #fecaca;
    --orange-bg: #4a1d0a; --orange-fg: #fed7aa;
    --amber-bg: #45290a;  --amber-fg: #fde68a;
    --green-bg: #0b3a1f;  --green-fg: #bbf7d0;
    --blue-bg: #172554;   --blue-fg: #bfdbfe;
    --purple-bg: #2e1065; --purple-fg: #ddd6fe;
    --teal-bg: #083d3a;   --teal-fg: #99f6e4;
    --grey-bg: #2a313b;   --grey-fg: #e5e7eb;
    --shadow-card: none; --shadow-raised: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f14; --card: #161b22; --sheet: #1b2129;
  --ink: #f3f4f6; --muted: #a8b1bd;
  --line: #2a313b; --divider: #232a33;
  --field: #0f141a; --field-line: #6b7684;
  --brand: #F2A23A; --brand-ink: #14284B; --brand-text: #F2A23A; --brand-soft: #1C2D4F;
  --header: #0F1E3A; --header-sub: #A9B9D9; --ink: #f3f4f6; --muted: #AEB8C9; --bg: #0b0f14;
  --seg: #232a33; --seg-on: #3a4350;
  --danger: #f87171; --skeleton: #252c35; --backdrop: rgba(0,0,0,.6);
  --toast: #f3f4f6; --toast-ink: #111827;
  --red-bg: #4c1515;    --red-fg: #fecaca;
  --orange-bg: #4a1d0a; --orange-fg: #fed7aa;
  --amber-bg: #45290a;  --amber-fg: #fde68a;
  --green-bg: #0b3a1f;  --green-fg: #bbf7d0;
  --blue-bg: #172554;   --blue-fg: #bfdbfe;
  --purple-bg: #2e1065; --purple-fg: #ddd6fe;
  --teal-bg: #083d3a;   --teal-fg: #99f6e4;
  --grey-bg: #2a313b;   --grey-fg: #e5e7eb;
  --shadow-card: none; --shadow-raised: none;
}

/* Badge tones: <span class="badge tone-red">S1 Critical</span> */
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: var(--pill); font-size: var(--fs-small); font-weight: 600; line-height: 1.2; white-space: nowrap; flex-shrink: 0; }
.tone-red { background: var(--red-bg); color: var(--red-fg); }
.tone-orange { background: var(--orange-bg); color: var(--orange-fg); }
.tone-amber { background: var(--amber-bg); color: var(--amber-fg); }
.tone-green { background: var(--green-bg); color: var(--green-fg); }
.tone-blue { background: var(--blue-bg); color: var(--blue-fg); }
.tone-purple { background: var(--purple-bg); color: var(--purple-fg); }
.tone-teal { background: var(--teal-bg); color: var(--teal-fg); }
.tone-grey { background: var(--grey-bg); color: var(--grey-fg); }
.badge.overdue { background: var(--overdue-bg); color: var(--overdue-fg); font-weight: 700; }

/* Buttons */
.btn { min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-control); border: 1px solid transparent; font: inherit; font-size: var(--fs-sub); font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.btn-soft { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.btn-outline { background: transparent; border-color: var(--field-line); color: var(--ink); }
.btn-danger-outline { background: transparent; border-color: var(--field-line); color: var(--danger); }
.btn-danger { background: #b91c1c; color: #fff; font-weight: 700; }
.btn:focus-visible, .chip:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand-text); outline-offset: 2px; }

/* Chips (filters and form choices) */
.chip { min-height: var(--tap); padding: 6px 14px; border-radius: var(--pill); border: 1px solid var(--field-line); background: var(--card); color: var(--ink); font: inherit; font-size: var(--fs-sub); font-weight: 500; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }

/* ---------- base ---------- */
:root { --tab-h: 64px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs-body)/1.45 var(--font); }
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
a { color: var(--brand-text); text-decoration: none; }
h1, h2, h3, .screen-title, .page-title { font-family: var(--font-head); }
h1 { font-size: 1.5rem; margin: 0; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: var(--fs-section); line-height: 1.3; margin: 0; font-weight: 700; color: var(--ink); }
.muted { color: var(--muted); } .small { font-size: var(--fs-small); } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .spread { justify-content: space-between; }
:focus-visible { outline: 3px solid var(--brand-text); outline-offset: 2px; }

/* ---------- header, page, cards ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--header); color: var(--header-ink); padding: calc(10px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 10px; }
.top h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top a, .top button { color: var(--header-ink); }
.back { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); margin-left: -12px; font-size: 1.75rem; line-height: 1; color: var(--header-ink); }
main { max-width: 1200px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 104px max(16px, env(safe-area-inset-left)); }
.card { background: var(--card); border-radius: var(--radius); padding: var(--s4); margin-bottom: 14px; box-shadow: var(--shadow-card); }
.card > .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.list a.item, .list .item { display: block; padding: var(--s4); background: var(--card); border-radius: var(--radius); margin-bottom: 12px; color: inherit; box-shadow: var(--shadow-card); }
.item .title { font-weight: 600; font-size: var(--fs-card); line-height: 1.35; } .item .sub { color: var(--muted); font-size: var(--fs-sub); margin-top: 2px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; font-size: var(--fs-body); } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.timeline .ev { padding: 10px 0; border-bottom: 1px solid var(--divider); font-size: var(--fs-sub); } .timeline .ev:last-child { border: 0; }
.bar { height: 6px; background: var(--brand-soft); border-radius: 3px; margin-top: 4px; min-width: 60px; } .bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-card); } .kpi b { display: block; font-size: 1.375rem; } .kpi span { font-size: var(--fs-small); color: var(--muted); }

/* ---------- buttons ---------- */
button, .btn { font: inherit; font-size: var(--fs-sub); font-weight: 600; border: 1px solid var(--field-line); background: transparent; color: var(--ink); padding: 8px 16px; border-radius: var(--radius-control); min-height: var(--tap); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
button.danger { color: var(--danger); }
.sheet > .actions button.danger[type=submit] { background: #b91c1c; color: #fff; border-color: #b91c1c; font-weight: 700; }
button.small { min-height: var(--tap); min-width: var(--tap); padding: 4px 12px; font-size: var(--fs-small); border-radius: 10px; background: var(--brand-soft); color: var(--brand-text); border-color: transparent; font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- fields ---------- */
input, select, textarea { font: inherit; font-size: var(--fs-input); width: 100%; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: var(--radius-control); background: var(--field); color: var(--ink); min-height: 48px; }
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-size: var(--fs-sub); font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
label.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 500; font-size: var(--fs-body); min-height: var(--tap); }
label.check input, input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 340px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border: 2px solid var(--danger); }
.field-error { color: var(--danger); font-size: var(--fs-small); font-weight: 700; margin-top: 4px; }
.err { scroll-margin-bottom: 96px; background: var(--red-bg); color: var(--red-fg); padding: 10px 12px; border-radius: 10px; margin-top: 12px; font-size: var(--fs-sub); font-weight: 600; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { border-radius: var(--pill); min-height: var(--tap); padding: 6px 16px; white-space: nowrap; background: var(--card); font-weight: 500; }
.chips button.on, .chips button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.chips .sep { flex: 0 0 1px; background: var(--line); margin: 6px 2px; }
button.tone-red, button.tone-orange, button.tone-amber, button.tone-green, button.tone-blue, button.tone-purple, button.tone-teal, button.tone-grey { border-color: transparent; border-radius: var(--pill); min-height: var(--tap); padding: 6px 14px; font-weight: 600; }

/* ---------- tab bar, + button ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--card); border-top: 1px solid var(--line); display: flex; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--fs-tab); font-weight: 500; color: var(--muted); min-height: var(--tap); }
.tabbar a svg { width: 24px; height: 24px; } .tabbar a.on { color: var(--brand-text); font-weight: 700; }
.fab { position: fixed; right: 16px; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); z-index: 9; width: 72px; height: 72px; border-radius: 50%; flex-direction: column; gap: 0; font-size: var(--fs-small); font-weight: 700; line-height: 1; box-shadow: var(--shadow-raised, 0 6px 18px rgba(0,0,0,.25)); padding: 0; }

/* ---------- sheet ---------- */
.sheet-bg { position: fixed; inset: 0; overscroll-behavior: contain; z-index: 30; background: var(--backdrop); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; background: var(--sheet); color: var(--ink); width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overscroll-behavior: contain; overflow-y: auto; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 22px 16px 0; }
.sheet::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--field-line); }
.sheet h1 { font-size: 1.1875rem; text-align: center; margin: 4px 0 8px; letter-spacing: 0; }
.sheet > .actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin: 16px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--sheet); border-top: 1px solid var(--divider); }
.sheet > .actions button { min-height: 52px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: var(--radius-sheet); } .sheet > .actions { border-radius: 0 0 var(--radius-sheet) var(--radius-sheet); } }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sub); font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: var(--fs-small); font-weight: 700; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--divider); vertical-align: top; } td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td, tr.totals td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }

/* ---------- states: loading, empty, error, toast ---------- */
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.state { background: var(--card); border-radius: var(--radius); padding: 28px 20px; text-align: center; box-shadow: var(--shadow-card); }
.state svg { width: 40px; height: 40px; color: var(--muted); margin-bottom: 8px; }
.state h3 { margin: 0 0 4px; font-size: var(--fs-card); } .state p { margin: 0 0 14px; color: var(--muted); }
.state.error h3 { color: var(--danger); }
.skel { background: var(--card); border-radius: var(--radius); padding: var(--s4); margin-bottom: 12px; box-shadow: var(--shadow-card); }
.skel i { display: block; height: 14px; border-radius: 7px; background: var(--skeleton); margin: 8px 0; animation: pulse 1.4s ease-in-out infinite; }
.skel i:nth-child(1) { width: 35%; } .skel i:nth-child(2) { width: 85%; height: 18px; } .skel i:nth-child(3) { width: 60%; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .skel i { animation: none; } #toast { transition: none; } }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--toast); color: var(--toast-ink); padding: 12px 18px; border-radius: var(--pill); opacity: 0; transition: .25s; z-index: 40; pointer-events: none; font-size: var(--fs-sub); font-weight: 600; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; } .login h1 { margin-bottom: 4px; font-size: 1.625rem; }
.segmented { display: inline-flex; background: var(--seg); border-radius: var(--radius-control); padding: 3px; }
.segmented button { border: 0; min-height: var(--tap); border-radius: 10px; background: transparent; font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--seg-on); font-weight: 700; }

/* ---------- list screens: teal hero header, ticket cards ---------- */
.top.hero { position: static; flex-direction: column; align-items: stretch; gap: 16px; padding-bottom: 20px; }
.screen-title { font-size: var(--fs-screen); line-height: 1.2; letter-spacing: -.4px; margin: 0; }
.hero-sub { margin: 2px 0 0; font-size: var(--fs-sub); color: var(--header-sub); }
.hero-search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 6px 0 14px; background: #fff; color: #4b5563; border-radius: var(--radius-control); }
.hero-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #111827; padding: 0; min-height: 0; height: 100%; font-size: var(--fs-input); }
.hero-search input::placeholder { color: #6b7280; }
.hero-search:focus-within { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--brand-text); }
.hero-search input:focus-visible { outline: none; }
.hero-search .clear { min-height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--brand); font-weight: 700; }
.fab .plus { font-size: 1.75rem; line-height: .9; font-weight: 600; }
.countline { margin: 4px 0 12px; color: var(--muted); font-size: var(--fs-sub); }
.tlist { display: flex; flex-direction: column; gap: 12px; }
.tcard { display: flex; flex-direction: column; gap: 10px; padding: var(--s4); background: var(--card); border-radius: var(--radius); color: var(--ink); box-shadow: var(--shadow-card); }
.tnum { font-size: var(--fs-small); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.ttitle { font-size: var(--fs-card); line-height: 1.33; font-weight: 600; overflow-wrap: anywhere; }
.tsub { font-size: var(--fs-sub); color: var(--muted); }
.tfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--divider); font-size: .875rem; }
.tfoot .who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--teal-bg); color: var(--teal-fg); font-size: 11px; font-weight: 700; }
.due { flex: none; color: var(--muted); } .due.over { color: var(--danger); font-weight: 700; }

/* ---------- choice chips, search picker, hint ---------- */
fieldset.choice { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
fieldset.choice legend { padding: 0; font-size: var(--fs-sub); font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.hintbox { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-control); background: var(--brand-soft); color: var(--brand-text); font-size: var(--fs-sub); font-weight: 600; }
.hintbox:empty { display: none; }
.linkbtn { margin-top: 12px; border: 0; background: transparent; color: var(--brand-text); font-weight: 700; padding: 0 4px; }
.picksel { min-height: 28px; margin: 2px 0 6px; font-size: var(--fs-body); }
.picked { display: inline-flex; align-items: center; gap: 4px; padding: 0 0 0 12px; border-radius: var(--pill); background: var(--brand-soft); color: var(--brand-text); font-weight: 600; max-width: 100%; }
.picked button { border: 0; min-height: var(--tap); min-width: var(--tap); background: transparent; color: inherit; font-size: 1.25rem; padding: 0; }
.pickres { margin-top: 6px; border: 1px solid var(--field-line); border-radius: var(--radius-control); background: var(--field); overflow: hidden; }
.pickrow { display: flex; width: 100%; justify-content: flex-start; text-align: left; border: 0; border-radius: 0; border-bottom: 1px solid var(--divider); min-height: var(--tap); font-weight: 500; }
.pickrow:last-child { border-bottom: 0; }

/* ---------- detail header, action card, ticket page ---------- */
.top.detail { position: static; flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 48px; }
.top.detail + main > .card:first-child, .top.detail + main > .cols > div:first-child > .card:first-child { margin-top: -32px; position: relative; z-index: 1; }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); margin-left: -8px; color: var(--header-ink); font-weight: 600; font-size: var(--fs-body); align-self: flex-start; }
.tnum-h { font-size: var(--fs-small); font-weight: 600; color: var(--header-sub); font-variant-numeric: tabular-nums; }
.page-title { font-size: var(--fs-title); line-height: 1.23; letter-spacing: -.3px; margin: 0; overflow-wrap: anywhere; white-space: normal; }
.card.action { box-shadow: var(--shadow-raised, var(--shadow-card)); }
.card.action .who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.agrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.agrid button { min-height: 48px; padding: 6px 4px; }
button.soft { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; font-weight: 700; }
button.dangerline { color: var(--danger); }
button.take { border-color: var(--brand); color: var(--brand-text); font-weight: 700; }
.problem { white-space: pre-wrap; margin: 0 0 12px; }
.total { color: var(--muted); font-size: var(--fs-sub); } .total strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.overtext { color: var(--danger); font-weight: 700; }
.lrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--divider); }
.lrow:last-of-type { border-bottom: 0; }
.lmain { flex: 1; min-width: 0; display: flex; flex-direction: column; } .lt { font-weight: 600; overflow-wrap: anywhere; } .ls { display: block; color: var(--muted); font-size: var(--fs-small); }
.lh { flex: none; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.iconbtn { flex: none; min-width: var(--tap); padding: 0; color: var(--danger); }
.textrow { margin: 10px 0 0; color: var(--muted); } .textrow strong { color: var(--ink); }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.tl li::before { content: ""; position: absolute; left: 4px; top: 14px; bottom: 0; width: 2px; background: var(--divider); }
.tl li:last-child { padding-bottom: 0; } .tl li:last-child::before { display: none; }
.tl .dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--field-line); position: relative; z-index: 1; }
.tl li.latest .dot { background: var(--brand); }
.tl .etext { display: block; overflow-wrap: anywhere; } .tl .etext:not(.note) { color: var(--muted); }
.tl .emeta { display: block; color: var(--muted); font-size: var(--fs-small); }
/* ---------- stepper, segmented ---------- */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { flex: none; width: 56px; height: 52px; padding: 0; font-size: 1.5rem; }
.stepper input { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; flex: 1; }
.choices.quick { margin-top: 8px; }
.segmented button.yes[aria-pressed="true"] { background: var(--red-bg); color: var(--red-fg); }
.segmented button { min-width: 74px; }

/* ---------- close ticket steps ---------- */
.sheet-sub { margin: -4px 0 10px; text-align: center; color: var(--muted); font-size: var(--fs-small); }
.stepbar { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; }
.stepbar li { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; border-radius: var(--pill); background: var(--seg); color: var(--muted); font-size: var(--fs-small); font-weight: 600; }
.stepbar li .num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--field-line); color: #fff; font-size: 11px; }
.stepbar li[aria-current="step"] { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.stepbar li[aria-current="step"] .num, .stepbar li.done .num { background: var(--brand); }
.review { margin-bottom: 4px; }
.warnbox { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-control); background: var(--amber-bg); color: var(--amber-fg); font-weight: 600; font-size: var(--fs-sub); }

[hidden] { display: none !important; }
/* ---------- sites ---------- */
.scard { gap: 6px; } .partof { font-size: var(--fs-small); font-weight: 600; color: var(--brand-text); }
.lrow.link { color: inherit; text-decoration: none; }
.swipehint { margin: 6px 0 0; color: var(--muted); font-size: var(--fs-small); display: none; }
@media (max-width: 700px) { .swipehint { display: block; } }

.agrid.two { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 0; }

/* ---------- stock: ordered parts and parts cards ---------- */
.btnreset { width: 100%; text-align: left; border: 0; font: inherit; font-weight: 400; cursor: pointer; min-height: 0; align-items: stretch; justify-content: flex-start; }
.btnreset .row { width: 100%; }
.ocard { gap: 8px; }
.acct { font-size: var(--fs-small); font-weight: 700; } .acct.ok { color: var(--green-fg); } .acct.warn { background: var(--amber-bg); color: var(--amber-fg); padding: 3px 10px; border-radius: var(--pill); }
.card .tcard { box-shadow: none; border: 1px solid var(--divider); }

/* ---------- reports ---------- */
.dlrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.dlrow .btn, .dlrow button { flex: 1 1 auto; min-width: 88px; }
.filterrow { display: none; }
.phone-only { display: inline-flex; }
.rowbtn { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--divider); border-radius: 0; background: transparent; font-weight: 400; min-height: var(--tap); align-items: flex-start; justify-content: flex-start; }
.rowbtn[aria-pressed="true"] .lt { color: var(--brand-text); }
.desk-only { display: none; }
@media (min-width: 1024px) { .desk-only.filterrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; margin-top: 12px; } .phone-only { display: none; } }

.tablewrap table { width: max-content; min-width: 100%; } .tablewrap td { max-width: 26rem; }

/* ---------- more, steps, avatar ---------- */
.profile { display: flex; align-items: center; gap: 16px; }
.avatar.big { width: 56px; height: 56px; font-size: 1.125rem; }
button.signout .lt { color: var(--danger); }
.list button.item { display: block; width: 100%; padding: var(--s4); background: var(--card); border: 0; border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow-card); color: inherit; text-align: left; font-weight: 400; }
.steps { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps .num { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: var(--fs-sub); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--card); color: var(--brand-text); padding: 10px 14px; border-radius: var(--radius-control); font-weight: 700; }
.skip:focus { left: 8px; }
main:focus { outline: none; }
.thbtn { border: 0; background: transparent; padding: 0; min-height: 0; font-weight: 700; color: var(--muted); font-size: var(--fs-small); cursor: pointer; }
.thbtn:hover { color: var(--ink); }
.clickrow { cursor: pointer; } .clickrow:hover td { background: var(--divider); }
.cellbtn { min-height: 32px; min-width: 36px; padding: 2px 10px; font-size: var(--fs-small); }
.cols > div { min-width: 0; }
.mob-only { display: block; }
.dtwrap { display: none; }

/* ---------- desktop (1024 px and wider) ---------- */
@media (min-width: 1024px) {
  body { padding-left: 220px; padding-bottom: 0; }
  .tabbar { top: 0; right: auto; bottom: 0; width: 220px; height: 100vh; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 76px 12px 16px; border-top: 0; border-right: 1px solid var(--line); }
  .tabbar::before { content: "Service Platform"; position: absolute; top: 24px; left: 24px; font-weight: 700; font-size: var(--fs-section); color: var(--brand-text); }
  .tabbar a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: var(--radius-control); font-size: var(--fs-sub); }
  .tabbar a.on { background: var(--brand-soft); }
  .mob-only { display: none !important; }
  .dtwrap { display: block; }
  .desk-only:not(.filterrow):not(.dtwrap) { display: block; }
  .fab { bottom: 24px; }
  #toast { bottom: 32px; left: calc(50% + 110px); }
  .top.hero, .top.detail { padding-left: 32px; padding-right: 32px; }
  main { padding-left: 32px; padding-right: 32px; padding-bottom: 96px; }
  /* list and tab screens use the whole width next to the side menu; detail pages keep the narrower reading width */
  body:has(.top.hero) main, main:has(.dtwrap) { max-width: none; margin: 0; }
  .dtwrap .tablewrap { margin: 0; padding: 0; }
  .cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 20px; align-items: start; }
  .cols > div:last-child > .card:first-child { margin-top: 0; }
  /* forms open as a panel on the right */
  .sheet-bg { align-items: stretch; justify-content: flex-end; }
  .sheet { width: 480px; max-width: 480px; height: 100vh; max-height: 100vh !important; border-radius: 0; display: flex; flex-direction: column; }
  .sheet::before { display: none; }
  .sheet > * { flex-shrink: 0; } /* in the side panel, long content scrolls; it must never be squeezed together */
  .sheet > .actions { margin-top: auto; border-radius: 0; position: sticky; }
  .tcard, .scard { max-width: none; }
}

.subhead { margin: 14px 0 0; font-size: var(--fs-sub); color: var(--muted); font-weight: 700; }

/* ---------- two-step sign in ---------- */
.login.wide { max-width: 480px; }
.keybox { margin-top: 8px; padding: 12px 14px; border-radius: var(--radius-control); background: var(--brand-soft); color: var(--brand-text); font: 700 1.125rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; word-break: break-all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.codes code { padding: 10px; border-radius: var(--radius-control); background: var(--card); border: 1px solid var(--field-line); font: 600 1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: center; }

/* ---------- Marigold Field brand touches ---------- */
.top { box-shadow: inset 0 -4px 0 var(--accent); }
.top.detail { box-shadow: none; }
.primary.fab { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tabbar a.on { position: relative; }
.tabbar a.on::after { content: ""; position: absolute; top: 0; width: 28px; height: 4px; border-radius: 0 0 4px 4px; background: var(--accent); }
.kv a, .ls a, .tsub a, .lt a, td a, p a, .hintbox a { text-decoration: underline; text-underline-offset: 2px; }
.logo { display: inline-flex; align-items: center; gap: .4em; line-height: 1; }
.logo svg { height: 2.6em; width: auto; flex: none; }
.logo .wm { font-family: var(--font-head); letter-spacing: -.03em; font-size: 1em; color: var(--mf-navy); }
.logo .wm b { font-weight: 600; } .logo .wm span { font-weight: 300; }
.logo.on-dark .wm { color: #fff; }
.login .logo { font-size: 1.75rem; margin-bottom: 18px; }
.hlogo { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 20px; opacity: .95; }
.hlogo svg { height: 30px; width: auto; display: block; }
.top.hero, .top.detail { position: relative; z-index: 0; } /* positioned for the logo, but below the card that overlaps it */
.brandbar { display: none; }
@media (min-width: 1024px) {
  .tabbar::before { content: none; }
  .brandbar { display: flex; position: absolute; top: 22px; left: 22px; font-size: 1.125rem; }
  .tabbar a.on::after { top: 12px; left: 0; width: 4px; height: 24px; border-radius: 0 4px 4px 0; }
}

.btnrow { display: inline-flex; gap: 8px; }
.lt a { color: inherit; text-decoration: underline; }
