/* BAPC Warehouse. One idea carries the look: a ledger. Numbers sit on quiet ruled paper in tabular figures,
   and colour is spent only on meaning - state, change and data series. */
:root {
  --background: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #15201f;
  --text-soft: #4c5c5a;
  --border: #d5dedc;
  --primary: #0e4d52;
  --primary-soft: #e1eeee;
  --link: #10676e;
  --success: #24785a;
  --warning: #9a6311;
  --error: #b3261e;
  --unknown: #6b7775;
  --focus-ring: #e8a317;
  --ok-ink: #1b6248; --warn-ink: #774a07; --bad-ink: #951d16; --unknown-ink: #4f5a58;
  --s1: #0e7c86; --s2: #c2622d; --s3: #5b4fb3; --s4: #3f8f3a; --s5: #b23a6b; --s6: #8a7a12; --s7: #2f6db5; --s8: #7a5230;
  --radius-s: 6px;
  --radius-l: 12px;
  --rail-w: 232px;
  --top-h: 56px;
  --tab-h: 62px;
  --shadow: 0 1px 2px rgb(16 32 30 / 6%), 0 4px 14px rgb(16 32 30 / 6%);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --background: #0d1514; --surface: #141f1e; --surface-2: #1a2827; --text: #e6efed; --text-soft: #a2b3b0; --border: #2a3b39;
    --primary: #7fd0d4; --primary-soft: #1a3436; --link: #8ad7db; --success: #63c79b; --warning: #e4a94e; --error: #f08679; --unknown: #8d9a98;
    --s1: #4fc3cc; --s2: #f08c55; --s3: #9d92f0; --s4: #78c96f; --s5: #ec7aa9; --s6: #d4c24a; --s7: #78a9ec; --s8: #c79a72;
    --ok-ink: #63c79b; --warn-ink: #e4a94e; --bad-ink: #f08679; --unknown-ink: #a2b3b0;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%); color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --background: #0d1514; --surface: #141f1e; --surface-2: #1a2827; --text: #e6efed; --text-soft: #a2b3b0; --border: #2a3b39;
  --primary: #7fd0d4; --primary-soft: #1a3436; --link: #8ad7db; --success: #63c79b; --warning: #e4a94e; --error: #f08679; --unknown: #8d9a98;
  --s1: #4fc3cc; --s2: #f08c55; --s3: #9d92f0; --s4: #78c96f; --s5: #ec7aa9; --s6: #d4c24a; --s7: #78a9ec; --s8: #c79a72;
  --ok-ink: #63c79b; --warn-ink: #e4a94e; --bad-ink: #f08679; --unknown-ink: #a2b3b0;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--background); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: .3rem 0 .8rem; }
.num, td.n, .kpi .value { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-soft); }
.small { font-size: .85rem; }
.pad { padding: 1rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; z-index: 99; background: var(--surface); padding: .5rem 1rem; }
.skip:focus { left: .5rem; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Shell */
.top { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: .6rem; padding: 0 .75rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--primary) 0 50%, var(--s2) 50% 100%); }
.env-flag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .15rem .45rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input { width: 100%; min-height: 40px; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 30; }
.search-results a { display: flex; justify-content: space-between; gap: .5rem; padding: .6rem .8rem; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); min-height: 44px; }
.search-results a:hover, .search-results a[aria-selected='true'] { background: var(--primary-soft); }
.status-dot { display: flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--text-soft); font-size: .85rem; min-height: 44px; padding: 0 .3rem; }
.status-dot .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); }
.status-dot.ok .dot { background: var(--success); } .status-dot.warn .dot { background: var(--warning); } .status-dot.bad .dot { background: var(--error); }
.icon-btn, .profile-btn { min-width: 44px; min-height: 44px; border: 0; background: transparent; border-radius: var(--radius-s); cursor: pointer; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--surface); font-weight: 700; font-size: .85rem; }
.profile { position: relative; }
.menu { position: absolute; right: 0; top: 48px; min-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: .4rem; z-index: 30; }
.menu .who { padding: .5rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.menu button, .menu a { display: block; width: 100%; text-align: left; padding: .6rem; min-height: 44px; border: 0; background: none; border-radius: var(--radius-s); cursor: pointer; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }

.frame { display: flex; min-height: calc(100vh - var(--top-h)); }
.rail { width: var(--rail-w); flex: none; border-right: 1px solid var(--border); background: var(--surface); padding: .6rem .5rem 2rem; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; }
.rail.collapsed { width: 0; padding: 0; overflow: hidden; border: 0; }
.rail h4, .drawer h4 { margin: .9rem .6rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-soft); }
.rail a, .drawer a { display: flex; align-items: center; gap: .55rem; padding: .45rem .6rem; min-height: 40px; border-radius: var(--radius-s); color: var(--text); text-decoration: none; font-size: .92rem; }
.rail a:hover, .drawer a:hover { background: var(--surface-2); }
.rail a[aria-current='page'], .drawer a[aria-current='page'] { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
main { flex: 1; min-width: 0; padding: 1.1rem 1.25rem 3rem; }
main:focus { outline: none; }

.tabs { display: none; }
.drawer-scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 35%); z-index: 40; }
.drawer { position: fixed; top: 0; bottom: 0; right: 0; width: min(86vw, 340px); background: var(--surface); z-index: 41; overflow-y: auto; padding: 1rem .6rem 5rem; box-shadow: var(--shadow); }
.drawer a { min-height: 44px; }

@media (max-width: 860px) {
  .rail, .rail-toggle, .status-text, .brand-name { display: none; }
  main { padding: .9rem 1rem calc(var(--tab-h) + 2rem); }
  .search { max-width: none; }
  .tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .tabs a, .tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; font-size: .72rem; color: var(--text-soft); text-decoration: none; border: 0; background: none; min-height: 44px; position: relative; cursor: pointer; }
  .tabs [aria-current='page'] { color: var(--primary); font-weight: 700; }
  .tabs span[aria-hidden] { font-size: 1.15rem; line-height: 1; }
  .badge { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--error); color: #fff; border-radius: 999px; font-size: .65rem; padding: 0 .35rem; min-width: 1.1rem; text-align: center; }
}

/* ---------- Page furniture */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head .lede { margin: .2rem 0 0; color: var(--text-soft); max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 1rem; }
.card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); margin-bottom: 1rem; }
.grid.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.grid .card + .card { margin-top: 0; }
.span-2 { grid-column: span 2; }
@media (max-width: 860px) { .span-2 { grid-column: auto; } }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.between { justify-content: space-between; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* KPIs */
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); margin-bottom: 1rem; }
.kpi { display: block; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: .85rem .9rem .7rem; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: .8rem; color: var(--text-soft); display: flex; justify-content: space-between; gap: .3rem; }
.kpi .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: .15rem 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .delta { font-size: .8rem; font-weight: 600; }
.delta.up { color: var(--success); } .delta.down { color: var(--error); } .delta.flat { color: var(--text-soft); }
.delta.up.inverse { color: var(--error); } .delta.down.inverse { color: var(--success); }
.kpi svg.spark { width: 100%; height: 30px; display: block; margin-top: .25rem; }

/* States */
.state { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--unknown-ink); white-space: nowrap; }
.state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.t-ok { color: var(--ok-ink); background: color-mix(in srgb, var(--success) 12%, transparent); }
.t-warn { color: var(--warn-ink); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.t-bad { color: var(--bad-ink); background: color-mix(in srgb, var(--error) 12%, transparent); }
.t-info { color: var(--link); background: var(--primary-soft); }
.t-unknown { color: var(--unknown-ink); }
.notice { border-left: 4px solid var(--link); background: var(--primary-soft); padding: .7rem .9rem; border-radius: var(--radius-s); margin: 0 0 1rem; }
.notice.warn { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.notice.bad { border-color: var(--error); background: color-mix(in srgb, var(--error) 8%, var(--surface)); }
.qstate { text-align: center; padding: 2rem 1rem; color: var(--text-soft); }
.qstate .big { font-size: 1.6rem; display: block; margin-bottom: .3rem; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius-s); height: 1rem; margin: .5rem 0; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .5rem 1rem; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--error); border-color: color-mix(in srgb, var(--error) 45%, var(--border)); }
.btn.small { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--link); cursor: pointer; padding: .3rem; min-height: 44px; text-decoration: underline; }
label.field { display: grid; gap: .25rem; font-size: .86rem; font-weight: 600; min-width: 0; }
label.field .hint { font-weight: 400; color: var(--text-soft); font-size: .8rem; }
input:not([type='checkbox']):not([type='radio']), select, textarea { min-height: 44px; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); width: 100%; }
textarea { min-height: 110px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
input[aria-invalid='true'], select[aria-invalid='true'], textarea[aria-invalid='true'] { border-color: var(--error); }
.err { color: var(--error); font-size: .82rem; font-weight: 600; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; font-size: .9rem; }
.check input { width: 20px; height: 20px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-s); padding: .7rem; margin: 0; }
legend { font-weight: 700; font-size: .85rem; padding: 0 .3rem; }

/* Filter bar */
.filterbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: .7rem; margin-bottom: 1rem; }
.filterbar label.field { flex: 1 1 140px; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { min-height: 36px; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .85rem; }
.chip[aria-pressed='true'] { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.multi { position: relative; }
.multi > button { width: 100%; min-height: 44px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); padding: .45rem .65rem; cursor: pointer; }
.multi .pop { position: absolute; z-index: 15; top: 48px; left: 0; min-width: 100%; max-height: 300px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); box-shadow: var(--shadow); padding: .3rem; }

/* Tables: wide on desktop, cards on phones (no sideways scrolling for key tasks) */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .5rem .55rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); background: var(--surface); position: sticky; top: 0; }
table.data th button { border: 0; background: none; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 0; min-height: 32px; }
table.data td.n, table.data th.n { text-align: right; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
.table-tools { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.table-tools input { max-width: 260px; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .5rem; font-size: .85rem; }
@media (max-width: 640px) {
  table.data.cards thead { display: none; }
  table.data.cards tr { display: block; border: 1px solid var(--border); border-radius: var(--radius-s); margin-bottom: .6rem; padding: .3rem .2rem; background: var(--surface); }
  table.data.cards td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem .5rem; text-align: right; }
  table.data.cards td::before { content: attr(data-label); font-weight: 600; color: var(--text-soft); text-align: left; }
  table.data.cards td.n { white-space: normal; }
}
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .84em; }
pre { background: var(--surface-2); padding: .7rem; border-radius: var(--radius-s); overflow: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-word; }

/* Charts */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis text { fill: var(--text-soft); font-size: 11px; }
.chart .axis line, .chart .grid-line { stroke: var(--border); }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: .78rem; padding: .35rem .5rem; border-radius: var(--radius-s); white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; }
.chart-wrap { position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .8rem; color: var(--text-soft); margin-top: .4rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.chart-toggle { font-size: .8rem; }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 80px; gap: .5rem; align-items: center; margin: .35rem 0; font-size: .86rem; }
.funnel-bar { height: 26px; background: var(--s1); border-radius: 4px; min-width: 2px; }
.heat td.n { color: var(--text); }
.bar-inline { height: 8px; background: var(--s1); border-radius: 4px; }

/* Steps, timeline, diff */
.steps { display: flex; gap: .3rem; list-style: none; padding: 0; margin: 0 0 1rem; flex-wrap: wrap; }
.steps li { flex: 1 1 110px; padding: .45rem .6rem; border-radius: var(--radius-s); background: var(--surface-2); font-size: .82rem; color: var(--text-soft); }
.steps li[aria-current='step'] { background: var(--primary); color: var(--surface); font-weight: 700; }
.steps li.done { background: var(--primary-soft); color: var(--primary); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--border); padding: 0 0 .8rem .9rem; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline li.deny::before { background: var(--error); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.diff pre.before { border-left: 3px solid var(--error); }
.diff pre.after { border-left: 3px solid var(--success); }
.lineage { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; align-items: start; }
.lineage .col h3 { font-size: .75rem; text-transform: uppercase; color: var(--text-soft); letter-spacing: .06em; }
.node { display: block; border: 1px solid var(--border); border-radius: var(--radius-s); padding: .4rem .55rem; margin-bottom: .4rem; background: var(--surface); font-size: .84rem; word-break: break-word; }
.node.focus { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); font-weight: 700; }
.builder-canvas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.builder-canvas > .card { margin: 0; }
@media (max-width: 860px) { .builder-canvas { grid-template-columns: 1fr; } .builder-canvas > .card { grid-column: auto !important; } }
.w-1 { grid-column: span 1; } .w-2 { grid-column: span 2; } .w-3 { grid-column: span 3; } .w-4 { grid-column: span 4; }

/* Dialog and toast */
.dialog { border: 1px solid var(--border); border-radius: var(--radius-l); padding: 0; width: min(560px, 94vw); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgb(0 0 0 / 40%); }
.dialog .dlg-body { padding: 1.1rem; }
.dialog .dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 1rem); background: var(--text); color: var(--surface); padding: .7rem 1rem; border-radius: var(--radius-s); z-index: 60; max-width: 92vw; box-shadow: var(--shadow); }
.toast.err { background: var(--error); color: #fff; }
@media (min-width: 861px) { .toast { bottom: 1.5rem; } }
.tabs-inline { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs-inline button { border: 0; background: none; padding: .6rem .8rem; min-height: 44px; cursor: pointer; color: var(--text-soft); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs-inline button[aria-selected='true'] { color: var(--primary); border-color: var(--primary); }
.persona { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.persona button { text-align: left; padding: .8rem; border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); cursor: pointer; min-height: 64px; }
.persona button:hover { border-color: var(--primary); }
.login { max-width: 760px; margin: 2rem auto; }

a.card { display: block; color: inherit; text-decoration: none; }
a.kpi:hover, a.card:hover { border-color: var(--primary); }

.grid > * { min-width: 0; }
.card { overflow-x: auto; }
html, body { overflow-x: clip; }

/* Shared BAPC language button (speakers.bapc.app): start it above the phone tab bar, and clear of the desktop rail.
   Only its starting spot is moved; once dragged, it goes wherever the person put it. */
@media (max-width: 860px) {
  body > div.notranslate[style*="bottom: 14px"] { bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom)) !important; }
  .env-flag { display: none !important; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .kpi .value { font-size: 1.25rem; }
  .kpi { padding: .7rem; }
  .top { gap: .35rem; }
}
@media (min-width: 861px) {
  body > div.notranslate[style*="left: 14px"] { left: calc(var(--rail-w) + 14px) !important; }
}

.chip[aria-current='true'] { background: var(--primary); border-color: var(--primary); color: var(--surface); }
a.chip { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }

/* Phones: the filter bar folds into one line that says what is selected; numbers come first. */
.filter-toggle { display: none; }
@media (max-width: 860px) {
  .filterbar .filter-toggle { display: flex; width: 100%; justify-content: flex-start; }
  .filterbar:not(.open) > :not(.filter-toggle) { display: none; }
}

.rail[hidden], .tabs[hidden] { display: none !important; }
