/* Customer portal. Tokens follow inventory-app (same brand, same light/dark
   mechanism). Chart colors: validated categorical slots 1-3 (dataviz
   reference palette); status colors are reserved and always paired with a
   label. Keep the two dark blocks identical. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1c2430;
  --muted: #5d6b7d;
  --faint: #b3bcc7;
  --border: #dde2e8;
  --grid: #e8ecf1;
  --accent: #3f6e9c; /* darker shade of logo blue #5E8AB4, for text contrast */
  --accent-soft: #e8f0f8;
  --on-accent: #ffffff;
  --row-hover: #eef4fb;
  --nav-bg: #16202e;
  --nav-text: #c9d3df;
  --nav-active-bg: #3f6e9c;
  --nav-active-text: #ffffff;
  --tile-1: #2a78d6;
  --tile-2: #0f8f84;
  --tile-3: #1f9d55;
  --tile-4: #7b5cd6;
  --nav-bg-top: #1d3554;
  --nav-indicator: #8db3d9;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-neutral: #8a96a6;
  --note-bg: #fff8e1;
  --note-border: #f0dca0;
  --note-text: #7a4f00;
  --error: #b42318;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1a2029;
    --surface-2: #1e252f;
    --text: #e6eaf0;
    --muted: #9aa6b5;
    --faint: #4a5566;
    --border: #2c3542;
    --grid: #262e3a;
    --accent: #8db3d9;
    --accent-soft: #22324a;
    --on-accent: #0b1a2b;
    --row-hover: #233041;
    --nav-bg: #0b0e12;
    --nav-text: #a9b4c2;
    --nav-active-bg: #2a5b8c;
    --nav-active-text: #ffffff;
    --tile-1: #3987e5;
    --tile-2: #2bb5a6;
    --tile-3: #3cb46e;
    --tile-4: #9a80ea;
    --nav-bg-top: #13223a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --status-neutral: #6b7686;
    --note-bg: #2a2413;
    --note-border: #4a3d1c;
    --note-text: #f5d47a;
    --error: #f2877d;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12161c;
  --surface: #1a2029;
  --surface-2: #1e252f;
  --text: #e6eaf0;
  --muted: #9aa6b5;
  --faint: #4a5566;
  --border: #2c3542;
  --grid: #262e3a;
  --accent: #8db3d9;
  --accent-soft: #22324a;
  --on-accent: #0b1a2b;
  --row-hover: #233041;
  --nav-bg: #0b0e12;
  --nav-text: #a9b4c2;
  --nav-active-bg: #2a5b8c;
  --nav-active-text: #ffffff;
  --tile-1: #3987e5;
  --tile-2: #2bb5a6;
  --tile-3: #3cb46e;
  --tile-4: #9a80ea;
  --nav-bg-top: #13223a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --status-neutral: #6b7686;
  --note-bg: #2a2413;
  --note-border: #4a3d1c;
  --note-text: #f5d47a;
  --error: #f2877d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.2; margin: 0; }

.muted { color: var(--muted); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

button, input, select { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.btn:hover { background: var(--row-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: progress; }

input[type="search"], input[type="email"], input[type="password"], input[type="text"], input[type="number"], input[inputmode], select, textarea {
  min-height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Gate: sign-in / set password ---------- */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(160deg, var(--accent-soft) 0%, var(--bg) 55%);
}
.gate-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-top: 4px solid var(--accent); border-radius: var(--radius); padding: 28px 24px;
  box-shadow: 0 12px 32px -18px rgba(16, 32, 56, .35);
}
.gate-logo { width: 140px; height: auto; display: block; margin-bottom: 18px; }
.gate-form { display: grid; gap: 6px; }
.gate-form h1 { font-size: 22px; }
.gate-form > p.muted { margin: 2px 0 12px; }
.gate-form label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.gate-form .btn-primary { margin-top: 14px; min-height: 44px; }
.gate-status { min-height: 1.4em; margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.gate-status.error, .error-text { color: var(--error); }
.gate-help { margin: 6px 0 0; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.field-hint { margin: 0; font-size: 13px; color: var(--muted); }
.link-btn { justify-self: start; border: 0; background: none; padding: 4px 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.stack-form { display: grid; gap: 6px; max-width: 380px; margin-top: 8px; }
.stack-form label { font-weight: 600; font-size: 14px; margin-top: 6px; }
.stack-form .btn { margin-top: 10px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px; color: var(--nav-text);
  background: linear-gradient(180deg, var(--nav-bg-top) 0%, var(--nav-bg) 55%);
}
.brand { display: flex; flex-direction: column; gap: 4px; padding: 0 10px 18px; }
.logo { width: 120px; height: auto; display: block; }
.brand-name { font-size: 13px; letter-spacing: .02em; color: var(--nav-text); }

.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: 8px; color: var(--nav-text); text-decoration: none; font-weight: 500;
}
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item[aria-current="page"] {
  background: var(--nav-active-bg); color: var(--nav-active-text);
  box-shadow: inset 3px 0 0 var(--nav-indicator);
}

.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-customer { margin: 0; font-size: 13px; color: var(--nav-text); overflow-wrap: anywhere; }

/* A faint brand wash behind the page heading. */
.main {
  min-width: 0; padding: 20px 28px 40px;
  background: linear-gradient(180deg, var(--accent-soft) 0, var(--bg) 260px) no-repeat;
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 24px; }
.asof { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
  color: var(--muted); font-size: 13px;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); }

/* Staff "view as customer" banner. */
.viewas {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--note-bg); border: 1px solid var(--note-border); color: var(--note-text); font-size: 14px;
}

.view { display: grid; gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; min-width: 0;
}
.card h2 { font-size: 16px; }
.card-sub { margin: 2px 0 14px; color: var(--muted); font-size: 13px; }

.notice {
  background: var(--note-bg); border: 1px solid var(--note-border); color: var(--note-text);
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px; margin: 0;
}

/* ---------- Home ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: inherit;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; align-items: start;
  border-top: 3px solid var(--tile-c, var(--tile-1));
  transition: transform .12s ease, box-shadow .12s ease;
}
a.tile:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--tile-c) 60%, transparent); }
.tile-1 { --tile-c: var(--tile-1); }
.tile-2 { --tile-c: var(--tile-2); }
.tile-3 { --tile-c: var(--tile-3); }
.tile-4 { --tile-c: var(--tile-4); }
.tile-body { min-width: 0; }
/* Decorative icon chip: tinted circle, icon in the tile's hue. Text stays in text colors. */
.tile-icon {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--tile-c) 14%, var(--surface)); color: var(--tile-c);
}
.tile-icon svg { width: 22px; height: 22px; }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 32px; font-weight: 600; line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }

/* Tall segmented bar: open orders by status. Segment widths set from JS (flex-grow). */
.segbar { display: flex; gap: 2px; height: 44px; border-radius: 6px; overflow: hidden; }
.seg {
  min-width: 4px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums;
}
.seg-1 { background: var(--series-1); }
.seg-2 { background: var(--series-2); }
/* On hold uses the reserved warning color (same as its badge dot), with dark text for contrast. */
.seg-hold { background: var(--status-warning); color: #3d2a00; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend b { font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.seg-1 { background: var(--series-1); }
.swatch.seg-2 { background: var(--series-2); }
.swatch.seg-hold { background: var(--status-warning); }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

.attention { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.attention h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.attention h3 svg { width: 16px; height: 16px; color: var(--status-warning); flex: none; }
.attention ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.attention a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--status-warning) 10%, var(--surface)); color: inherit; text-decoration: none; font-size: 14px;
}
.attention a:hover { background: color-mix(in srgb, var(--status-warning) 18%, var(--surface)); }
.attention small { color: var(--muted); }
.attention .all-good { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--muted); }
.attention .all-good svg { width: 16px; height: 16px; color: var(--status-good); }

/* Bar chart: orders per month. Bar heights set from JS. */
.barchart { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 6px; }
.bc-axis { position: relative; height: 160px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bc-axis span { position: absolute; right: 0; transform: translateY(-50%); }
.bc-plot { position: relative; height: 160px; border-bottom: 1px solid var(--faint); }
.bc-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--grid); }
.bc-bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: 100%; gap: 2px; }
.bc-col {
  position: relative; display: flex; align-items: flex-end; justify-content: center;
  border: 0; padding: 0; background: transparent; cursor: default; height: 100%;
}
.bc-col:hover, .bc-col:focus-visible { background: var(--row-hover); border-radius: 4px 4px 0 0; }
.bc-bar { width: 62%; max-width: 28px; background: var(--series-1); border-radius: 4px 4px 0 0; }
.bc-labels {
  grid-column: 2; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px;
  font-size: 11px; color: var(--muted); text-align: center;
}

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--surface);
  padding: 6px 10px; border-radius: 6px; font-size: 13px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
}

.next-list { list-style: none; margin: 0; padding: 0; }
.next-list li + li { border-top: 1px solid var(--border); }
.next-list a {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center;
  padding: 10px 4px; color: inherit; text-decoration: none;
}
.next-list a:hover { background: var(--row-hover); }
.date-chip {
  display: grid; justify-items: center; width: 52px; padding: 4px 0 6px; border-radius: 8px;
  background: var(--accent-soft); color: var(--text); line-height: 1.1;
}
.date-chip small { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.date-chip b { font-size: 20px; font-variant-numeric: tabular-nums; }
.date-chip.soon { background: color-mix(in srgb, var(--series-2) 16%, var(--surface)); }
.date-chip.soon small { color: var(--text); }
.next-what { min-width: 0; }
.next-what div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-what small { color: var(--muted); }

/* ---------- Status badge: colored dot + text label (never color alone) ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap;
  padding: 2px 10px 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status-neutral); }
.st-open, .st-partial, .st-hold, .st-shipped {
  background: color-mix(in srgb, var(--pill) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--pill) 35%, var(--surface));
}
.status::before { background: var(--pill, var(--status-neutral)); }
.st-open { --pill: var(--series-1); }
.st-partial { --pill: var(--series-2); }
.st-hold { --pill: var(--status-warning); }
.st-shipped { --pill: var(--status-good); }
.st-cancelled { color: var(--muted); text-decoration: line-through; }

/* ---------- Order lists ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 260px; min-width: 0; }
.toolbar select { flex: 0 1 auto; max-width: 100%; }
.list-count { margin: 0; color: var(--muted); font-size: 13px; }

.olist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.orow {
  display: grid; grid-template-columns: 1.1fr 0.8fr 0.8fr 1.6fr 1.1fr 0.9fr; gap: 12px; align-items: center;
  padding: 12px 16px; color: inherit; text-decoration: none; border-top: 1px solid var(--border);
}
.orow:first-child { border-top: 0; }
a.orow:hover { background: var(--row-hover); }
.orow-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); }
.o-num { font-weight: 600; }
.o-po { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.o-site { min-width: 0; }
.o-site div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-site small { color: var(--muted); }
.cell-label { display: none; }
.num { font-variant-numeric: tabular-nums; }

.progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; min-width: 40px; }
.progress-track, .progress-fill { display: block; }
.progress-fill { height: 100%; background: var(--status-good); border-radius: 3px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Order detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; text-decoration: none; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.detail-head h2 { font-size: 20px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 20px; margin: 16px 0 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }

.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.lines td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines tr:last-child td { border-bottom: 0; }
.lines .num { text-align: right; }
.lines th.num { text-align: right; }
.part { font-weight: 600; }
.part-desc { color: var(--muted); }
.rel-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }

/* ---------- Admin ---------- */
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 4px; }
.inline-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; flex: 1 1 180px; min-width: 0; }
.inline-form label:has(input[type="number"]) { flex: 0 0 90px; }
.inline-form input, .inline-form select { width: 100%; }

.alist { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.arow {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.4fr) minmax(0, 1.1fr) auto; gap: 10px 16px;
  align-items: center; padding: 12px 14px; border-top: 1px solid var(--border);
}
.arow:first-child { border-top: 0; }
.a-main { min-width: 0; display: grid; }
.a-main strong, .a-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-main small { color: var(--muted); }
.a-seats { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.a-seats .progress-track { grid-column: 1; }
.seat-label { grid-column: 1; }
.seat-form { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.seat-form input { width: 64px; min-height: 34px; padding: 0 8px; }
.seat-fill { background: var(--series-1); }
.seat-fill.full { background: var(--status-warning); }
.a-orders, .a-status { font-size: 13px; min-width: 0; display: grid; gap: 2px; justify-items: start; }
.a-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.a-custs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%; padding: 2px 4px 2px 10px; font-size: 13px;
  border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--border);
}
.chip:not(:has(button)) { padding-right: 10px; }
.chip-x {
  border: 0; background: none; cursor: pointer; width: 24px; height: 24px; border-radius: 50%;
  color: var(--muted); font-size: 16px; line-height: 1;
}
.chip-x:hover { background: var(--row-hover); color: var(--text); }
.link-sel { min-height: 30px; padding: 0 8px; font-size: 13px; max-width: 180px; }
.people-q { width: 100%; margin-top: 16px; }

.us-active { --pill: var(--status-good); }
.us-invited { --pill: var(--series-1); }
.us-warn { --pill: var(--status-warning); }
.us-off { color: var(--muted); }
.us-active, .us-invited, .us-warn {
  background: color-mix(in srgb, var(--pill) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--pill) 35%, var(--surface));
}

.welcome { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.welcome-text { width: 100%; font: 14px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; padding: 10px 12px; resize: vertical; }

/* ---------- Account ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.seg-ctl { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 10px; }
.seg-ctl button { border: 0; background: var(--surface); padding: 0 14px; min-height: 40px; cursor: pointer; }
.seg-ctl button + button { border-left: 1px solid var(--border); }
.seg-ctl button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* ---------- Tablet: icon-only sidebar ---------- */
@media (max-width: 1023px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 14px 10px; align-items: stretch; }
  .brand, .nav-item span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 18px 20px 40px; }
  .arow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .a-actions { justify-content: flex-start; }
}

/* ---------- Phone: bottom tab bar, cards instead of tables ---------- */
@media (max-width: 639px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .brand { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; min-height: 52px; font-size: 11px; justify-content: center; }
  .nav-item span { display: block; }
  .nav-item[aria-current="page"] { box-shadow: inset 0 3px 0 var(--nav-indicator); }
  .sidebar { background: var(--nav-bg); }
  .main { padding: 14px 16px calc(88px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 20px; }
  #theme-label { display: none; }
  .tiles { gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-value { font-size: 26px; }
  .card { padding: 14px 16px; }

  .toolbar select { flex: 1 1 40%; }
  .orow-head { display: none; }
  .orow { grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; }
  .o-num { grid-column: 1; }
  .o-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .o-site, .o-progress { grid-column: 1 / -1; }
  .o-date { font-size: 13px; color: var(--muted); }
  .cell-label { display: inline; color: var(--muted); }

  .next-list a { grid-template-columns: 52px minmax(0, 1fr); }
  .next-list .status { display: none; }

  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100%; }
  .lines tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  .lines tr:last-child { border-bottom: 0; }
  .lines td { border: 0; padding: 2px 0; text-align: left !important; }
  .lines td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  .bc-labels span:nth-child(even) { visibility: hidden; }
  .arow { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .inline-form label, .inline-form .btn { flex: 1 1 100%; }
  .inline-form label:has(input[type="number"]) { flex: 1 1 100%; }
  .viewas .btn { width: 100%; }
}
