/* Figma design language — see ~/.claude/plans/web-app-async-scott.md.
   Ink is pure black everywhere; hierarchy comes from weight (320/330/340/480/
   540/700), never from a mid-gray. Blue has two tiers: solid = an action you
   take, pale = the thing currently selected. Pastel blocks carry section
   identity, and no screen leans on a single one. */
/* The light palette is declared on the pinned-light screens as well as :root.
   Custom properties resolve by tree proximity, so inside .login-view / .lp-boot
   these win over whatever :root says -- including the dark block below. Without
   this, color-scheme: light keeps the UA out but --text still flips, and the
   login inputs render near-white on near-white. */
:root,
.login-view,
.lp-boot {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #000000;
  --muted: #000000;
  --border: #e6e6e6;
  --hairline-soft: #f1f1f1;
  --rule: #ededed;
  --zebra: #ededec;
  --surface-soft: #f7f7f5;

  --accent: #3a7ca5;          /* action: filled pill, white text */
  --accent-ink: #2c6588;      /* accent as type, and bars on pastel */
  --accent-weak: #e8f1f7;     /* selected surface */
  --accent-line: #c3dbea;     /* selected border */

  --positive: #4a7c59;        /* MTD delta, on-pace, unread dot */
  --info: #2c6588;
  --warn: #2c6588;
  --danger: #2c6588;
  --ink-soft: #000000;
  --on-accent: #ffffff;        /* type/marks that sit ON a saturated fill */
  --ink-rgb: 0, 0, 0;          /* --text in parts, for hairlines with alpha */
  --surface-rgb: 255, 255, 255;
  --shadow: none;

  --block-cream: #f4ecd6;
  --block-mint: #c8e6cd;
  --block-pink: #efd4d4;
  --block-coral: #f3c9b6;
  --block-lilac: #d6c7f7;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-shell {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.login-view {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

.brand-row p,
.topbar p,
.muted {
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.form-title,
.filter-title {
  font-size: 18px;
}

form,
.field-stack {
  display: grid;
  gap: 12px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfb;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 107, 74, 0.12);
}

.advanced-grid,
.date-grid {
  display: grid;
  gap: 12px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--muted);
}

.inline-check input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.segmented,
.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  padding: 4px;
  background: #eef1ee;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.database-radio {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.database-radio label {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--muted);
  font-weight: 900;
}

.database-radio label.is-active {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--accent);
}

.database-radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented button,
.tabs button {
  min-height: 44px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.is-active,
.tabs button.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 8px rgba(31, 40, 35, 0.08);
}

.action-row,
.toolbar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.action-row > button,
.toolbar-row > button {
  flex: 1 1 140px;
}

.primary,
.ghost,
.danger,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.ghost {
  background: #eef1ee;
  color: var(--text);
  border: 1px solid var(--border);
}

.danger {
  background: var(--danger);
  color: var(--on-accent);
}

.icon-button {
  background: var(--ink-soft);
  color: var(--surface);
  min-width: 56px;
}

.status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.status.is-error {
  color: var(--danger);
}

.is-hidden {
  display: none !important;
}

.workspace {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar h1 {
  font-size: 22px;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 14px;
}

.menu-view,
.action-list {
  display: grid;
  gap: 12px;
}

.action-card {
  display: grid;
  gap: 6px;
  min-height: 86px;
  width: 100%;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  color: var(--on-accent);
  box-shadow: var(--shadow);
}

.action-card strong {
  font-size: 17px;
}

.action-card span {
  color: rgba(255, 255, 255, 0.84);
  font-size: 12px;
  line-height: 1.35;
}

.action-card.accent {
  background: var(--accent);
}

.action-card.info {
  background: var(--info);
}

.action-card.danger {
  background: #da5c60;
}

.action-card.purple {
  background: #c8b8ee;
  color: #241b36;
}

.action-card.purple span {
  color: rgba(36, 27, 54, 0.72);
}

.full-button {
  width: 100%;
}

.stacked-button {
  display: grid;
  gap: 3px;
  text-align: left;
}

.stacked-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.view-header h2 {
  font-size: 22px;
}

.view-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-back {
  flex: 0 0 auto;
  min-width: 82px;
}

.section-head.compact {
  align-items: center;
}

.branch-head {
  margin-top: 4px;
}

.notice {
  border: 1px solid #d8e6dd;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--accent-weak);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.menu-view {
  min-height: calc(100vh - 150px);
  align-content: center;
}

.live-meta {
  color: var(--muted);
  font-size: 12px;
}

.refresh-button {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.refresh-button span {
  color: var(--muted);
  font-size: 12px;
}

.fallback-badge {
  justify-self: start;
  padding: 6px 10px;
  border: 1px solid #efb4ad;
  border-radius: 999px;
  background: #ffe9e6;
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
  animation: slowBlink 1.7s ease-in-out infinite;
}

@keyframes slowBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.42; }
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hour-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 8px;
}

.hour-cell {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.hour-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compare-grid {
  display: grid;
  gap: 8px;
}

.fav-row {
  justify-content: flex-start;
}

.fav-row > button {
  flex: 0 1 auto;
}

.star-button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid #b8dbcc;
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.star-button.is-saved {
  background: var(--accent);
  color: var(--on-accent);
}

.muted-pill {
  opacity: 0.55;
}

.scan-panel {
  margin-top: -4px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile,
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.metric-tile {
  min-height: 90px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.metric-tile small,
.item-card small,
.table-caption {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
}

.metric-tile strong {
  font-size: 22px;
  line-height: 1.1;
}

.metric-tile span {
  color: var(--muted);
  font-size: 12px;
}

.live-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.live-kpi {
  min-width: 0;
  padding: 10px 6px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.live-kpi:last-child {
  border-right: 0;
}

.live-kpi small {
  display: block;
  color: var(--muted);
  font-size: clamp(9px, 2.4vw, 12px);
  font-weight: 800;
  line-height: 1.2;
}

.live-kpi strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(16px, 4.6vw, 24px);
  line-height: 1;
}

.live-kpi.tone-accent strong,
.live-total-cell {
  color: var(--accent);
}

.live-kpi.tone-info strong {
  color: var(--info);
}

.live-kpi.tone-warn strong {
  color: #b57900;
}

.live-kpi.tone-danger strong {
  color: var(--danger);
}

.live-matrix-wrap {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.live-matrix {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.live-matrix caption {
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: clamp(15px, 4vw, 21px);
  font-weight: 900;
  text-align: center;
}

.live-matrix th,
.live-matrix td {
  position: static;
  padding: 7px 4px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #f7fbf8;
  color: var(--text);
  font-size: clamp(10px, 2.85vw, 15px);
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  font-weight: 400;
}

.live-matrix th:first-child,
.live-matrix td:first-child {
  position: static;
  width: 22%;
  background: #f9f8ea;
  text-align: left;
}

.live-matrix thead th {
  background: #f7fbf8;
  color: var(--text);
  font-weight: 900;
}

.live-matrix .live-total-head {
  color: var(--text);
}

.live-head-best {
  background: #e5f7ee !important;
  border-top: 3px solid var(--accent);
}

.live-head-mid {
  background: #fff7df !important;
  border-top: 3px solid #e0b33f;
}

.live-head-low {
  background: #ffe7e5 !important;
  border-top: 3px solid var(--danger);
}

.live-matrix tbody th {
  font-weight: 900;
}

.live-matrix td.money-cell {
  background: #fbf8e8;
}

.live-matrix td.soft-cell {
  background: #eef9f1;
}

.live-matrix td.info-cell {
  background: #e8f8fb;
}

.live-matrix td.warn-cell {
  background: #fff0cf;
}

.live-matrix td.live-total-cell {
  background: #eef9f1;
  font-weight: 900;
}

.changed-cell {
  position: relative !important;
}

.changed-cell::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00a76f;
}

.live-section-row th {
  padding: 8px 12px;
  background: #efeee8 !important;
  color: var(--text);
  text-align: left !important;
  text-transform: uppercase;
}

.android-dashboard {
  display: grid;
  gap: 12px;
}

.matrix-loading {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #dbe4de;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.android-meta,
.android-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.android-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.android-tabs button,
.android-teaser {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
}

.android-tabs button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.android-section {
  display: grid;
  gap: 10px;
}

.android-section h2 {
  font-size: 17px;
}

.android-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.android-stat {
  min-width: 0;
  min-height: 76px;
  display: grid;
  align-content: space-between;
  gap: 4px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.android-stat small,
.android-bogo-card small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.android-stat strong {
  color: var(--accent);
  font-size: clamp(17px, 4.8vw, 23px);
  line-height: 1;
}

.android-stat.tone-info strong {
  color: var(--info);
}

.android-stat.tone-danger strong {
  color: var(--danger);
}

.android-stat span,
.android-bogo-card span,
.android-segment small,
.android-branch-card small {
  color: var(--muted);
  font-size: 11px;
}

.android-bar-list,
.android-time-list,
.android-segment-list,
.android-branch-stack {
  display: grid;
  gap: 8px;
}

.android-bar-row {
  display: grid;
  gap: 5px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.android-bar-row.compact {
  padding: 7px 0;
  border: 0;
  border-radius: 0;
}

.android-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
}

.android-bar-label strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.android-bar-label span {
  flex: 0 0 auto;
  color: #b57900;
  font-weight: 900;
}

.android-expand-row {
  display: grid;
  gap: 7px;
}

.android-expand-row > summary {
  cursor: pointer;
  list-style: none;
}

.android-expand-row > summary::-webkit-details-marker {
  display: none;
}

.android-expand-row .expand-open {
  display: none;
}

.android-expand-row[open] .expand-closed {
  display: none;
}

.android-expand-row[open] .expand-open {
  display: inline;
}

.android-expand-row > summary.android-bar-row {
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.android-expand-row[open] > summary.android-bar-row {
  border-color: #b8e1ca;
  background: #f6fbf8;
}

.android-expand-row > summary.android-bar-row.compact {
  background: transparent;
}

.android-expand-row[open] > summary.android-bar-row.compact {
  background: transparent;
}

.android-expand-body {
  display: grid;
  gap: 8px;
  padding: 0 0 2px 12px;
  border-left: 2px solid #d8e6dc;
}

.android-nested-bars {
  display: grid;
  gap: 7px;
}

.bogo-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ffe9e6;
  color: var(--danger);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.android-bar-track {
  height: 9px;
  overflow: hidden;
  background: #e8eeeb;
  border-radius: 999px;
}

.android-bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--accent);
}

.android-bar-fill.tone-info,
.android-column span.tone-info {
  background: var(--info);
}

.android-bar-fill.tone-warn,
.android-column span.tone-warn {
  background: var(--warn);
}

.android-bar-fill.tone-danger,
.android-column span.tone-danger {
  background: var(--danger);
}

.android-overview-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.android-overview-row {
  display: grid;
  gap: 6px;
}

.android-overview-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.android-overview-head span {
  font-weight: 900;
}

.android-overview-head .tone-accent {
  color: var(--accent);
}

.android-overview-head .tone-info {
  color: var(--info);
}

.android-overview-head .tone-warn {
  color: var(--warn);
}

.android-overview-head .tone-danger {
  color: var(--danger);
}

.android-overview-row small {
  color: var(--muted);
  font-size: 12px;
}

.android-time-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 70px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}

.android-time-row span {
  color: var(--muted);
  text-align: right;
}

.android-teaser {
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 10px 12px;
  background: #e8f7ef;
  border-color: #b8e1ca;
  color: var(--accent);
  text-align: left;
}

.android-teaser span {
  color: var(--muted);
  font-size: 11px;
}

.android-accordion {
  border: 1px solid #b8e1ca;
  border-radius: 8px;
  background: #e8f7ef;
}

.android-accordion summary {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}

.android-accordion summary::-webkit-details-marker {
  display: none;
}

.android-accordion summary strong::after {
  content: " +";
}

.android-accordion[open] summary strong::after {
  content: " -";
}

.android-accordion summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.android-accordion-body {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}

.android-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.android-legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 2px;
  background: var(--accent);
}

.android-legend .tone-info::before {
  background: var(--info);
}

.android-legend .tone-warn::before {
  background: var(--warn);
}

.android-legend .tone-danger::before {
  background: var(--danger);
}

.android-segment,
.android-branch-block,
.android-mini-chart,
.android-bogo-card,
.android-branch-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.android-segment > div:first-child,
.android-branch-card > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.android-segment span,
.android-branch-card span {
  color: #b57900;
  font-weight: 900;
}

.android-bogo-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.android-bogo-card strong {
  display: block;
  color: var(--text);
  font-size: 21px;
}

.android-stack {
  display: flex;
  height: 10px;
  overflow: hidden;
  background: #e8eeeb;
  border-radius: 999px;
}

.android-stack span {
  display: block;
  min-width: 0;
}

.android-stack .good {
  background: var(--accent);
}

.android-stack .ok {
  background: var(--warn);
}

.android-stack .bad {
  background: var(--danger);
}

.android-stack-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.android-branch-cards {
  display: grid;
  gap: 8px;
}

.android-branch-card.tone-info {
  border-left: 4px solid var(--info);
}

.android-branch-card.tone-warn {
  border-left: 4px solid var(--warn);
}

.android-branch-card.tone-danger {
  border-left: 4px solid var(--danger);
}

.android-branch-card:not(.tone-info):not(.tone-warn):not(.tone-danger) {
  border-left: 4px solid var(--accent);
}

.android-branch-block h3,
.android-mini-chart h3 {
  font-size: 13px;
}

.android-column-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(10px, 1fr));
  gap: 5px;
  align-items: end;
  height: 118px;
}

.android-column {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 4px;
  justify-items: center;
  color: var(--muted);
  font-size: 9px;
}

.android-column b {
  color: var(--text);
  font-size: 10px;
  line-height: 1;
}

.android-column span {
  align-self: end;
  width: 100%;
  min-height: 4px;
  border-radius: 999px 999px 2px 2px;
  background: var(--accent);
}

.android-column.is-zero span {
  min-height: 0;
}

.android-column em {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  line-height: 1;
}

.weekend-label {
  color: var(--accent);
}

.section {
  display: grid;
  gap: 10px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.section-head h2 {
  font-size: 17px;
}

.section-head p {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}

th:first-child,
td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
}

th {
  background: #eef1ee;
  color: var(--ink-soft);
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

.bars {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) minmax(0, 2fr) minmax(86px, auto);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.bar-track {
  height: 10px;
  border-radius: 8px;
  background: #ecefed;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar-fill.info {
  background: var(--info);
}

.bar-fill.warn {
  background: var(--warn);
}

.bar-fill.danger {
  background: var(--danger);
}

.branch-list,
.sku-list,
.product-list,
.risk-list {
  display: grid;
  gap: 8px;
}

.item-card {
  display: grid;
  gap: 6px;
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.item-title span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.product-card {
  gap: 10px;
}

.product-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.product-title-row h3 {
  min-width: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.product-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.code-badge,
.cat1-badge,
.cat-badge {
  border-radius: 999px;
  /* The border is on all three so the outlined CAT1 chip sits at exactly the
     same height as its filled neighbours; only CAT1 lets it show. */
  border: 1px solid transparent;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
}

.code-badge {
  background: #fff1dc;
  color: #9a5b00;
}

/* CAT1 is CAT4's parent, so it stays in the same blue family and says so by
   being outlined rather than filled — one glance gives aisle then shelf,
   without a third colour competing with the code chip's amber. */
.cat1-badge {
  background: var(--surface);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

.cat-badge {
  background: var(--accent-weak);
  color: var(--accent);
}

.barcode-line {
  color: var(--muted);
  font-size: 12px;
}

.product-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.product-metrics div {
  display: grid;
  gap: 2px;
}

.product-metrics small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.product-metrics strong {
  color: var(--text);
  font-size: 14px;
}

.stock-title {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.stock-chip {
  color: var(--info);
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef1ee;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.pill.warn {
  background: #fff3df;
  color: #8b5300;
}

.pill.danger {
  background: #ffe8e5;
  color: #8f281e;
}

.pill.warn,
.pill.danger,
.bar-fill.danger,
.bar-fill.warn,
.bar-fill.info {
  min-height: 0;
}

.bar-fill.danger,
.bar-fill.warn,
.bar-fill.info {
  padding: 0;
  font-weight: inherit;
}

.android-legend .tone-info,
.android-legend .tone-warn,
.android-legend .tone-danger {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.company-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.company-box label {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.company-box input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin-right: 8px;
  accent-color: var(--accent);
}

.sku-select-box {
  display: grid;
  gap: 8px;
}

.sku-select-box label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.sku-select-box input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.sku-select-box span {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sku-select-box strong {
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sku-select-box small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sku-comparison-stack {
  display: grid;
  gap: 12px;
}

.comparison-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.comparison-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.comparison-card-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.comparison-card-head span {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.comparison-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.comparison-table {
  min-width: 420px;
  table-layout: auto;
}

.comparison-table th,
.comparison-table td {
  padding: 8px 10px;
  font-size: 12px;
}

.comparison-table td:last-child,
.comparison-total-row td,
.comparison-total-row th {
  color: var(--accent);
  font-weight: 900;
}

.comparison-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.comparison-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.comparison-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.comparison-chart {
  width: 100%;
  min-height: 220px;
  overflow: visible;
}

.comparison-line {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comparison-point {
  cursor: pointer;
  stroke: var(--surface);
  stroke-width: 2;
}

.comparison-grid-line {
  stroke: #e3e8e4;
  stroke-width: 1;
}

.comparison-axis-line {
  stroke: #bdc7c0;
  stroke-width: 1;
}

.comparison-axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.comparison-tooltip {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.split-panel {
  display: grid;
  gap: 12px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(var(--surface-rgb), 0.7);
  text-align: center;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 24px;
  }

  .login-view {
    width: min(720px, 100%);
    margin: 0 auto;
  }

  .advanced-grid,
  .date-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .split-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 430px) {
  .topbar {
    align-items: flex-start;
  }

  .metric-tile strong {
    font-size: 19px;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .tabs button {
    font-size: 13px;
  }

  .mini-grid {
    grid-template-columns: 1fr;
  }

  .view-header {
    align-items: flex-start;
  }

  .item-title {
    align-items: flex-start;
  }

  .star-button {
    min-width: 74px;
  }
}

/* ── Chat with Yoyo ─────────────────────────────────────────────────────── */

.action-card.yoyo {
  background: var(--ink-soft);
}

/* Cards with a portrait (e.g. Chat with Yoyo): text left, round photo right. */
.action-card.has-img {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.action-card-text {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.action-card-imgwrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.action-card-img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.55);
  display: block;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  /* CRITICAL: grid items default to min-width:auto, which lets the chips row's
     intrinsic width (~1000px) blow the whole page out on mobile. min-width:0
     lets the shell shrink to the viewport so the chips scroll instead. */
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  /* LINE-like: fill the remaining viewport height; thread flexes, composer
     stays pinned at the bottom of the shell. JS (sizeChatShell) sets an exact
     inline height from visualViewport and follows the keyboard; this calc is
     just the first-paint fallback before JS runs. */
  height: calc(100vh - 168px);
  height: calc(100dvh - 168px);
  min-height: 360px;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* Stacks like the Yoyo row now: the bubble, then the time it was asked under
   it. justify-content is gone on purpose — with a column direction it would
   push on the vertical axis, and the right edge is align-items' job. */
.chat-row.out {
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

/* Yoyo row stacks vertically: the avatar+bubble line, then the meta under it.
   The avatar bottom-aligns to the BUBBLE bottom (not the meta) via .chat-line. */
.chat-row.in {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.chat-line {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
}

.chat-in-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 85%;
}

.chat-avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--accent);
}

.chat-bubble {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.chat-bubble.in {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

.chat-bubble.out {
  background: var(--accent);
  color: var(--on-accent);
  max-width: 85%;
  border-bottom-right-radius: 2px;
}

.chat-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 4px 10px;
}

.chat-bubble.typing {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-meta {
  font-size: 11px;
  color: var(--muted);
  padding-left: 36px; /* avatar (28) + gap (8) — sits under the bubble */
}

/* The question side has no avatar to clear, and reads from the right edge. */
.chat-meta.out {
  padding-left: 0;
  padding-right: 2px;
}

.chat-img-tag {
  opacity: 0.85;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
  animation: chatBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.typing-label {
  font-size: 12px;
  color: var(--muted);
}

.chat-composer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: max(2px, env(safe-area-inset-bottom));
}

.chat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
  min-width: 0;
  max-width: 100%;
}

.chat-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 44px;
  /* a chip with a very short label ("WTD") would otherwise be narrower than it
     is tall, which is the one dimension padding does not defend */
  min-width: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.chip:hover {
  background: #d9efe3;
}

.chip:disabled {
  opacity: 0.45;
  cursor: default;
}

/* utility chips (Hello / Clear chat) — neutral, set apart from the data commands */
.chip.util {
  background: var(--bg);
  color: var(--ink-soft);
}

.chip.util:hover {
  background: var(--border);
}

.chat-daypicker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent-weak);
}

.daypicker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.daypicker-head button {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.daypicker-body {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

/* sub-choice popup (e.g. KOL: How it works / Show scorecard) */
.choice-body {
  display: flex;
  gap: 8px;
}

.choice-btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.choice-btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.choice-btn.secondary {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--border);
}

.daypicker-today {
  flex: 0 0 auto;
  min-width: 104px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.daypicker-today:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.daypicker-divider {
  flex: 0 0 0;
  align-self: stretch;
  border-left: 1px dashed var(--muted);
}

.daypicker-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.daypicker-right input[type="date"] {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;
}

.daypicker-go {
  width: 100%;
  min-height: 40px;
  padding: 6px 18px;
}

.daypicker-note {
  margin: 0;
  font-size: 12px;
  color: #b23b3f;
}

/* Greyed/locked composer while Yoyo is thinking */
.chat-composer.is-busy .chat-chips,
.chat-composer.is-busy .chat-input-row,
.chat-composer.is-busy .chat-daypicker {
  opacity: 0.45;
  pointer-events: none;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  min-width: 0;
}

.chat-input-row textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 44px;
  max-height: 110px;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  line-height: 1.4;
}

.chat-input-row textarea:disabled {
  background: #f0f2f0;
  color: var(--muted);
}

.chat-icon-btn {
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.chat-icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.chip:focus-visible,
.chat-icon-btn:focus-visible,
.chat-input-row textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-quota-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 2px 0;
}

.chat-quota-note {
  font-size: 11px;
  color: var(--muted);
}

.quota-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.quota-badge.is-empty {
  background: #fdecea;
  color: var(--danger);
}

.chat-image-preview {
  position: relative;
  width: 64px;
}

.chat-image-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.chat-image-preview button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-disabled-note {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

/* Admin: per-user quota */
.action-card.admin {
  background: var(--warn);
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.admin-sub {
  font-size: 12px;
  color: var(--muted);
}

.admin-refresh {
  min-height: 38px;
  padding: 6px 16px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.admin-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-row-main strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.admin-usage {
  font-size: 12px;
  color: var(--muted);
}

.admin-usage.is-empty {
  color: var(--danger);
  font-weight: 700;
}

.admin-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-weak);
  overflow: hidden;
}

.admin-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.admin-reset {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 16px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-height: 42vh;
  overflow-y: auto;
}

.activity-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
}

.activity-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.activity-user {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-act {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 700;
}

/* Admin: Chat-with-Yoyo access list */
.wl-add {
  display: flex;
  gap: 8px;
  margin: 4px 0 8px;
}

.wl-add input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;
}

.wl-add-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 16px;
}

.wl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wl-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg);
}

.wl-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.wl-you {
  color: var(--muted);
  font-size: 11px;
}

.wl-remove {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 4px 12px;
  font-size: 12px;
  color: #b23b3f;
}

@media (prefers-reduced-motion: reduce) {
  .typing-dots span {
    animation: none;
    opacity: 0.7;
  }
}

@media (max-width: 430px) {
  .chat-bubble.out,
  .chat-line {
    max-width: 92%;
  }

  .chip {
    font-size: 12.5px;
  }

  .chat-shell {
    height: calc(100dvh - 150px);
    min-height: 320px;
    padding: 10px;
  }
}
