:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --panel: #f9fafb;
  --hover: #f1f3f6;
  --ink: #12141c;
  --ink-2: #4f5468;
  --ink-3: #868b9f;
  --line: #e3e6ec;
  --line-strong: #cfd4dd;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-hover: #1a43bd;
  --accent-soft: rgba(29, 78, 216, 0.1);
  --good: #12804a;
  --bad: #c8322b;
  --warn: #b45309;
  --grid: #eef0f4;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --pop-shadow: 0 10px 28px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b7088' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ctl-h: 34px;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1015;
    --surface: #17181f;
    --panel: #1c1d26;
    --hover: #22242e;
    --ink: #eef0f6;
    --ink-2: #b2b6c8;
    --ink-3: #82879c;
    --line: #2a2c38;
    --line-strong: #3a3d4c;
    --accent: #6d8bff;
    --accent-ink: #0b0d14;
    --accent-hover: #8aa1ff;
    --accent-soft: rgba(109, 139, 255, 0.16);
    --good: #4cc38a;
    --bad: #ff7b72;
    --warn: #f0a24a;
    --grid: #23252f;
    --shadow: none;
    --pop-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239aa0b6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1015;
  --surface: #17181f;
  --panel: #1c1d26;
  --hover: #22242e;
  --ink: #eef0f6;
  --ink-2: #b2b6c8;
  --ink-3: #82879c;
  --line: #2a2c38;
  --line-strong: #3a3d4c;
  --accent: #6d8bff;
  --accent-ink: #0b0d14;
  --accent-hover: #8aa1ff;
  --accent-soft: rgba(109, 139, 255, 0.16);
  --good: #4cc38a;
  --bad: #ff7b72;
  --warn: #f0a24a;
  --grid: #23252f;
  --shadow: none;
  --pop-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239aa0b6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "DM Sans", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2 { margin: 0; }
.muted { color: var(--ink-3); font-size: 12px; }
[hidden] { display: none !important; }

/* ---- app bar: identical on every view ---- */
.appbar { position: sticky; top: 0; z-index: 12; background: var(--surface); border-bottom: 1px solid var(--line); }
.appbar-inner { display: flex; align-items: center; gap: 28px; height: 52px; padding: 0 24px; max-width: 1440px; margin: 0 auto; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
/* Mono's wordmark (web/mono-logo.svg, from mono-boring) as a mask, so it takes the ink colour in dark mode too */
.mono-logo {
  display: block; height: 15px; aspect-ratio: 81 / 12; background: currentColor;
  -webkit-mask: url(mono-logo.svg) no-repeat center / contain; mask: url(mono-logo.svg) no-repeat center / contain;
}
.logo-lg .mono-logo { height: 22px; }
.nav { display: flex; align-self: stretch; gap: 4px; }
.nav a {
  display: inline-flex; align-items: center; padding: 0 12px; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.12s, border-color 0.12s;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: -6px; border-radius: 6px; }
.fresh {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px;
  font-size: 12px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; cursor: default;
}
.fresh i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.fresh[data-state="live"] i { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.fresh[data-state="stale"] { color: var(--bad); }
.fresh[data-state="stale"] i { background: var(--bad); }

/* ---- per-view toolbar ---- */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 20px; padding: 18px 24px 14px; max-width: 1440px; margin: 0 auto; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.custom { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }

/* ---- controls: one look for selects, inputs, dates (Cloudflare-style) ---- */
.ctl, .combo-input, .cfg-field select, .cfg-field input:not([type="checkbox"]) {
  height: var(--ctl-h); padding: 0 10px; min-width: 0;
  font: inherit; font-size: 13px; font-weight: 400; color: var(--ink);
  background-color: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}
select.ctl, .cfg-field select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; min-width: 132px;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 7px;
}
.ctl:hover, .combo-input:hover, .cfg-field select:hover, .cfg-field input:not([type="checkbox"]):hover { border-color: var(--ink-3); }
.ctl:focus-visible, .combo-input:focus, .cfg-field select:focus-visible, .cfg-field input:not([type="checkbox"]):focus-visible, .cfg-rates:focus-visible {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="date"].ctl { padding-right: 8px; min-width: 140px; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 0.9; }
select option { color: var(--ink); background: var(--surface); }

.grid {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); gap: 12px;
  padding: 0 24px 24px; max-width: 1440px; margin: 0 auto;
}
.left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grid[aria-busy="true"] { opacity: 0.55; transition: opacity 0.2s; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { font-size: 16px; font-weight: 700; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.kpi h3 { margin: 0; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.kpi .value { display: block; font-size: clamp(18px, 1.9vw, 26px); font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 4px; overflow-wrap: anywhere; }
.change { font-size: 12px; color: var(--ink-3); }
.change b { font-weight: 700; }
.change .up { color: var(--good); }
.change .down { color: var(--bad); }

.seg { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 12px; border: 0; background: none; color: var(--ink-2); padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.chart-total { font-size: 22px; font-weight: 700; }
.chart-total .change { font-size: 12px; font-weight: 400; margin-left: 8px; }
.chart-wrap { position: relative; height: 280px; margin-top: 8px; }

.data-view { margin-top: 10px; }
.data-view summary { cursor: pointer; color: var(--ink-2); font-size: 12px; }
.table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
th.num, td.num { text-align: right; white-space: nowrap; }
td.ep { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink); word-break: break-all; }
tr:last-child td { border-bottom: 0; }

.revenue { display: flex; flex-direction: column; }
.rev-total { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0 18px; border-bottom: 1px solid var(--line); }
.rev-total strong { font-size: 28px; letter-spacing: -0.02em; overflow-wrap: anywhere; text-align: center; }
.rev-split { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 14px 0; font-size: 13px; }
.rev-split dt { color: var(--ink-3); }
.rev-split dd { margin: 0; text-align: right; font-weight: 500; }
.biz-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.biz-list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.biz-list li:last-child { border-bottom: 0; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.biz-name { flex: 1; min-width: 0; }
.biz-name b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-amt { text-align: right; font-weight: 700; white-space: nowrap; }
.biz-amt .muted { display: block; font-weight: 400; }

.error { max-width: 1440px; margin: 0 auto 24px; padding: 12px 24px; color: var(--bad); }

@media (max-width: 1000px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .top { padding: 16px 16px 10px; }
  .grid { padding: 0 16px 16px; }
  .filters, .custom { width: 100%; }
  .field { flex: 1 1 140px; }
  .kpi .value { font-size: 22px; }
  .card { padding: 16px; }
}

/* ---- tabs ---- */
.tabs { display: inline-flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.tabs a { color: var(--ink-2); text-decoration: none; font-size: 13px; padding: 5px 12px; border-radius: 6px; }
.tabs a[aria-selected="true"] { background: var(--ink); color: var(--surface); font-weight: 500; }
.filters[hidden], .grid[hidden] { display: none; }

/* ---- explore (dense, Cloudflare-dashboard style) ---- */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --spark: #f38020;
  --code-bg: #0f1117; --code-ink: #e6e8ef;
  --j-str: #116329; --j-num: #0550ae; --j-bool: #8250df; --j-oid: #953800;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --code-bg: #0b0c11;
    --j-str: #7ee2a8; --j-num: #79c0ff; --j-bool: #d2a8ff; --j-oid: #ffa657;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --code-bg: #0b0c11;
  --j-str: #7ee2a8; --j-num: #79c0ff; --j-bool: #d2a8ff; --j-oid: #ffa657;
}

/* clickable result rows */
.ex-hint { margin: 0 0 8px; font-size: 12px; color: var(--ink-3); }
.ex-hint[hidden] { display: none; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover td { background: var(--bg); color: var(--ink); }
table.clickable tbody tr:focus-visible { outline: 2px solid var(--spark); outline-offset: -2px; }
table.clickable tbody tr.selected td { background: var(--accent-soft); color: var(--ink); }

/* right-side call drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(13, 15, 26, 0.18); z-index: 19; }
.drawer-backdrop[hidden], .drawer[hidden] { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 20;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(13, 15, 26, 0.12); transform: translateX(100%); transition: transform 0.2s ease;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; }
.drawer-id { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-3); }
.drawer-x { flex: none; width: 32px; height: 32px; font: inherit; font-size: 22px; line-height: 1; color: var(--ink-2); background: none; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.drawer-x:hover { color: var(--ink); background: var(--bg); }
.drawer-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.drawer-summary:empty { display: none; }
.drawer-chip { min-width: 0; }
.drawer-chip span { display: block; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.drawer-chip b { display: block; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.drawer-chip.ok b { color: var(--good); }
.drawer-chip.bad b { color: var(--bad); }
.drawer-tools { display: flex; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.drawer-tools button { font: inherit; font-size: 12px; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.drawer-body { flex: 1; overflow: auto; padding: 12px 18px 24px; }

/* JSON tree */
/* Indents are exactly 2 characters, as in JSON.stringify(doc, null, 2); the fold carets sit in the
   left gutter so they don't shift the text, and a hairline guide (no width) marks each level */
.json { font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); padding-left: 2ch; }
.json summary { position: relative; list-style: none; cursor: pointer; border-radius: 4px; }
.json summary::-webkit-details-marker { display: none; }
.json summary::before { content: '▸'; position: absolute; left: -2ch; width: 2ch; text-align: center; color: var(--ink-3); transition: transform 0.1s; }
.json details[open] > summary::before { transform: rotate(90deg); }
.json summary:hover { background: var(--bg); }
.json details[open] > summary .j-count { display: none; }
.json details:not([open]) > .j-close { display: none; }
.j-kids { padding-left: 2ch; box-shadow: inset 1px 0 var(--line); }
.j-row { overflow-wrap: anywhere; }
.json-raw { margin: 0; padding-left: 0; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }

/* pager, exports, small buttons */
.ghost.small { font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px; cursor: pointer; }
.ghost:disabled { opacity: 0.45; cursor: default; }
.head-actions { display: inline-flex; align-items: center; gap: 10px; }
.ex-export { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; }
.pager[hidden] { display: none; }
.pager-buttons { display: inline-flex; align-items: center; gap: 6px; }
.drawer-tools .seg { margin-right: 4px; }
.drawer-tools .seg button { padding: 3px 10px; }
.j-key { color: var(--ink); font-weight: 500; }
.j-idx { color: var(--ink-3); }
.j-str { color: var(--j-str); white-space: pre-wrap; }
.j-num { color: var(--j-num); }
.j-bool { color: var(--j-bool); }
.j-null, .j-punc, .j-count { color: var(--ink-3); }
.j-oid, .j-date { color: var(--j-oid); }
.j-more { font: inherit; font-size: 11px; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

.explore { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; padding: 0 24px 32px; max-width: 1440px; margin: 0 auto; }
.explore[hidden] { display: none; }
.eyebrow { margin: 0 0 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.ex-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ex-side-block { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.ex-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ex-side-head { display: flex; align-items: baseline; justify-content: space-between; }
.ex-history-clear { font: inherit; font-size: 11px; color: var(--ink-3); background: none; border: 0; padding: 0; cursor: pointer; }
.ex-history-clear:hover { color: var(--bad); }
.ex-history-clear[hidden] { display: none; }
.ex-history li { display: flex; align-items: center; border-radius: 6px; }
.ex-history li:hover, .ex-history li:focus-within { background: var(--bg); }
.ex-history-run { flex: 1; min-width: 0; text-align: left; font: inherit; font-size: 12.5px; color: var(--ink-2); background: none; border: 0; padding: 6px 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-history li:hover .ex-history-run { color: var(--ink); }
/* The × shows on hover/focus; on touch screens (no hover) it is always visible */
.ex-history-del { flex: none; width: 24px; height: 24px; margin-right: 2px; font: inherit; font-size: 16px; line-height: 1; color: var(--ink-3); background: none; border: 0; border-radius: 5px; cursor: pointer; opacity: 0; }
.ex-history li:hover .ex-history-del, .ex-history-del:focus-visible { opacity: 1; }
.ex-history-del:hover { color: var(--bad); background: var(--surface); }
@media (hover: none) { .ex-history-del { opacity: 1; } }
.ex-history .empty { font-size: 12px; color: var(--ink-3); padding: 2px 8px; }
.ex-schema summary { cursor: pointer; margin: 0; }
.ex-schema[open] summary { margin-bottom: 8px; }
.ex-schema p { margin: 0 0 8px; font-size: 11.5px; }
.ex-schema dl { margin: 0; font-size: 12px; }
.ex-schema dt { font-weight: 700; margin-top: 10px; color: var(--ink); }
.ex-schema dd { margin: 2px 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--ink-2); line-height: 1.6; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); color: var(--ink-2); }

.ex-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ask-box {
  display: flex; align-items: flex-start; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 10px 10px 14px; box-shadow: var(--shadow); transition: border-color 0.15s, box-shadow 0.15s;
}
.ask-box:focus-within { border-color: var(--spark); box-shadow: 0 0 0 3px rgba(243, 128, 32, 0.15); }
.spark { width: 20px; height: 20px; color: var(--spark); flex: none; margin-top: 6px; }
.ask-box textarea { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: none; color: var(--ink); font: inherit; font-size: 15px; line-height: 1.5; padding: 4px 0; max-height: 160px; }
.ask-btn { flex: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--surface); background: var(--ink); border: 0; border-radius: 7px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.ask-btn kbd { background: transparent; color: inherit; border-color: currentColor; opacity: 0.6; }
.ask-btn:disabled { opacity: 0.5; cursor: progress; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { font: inherit; font-size: 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.chips button:hover { border-color: var(--spark); color: var(--ink); }
.ask-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }

.ex-loading { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); padding: 4px 2px; }
.ex-loading[hidden], .ex-error[hidden], .ask-note[hidden] { display: none; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--spark); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }
.ex-error { margin: 0; padding: 10px 12px; border: 1px solid var(--bad); border-radius: 8px; color: var(--bad); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

.ex-result { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 0; }
.ex-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 20px; padding: 16px 18px 12px; }
.ex-head h2 { font-size: 17px; letter-spacing: -0.01em; }
.ex-explain { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); max-width: 70ch; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 11.5px; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.pill b { color: var(--ink); font-weight: 500; }
.ex-tabs { display: flex; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.ex-tabs [role=tab] { font: inherit; font-size: 13px; color: var(--ink-3); background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 0; margin-bottom: -1px; cursor: pointer; }
.ex-tabs [role=tab][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--spark); font-weight: 500; }
.ex-panel { padding: 16px 18px 18px; }
.ex-panel[hidden] { display: none; }
.ex-chart-box { position: relative; height: 320px; }
.ex-multi { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.ex-multi h4 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.ex-multi .ex-chart-box { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.big-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.big-numbers div { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.big-numbers span { display: block; font-size: 12px; color: var(--ink-3); }
.big-numbers strong { display: block; font-size: 28px; letter-spacing: -0.02em; margin-top: 4px; overflow-wrap: anywhere; }
.ex-table-wrap { max-height: 480px; }
.ex-table-wrap td { white-space: nowrap; }
.sql {
  width: 100%; min-height: 200px; resize: vertical; border: 0; border-radius: 8px; padding: 14px 16px;
  background: var(--code-bg); color: var(--code-ink); font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2;
}
.sql:focus { outline: 2px solid var(--spark); outline-offset: 1px; }
.sql-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; }
.sql-actions button { font: inherit; font-size: 12.5px; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.ghost { background: none; border: 1px solid var(--line); color: var(--ink-2); }
.run { background: var(--ink); color: var(--surface); border: 1px solid var(--ink); font-weight: 500; margin-left: 6px; }
.ex-empty { border: 1px dashed var(--line); border-radius: 10px; padding: 28px; text-align: center; color: var(--ink-2); font-size: 13.5px; }
.ex-empty p { margin: 4px 0; }
.ex-empty[hidden], .ex-result[hidden] { display: none; }

@media (max-width: 860px) {
  .explore { grid-template-columns: minmax(0, 1fr); }
  .ex-side { order: 2; }
}
@media (max-width: 560px) {
  .explore { padding: 0 16px 16px; }
  .ask-btn kbd { display: none; }
}

/* ---- searchable business picker ---- */
.combo { position: relative; min-width: 220px; }
.combo-input {
  width: 100%; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 28px 7px 10px;
}
.combo-input::placeholder { color: var(--ink); }
.combo-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.combo-input:focus::placeholder { color: var(--ink-3); }
.combo-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; font-size: 15px; line-height: 1; color: var(--ink-3); background: none; border: 0; border-radius: 5px; cursor: pointer; }
.combo-clear:hover { color: var(--ink); background: var(--bg); }
.combo-clear[hidden] { display: none; }
.combo-list {
  position: absolute; z-index: 15; top: calc(100% + 4px); left: 0; right: 0; min-width: 260px; max-height: 340px; overflow: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(13, 15, 26, 0.12);
}
.combo-list[hidden] { display: none; }
.combo-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.combo-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-list li:hover, .combo-list li.active { background: var(--bg); color: var(--ink); }
.combo-list li[aria-selected="true"] { color: var(--accent); font-weight: 500; }
.combo-list li.combo-note { color: var(--ink-3); cursor: default; }
.combo-list li.combo-note:hover { background: none; }

/* ---- BI ---- */
.bi { padding: 0 24px 32px; max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.bi[hidden] { display: none; }
.bi-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 20px; }
.bi-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bi-actions .ghost { font: inherit; font-size: 12.5px; padding: 6px 11px; border-radius: 7px; cursor: pointer; }
#bi-status { font-size: 12px; margin-right: 4px; }
#bi-status.bad { color: var(--bad); }
.bi-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.bi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.bi-grid .w2 { grid-column: span 2; }
.bi-grid .w3 { grid-column: 1 / -1; }
.bi-card { min-width: 0; }
.bi-card .card-head h2 { font-size: 15px; }
.bi-kpi { padding: 14px 16px; }
.bi-kpi .card-head { margin-bottom: 4px; }
.bi-kpi .card-head h2 { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.bi-value { display: block; font-size: clamp(18px, 1.6vw, 26px); letter-spacing: -0.02em; margin-bottom: 4px; overflow-wrap: anywhere; }
.bi-body { transition: opacity 0.15s; }
.bi-body.busy { opacity: 0.5; }
.bi-chart { height: 260px; }
.bi-table { max-height: 520px; }
.bi-table tfoot td { font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); border-bottom: 0; position: sticky; bottom: 0; background: var(--surface); }
.bi-table td .up, .bi-table td.up { color: var(--good); }
.bi-table td .down { color: var(--bad); }
.icon-btn { width: 28px; height: 28px; font-size: 15px; line-height: 1; color: var(--ink-3); background: none; border: 1px solid transparent; border-radius: 7px; cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--line); background: var(--bg); }

/* settings drawer */
.cfg { width: min(560px, 100vw); }
.cfg-body { flex: 1; overflow: auto; padding: 14px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.cfg-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.cfg-foot .ex-error { flex-basis: 100%; }
.cfg-foot button { font: inherit; font-size: 13px; border-radius: 7px; padding: 7px 14px; cursor: pointer; }
.cfg-foot button[hidden] { display: none; }
.danger { color: var(--bad) !important; }
.cfg-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); min-width: 0; flex: 1; }
.cfg-field > span:first-child, .cfg-field > label { font-weight: 500; }
.cfg-field input, .cfg-field select, .cfg-rates {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; min-width: 0;
}
.cfg-field input[readonly] { color: var(--ink-3); background: var(--bg); }
.cfg-rates { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
.cfg-row { display: flex; flex-wrap: wrap; gap: 10px; }
.cfg-row > * { flex: 1 1 160px; }
.cfg-typed { display: flex; flex-direction: column; gap: 12px; }
.cfg-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.cfg-filters { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.cfg-filters legend { padding: 0 4px; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.pills-pick { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pick { font: inherit; font-size: 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.pick.on { color: var(--surface); background: var(--ink); border-color: var(--ink); }
.pick-add { font: inherit; font-size: 12px; width: 120px; border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; background: none; color: var(--ink); }
.cfg-metrics { display: flex; flex-direction: column; gap: 8px; }
.cfg-metric { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.cfg-metric[open] { padding-bottom: 12px; }
.cfg-metric > summary { cursor: pointer; font-size: 13px; padding: 2px 0; }
.cfg-metric[open] > summary { margin-bottom: 10px; }
.cfg-metric > * + * { margin-top: 10px; }

@media (max-width: 1000px) {
  .bi-grid { grid-template-columns: minmax(0, 1fr); }
  .bi-grid .w2, .bi-grid .w3 { grid-column: auto; }
}
@media (max-width: 560px) {
  .bi { padding: 0 16px 16px; }
  .combo { min-width: 0; width: 100%; }
}

/* =====================================================================
   Component layer (Cloudflare-dashboard inspired): one look for buttons,
   cards, tables, segmented controls and pills. Later rules win, so this
   block overrides the older one-off styles above.
   ===================================================================== */

/* buttons */
.ghost, .run, .ask-btn, .bi-actions .ghost, .sql-actions button, .cfg-foot button, .drawer-tools .ghost, .ghost.small {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
  cursor: pointer; transition: background-color 0.12s, border-color 0.12s, color 0.12s; white-space: nowrap;
}
.ghost:hover, .bi-actions .ghost:hover, .drawer-tools .ghost:hover { background: var(--hover); border-color: var(--ink-3); }
.ghost.small, .pager .ghost.small, .head-actions .ghost.small { height: 26px; padding: 0 9px; font-size: 12px; }
.run, .cfg-foot .run, .sql-actions .run, .ask-btn {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
}
.run:hover, .ask-btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.ghost:focus-visible, .run:focus-visible, .ask-btn:focus-visible, .icon-btn:focus-visible, .pick:focus-visible, .seg button:focus-visible {
  outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent);
}
.ghost:disabled, .run:disabled, .ask-btn:disabled { opacity: 0.5; cursor: default; }
.ghost.danger, .danger { color: var(--bad) !important; }
.ghost.danger:hover { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border-color: var(--bad); }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); border-color: var(--line); }

/* segmented controls (chart metric, Tree/Raw) */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; }
.seg button { height: 26px; padding: 0 12px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); background: none; border: 0; border-radius: 5px; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(16, 24, 40, 0.06); }

/* cards: flat, hairline border */
.card, .kpi, .ex-result, .ex-side-block, .ask-box { border-radius: var(--radius); border-color: var(--line); box-shadow: var(--shadow); }
.card-head { min-height: 30px; }
.card-head h2 { font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; }
.kpi h3, .bi-kpi .card-head h2 { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.kpi .value, .bi-value { font-weight: 700; letter-spacing: -0.02em; }

/* tables */
table { font-size: 13px; }
th {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-2);
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 10px;
}
thead th:first-child { border-top-left-radius: 6px; }
thead th:last-child { border-top-right-radius: 6px; }
td { padding: 9px 10px; color: var(--ink); border-bottom: 1px solid var(--line); }
tbody tr:hover td { background: var(--hover); }
td.num, th.num { font-variant-numeric: tabular-nums; }

/* KPI change and table deltas */
.change b.up, td .up, span.up { color: var(--good); }
.change b.down, td .down, span.down { color: var(--bad); }

/* pills, chips, picks */
.pill { background: var(--panel); border-color: var(--line); }
.chips button, .pick { height: 26px; display: inline-flex; align-items: center; border-color: var(--line-strong); }
.chips button:hover, .pick:hover { background: var(--hover); }
.pick.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* result tabs: underline like the app nav */
.ex-tabs [role=tab] { font-weight: 500; }
.ex-tabs [role=tab][aria-selected="true"] { border-bottom-color: var(--accent); }

/* combobox list matches the rest of the popovers */
.combo { min-width: 240px; }
.combo-list { border-color: var(--line-strong); box-shadow: var(--pop-shadow); border-radius: 8px; }
.combo-list li.active, .combo-list li:hover { background: var(--accent-soft); color: var(--ink); }

/* drawers */
.drawer { box-shadow: var(--pop-shadow); border-left-color: var(--line); }
.drawer-x { width: 32px; height: 32px; border-color: var(--line-strong); border-radius: 6px; }
.drawer-x:hover { background: var(--hover); }
.drawer-backdrop { background: rgba(10, 12, 20, 0.28); backdrop-filter: blur(1px); }

/* views share one gutter and width */
.grid, .explore, .bi { padding-left: 24px; padding-right: 24px; }
.explore { padding-top: 18px; }
.bi > .toolbar { padding-left: 0; padding-right: 0; margin: 0; width: 100%; max-width: none; }

/* Explore's ask box keeps its orange spark but the shared focus ring */
.ask-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 760px) {
  .appbar-inner { gap: 12px; padding: 0 16px; }
  .nav a { padding: 0 8px; }
  .fresh { padding: 0 8px; }
  #fresh-text { display: none; }
  .toolbar { padding: 14px 16px 10px; }
  .grid, .explore, .bi { padding-left: 16px; padding-right: 16px; }
  .filters > .field { flex: 1 1 150px; }
  .filters .combo { min-width: 0; width: 100%; }
  select.ctl { width: 100%; }
}

/* =====================================================================
   Spacing & layout: one 16px rhythm, 20px card padding, page headers
   ===================================================================== */
:root { --gap: 16px; --pad: 20px; }
.grid, .left, .kpis, .bi, .bi-kpis, .bi-grid, .ex-main, .ex-side { gap: var(--gap); }
.grid { padding-bottom: 32px; }
.card { padding: var(--pad); }
.kpi { padding: 16px 18px; }
.card-head { margin-bottom: 12px; }
.chart-total { margin-bottom: 4px; }
.rev-total { padding: 8px 0 20px; }
.rev-split { margin: 16px 0; }
.biz-list li { padding: 12px 0; }

/* page header in a view's toolbar */
.page-title h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.page-title p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; font-size: 12px; font-weight: 500;
  color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}

/* Explore: main column + a sticky side column */
.explore {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--gap); align-items: start;
  padding: 0 24px 32px; max-width: 1440px; margin: 0 auto;
}
.ex-side { position: sticky; top: 68px; display: flex; flex-direction: column; }
.ask-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.ask-card .ask-box { border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: none; padding: 10px 10px 10px 14px; }
.ask-foot { display: flex; align-items: flex-start; gap: 12px; }
.ask-foot .eyebrow { margin: 5px 0 0; flex: none; }
.ask-foot .chips { margin: 0; gap: 8px; }
.ask-note { margin: 0; }
.ex-loading { padding: 2px 4px; }
.ex-result { overflow: hidden; }
.ex-head { padding: 18px 20px 14px; }
.ex-head h2 { font-size: 16px; }
.ex-explain { margin-top: 6px; }
.ex-tabs { padding: 0 20px; gap: 20px; }
.ex-panel { padding: 18px 20px 20px; }
.ex-hint { margin-bottom: 10px; }
.pager { margin-top: 14px; }

/* empty state: what Explore does, in three steps */
.ex-empty { border-style: solid; text-align: left; padding: 24px; color: var(--ink-2); font-size: 13px; }
.ex-empty h2 { font-size: 15px; color: var(--ink); }
.ex-empty > p { margin: 6px 0 18px; }
.ex-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; counter-reset: step; }
.ex-steps li {
  counter-increment: step; display: flex; flex-direction: column; gap: 4px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; line-height: 1.5;
}
.ex-steps li::before {
  content: counter(step); display: grid; place-items: center; width: 22px; height: 22px; margin-bottom: 4px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px;
}
.ex-steps b { color: var(--ink); font-weight: 600; }

/* side cards: Recent and Tables */
.side-card { padding: 0; overflow: hidden; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.side-head h2 { font-size: 13px; font-weight: 600; }
.ex-schema > summary.side-head { cursor: pointer; list-style: none; margin: 0; }
.ex-schema > summary.side-head::-webkit-details-marker { display: none; }
.ex-schema:not([open]) > summary.side-head { border-bottom: 0; }
.ex-schema[open] summary { margin-bottom: 0; }
.ex-history { padding: 6px; max-height: 360px; overflow: auto; }
.ex-history .empty { padding: 10px; }
.ex-history-run { padding: 8px 10px; font-size: 13px; }
.ex-history-clear { font-size: 12px; }
.side-note { margin: 0; padding: 12px 16px 0; font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.ex-schema dl { margin: 0; padding: 2px 16px 16px; }
.ex-schema dt { font-size: 12.5px; font-weight: 600; margin-top: 12px; color: var(--ink); }
.ex-schema dd { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px; font-family: inherit; }
.ex-schema dd code { font-size: 11px; padding: 1px 6px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }

@media (max-width: 1000px) {
  .explore { grid-template-columns: minmax(0, 1fr); }
  .ex-side { position: static; }
  .ex-steps { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .explore { padding: 0 16px 24px; }
  .ask-foot { flex-direction: column; gap: 8px; }
  .ask-foot .eyebrow { margin: 0; }
}

/* Overview's Revenue panel: stays in view and scrolls its business list */
.revenue { position: sticky; top: 68px; max-height: calc(100vh - 84px); align-self: start; overflow: hidden; }
.revenue .biz-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 calc(var(--pad) * -1) calc(var(--pad) * -1); padding: 0 var(--pad) 8px; overscroll-behavior: contain; }
@media (max-width: 1000px) {
  .revenue { position: static; max-height: 640px; }
}

/* Overview toolbar: the same two columns as the page grid, so Product and Period line up with the Revenue pane */
.toolbar.overview-bar { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); gap: var(--gap); align-items: end; }
.filters-right { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.filters-right .field, .filters-right .ctl { min-width: 0; width: 100%; }
.filters-right .custom { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.filters-right .custom[hidden] { display: none; }
@media (max-width: 1000px) {
  .toolbar.overview-bar { grid-template-columns: minmax(0, 1fr); }
}

/* ---- sign-in, account menu, Users tab ---- */
/* Nothing of the app shows until /api/me says who is signed in; tabs a role can't open are hidden */
body:not(.signed-in) > .appbar, body:not(.signed-in) > .view { display: none !important; }
body:not(.can-overview) [data-perm="overview"],
body:not(.can-explore) [data-perm="explore"],
body:not(.can-bi) [data-perm="bi"],
body:not(.can-users) [data-perm="users"] { display: none !important; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-card h1 { font-size: 20px; letter-spacing: -0.015em; margin-top: 10px; }
.login-card .ctl { width: 100%; height: 38px; font-size: 14px; }
.login-card .run { margin: 4px 0 0; height: 38px; font-size: 14px; }
.login-card .muted { margin: 0; text-align: center; }

.role-pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; font-size: 11px; font-weight: 500; text-transform: capitalize;
  color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}
.role-pill[data-role="finance"] { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); border-color: transparent; }
.role-pill[data-role="admin"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.me { position: relative; }
.me > summary {
  list-style: none; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 4px;
  font-size: 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.me > summary::-webkit-details-marker { display: none; }
.me > summary:hover, .me[open] > summary { background: var(--hover); }
.me > summary:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.me-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-avatar {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
}
.me-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--pop-shadow);
}
.me-menu button { font: inherit; font-size: 13px; text-align: left; color: var(--ink); background: none; border: 0; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.me-menu button:hover, .me-menu button:focus-visible { outline: 0; background: var(--hover); }

.users {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start;
  padding: 0 24px 32px; max-width: 1440px; margin: 0 auto;
}
.users-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.users-add { display: flex; flex-direction: column; gap: 12px; }
.users-add h2, .roles-card h2 { font-size: 16px; }
.users-add-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.users-add-row .field:first-child { flex: 1 1 240px; }
.users-add-row .ctl { width: 100%; }
.users-add-row .run { margin: 0; height: var(--ctl-h); }
.users-table td { vertical-align: middle; }
.users-table td:not(:first-child) { white-space: nowrap; }
.users-table .role-select { min-width: 116px; height: 30px; text-transform: capitalize; }
.users-table tr.is-disabled .user-cell b { color: var(--ink-3); text-decoration: line-through; }
.user-cell { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.user-cell b { font-weight: 500; overflow-wrap: anywhere; }
.user-actions { display: inline-flex; justify-content: flex-end; gap: 6px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.status-dot.off::before { background: var(--ink-3); }
.roles { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.roles dt { margin-top: 14px; }
.roles dt:first-child { margin-top: 0; }
.roles dd { margin: 6px 0 0; }

.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--pop-shadow);
}
.dialog::backdrop { background: rgba(13, 15, 26, 0.35); }
.dialog form { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.dialog h2 { font-size: 17px; }
.dialog .ctl { width: 100%; }
.pw-who { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.pw-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 12px 16px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
}
.pw-box code { font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; user-select: all; overflow-wrap: anywhere; }
.pw-note { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .run { margin: 0; }

@media (max-width: 1000px) {
  .users { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .users { padding: 0 16px 24px; }
  .me-name { display: none; }
}
