/* Chonjo — the dashboard's one stylesheet.
 *
 * Read on cheap Android phones over weak connections, so: system fonts (nothing to download), no
 * framework, one cached file. Every value comes from the tokens below; a page that needs a new
 * colour or spacing needs a new token, not an inline style. The server's Content-Security-Policy
 * forbids inline styles outright, which keeps this file the single source of truth.
 */

/* ─────────────────────────────────────────────────────────────── tokens */

:root {
  color-scheme: light;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* type scale (rem, so a phone's font-size setting is respected) */
  --text-xs: 0.75rem;     /* 12 — badges, captions */
  --text-sm: 0.875rem;    /* 14 — labels, secondary text, tables */
  --text-md: 1rem;        /* 16 — body, inputs (16 stops iOS zooming into fields) */
  --text-lg: 1.125rem;    /* 18 — section headings */
  --text-xl: 1.375rem;    /* 22 — key figures */
  --text-2xl: 1.625rem;   /* 26 — page titles */
  --leading-tight: 1.25;
  --leading: 1.5;

  /* spacing: a 4px grid */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.5rem;  --s-6: 2rem;   --s-7: 3rem;

  --radius-sm: 6px;       /* controls */
  --radius: 10px;         /* cards, dialogs */
  --radius-pill: 999px;   /* badges */
  --shadow-1: 0 1px 2px rgb(16 24 20 / 0.06);
  --shadow-2: 0 12px 32px rgb(16 24 20 / 0.18);

  --header-h: 56px;
  --tabbar-h: 64px;
  --content-w: 1120px;

  /* colour — every pair below is at least 4.5:1 for text */
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --border: #dbe2de;
  --border-strong: #b9c4be;
  --text: #15201a;
  --text-2: #4b5852;      /* secondary text: 7.2:1 on surface */
  --text-3: #5d6a63;      /* captions: 5.4:1 on bg */
  --link: #0b6a43;

  --primary: #0f7b4f;
  --primary-hover: #0b6641;
  --on-primary: #ffffff;
  --primary-soft: #e2f3ea;

  --success: #06704a;  --success-soft: #dcf5e7;
  --warning: #8a3a0b;  --warning-soft: #fdefd0;
  --danger: #b42318;   --danger-soft: #fde7e5;  --on-danger: #ffffff;  --danger-hover: #971c13;
  --info: #1a55c2;     --info-soft: #e3ebfd;
  --neutral: #3c4842;  --neutral-soft: #e6ebe8;

  --focus: #1a55c2;

  /* the logo (brand.mjs): green lettering, white eyes in a green ring, amber irises */
  --logo-ink: #0B5D3F; --logo-sclera: #ffffff; --logo-ring: #0B5D3F;
  --logo-iris: #F5B324; --logo-pupil: #0A2A1F; --logo-glint: #ffffff;
}

/* Dark: follows the phone unless the owner chose a theme on their profile. The block appears
 * twice — once for "follow the phone", once for "always dark" — because CSS cannot share it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1411; --surface: #151d19; --surface-2: #1c2621; --border: #29352f; --border-strong: #3d4b44;
    --text: #e6eee9; --text-2: #b4c2bb; --text-3: #9dada5; --link: #6fdfae;
    --primary: #3ccb8b; --primary-hover: #5cd8a1; --on-primary: #05130c; --primary-soft: #133322;
    --success: #6be3a6; --success-soft: #11301f;
    --warning: #f9b54a; --warning-soft: #33250b;
    --danger: #ff9f95; --danger-soft: #3a1613; --on-danger: #1d0605; --danger-hover: #ffbab2;
    --info: #8fb4ff; --info-soft: #142343;
    --neutral: #c4d0c9; --neutral-soft: #26312b;
    --focus: #8fb4ff;
    --shadow-1: none; --shadow-2: 0 12px 32px rgb(0 0 0 / 0.5);
    --logo-ink: #FFF6E0; --logo-sclera: #FFF6E0; --logo-ring: #FFF6E0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1411; --surface: #151d19; --surface-2: #1c2621; --border: #29352f; --border-strong: #3d4b44;
  --text: #e6eee9; --text-2: #b4c2bb; --text-3: #9dada5; --link: #6fdfae;
  --primary: #3ccb8b; --primary-hover: #5cd8a1; --on-primary: #05130c; --primary-soft: #133322;
  --success: #6be3a6; --success-soft: #11301f;
  --warning: #f9b54a; --warning-soft: #33250b;
  --danger: #ff9f95; --danger-soft: #3a1613; --on-danger: #1d0605; --danger-hover: #ffbab2;
  --info: #8fb4ff; --info-soft: #142343;
  --neutral: #c4d0c9; --neutral-soft: #26312b;
  --focus: #8fb4ff;
  --shadow-1: none; --shadow-2: 0 12px 32px rgb(0 0 0 / 0.5);
  --logo-ink: #FFF6E0; --logo-sclera: #FFF6E0; --logo-ring: #FFF6E0;
}

/* ─────────────────────────────────────────────────────────────── base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: var(--text-md) / var(--leading) var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; }
h1 { font-size: var(--text-2xl); line-height: var(--leading-tight); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); line-height: var(--leading-tight); font-weight: 650; }
h3 { font-size: var(--text-md); line-height: var(--leading-tight); font-weight: 650; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
svg { flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s-4); top: -100px; z-index: 100; padding: var(--s-2) var(--s-3);
  background: var(--surface); color: var(--text); border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
}
.skip-link:focus { top: var(--s-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ─────────────────────────────────────────────────────────────── the application shell */

.app-header {
  position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: var(--content-w); margin: 0 auto; height: var(--header-h); padding: 0 var(--s-4);
  display: flex; align-items: center; gap: var(--s-4);
}
.brand {
  display: flex; align-items: center; gap: var(--s-2); min-width: 0;
  color: var(--text); text-decoration: none;
}
.brand__mark { width: 32px; height: 32px; flex: none; display: block; }
.brand__text { display: grid; min-width: 0; line-height: 1.2; }
.brand__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand__sub { font-size: var(--text-xs); color: var(--text-3); }

/* The wordmark (brand.mjs). Sized by height; its width follows from the drawing. */
.logo { display: block; width: auto; flex: none; }
.logo--sm { height: 24px; } .logo--md { height: 30px; } .logo--lg { height: 44px; }
.logo__ink { fill: var(--logo-ink); }
.logo__sclera { fill: var(--logo-sclera); stroke: var(--logo-ring); stroke-width: 6.44; }
.logo__iris { fill: var(--logo-iris); } .logo__pupil { fill: var(--logo-pupil); } .logo__glint { fill: var(--logo-glint); }

.primary-nav { display: none; }
.primary-nav ul { list-style: none; display: flex; gap: var(--s-1); }
.primary-nav a {
  display: flex; align-items: center; gap: var(--s-2); height: 40px; padding: 0 var(--s-3);
  border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 600;
  font-size: var(--text-sm);
}
.primary-nav a:hover { background: var(--surface-2); color: var(--text); }
.primary-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

/* Menus are <details>: they open and close with no script. app.js adds closing on Escape and
 * on a click elsewhere. */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__button {
  display: flex; align-items: center; gap: var(--s-2); height: 40px; padding: 0 var(--s-2) 0 var(--s-3);
  border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; font-size: var(--text-sm);
}
.menu__button:hover, .menu[open] > .menu__button { background: var(--surface-2); color: var(--text); }
.menu__button--avatar { padding: 0 var(--s-1); }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 240px; padding: var(--s-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.menu__panel a, .menu__panel .menu__item {
  display: flex; align-items: center; gap: var(--s-3); min-height: 40px; padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: var(--text-sm);
}
.menu__panel a:hover { background: var(--surface-2); }
.menu__panel a[aria-current="page"] { color: var(--primary); font-weight: 600; }
.menu__panel a svg { color: var(--text-3); }
.menu__identity { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--border); margin-bottom: var(--s-2); }
.menu__identity strong { display: block; overflow-wrap: anywhere; }
.menu__identity span { font-size: var(--text-sm); color: var(--text-2); }
.menu__divider { border: 0; border-top: 1px solid var(--border); margin: var(--s-2) 0; }
.shop-menu { display: none; }

/* Phones: the five daily destinations sit at the bottom, under the thumb. */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar ul { list-style: none; display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; height: var(--tabbar-h); }
.tab-bar a {
  position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-2); text-decoration: none; font-size: var(--text-xs); font-weight: 600;
}
.tab-bar a[aria-current="page"] { color: var(--primary); }
.tab-bar a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}
.tab-bar .count { position: absolute; top: 6px; left: calc(50% + 6px); }
body.has-tab-bar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .primary-nav { display: block; }
  .shop-menu { display: block; }
  .tab-bar { display: none; }
  body.has-tab-bar { padding-bottom: 0; }
}

.page { max-width: var(--content-w); margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-7); }
.page--narrow { max-width: 720px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); }
.page-header__text { display: grid; gap: var(--s-1); min-width: 0; }
.page-header__text p { color: var(--text-2); max-width: 65ch; }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.breadcrumb { font-size: var(--text-sm); }
.breadcrumb a { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

.stack { display: grid; gap: var(--s-4); }
.stack--lg { gap: var(--s-5); }
.cols { display: grid; gap: var(--s-4); }
@media (min-width: 900px) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.cols--sidebar { }
@media (min-width: 900px) { .cols--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }

/* ─────────────────────────────────────────────────────────────── cards and sections */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); min-width: 0; }
.card__header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: var(--s-4) var(--s-4) 0;
}
.card__header p { flex-basis: 100%; color: var(--text-2); font-size: var(--text-sm); }
.card__header a { font-size: var(--text-sm); font-weight: 600; }
.card__body { padding: var(--s-4); }
.card__body > * + * { margin-top: var(--s-3); }
.card__footer { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); font-size: var(--text-sm); }
/* A card that opens and closes (<details>): its heading is the control, marked by a chevron. */
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '▸'; margin-left: auto; color: var(--text-2); }
details.card[open] > summary::after { content: '▾'; }
/* Product photos: a square thumbnail beside a name, and a grid on the product's page. */
.thumb { width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: cover; background: var(--surface-2, var(--border)); }
.thumb--empty { display: inline-grid; place-items: center; color: var(--text-2); }
.product-link { display: inline-flex; align-items: center; gap: var(--s-3); color: inherit; text-decoration: none; min-width: 0; }
.product-link:hover span { text-decoration: underline; }
.photo-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-3); }
.photo-grid li { display: grid; gap: var(--s-2); justify-items: start; }
.photo-grid img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
/* A row of buttons ending a form: the main action first. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.card--accent { border-color: var(--primary); }
.card--warning { border-color: var(--warning); }
.card--danger { border-color: var(--danger); }
.section-title { font-size: var(--text-lg); margin: var(--s-2) 0 var(--s-3); }

/* ─────────────────────────────────────────────────────────────── figures */

.stats { display: grid; gap: var(--s-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { display: grid; gap: var(--s-1); padding: var(--s-4); color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--border-strong); }
.stat__label { font-size: var(--text-sm); color: var(--text-2); }
.stat__value { font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.stat__hint { font-size: var(--text-xs); color: var(--text-3); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }
.strike { text-decoration: line-through; }

progress {
  appearance: none; width: 100%; height: 8px; border: 0; border-radius: var(--radius-pill);
  background: var(--surface-2); overflow: hidden; accent-color: var(--primary);
}
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: var(--radius-pill); }
progress::-webkit-progress-value { background: var(--primary); border-radius: var(--radius-pill); }
progress::-moz-progress-bar { background: var(--primary); border-radius: var(--radius-pill); }
progress.progress--warning::-webkit-progress-value { background: var(--warning); }
progress.progress--warning::-moz-progress-bar { background: var(--warning); }
progress.progress--danger::-webkit-progress-value { background: var(--danger); }
progress.progress--danger::-moz-progress-bar { background: var(--danger); }

/* ─────────────────────────────────────────────────────────────── buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-4); border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: var(--text-sm); font-weight: 650; line-height: 1.2; text-decoration: none;
  white-space: nowrap; cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: var(--on-danger); }
.btn--danger:hover { background: var(--danger-hover); }
.btn--danger-outline { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn--danger-outline:hover { background: var(--danger-soft); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { min-height: 36px; padding: 0 var(--s-3); }
.btn--block { width: 100%; }
.btn[aria-disabled="true"], .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.8; }
.btn[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }

/* ─────────────────────────────────────────────────────────────── badges and status */

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--neutral-soft); color: var(--neutral); font-size: var(--text-xs); font-weight: 650;
  line-height: 1.5; white-space: nowrap; vertical-align: middle;
}
.badge svg { width: 12px; height: 12px; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--info    { background: var(--info-soft);    color: var(--info); }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
  background: var(--danger); color: var(--on-danger); font-size: var(--text-xs); font-weight: 700; line-height: 1;
}

/* ─────────────────────────────────────────────────────────────── notices */

.notice {
  display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--surface);
}
.notice svg { margin-top: 2px; }
.notice__body { display: grid; gap: var(--s-1); min-width: 0; }
.notice__body p { color: var(--text-2); font-size: var(--text-sm); }
.notice--success { border-color: var(--success); } .notice--success > svg { color: var(--success); }
.notice--warning { border-color: var(--warning); } .notice--warning > svg { color: var(--warning); }
.notice--danger  { border-color: var(--danger); }  .notice--danger > svg  { color: var(--danger); }
.notice--info    { border-color: var(--info); }    .notice--info > svg    { color: var(--info); }

/* ─────────────────────────────────────────────────────────────── forms */

.form { display: grid; gap: var(--s-4); max-width: 560px; }
.form--wide { max-width: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--s-3); }
legend { padding: 0; font-weight: 650; margin-bottom: var(--s-1); }
.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: var(--text-sm); }
.field__label .optional { font-weight: 400; color: var(--text-3); }
.field__label .required { color: var(--danger); }
.field__hint { font-size: var(--text-sm); color: var(--text-2); }
.field__error { display: flex; gap: var(--s-1); align-items: center; font-size: var(--text-sm); font-weight: 600; color: var(--danger); }
.field__counter { font-size: var(--text-xs); color: var(--text-3); text-align: right; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-md);
}
.textarea { min-height: 72px; resize: vertical; line-height: var(--leading); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.input--code { font-family: var(--font-mono); font-size: var(--text-xl); letter-spacing: 0.3em; text-align: center; }
.check { display: flex; gap: var(--s-3); align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--primary); cursor: pointer; }
.check__text { display: grid; gap: 2px; }
.check__text small { color: var(--text-2); font-size: var(--text-sm); }
.choice-group { display: grid; gap: var(--s-2); }
.search { display: flex; gap: var(--s-2); max-width: 480px; }
.search .input { flex: 1; }

/* ─────────────────────────────────────────────────────────────── lists and tables */

.rows { list-style: none; }
.rows > li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); min-width: 0; }
.rows > li:first-child { border-top: 0; }
.rows__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rows__main > span, .rows__main > small { color: var(--text-2); font-size: var(--text-sm); overflow-wrap: anywhere; }
.rows__title { font-weight: 600; overflow-wrap: anywhere; }
.rows__end { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.rows a.rows__link { color: inherit; text-decoration: none; }
.rows a.rows__link:hover .rows__title { text-decoration: underline; }
.icon-circle {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--neutral-soft); color: var(--neutral);
}
.icon-circle--danger { background: var(--danger-soft); color: var(--danger); }
.icon-circle--warning { background: var(--warning-soft); color: var(--warning); }
.icon-circle--info { background: var(--info-soft); color: var(--info); }
.icon-circle--success { background: var(--success-soft); color: var(--success); }
.icon-circle--primary { background: var(--primary-soft); color: var(--primary); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table caption { text-align: left; }
.table th {
  text-align: left; font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-2); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num, .table th.num { text-align: right; }
.table .cell-main { font-weight: 600; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table tr.is-muted td { color: var(--text-3); }

/* Phones: a table row becomes a compact block — name and amount on the first line, details
 * under it, actions last — instead of a table squeezed until every cell wraps. */
@media (max-width: 719px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody { display: block; }
  .table--stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { display: block; padding: 0; border: 0; }
  .table--stack .cell-main { flex: 1 1 55%; min-width: 0; font-size: var(--text-md); }
  .table--stack .num { margin-left: auto; font-size: var(--text-md); font-weight: 650; }
  .table--stack .cell-meta { order: 3; flex-basis: 100%; color: var(--text-2); }
  .table--stack .cell-meta:empty { display: none; }
  .table--stack .cell-actions { order: 4; flex-basis: 100%; text-align: left; padding-top: var(--s-2); }
}

.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); overflow-x: auto; }
.tabs a {
  display: flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-3);
  border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--text-2); text-decoration: none; font-weight: 600;
  font-size: var(--text-sm); white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--primary); }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); font-size: var(--text-sm); }

.day-heading { padding: var(--s-3) var(--s-4) var(--s-2); background: var(--surface-2); font-size: var(--text-sm); font-weight: 650; display: flex; justify-content: space-between; gap: var(--s-3); }

/* ─────────────────────────────────────────────────────────────── empty states */

.empty { display: grid; justify-items: center; gap: var(--s-2); text-align: center; padding: var(--s-6) var(--s-4); }
.empty .icon-circle { width: 48px; height: 48px; }
.empty p { color: var(--text-2); max-width: 44ch; }
.empty .btn { margin-top: var(--s-2); }

/* ─────────────────────────────────────────────────────────────── specific pieces */

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: var(--text-sm); text-transform: uppercase;
}
.avatar--lg { width: 64px; height: 64px; font-size: var(--text-xl); }

.request { display: grid; gap: var(--s-3); }
.request__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.request__head h3 { font-size: var(--text-md); }
.request__head time { margin-left: auto; color: var(--text-3); font-size: var(--text-sm); }
.request__quote { font-size: var(--text-md); padding-left: var(--s-3); border-left: 3px solid var(--border-strong); }
.request__from { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); font-size: var(--text-sm); color: var(--text-2); }
.preview { font-size: var(--text-sm); color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--s-2) var(--s-3); white-space: pre-line; }
.preview strong { color: var(--text); }

.steps { list-style: none; counter-reset: step; }
.step { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-top: 1px solid var(--border); }
.step:first-child { border-top: 0; }
.step__marker {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 2px solid var(--border-strong); color: var(--text-2); font-weight: 700; font-size: var(--text-sm);
}
.step--done .step__marker { background: var(--success); border-color: var(--success); color: var(--surface); }
.step--next { background: var(--primary-soft); }
.step--next .step__marker { border-color: var(--primary); color: var(--primary); }
.step__body { flex: 1; display: grid; gap: var(--s-1); min-width: 0; }
.step__body p { color: var(--text-2); font-size: var(--text-sm); }
.step__action { margin-top: var(--s-2); }

.qr { display: grid; justify-items: center; gap: var(--s-3); text-align: center; }
.qr__code { background: #ffffff; padding: var(--s-3); border-radius: var(--radius); border: 1px solid var(--border); line-height: 0; }
.qr__code svg { width: min(280px, 70vw); height: auto; }
.pairing-code { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; letter-spacing: 0.15em; }
.how-to { list-style: decimal; padding-left: var(--s-5); display: grid; gap: var(--s-1); color: var(--text-2); font-size: var(--text-sm); text-align: left; }

.dl { display: grid; gap: var(--s-3); }
.dl > div { display: grid; gap: 2px; }
@media (min-width: 600px) { .dl > div { grid-template-columns: 200px 1fr; gap: var(--s-4); } }
.dl dt { color: var(--text-2); font-size: var(--text-sm); }
.dl dd { overflow-wrap: anywhere; }

.plan-grid { display: grid; gap: var(--s-4); }
@media (min-width: 720px) { .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .plan-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.plan { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
.plan__price { font-size: var(--text-xl); font-weight: 700; }
.plan ul { list-style: none; display: grid; gap: var(--s-2); font-size: var(--text-sm); flex: 1; }
.plan li { display: flex; gap: var(--s-2); }
.plan li svg { color: var(--success); margin-top: 2px; }
.plan--current { border-color: var(--primary); border-width: 2px; }

/* Paying: the disclosure's summary is the button, so it works with no script and a keyboard. */
.pay > summary { list-style: none; }
.pay > summary::-webkit-details-marker { display: none; }
.pay[open] > summary { margin-bottom: var(--s-3); }
.pay__form { max-width: none; gap: var(--s-3); }
.card--info { border-color: var(--info); border-width: 2px; }
.pay-wait .section-title { margin: 0; }
/* Stops turning when reduced motion is asked for (the rule above), and still reads as "busy". */
.spinner { width: 20px; height: 20px; flex: none; border: 3px solid var(--border-strong);
  border-top-color: var(--info); border-radius: 50%; animation: spin 0.9s linear infinite; }

.more-list .rows > li { padding: 0; }
.more-list .rows a { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 56px; padding: var(--s-2) var(--s-4); color: var(--text); text-decoration: none; }
.more-list .rows a:hover { background: var(--surface-2); }
.more-list .rows a > svg:last-child { margin-left: auto; color: var(--text-3); }

details.disclosure > summary { cursor: pointer; font-weight: 600; font-size: var(--text-sm); color: var(--link); }
details.disclosure > summary + * { margin-top: var(--s-2); }

/* ─────────────────────────────────────────────────────────────── sign-in pages */

.auth { min-height: 100vh; display: grid; align-content: start; justify-items: center; padding: var(--s-7) var(--s-4); gap: var(--s-5); }
@media (min-height: 700px) { .auth { align-content: center; } }
.auth__brand { display: block; border-radius: var(--radius-sm); }
.auth__card { width: 100%; max-width: 420px; padding: var(--s-5); display: grid; gap: var(--s-4); }
.auth__card h1 { font-size: var(--text-xl); }
.auth__foot { font-size: var(--text-sm); color: var(--text-2); text-align: center; }
.btn--google { min-height: 48px; font-weight: 600; }
.google-mark { flex: none; }
.or-divider { display: flex; align-items: center; gap: var(--s-3); color: var(--text-2); font-size: var(--text-sm); }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ─────────────────────────────────────────────────────────────── dialog (app.js) */

.dialog {
  width: min(440px, calc(100% - 2 * var(--s-4))); padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-2);
}
.dialog::backdrop { background: rgb(8 12 10 / 0.55); }
.dialog__body { display: grid; gap: var(--s-3); padding: var(--s-5); }
.dialog__message { color: var(--text-2); }
.dialog__actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
.dialog[open] { animation: dialog-in 0.15s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }

/* ─────────────────────────────────────────────────────────────── additions to the shell */

.menu__button[data-current] { background: var(--primary-soft); color: var(--primary); }
.primary-nav .count { margin-left: 2px; }
.card__flush { overflow: hidden; border-radius: 0 0 var(--radius) var(--radius); }
.card__header + .card__flush { margin-top: var(--s-3); border-top: 1px solid var(--border); }
.h3 { font-size: var(--text-md); line-height: var(--leading-tight); font-weight: 650; }
.admin-plan { display: grid; gap: var(--s-3); align-items: end; }
@media (min-width: 600px) { .admin-plan { grid-template-columns: minmax(0, 1fr) 120px auto; } }
.card__body.muted { margin: 0; }

/* ─────────────────────────────────────────────────────────────── QA fixes: layout and targets */

/* Grid children default to min-width:auto and would grow to fit a wide table instead of letting
 * it scroll inside its card. */
.stack > *, .cols > * { min-width: 0; }
.stat { align-content: start; }

/* Rows that end in an action: on a phone the action moves under the text instead of squeezing it. */
@media (max-width: 599px) {
  .rows--actions > li { flex-wrap: wrap; }
  .rows--actions > li > .rows__end { flex-basis: 100%; padding-left: calc(36px + var(--s-3)); }
}

/* Links inside tables and lists are real tap targets, not just words. */
.table a, .rows__main a, .request__from a, .card__header a, .breadcrumb a, .auth__foot a, .card__body > .small > a, .auth__card .small a {
  display: inline-block; padding: 6px 0; min-height: 24px;
}
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.meta-line { display: block; }
.check input { width: 24px; height: 24px; margin: 0; }
.check { align-items: center; min-height: 44px; }
.check:has(small) { align-items: flex-start; }
.check:has(small) input { margin-top: 2px; }

/* Anything scrolled into view — by keyboard focus, a screen reader, or a link to #main — stops
 * clear of the sticky header and the phone tab bar instead of hiding underneath them. */
html { scroll-padding-top: calc(var(--header-h) + var(--s-3)); scroll-padding-bottom: calc(var(--tabbar-h) + var(--s-3)); }
@media (min-width: 900px) { html { scroll-padding-bottom: var(--s-3); } }
