/* บุญมีเห็ดฟาง — styles taken from the dashboard design (desktop 1440 / mobile 390).
   One stylesheet serves the browser, the Google Sheets sidebar (300px) and the
   Excel task pane (~350px): below 1024px the sidebar becomes a bottom nav. */

:root {
  --bg: #F7F1E6;
  --surface: #FFFDF8;
  --surface-2: #EFE6D5;
  --line: #E1D4BE;
  --line-strong: #C2AF8E;
  --text: #3A2E22;
  --text-2: #6B5D48;
  --olive-900: #52603A;
  --olive-700: #6B7A4F;
  --olive-100: #E4E9D8;
  --brown-700: #9C5F34;
  --brown-100: #F3E3D3;
  --gold-700: #9C7620;
  --gold-500: #C99A3C;
  --gold-100: #F6E9CB;
  --sage: #8FA98C;
  --good-700: #3F7A57;
  --good-100: #E1EDDE;
  --bad-700: #A83E2D;
  --bad-100: #F5DEDA;
  --shadow: 0 1px 2px rgba(58, 46, 34, 0.06);
  --shadow-lg: 0 12px 32px rgba(58, 46, 34, 0.18);
  --font-body: "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  --font-head: "Kanit", "Sarabun", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", "Sarabun", ui-monospace, monospace;
  --r-xl: 24px;
  --r-lg: 14px;
  --r-md: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/20px var(--font-body);
}
[hidden] { display: none !important; }
a { color: var(--brown-700); }
a:hover { color: var(--olive-900); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--olive-900); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 12px; line-height: 16px; font-weight: 500; }
.overline { font-size: 11px; line-height: 14px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-2); }
.good { color: var(--good-700); }
.bad { color: var(--bad-700); }
.strong { font-weight: 700; }

h1, h2, h3 { margin: 0; font-family: var(--font-head); font-weight: 600; color: var(--text); }
h1 { font-size: 28px; line-height: 36px; }
h2 { font-size: 20px; line-height: 28px; }
h3 { font-size: 16px; line-height: 24px; }

/* ---------- shell ---------- */
.shell {
  display: flex;
  gap: 24px;
  padding: 24px;
  max-width: 1680px;
  margin: 0 auto;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  background: var(--olive-900); color: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-family: var(--font-head); font-size: 20px; line-height: 28px; font-weight: 600; display: block; }
.brand-sub { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); display: block; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav .overline { padding: 0 12px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--r-md); border: 0; background: none;
  color: var(--text-2); text-decoration: none; text-align: left;
  font-size: 13px; line-height: 18px; font-weight: 600; cursor: pointer; width: 100%;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--olive-100); color: var(--olive-900); }
.side-spacer { flex-grow: 1; }

.payback { background: var(--olive-100); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.payback .overline { color: var(--olive-900); }
.payback-value { font-family: var(--font-num); font-size: 20px; line-height: 26px; font-weight: 600; }
.payback .small { color: var(--olive-900); }
.meter { height: 8px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.meter > div { height: 100%; background: var(--olive-700); }

.cycle-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 8px; background: none; text-align: left; cursor: pointer; width: 100%; }
.cycle-card:hover { border-color: var(--line-strong); }
.cycle-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cycle-card-head h3 { font-size: 16px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 32px; }

.topbar {
  min-height: 64px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 10px 12px 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.topbar-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.topbar-title .sub { font-size: 13px; line-height: 20px; color: var(--text-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mobile-brand { display: none; }

.footer { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); padding: 0 4px 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brown-700); font-weight: 600; cursor: pointer; font-size: inherit; }
.link-btn:hover { color: var(--olive-900); }

.bottomnav { display: none; }
.fab { display: none; }

/* ---------- controls ---------- */
.btn {
  height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; border-radius: var(--r-md); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--olive-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--olive-900); color: #fff; }
.btn-secondary { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #E7DCC7; color: var(--text); }
.btn-ghost { background: none; color: var(--text-2); padding: 0 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--bad-100); color: var(--bad-700); }
.btn-danger:hover:not(:disabled) { background: #EFCFC9; color: var(--bad-700); }
.btn-sm { height: 36px; padding: 0 12px; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: var(--r-md); border: 0; background: none; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.avatar { width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--brown-100); color: var(--brown-700); font-family: var(--font-head); font-size: 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  height: 44px; padding: 0 36px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); font-size: 13px; font-weight: 600; cursor: pointer; max-width: 220px;
}
.select-wrap.has-icon select { padding-left: 38px; }
.select-wrap .lead, .select-wrap .trail { position: absolute; pointer-events: none; display: flex; }
.select-wrap .lead { left: 12px; }
.select-wrap .trail { right: 12px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card-head .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-head .sub { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.card-foot { margin-top: auto; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.kpi { gap: 8px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.kpi-icon { width: 36px; height: 36px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-value { font-family: var(--font-num); font-size: 32px; line-height: 38px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.tone-olive { background: var(--olive-100); color: var(--olive-900); }
.tone-brown { background: var(--brown-100); color: var(--brown-700); }
.tone-bad { background: var(--bad-100); color: var(--bad-700); }
.tone-good { background: var(--good-100); color: var(--good-700); }
.tone-warn { background: var(--gold-100); color: var(--gold-700); }


.hero {
  display: none; flex-direction: column; gap: 12px;
  background: var(--olive-900); color: var(--surface); border-radius: var(--r-xl); padding: 20px;
}
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; }
.grid-1-1 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.stack { display: flex; flex-direction: column; gap: 32px; }

/* ---------- badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 12px; font-size: 13px; line-height: 18px; font-weight: 600; white-space: nowrap; }
.pill-good { background: var(--good-100); color: var(--good-700); }
.pill-warn { background: var(--gold-100); color: var(--gold-700); }
.pill-bad { background: var(--bad-100); color: var(--bad-700); }
.pill-muted { background: var(--surface-2); color: var(--text-2); }
.pill-olive { background: var(--olive-100); color: var(--olive-900); }
.delta { display: inline-flex; border-radius: 999px; padding: 2px 8px; font-size: 13px; line-height: 18px; font-weight: 600; }
.delta-good { background: var(--good-100); color: var(--good-700); }
.delta-bad { background: var(--bad-100); color: var(--bad-700); }
.delta-flat { background: var(--surface-2); color: var(--text-2); }

/* ---------- legends + bars ---------- */
.legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.chart { width: 100%; min-height: 40px; }

.bars { display: flex; flex-direction: column; gap: 16px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; line-height: 18px; }
.track { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.track.thin { height: 10px; }
.track > div { height: 100%; }
.note-good { background: var(--good-100); border-radius: var(--r-md); padding: 12px; font-size: 13px; line-height: 20px; }
.note-warn { background: var(--gold-100); border-radius: var(--r-md); padding: 12px; font-size: 13px; line-height: 20px; }
.mt-auto { margin-top: auto; }

/* ---------- transactions ---------- */
.txns { display: flex; flex-direction: column; font-size: 13px; line-height: 20px; }
.txn {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 72px 128px 120px 76px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.txn:nth-child(even) { background: var(--surface-2); }
.txn:last-child { border-bottom: 0; }
.txn > div { padding: 12px; min-width: 0; }
.txn-head { background: none !important; }
.txn-head > div { padding: 8px 12px; }
.txn .t-date { color: var(--text-2); }
.txn .t-item { overflow-wrap: anywhere; }
.txn .t-amt { text-align: right; font-family: var(--font-num); font-size: 14px; font-weight: 500; }
.txn .t-act { display: flex; justify-content: flex-end; gap: 2px; padding: 4px 8px; }
.txns.no-actions .txn { grid-template-columns: 96px minmax(0, 1fr) 72px 128px 120px; }
.txns.no-actions .t-act { display: none; }
.inferred-mark { color: var(--gold-700); font-size: 12px; margin-left: 4px; cursor: help; }

/* ---------- alerts ---------- */
.alerts { display: flex; flex-direction: column; gap: 12px; }
.alert-item { display: flex; gap: 12px; padding: 12px; border-radius: var(--r-md); background: var(--bg); border: 0; text-align: left; width: 100%; cursor: pointer; }
.alert-item:hover { background: #F1E8D8; }
.alert-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--r-md); background: var(--gold-100); color: var(--gold-700); display: flex; align-items: center; justify-content: center; }
.alert-icon.info { background: var(--surface-2); color: var(--text-2); }
.alert-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alert-text strong { font-size: 13px; line-height: 18px; font-weight: 600; }
.alert-text span { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.all-clear { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r-md); background: var(--good-100); color: var(--good-700); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 20px; }
.table th { text-align: left; padding: 8px 12px; font-size: 11px; line-height: 14px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table td.num { font-family: var(--font-num); }
.table tr.is-selected td { background: var(--olive-100) !important; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #F1E8D8; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; }

/* ---------- misc page pieces ---------- */
.page { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.toolbar .grow { flex: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { height: 44px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); padding: 0 12px; min-width: 0; flex: 1 1 180px; font-size: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 16px 24px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-family: var(--font-num); font-size: 22px; line-height: 28px; font-weight: 600; }
.timeline { display: flex; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.tl-step { flex: 1 0 112px; display: flex; flex-direction: column; gap: 6px; position: relative; padding-right: 12px; }
.tl-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--olive-700); position: relative; z-index: 1; }
.tl-dot.todo { background: var(--surface); border: 2px solid var(--line-strong); }
.tl-step::before { content: ""; position: absolute; top: 5px; left: 12px; right: 0; height: 2px; background: var(--line); }
.tl-step:last-child::before { display: none; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-lg); font-size: 13px; line-height: 20px; }
.banner.warn { background: var(--gold-100); color: #6E5416; }
.banner.bad { background: var(--bad-100); color: var(--bad-700); }
.banner.info { background: var(--olive-100); color: var(--olive-900); }
.banner .grow { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; align-items: center; }
.kv dt { color: var(--text-2); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.code { font-family: var(--font-num); font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.field { display: flex; flex-direction: column; gap: 6px; grid-column: 1 / -1; min-width: 0; }
.field.half { grid-column: auto; }
.field label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  height: 44px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  padding: 0 12px; font-size: 16px; width: 100%; min-width: 0;
}
.field textarea { height: auto; min-height: 88px; padding: 10px 12px; }
.field input:focus, .field select:focus { border-color: var(--olive-700); outline: none; box-shadow: 0 0 0 3px var(--olive-100); }
.field .hint { font-size: 12px; line-height: 16px; color: var(--text-2); }
.field.invalid input { border-color: var(--bad-700); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; grid-column: 1 / -1; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--olive-700); }
.computed { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; background: var(--olive-100); border-radius: var(--r-md); color: var(--olive-900); font-weight: 600; grid-column: 1 / -1; }
.computed .num { font-size: 18px; }
.form-error { color: var(--bad-700); font-weight: 600; }

/* ---------- modal + toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(58, 46, 34, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.dialog { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 12px 24px; }
.dialog-body { padding: 4px 24px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 24px; flex-wrap: wrap; }
.dialog-foot .spacer { flex: 1; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 60; pointer-events: none; width: calc(100% - 32px); }
.toast { background: var(--text); color: var(--surface); border-radius: 999px; padding: 10px 18px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 520px; text-align: center; animation: toast-in 0.18s ease-out; }
.toast.bad { background: var(--bad-700); }
.toast.ok { background: var(--olive-900); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.syncbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--olive-100); color: var(--olive-900); border-radius: var(--r-lg); padding: 12px 16px; }
.syncbar .grow { flex: 1; min-width: 140px; font-size: 12px; line-height: 16px; font-weight: 600; }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, #F5EEE1 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-lg); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .spin, .skeleton, .toast { animation: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1439px) {
  .kpi-value { font-size: 28px; line-height: 34px; }
}
@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1179px) {
  .grid-2-1, .grid-1-1 { grid-template-columns: minmax(0, 1fr); }
}

/* phone, tablet, Sheets sidebar, Excel task pane */
@media (max-width: 1023px) {
  .shell { display: block; padding: 20px 16px 104px; }
  .sidebar { display: none; }
  .main, .stack, .page { gap: 16px; }
  .topbar { background: none; border: 0; box-shadow: none; padding: 0; min-height: 0; flex-wrap: nowrap; }
  .topbar-title { flex-direction: column; gap: 0; align-items: flex-start; }
  .topbar-title h1 { display: none; }
  .mobile-brand { display: block; font-family: var(--font-head); font-size: 20px; line-height: 28px; font-weight: 600; }
  .topbar-title .sub { font-size: 12px; line-height: 16px; font-weight: 500; }
  .topbar .hide-mobile { display: none; }
  .topbar .select-wrap select { border-radius: 999px; background: var(--surface); padding-left: 14px; max-width: 150px; }
  .topbar .select-wrap .lead { display: none; }
  .card { padding: 16px; gap: 12px; }
  .card-head { gap: 8px; }
  h2 { font-size: 18px; line-height: 26px; }
  .kpis { gap: 12px; }
  .kpi { gap: 6px; }
  .kpi-value { font-size: 22px; line-height: 28px; }
  .kpi-icon { display: none; }
  .kpi .delta { font-size: 12px; line-height: 16px; }
  .grid-2-1, .grid-1-1 { gap: 16px; }
  .stat-grid { gap: 12px; }
  .hero { display: flex; }
  .hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .hero-top .label { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--olive-100); }
  .hero .delta { background: rgba(255, 253, 248, 0.16); color: var(--surface); padding: 2px 10px; }
  .hero-value { font-family: var(--font-num); font-size: 40px; line-height: 46px; font-weight: 600; }
  .hero-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid rgba(228, 233, 216, 0.3); }
  .hero-split span { display: block; }
  .hero-split .k { font-size: 12px; line-height: 16px; color: var(--olive-100); }
  .hero-split .v { font-family: var(--font-num); font-size: 15px; line-height: 22px; font-weight: 600; }
  .track { height: 12px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .table th, .table td { white-space: nowrap; } /* scroll sideways instead of wrapping into tall columns */
  .table td, .table th { padding-left: 10px; padding-right: 10px; }

  .txn { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "item amt" "meta status" "act act"; }
  .txns.no-actions .txn { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "item amt" "meta status"; }
  .txn > div { padding: 0 12px; }
  .txn { padding: 10px 0; }
  .txn .t-item { grid-area: item; font-weight: 600; }
  .txn .t-amt { grid-area: amt; }
  .txn .t-date { grid-area: meta; font-size: 12px; }
  .txn .t-cycle { display: none; }
  .txn .t-status { grid-area: status; justify-self: end; padding-top: 4px; }
  .txn .t-status .pill { font-size: 12px; line-height: 16px; padding: 2px 10px; }
  .txn .t-act { grid-area: act; justify-content: flex-start; padding: 2px 4px 0; }
  .txn-head { display: none; }
  .t-date .m-cycle { display: inline; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(76px + env(safe-area-inset-bottom)); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bottomnav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 0; background: none; border-radius: 12px; color: var(--text-2);
    font-size: 11px; line-height: 14px; font-weight: 600; cursor: pointer; padding: 0 2px; min-width: 0;
  }
  .bottomnav button[aria-current="page"] { background: var(--olive-100); color: var(--olive-900); font-weight: 700; }
  .fab {
    display: flex; position: fixed; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 31;
    width: 56px; height: 56px; border-radius: 999px; border: 0; background: var(--olive-700); color: #fff;
    align-items: center; justify-content: center; box-shadow: var(--shadow-lg); cursor: pointer;
  }
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .overlay { align-items: flex-end; padding: 0; }
  .dialog { width: 100%; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .dialog-head { padding: 16px 16px 8px 20px; }
  .dialog-body { padding: 4px 20px 12px; }
  .dialog-foot { padding: 12px 20px calc(20px + env(safe-area-inset-bottom)); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
@media (min-width: 1024px) {
  .t-date .m-cycle { display: none; }
  .only-mobile { display: none !important; }
}
@media (max-width: 1023px) {
  .only-desktop { display: none !important; }
  /* overview on phones follows the mobile design's order: charts, quality, alerts first */
  .page-flow { display: flex; flex-direction: column; gap: 16px; }
  .page-flow > .grid-2-1 { display: contents; }
  .o-1 { order: 1; } .o-2 { order: 2; } .o-3 { order: 3; } .o-4 { order: 4; } .o-5 { order: 5; } .o-6 { order: 6; } .o-7 { order: 7; }
}
@media (max-width: 380px) {
  .mobile-brand { font-size: 17px; line-height: 24px; white-space: nowrap; }
  .topbar .select-wrap select { max-width: 124px; }
  .hero-value { font-size: 34px; line-height: 40px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .field.half { grid-column: 1 / -1; }
  .seg button { padding: 8px 10px; }
}
