/* The mail console's stylesheet: billing-report's panel.css, copied whole (the platform's design language).
   funnel-stories app/public/assets/css/tokens.css (itself a mirror of
   static-sites/docs/DESIGN_SYSTEM.md), the member app's shell (a white sticky
   sidebar of pill links in grouped containers, a white header), pill buttons,
   and semantic tints. Components consume tokens only; the few panel tokens at
   the end of :root say why they exist. No inline style anywhere (the CSP has
   style-src 'self'): state is classes, geometry is SVG attributes or CSSOM. */

@font-face {
  font-family: "Inter Tight";
  src: url("/fonts/inter-tight-variable.woff2") format("woff2-variations"),
       url("/fonts/inter-tight-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
}

:root {
  /* --- platform tokens (funnel-stories tokens.css) --- */
  --brand-primary: #0890de;
  --brand-secondary: #004e7a;
  --brand-accent: #1a1a1a;
  --brand-surface: #ffffff;
  --brand-ink: #2a2a2a;

  --color-text-primary: #2a2a2a;
  --color-text-secondary: #4d4d4d;
  --color-text-tertiary: #828282;
  --color-text-on-dark: #fafafa;
  --color-surface-page: #ffffff;
  --color-surface-container: #f2f2f2;
  --color-border-container: #cccccc;
  --color-button-low-attention: #efefef;
  --color-button-low-attention-hover: #e3e3e3;
  --color-button-text-on-primary: #ffffff;
  --color-state-hover: #f5f5f5;
  --color-state-active: #eaeaea;
  --color-modal-scrim: rgba(0, 0, 0, 0.42);

  --color-n1: #fafafa;
  --color-n2: #f5f5f5;
  --color-n3: #eaeaea;
  --color-n4: #cccccc;
  --color-n5: #828282;
  --color-success: #2f7a3d;
  --color-success-bg: rgba(47, 122, 61, 0.10);
  --color-warning: #c47e1f;
  --color-warning-bg: rgba(196, 126, 31, 0.10);
  --color-danger: #b13a2e;
  --color-danger-bg: rgba(177, 58, 46, 0.10);
  --color-info: #2f6b8c;
  --color-info-bg: rgba(47, 107, 140, 0.10);

  --font-body: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --letter-spacing-body: 0.014em;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --text-2xs: 0.625rem;
  --text-xs: 0.6875rem;
  --text-sm: 0.75rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-md2: 1.25rem;
  --text-lg: 1.375rem;
  --text-xlg: 1.8rem;

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-base: 1.55;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --size-header-desktop: 5rem;
  --size-sidebar: 15rem;
  --size-icon: 1.25rem;
  --size-icon-sm: 1rem;

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.5rem;
  --radius-pill: 9999px;
  --border-thin: 1px;
  --outline-width: 2px;
  --outline-offset: 2px;
  --focus-ring-primary: 0 0 0 3px rgba(8, 144, 222, 0.20);
  --shadow-low: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-high: 0 12px 28px rgba(0, 0, 0, 0.12);

  --z-sticky: 100;
  --z-sidebar: 110;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.3, 0, 0, 1);

  /* --- panel tokens --- */
  /* Hairline inside cards and tables: one step off the surface (recessive). */
  --color-hairline: #eaeaea;
  /* The lanes: PROD is the brand blue; STAGE borrows the warning ramp so a
     test lane is never mistaken for money. */
  --lane-prod: var(--brand-primary);
  --lane-prod-bg: rgba(8, 144, 222, 0.10);
  --lane-stage: #9a5f10;
  --lane-stage-bg: rgba(196, 126, 31, 0.12);
  /* Chart marks. Approved keeps the platform success green; declined is an
     orange, not the danger red: red vs green fails deuteranopia (dE 3.3), this
     pair passes every check of the dataviz validator (CVD dE 10.5). The
     orange is under 3:1 on white, so the charts carry a legend, tooltips, and
     a table view. The single-series activity chart uses the brand blue. */
  --chart-activity: var(--brand-primary);
  --chart-approved: #2f7a3d;
  --chart-declined: #e0833f;
  --chart-grid: #eaeaea;
}

@media (prefers-reduced-motion: reduce) {
  :root { --motion-fast: 1ms; --motion-base: 1ms; }
}

/* --- base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-surface-page);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-base);
  letter-spacing: var(--letter-spacing-body);
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}
body.is-drawer-open { overflow: hidden; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: var(--outline-width) solid var(--brand-accent); outline-offset: var(--outline-offset); }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: var(--size-icon); height: var(--size-icon); flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: var(--size-icon-sm); height: var(--size-icon-sm); }
.skip-link { position: absolute; left: -9999px; top: var(--space-2); z-index: var(--z-toast); padding: var(--space-2) var(--space-4); background: var(--brand-accent); color: var(--color-text-on-dark); border-radius: var(--radius-sm); text-decoration: none; }
.skip-link:focus-visible { left: var(--space-2); }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--color-text-tertiary); }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { color: var(--color-text-tertiary); font-size: var(--text-sm); font-weight: var(--weight-medium); }

/* --- buttons (the platform's pill CTAs) ------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 2.5rem; padding: 0 var(--space-4);
  border: 0; border-radius: var(--radius-pill);
  background: var(--color-button-low-attention); color: var(--brand-ink);
  font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading-tight);
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--motion-fast) var(--ease-standard), filter var(--motion-fast) var(--ease-standard);
}
.btn:hover { background: var(--color-button-low-attention-hover); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn--primary { background: var(--brand-primary); color: var(--color-button-text-on-primary); }
.btn--primary:hover { background: var(--brand-primary); filter: brightness(0.96); }
.btn--primary:focus-visible { box-shadow: var(--focus-ring-primary); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--color-state-hover); }
.btn--outline { background: transparent; border: var(--border-thin) solid var(--color-border-container); }
.btn--outline:hover { background: transparent; border-color: #7b7b7b; }
.btn--sm { min-height: 2rem; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn--block { width: 100%; }
.btn--icon { width: 2.5rem; padding: 0; background: transparent; }
.btn--icon:hover { background: var(--color-state-hover); }
.btn.is-busy .icon { animation: spin 900ms linear infinite; }
.btn__count { min-width: 1.25rem; padding: 0 0.35rem; border-radius: var(--radius-pill); background: var(--brand-ink); color: var(--color-text-on-dark); font-size: var(--text-xs); line-height: 1.25rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- segmented control (period presets, lanes, window switch) --------------- */
.segmented { display: inline-flex; padding: 0.1875rem; gap: 0.125rem; border-radius: var(--radius-pill); background: var(--color-state-hover); }
.segmented__option {
  min-height: 2rem; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-pill); background: transparent;
  color: var(--color-text-secondary); font-size: var(--text-sm); font-weight: var(--weight-semibold);
  cursor: pointer; white-space: nowrap;
}
.segmented__option:hover { color: var(--color-text-primary); }
.segmented__option[aria-checked="true"], .segmented__option[aria-pressed="true"] { background: var(--brand-surface); color: var(--color-text-primary); box-shadow: var(--shadow-low), 0 0 0 1px rgba(0, 0, 0, 0.06); }
.segmented--lane .segmented__option[data-lane="prod"][aria-checked="true"] { color: var(--lane-prod); }
.segmented--lane .segmented__option[data-lane="stage"][aria-checked="true"] { color: var(--lane-stage); }
.lane-switch { display: inline-flex; flex: 0 0 auto; }
.lane-pill { display: inline-flex; align-items: center; min-height: 2rem; padding: 0 var(--space-3); border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.lane-pill--prod { background: var(--lane-prod-bg); color: var(--lane-prod); }
.lane-pill--stage { background: var(--lane-stage-bg); color: var(--lane-stage); }

/* --- fields ------------------------------------------------------------------ */
.field { display: grid; gap: var(--space-1); min-width: 0; }
.field__label { color: var(--color-text-secondary); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field__input {
  width: 100%; min-height: 2.5rem; padding: 0 var(--space-3);
  border: var(--border-thin) solid var(--color-border-container); border-radius: var(--radius-sm);
  background: var(--brand-surface); color: var(--color-text-primary);
}
select.field__input { padding-right: var(--space-6); }
.field__input::placeholder { color: var(--color-text-tertiary); }
.field__input:hover { border-color: #9a9a9a; }
.field__input:focus { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 1px var(--brand-accent); }
.field__input--mono { font-family: var(--font-mono); letter-spacing: 0; }
.field__input--narrow { width: 6.5rem; }
.field__input--area { min-height: 8rem; padding: var(--space-2) var(--space-3); line-height: 1.5; resize: vertical; }

/* --- chips (status is never color alone: every chip carries its word) -------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  min-height: 1.5rem; padding: 0 0.625rem;
  border-radius: var(--radius-pill); background: var(--color-state-active); color: var(--color-text-secondary);
  font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap;
}
.chip::before { content: ""; width: 0.375rem; height: 0.375rem; border-radius: 50%; background: currentColor; opacity: 0.85; }
.chip--plain::before { display: none; }
.chip--success { background: var(--color-success-bg); color: var(--color-success); }
.chip--danger { background: var(--color-danger-bg); color: var(--color-danger); }
.chip--warning { background: var(--color-warning-bg); color: #8a560f; }
.chip--info { background: var(--color-info-bg); color: var(--color-info); }
.chip--neutral { background: var(--color-state-active); color: var(--color-text-secondary); }
.chip--removable { padding-right: 0.25rem; background: var(--brand-surface); border: var(--border-thin) solid var(--color-border-container); color: var(--color-text-primary); }
.chip--removable::before { display: none; }
.chip__remove { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--color-text-tertiary); cursor: pointer; }
.chip__remove:hover { background: var(--color-state-hover); color: var(--color-text-primary); }
.chip__remove .icon { width: 0.875rem; height: 0.875rem; }

/* --- brand ------------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: var(--space-2); }
.brand__mark { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: var(--radius-sm); background: var(--brand-ink); color: var(--color-text-on-dark); }
.brand__mark .icon { width: 1.125rem; height: 1.125rem; stroke-width: 2; }
.brand__name { font-size: var(--text-md); font-weight: var(--weight-bold); letter-spacing: -0.01em; }

/* --- app shell ------------------------------------------------------------------ */
.app-frame { display: grid; grid-template-columns: var(--size-sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; z-index: var(--z-sidebar);
  display: flex; flex-direction: column; gap: var(--space-2);
  height: 100vh; padding: 0 var(--space-4) var(--space-4);
  overflow-y: auto; background: var(--brand-surface);
  border-right: var(--border-thin) solid var(--color-hairline);
  scrollbar-width: thin;
}
.sidebar__brand { min-height: var(--size-header-desktop); }
.sidebar__nav { display: grid; gap: var(--space-4); flex: 1 1 auto; align-content: start; }
.nav-group__label { margin: 0 0 var(--space-2); padding-left: var(--space-3); color: var(--color-text-secondary); font-size: var(--text-sm); }
.nav-group__list { display: grid; gap: 0.125rem; margin: 0; padding: var(--space-2); list-style: none; border-radius: var(--radius-md); background: var(--color-state-hover); }
.nav-link {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  min-height: 2.25rem; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-pill); background: transparent;
  color: var(--color-text-primary); font-size: var(--text-base); font-weight: var(--weight-semibold);
  text-align: left; cursor: pointer; white-space: nowrap;
}
a.nav-link { text-decoration: none; }
.nav-link:hover { background: rgba(17, 17, 17, 0.06); }
.nav-link[aria-current="page"] { background: rgba(17, 17, 17, 0.12); }
.nav-link .icon { color: var(--color-text-secondary); }
.nav-link[aria-current="page"] .icon { color: var(--color-text-primary); }
.sidebar__foot { display: grid; gap: var(--space-2); padding-top: var(--space-3); border-top: var(--border-thin) solid var(--color-hairline); }
.who { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); min-width: 0; }
.who__avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 50%; background: #bae9ff; color: var(--brand-ink); font-weight: var(--weight-bold); text-transform: uppercase; }
.who__name { font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; }
.sidebar__foot .btn { justify-content: flex-start; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--size-header-desktop); padding: var(--space-3) var(--space-6);
  background: rgba(255, 255, 255, 0.94); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: var(--border-thin) solid var(--color-hairline);
}
.topbar__title { flex: 1 1 auto; min-width: 0; }
.topbar__title h1 { font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-tight); letter-spacing: -0.01em; }
.topbar__sub { margin-top: 0.125rem; color: var(--color-text-tertiary); font-size: var(--text-sm); }
.find { position: relative; display: flex; align-items: center; flex: 0 1 18rem; }
.find__icon { position: absolute; left: var(--space-3); color: var(--color-text-tertiary); pointer-events: none; }
.find__input {
  width: 100%; min-height: 2.5rem; padding: 0 var(--space-3) 0 2.25rem;
  border: var(--border-thin) solid transparent; border-radius: var(--radius-pill);
  background: var(--color-state-hover); color: var(--color-text-primary);
}
.find__input:hover { background: var(--color-state-active); }
.find__input:focus { outline: none; background: var(--brand-surface); border-color: var(--brand-accent); }
.find.is-invalid .find__input { border-color: var(--color-danger); background: var(--brand-surface); }

.lane-banner {
  display: flex; align-items: center; gap: var(--space-2);
  margin: var(--space-4) var(--space-6) 0; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); background: var(--lane-stage-bg); color: var(--lane-stage);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.content { width: 100%; max-width: 90rem; padding: var(--space-5) var(--space-6) var(--space-7); display: grid; gap: var(--space-5); align-content: start; outline: none; }
.content-stack { display: grid; gap: var(--space-5); align-content: start; min-width: 0; }
/* Grid children default to min-width: auto and would grow to a wide table's width; the table scrolls inside its card instead. */
.content > *, .content-stack > *, .grid-2 > * { min-width: 0; }
.card .content-stack { gap: var(--space-4); }
.app-foot { padding: 0 var(--space-6) var(--space-5); color: var(--color-text-tertiary); font-size: var(--text-sm); }

/* --- filter bar (one row above the content it scopes) ------------------------------ */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.toolbar .field { flex: 0 1 10rem; }
.toolbar .field--auto { flex: 0 0 auto; }
.toolbar__spacer { flex: 1 1 auto; }
.toolbar__more { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-state-hover); }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.custom-period { display: inline-flex; align-items: center; gap: var(--space-2); }

/* --- stat tiles ------------------------------------------------------------------------ */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--space-3); }
.tile {
  display: grid; gap: var(--space-1); align-content: start;
  padding: var(--space-4); border: var(--border-thin) solid var(--color-hairline); border-radius: var(--radius-md);
  background: var(--brand-surface); box-shadow: var(--shadow-low);
}
.tile__label { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--color-text-secondary); font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.tile__label::before { content: ""; flex: 0 0 auto; width: 0.5rem; height: 0.5rem; margin-top: 0.3em; border-radius: 50%; background: var(--color-n4); }
.tile--success .tile__label::before { background: var(--color-success); }
.tile--danger .tile__label::before { background: var(--color-danger); }
.tile--warning .tile__label::before { background: var(--color-warning); }
.tile--info .tile__label::before { background: var(--brand-primary); }
.tile__value { font-size: var(--text-xlg); font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: -0.01em; }
.tile__value--text { font-size: var(--text-md2); }
.tile__sub { color: var(--color-text-tertiary); font-size: var(--text-sm); }
.section-title { font-size: var(--text-md); font-weight: var(--weight-semibold); }

/* --- cards ------------------------------------------------------------------------------ */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.card { min-width: 0; border: var(--border-thin) solid var(--color-hairline); border-radius: var(--radius-md); background: var(--brand-surface); box-shadow: var(--shadow-low); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5) 0; }
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.card__desc { margin-top: 0.125rem; color: var(--color-text-tertiary); font-size: var(--text-sm); }
.card__actions { display: flex; gap: var(--space-2); flex: 0 0 auto; }
.card__body { padding: var(--space-4) var(--space-5) var(--space-5); }
.card__body--flush { padding: var(--space-3) 0 var(--space-2); }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: var(--border-thin) solid var(--color-hairline); color: var(--color-text-tertiary); font-size: var(--text-sm); }
.is-refreshing { opacity: 0.55; transition: opacity var(--motion-base) var(--ease-standard); pointer-events: none; }

/* --- tables ------------------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.625rem var(--space-3); text-align: left; white-space: nowrap; vertical-align: middle; border-bottom: var(--border-thin) solid var(--color-hairline); }
th:first-child, td:first-child { padding-left: var(--space-5); }
th:last-child, td:last-child { padding-right: var(--space-5); }
th { position: sticky; top: 0; background: var(--brand-surface); color: var(--color-text-tertiary); font-size: var(--text-sm); font-weight: var(--weight-medium); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-clickable { cursor: pointer; }
tr.is-clickable:hover td { background: var(--color-state-hover); }
tr.is-clickable:focus-visible { outline: none; }
tr.is-clickable:focus-visible td { background: var(--color-state-active); }
td .sub { display: block; color: var(--color-text-tertiary); font-size: var(--text-sm); line-height: var(--leading-snug); }
.card-num { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.pager { display: flex; align-items: center; gap: var(--space-2); }

/* --- states: empty, error, loading --------------------------------------------------------- */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-7) var(--space-5); text-align: center; }
.empty__icon { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: 50%; background: var(--color-state-hover); color: var(--color-text-tertiary); }
.empty__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.empty__text { max-width: 44ch; color: var(--color-text-tertiary); }
.empty .btn { margin-top: var(--space-2); }
.alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-base); }
.alert--danger { background: var(--color-danger-bg); color: var(--color-danger); }
.alert--warning { background: var(--color-warning-bg); color: #8a560f; }
.alert--success { background: var(--color-success-bg); color: var(--color-success); }
.alert__body { flex: 1 1 auto; display: grid; gap: var(--space-1); }
.alert__title { font-weight: var(--weight-semibold); }
.skeleton { position: relative; overflow: hidden; border-radius: var(--radius-sm); background: var(--color-state-hover); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent); animation: shimmer 1.4s infinite; }
.skeleton--tile { height: 5.5rem; border-radius: var(--radius-md); }
.skeleton--card { height: 16rem; border-radius: var(--radius-md); }
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } .btn.is-busy .icon { animation: none; } }

/* --- charts (dataviz marks: <=24px columns, 4px rounded data-end, 2px surface gap,
       hairline recessive grid, a hover/focus tooltip per column, a table view) ----- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--color-n4); stroke-width: 1; shape-rendering: crispEdges; }
.chart text { fill: var(--color-text-tertiary); font-family: var(--font-body); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .axis-y text { text-anchor: end; }
.chart .axis-x text { text-anchor: middle; }
.chart .col { cursor: default; outline: none; }
.chart .col .hit { fill: transparent; }
.chart .col:hover .hit, .chart .col:focus-visible .hit { fill: rgba(0, 0, 0, 0.035); }
.chart .col:focus-visible .hit { stroke: var(--brand-accent); stroke-width: 1.5; }
.chart .col:hover .seg, .chart .col:focus-visible .seg { filter: brightness(1.08); }
.seg--activity { fill: var(--chart-activity); }
.seg--approved { fill: var(--chart-approved); }
.seg--declined { fill: var(--chart-declined); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-3); color: var(--color-text-secondary); font-size: var(--text-sm); }
.legend__item { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend__swatch { width: 0.75rem; height: 0.75rem; border-radius: 3px; }
.key--activity { background: var(--chart-activity); }
.key--approved { background: var(--chart-approved); }
.key--declined { background: var(--chart-declined); }
.chart__caption { margin-top: var(--space-2); color: var(--color-text-tertiary); font-size: var(--text-xs); }
.tooltip {
  position: absolute; z-index: var(--z-toast); min-width: 9rem; padding: var(--space-2) var(--space-3);
  border: var(--border-thin) solid var(--color-hairline); border-radius: var(--radius-sm);
  background: var(--brand-surface); box-shadow: var(--shadow-medium);
  font-size: var(--text-sm); pointer-events: none; transform: translate(-50%, calc(-100% - 8px));
}
.tooltip__title { margin-bottom: var(--space-1); color: var(--color-text-tertiary); font-weight: var(--weight-medium); }
.tooltip__row { display: flex; align-items: center; gap: var(--space-2); }
.tooltip__row strong { min-width: 2.5rem; font-variant-numeric: tabular-nums; }
.tooltip__key { width: 0.75rem; height: 2px; border-radius: 1px; }
.bars { display: grid; gap: var(--space-2); }
.bar-row { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr auto; align-items: center; gap: var(--space-3); }
.bar-row__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { height: 0.5rem; border-radius: var(--radius-pill); background: var(--color-state-hover); overflow: hidden; }
.bar-row__fill { height: 100%; border-radius: var(--radius-pill); background: var(--chart-activity); }
.bar-row__value { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }

/* --- definition lists (drawer, settings) --------------------------------------------------------- */
.fields { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.fields dt { color: var(--color-text-tertiary); font-size: var(--text-sm); }
.fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.fields--raw dd { font-family: var(--font-mono); font-size: var(--text-sm); letter-spacing: 0; }

/* --- drawer (slide-over, the platform's sheet) ------------------------------------------------- */
.drawer { position: fixed; inset: 0; z-index: var(--z-modal); }
.drawer__scrim { position: absolute; inset: 0; background: var(--color-modal-scrim); animation: fade var(--motion-base) var(--ease-standard); }
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  width: min(36rem, 100%); background: var(--brand-surface); box-shadow: var(--shadow-high);
  animation: slide-in var(--motion-base) var(--ease-emphasized);
}
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-4); border-bottom: var(--border-thin) solid var(--color-hairline); }
.drawer__heading { display: grid; gap: var(--space-2); min-width: 0; }
.drawer__title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-md2); font-weight: var(--weight-bold); }
.drawer__body { flex: 1 1 auto; overflow-y: auto; padding: var(--space-4) var(--space-5) var(--space-6); display: grid; gap: var(--space-5); align-content: start; }
.drawer__section { display: grid; gap: var(--space-3); }
.drawer__section h3 { font-size: var(--text-base); font-weight: var(--weight-semibold); }
details.raw summary { color: var(--color-text-secondary); font-weight: var(--weight-semibold); cursor: pointer; }
details.raw[open] summary { margin-bottom: var(--space-3); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(100%); } }

/* --- login ------------------------------------------------------------------------------------------ */
.login { display: grid; min-height: 100vh; place-items: center; padding: var(--space-5); background: var(--color-state-hover); }
.login__card { display: grid; gap: var(--space-4); width: min(26rem, 100%); padding: var(--space-6); border-radius: var(--radius-lg); background: var(--brand-surface); box-shadow: var(--shadow-medium); }
.login__card .brand { margin-bottom: var(--space-2); }
.login__title { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.login__lead { margin-top: calc(var(--space-2) * -1); color: var(--color-text-secondary); }
.login__card .btn { min-height: 3rem; }

/* --- responsive ------------------------------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  .app-frame { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: var(--space-3); padding: var(--space-3) var(--space-4); border-right: 0;
    border-bottom: var(--border-thin) solid var(--color-hairline); overflow: visible;
  }
  .sidebar__brand { min-height: 0; }
  .sidebar, .sidebar__nav, .topbar > * { min-width: 0; }
  .sidebar__nav { order: 3; flex: 1 1 100%; display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; }
  .nav-group { display: contents; }
  .nav-group__label { display: none; }
  .nav-group__list { display: flex; gap: var(--space-1); padding: 0; background: none; }
  .nav-link { width: auto; }
  .sidebar__foot { order: 2; margin-left: auto; display: flex; align-items: center; padding: 0; border: 0; }
  .topbar { position: static; flex-wrap: wrap; padding: var(--space-3) var(--space-4); min-height: 0; }
  .topbar__title { flex-basis: 100%; }
  .find { flex: 1 1 12rem; }
  .content { padding: var(--space-4) var(--space-4) var(--space-6); }
  .lane-banner { margin: var(--space-3) var(--space-4) 0; }
  .app-foot { padding: 0 var(--space-4) var(--space-4); }
}
@media (max-width: 640px) {
  .who__name { display: none; }
  /* Chart text is in SVG units, which scale with the chart: larger units keep it readable when the chart is narrow. */
  .chart text { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile__value { font-size: var(--text-lg); }
  .toolbar .field { flex: 1 1 calc(50% - var(--space-3)); }
  .toolbar .field--auto { flex-basis: 100%; }
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row__track { grid-column: 1 / -1; grid-row: 2; }
  .fields { grid-template-columns: 1fr; gap: 0 0; }
  .fields dd { margin-bottom: var(--space-2); }
}
@media (forced-colors: active) {
  .chip::before, .tile__label::before { forced-color-adjust: none; }
}

/* ---- the mail console's own (mailing-service D43, D44) ---- */
.msg-name { font-weight: var(--weight-semibold); color: var(--color-text-primary); }
.copy-frame { display: block; width: 100%; height: 640px; border: 1px solid var(--color-border-container); border-radius: 8px; background: #ffffff; }
.copy-source { white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: var(--text-xs); max-height: 520px; overflow: auto; background: var(--color-surface-container); border-radius: 8px; padding: var(--space-3); }
.reply-text { font-size: var(--text-xs); white-space: normal; word-break: break-word; }

/* ---- phones (item 5, the owner's of 2026-10-19): a table row is a card of label and value ---- */
@media (max-width: 640px) {
  .table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: var(--space-3) var(--space-4); border-bottom: var(--border-thin) solid var(--color-hairline); }
  .table--cards tbody tr:last-child { border-bottom: 0; }
  .table--cards td, .table--cards td:first-child, .table--cards td:last-child {
    display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
    padding: 0.1875rem 0; border: 0; white-space: normal; text-align: right; overflow-wrap: anywhere;
  }
  .table--cards td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; color: var(--color-text-tertiary); font-size: var(--text-sm); text-align: left; }
  .table--cards td.td-primary { display: block; padding-bottom: var(--space-2); text-align: left; font-size: var(--text-base); }
  .table--cards td.td-primary::before { content: none; }
  .table--cards td.is-blank { display: none; }
  .table--cards td.num { text-align: right; }
  .table--cards tr.is-clickable:hover td, .table--cards tr.is-clickable:focus-visible td { background: none; }
  .table--cards tr.is-clickable:hover, .table--cards tr.is-clickable:focus-visible { background: var(--color-state-hover); }
  .table--cards .chips { justify-content: flex-end; }
  .card__body--flush { padding: 0; }
  .topbar { gap: var(--space-2); }
  .channel-switch { order: 2; flex: 1 1 auto; }
  .channel-switch .segmented { width: 100%; }
  .channel-switch .segmented__option { flex: 1 1 0; }
  .lane-switch { order: 3; }
  #refresh { order: 4; }
  .copy-frame { height: 480px; }
  .drawer__head, .drawer__body { padding-left: var(--space-4); padding-right: var(--space-4); }
  .flow-when { display: inline; }
}

/* ---- the switch and the flow (D46) ---- */
.channel-switch { display: inline-flex; flex: 0 0 auto; }
.channel-switch .segmented__option { font-weight: var(--weight-semibold); }
.flow-name { display: block; font-weight: var(--weight-semibold); color: var(--color-text-primary); }
.flow-sub { display: block; color: var(--color-text-tertiary); font-size: var(--text-sm); white-space: normal; }
.flow-when { color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.flow-note { color: var(--color-text-tertiary); font-size: var(--text-sm); }

/* ---- the SMTP transcript (D43 step 4) ---- */
.transcript { margin: 0; padding: var(--space-3); border-radius: 8px; background: var(--color-surface-container); font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.transcript .tx-out { color: var(--brand-secondary); }
.transcript .tx-in { color: var(--color-text-secondary); }
.transcript .tx-bad { color: var(--color-danger); font-weight: var(--weight-semibold); }
details.attempt { border: var(--border-thin) solid var(--color-hairline); border-radius: 8px; padding: var(--space-2) var(--space-3); }
details.attempt > summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); }
details.attempt[open] > summary { margin-bottom: var(--space-2); }

/* ---- the allow-list form (E90, E91) ---- */
.field--grow { flex: 1 1 16rem; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.5rem; color: var(--color-text-secondary); font-size: var(--text-sm); }
