/* =============================================================================
   OnePayy operations console
   -----------------------------------------------------------------------------
   Hand-written, no build step. The deployment splits public_html from the
   application directory, and every additional build artefact is another path
   that can be wrong on the host. This file is copied verbatim.

   Design intent: a precise instrument, not a marketing dashboard. Neutral
   surfaces, one restrained accent, and typography that makes a column of
   money legible at a glance.
   ========================================================================== */

:root {
  /* Neutrals, warmed very slightly so long reading sessions are easier than
     they are on pure grey. */
  --paper: #fbfbfa;
  --surface: #ffffff;
  --surface-sunk: #f4f4f2;
  --line: #e3e3df;
  --line-strong: #cfcfc9;

  --ink: #1a1a18;
  --ink-soft: #5c5c56;
  --ink-faint: #8a8a82;

  /* One accent. Deep indigo reads as considered rather than promotional, and
     holds contrast against both white and the sunk surface. */
  --accent: #33417a;
  --accent-soft: #eceef7;
  --accent-line: #c3c9e2;

  --good: #1f6b45;
  --good-soft: #e7f3ec;
  --warn: #8a5a10;
  --warn-soft: #fbf1de;
  --bad: #97331f;
  --bad-soft: #fbeae6;
  --info: #2a5b74;
  --info-soft: #e8f1f5;

  --radius: 6px;
  --radius-sm: 4px;

  /* A single spacing scale. Everything is a multiple of 4px. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --shadow: 0 1px 2px rgba(26, 26, 24, 0.05), 0 1px 3px rgba(26, 26, 24, 0.04);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  /* Numerals the same width everywhere, so money columns align without
     forcing the whole interface into a monospace font. */
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.011em;
}

h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }

/* --accent-ink, not --accent. The former is the accent tuned for use as text:
   it darkens in the light theme and lightens in the dark one, where the raw
   accent is a mid purple that sits too close to the page behind it. */
a {
  color: var(--accent-ink);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

/* Visible focus everywhere. Keyboard operation is a requirement, and an
   invisible focus ring makes it unusable. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------- banners  */

.banner {
  padding: var(--s3) var(--s5);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid transparent;
}

.banner--live {
  background: var(--bad-soft);
  color: var(--bad);
  border-bottom-color: #eccabf;
}

.banner strong { font-weight: 700; }

/* ------------------------------------------------------------------ shell  */

.shell {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--s5) 0;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.brand {
  padding: 0 var(--s5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand__name {
  font-weight: 650;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.brand__host {
  font-size: 11px;
  color: var(--ink-faint);
  font-family: var(--mono);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 var(--s3);
}

.nav__section {
  padding: var(--s4) var(--s2) var(--s1);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: 6px var(--s2);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 13px;
}

.nav__link:hover {
  background: var(--surface-sunk);
  color: var(--ink);
  text-decoration: none;
}

.nav__link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}

.nav__link--disabled {
  color: var(--ink-faint);
  cursor: not-allowed;
  opacity: 0.55;
}

.nav__count {
  font-size: 11px;
  font-family: var(--mono);
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bad-soft);
  color: var(--bad);
}

.sidebar__foot {
  margin-top: auto;
  padding: 0 var(--s5);
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

/* ------------------------------------------------------------------- main  */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  min-width: 0;
}

.topbar__sub {
  font-size: 12px;
  color: var(--ink-faint);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.content {
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  max-width: 1400px;
  width: 100%;
}

/* ------------------------------------------------------------- env switch  */

.envswitch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-sunk);
}

.envswitch a {
  padding: 4px var(--s3);
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-soft);
}

.envswitch a:hover { text-decoration: none; background: #eaeae6; }

.envswitch a[aria-current="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.envswitch a[aria-current="true"].is-live { color: var(--bad); }

/* ------------------------------------------------------------------ cards  */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
}

.card__body { padding: var(--s5); }
.card__body--flush { padding: 0; }

.card__foot {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line);
  background: var(--surface-sunk);
  font-size: 12px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ tiles  */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--s4);
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s4) var(--s5);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.tile__value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tile__value--sm { font-size: 16px; }

/* The denominator behind a percentage. A rate with no denominator is not a
   measurement, and this is where it goes. */
.tile__note {
  font-size: 12px;
  color: var(--ink-soft);
}

.tile__note--warn { color: var(--warn); font-weight: 550; }
.tile__note--bad { color: var(--bad); font-weight: 550; }

.tile--alert { border-color: #e6c8be; background: var(--bad-soft); }
.tile--attention { border-color: #e6d5b0; background: var(--warn-soft); }

/* ------------------------------------------------------------------ table  */

.tablewrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: inherit;
  color: var(--ink-soft);
  padding: 8px 18px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-sunk);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.data td {
  padding: 11px 18px;
  border-bottom: 1px solid #eff3f4;
  vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafcfc; }
table.data th.num { text-align: right; }
table.data td.muted { color: var(--ink-soft); }
table.data td > a { color: var(--ink); font-weight: 500; }
table.data td > a:hover { color: var(--accent); }
table.data td.ref, table.data td .ref:not(code) { font-family: var(--font); font-size: inherit; }

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ref {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  word-break: break-all;
}

.muted { color: var(--ink-faint); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* An amount we have no evidence for. Visually distinct from zero, because
   "unknown fee" and "no fee" are different claims. */
.unknown {
  color: var(--ink-faint);
  font-style: italic;
}

/* ------------------------------------------------------------------- pill  */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill--good { color: var(--good); }
.pill--bad { color: var(--failed); }
.pill--warn { color: var(--pending); }
.pill--info { color: var(--accent); }
.pill--muted { color: var(--ink-soft); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-soft);
  font-family: var(--mono);
}

/* ----------------------------------------------------------------- forms   */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.field__label {
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-soft);
}

.field__hint {
  font-size: 11.5px;
  color: var(--ink-faint);
}

.field__error {
  font-size: 12px;
  color: var(--bad);
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  font: inherit;
  font-size: 13px;
  padding: 6px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

input[readonly] { background: var(--surface-sunk); color: var(--ink-soft); }

textarea { resize: vertical; min-height: 72px; }

.formgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3);
  align-items: end;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: end;
}

.filters .field { min-width: 130px; }

/* ---------------------------------------------------------------- buttons  */

.btn {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 6px var(--s4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  user-select: none;
}

.btn:hover { background: var(--surface-sunk); text-decoration: none; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover { background: #2b3768; }

/* Irreversible money actions. Distinct from primary so the two are never
   confused in a hurry. */
.btn--danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn--danger:hover { background: #7d2a19; }

.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn--ghost:hover { background: var(--surface-sunk); color: var(--ink); }

.btn--sm { padding: 3px var(--s3); font-size: 12px; }

.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn > svg { width: 16px; height: 16px; flex: none; }

.btnrow { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- notices  */

.notice {
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 13px;
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
}

.notice--ok { background: var(--good-soft); border-color: #c6e0d1; color: var(--good); }
.notice--warn { background: var(--warn-soft); border-color: #e5cfa4; color: var(--warn); }
.notice--bad { background: var(--bad-soft); border-color: #eccabf; color: var(--bad); }
.notice--info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.notice__body { flex: 1; min-width: 0; }
.notice strong { display: block; margin-bottom: 2px; }

/* ------------------------------------------------------------------ empty  */

.empty {
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: center;
}

.empty__title { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.empty__hint { font-size: 13px; max-width: 46ch; }

/* --------------------------------------------------------------- timeline  */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.timeline__item {
  display: grid;
  grid-template-columns: 128px 12px 1fr;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}

.timeline__item:last-child { border-bottom: none; }

.timeline__when {
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.timeline__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--line-strong);
}

.timeline__dot--good { background: var(--good); }
.timeline__dot--bad { background: var(--bad); }
.timeline__dot--warn { background: var(--warn); }
.timeline__dot--info { background: var(--info); }

.timeline__title { font-weight: 550; font-size: 13px; }
.timeline__detail { font-size: 12.5px; color: var(--ink-soft); }

/* ------------------------------------------------------------------- misc  */

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s2) var(--s5);
  font-size: 13px;
  align-items: baseline;
}

.kv dt { color: var(--ink-faint); white-space: nowrap; }
.kv dd { margin: 0; }

.split {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--s5);
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack--tight { gap: var(--s2); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }

.money {
  font-variant-numeric: tabular-nums;
  font-weight: inherit;
  white-space: nowrap;
}

.money__currency {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
  margin-left: 3px;
}

/* Freshness. The dashboard states how old its data is rather than implying
   it is current. */
.freshness {
  font-size: 11.5px;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.freshness--stale { color: var(--warn); font-weight: 550; }

.pagination {
  display: flex;
  gap: var(--s3);
  align-items: center;
  justify-content: space-between;
}

.codeblock {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.secret {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--warn-soft);
  border: 1px solid #e5cfa4;
  border-radius: var(--radius-sm);
  padding: var(--s3);
  word-break: break-all;
  user-select: all;
}

/* ------------------------------------------------------------------- auth  */

.authpage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background: var(--paper);
}

.authcard {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.authcard__title { text-align: center; }
.authcard__sub { text-align: center; font-size: 13px; color: var(--ink-faint); }

/* --------------------------------------------------------------- checkout  */

.centerpage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s5);
}

.centercard {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: var(--s4) 0;
  }

  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__section { display: none; }
  .content { padding: var(--s4); }
  .topbar { padding: var(--s3) var(--s4); flex-wrap: wrap; }
  .split { grid-template-columns: 1fr; }
  .timeline__item { grid-template-columns: 100px 12px 1fr; }
}

/* ==========================================================================
   Payflow dashboard
   --------------------------------------------------------------------------
   Everything below restyles the operator dashboard to the reference design:
   same markup and same features, denser layout, one teal accent, and charts
   that are readable at a glance. Tables and status indicators share this
   typography and palette throughout the application.
   ========================================================================== */

:root {
  --paper: #f6f8f9;
  --surface: #ffffff;
  --surface-sunk: #f3f7f8;
  --line: #e7ecee;
  --line-strong: #d8e0e3;

  --ink: #0f1b21;
  --ink-soft: #5a6b73;
  --ink-faint: #64757d;

  --accent: #0e8a8f;
  --accent-strong: #0b767b;
  --accent-soft: #e6f4f4;
  --accent-line: #bde0e1;

  --teal-1: #0d8a8f;
  --teal-2: #4fb0b4;
  --teal-3: #a8d8da;
  --teal-4: #d6ecec;
  --grid: #eaeff1;

  --good: #17a366;
  --good-soft: #e4f6ed;
  --pending: #d99b0b;
  --failed: #d6455a;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 27, 33, .04), 0 1px 3px rgba(15, 27, 33, .03);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

body {
  font-size: 13px;
  background: var(--paper);
  letter-spacing: -0.006em;
}

h1 { font-size: 27px; font-weight: 700; line-height: 1.15; letter-spacing: -0.028em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.014em; }
h3 { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- sidebar  */

.shell { grid-template-columns: 216px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px 16px;
  gap: 22px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  padding: 2px 10px 0;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--accent);
}

.brand:hover { text-decoration: none; }
.brand__mark { width: 26px; height: 26px; fill: currentColor; flex: none; }
.brand__name { font-size: 22px; font-weight: 700; letter-spacing: -0.035em; }

.nav { gap: 3px; padding: 0; }

.nav__link {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
}

.nav__link:hover { background: #f1f5f6; color: var(--ink); }

.nav__link[aria-current="page"] {
  background: #ddf0f1;
  color: #0a767c;
  font-weight: 600;
}

.nav__label { display: flex; align-items: center; gap: 13px; min-width: 0; }

.nav__label svg {
  width: 19px; height: 19px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.nav__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav__count {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fce8e8;
  color: #c0392b;
}

.nav__more { margin-top: 4px; }

.nav__more summary {
  padding: 8px 12px;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  list-style: none;
}

.nav__more summary::-webkit-details-marker { display: none; }

.nav__more summary::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}

.nav__more[open] summary::after { transform: translateY(-1px) rotate(45deg); }
.nav__more-links { display: flex; flex-direction: column; gap: 3px; }

.sidebar__foot {
  padding: 12px 10px 0;
  gap: 4px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}

.sidebar__foot > span:first-child { color: var(--ink-soft); font-weight: 500; }

/* ----------------------------------------------------------------- topbar  */

.topbar {
  align-items: flex-start;
  padding: 22px 24px 14px;
  background: transparent;
  border-bottom: 0;
  gap: 20px;
}

.topbar__title { flex-direction: column; align-items: flex-start; gap: 3px; }
.topbar__sub { font-size: 13px; color: var(--ink-soft); }
.topbar__actions { gap: 10px; align-items: center; flex-wrap: wrap; }

.content { max-width: none; padding: 0 24px 26px; gap: 16px; }

.envswitch { border-radius: 8px; }
.envswitch a { padding: 5px 12px; font-size: 12px; font-weight: 600; }

/* ---------------------------------------------------------------- toolbar  */

.dashboard-toolbar { display: flex; gap: 10px; align-items: center; }

.dashboard-toolbar svg {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.range-control { position: relative; }

.range-control summary,
.company-control {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.range-control summary { min-width: 158px; justify-content: space-between; }
.range-control summary > svg {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.range-control summary > span:first-of-type { margin-right: auto; }
.range-control summary::-webkit-details-marker { display: none; }
.range-control summary:hover, .company-control:hover { border-color: var(--line-strong); }
.range-control summary [aria-hidden] { color: var(--ink-faint); }

.range-popover {
  position: absolute;
  z-index: 20;
  right: 0;
  top: 46px;
  width: 258px;
  padding: 14px;
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 27, 33, .13);
}

.range-presets { display: grid; gap: 6px; }
.range-presets .btn { justify-content: flex-start; }
.range-presets .btn.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

.company-control { min-width: 200px; padding-right: 8px; }
.company-control select { border: 0; padding: 0; background: transparent; font-weight: 500; cursor: pointer; }

.dashboard-export { height: 40px; padding: 0 18px; border-radius: 9px; font-weight: 600; }

/* ------------------------------------------------------------- dashboard  */

.dashboard { position: relative; display: flex; flex-direction: column; gap: 16px; }
.dashboard__alerts { display: grid; gap: 8px; }
.dashboard__alerts:empty { display: none; }

/* The overview is a Monitor/Operate surface. Sections use dividers and
   hierarchy before boxes; color is reserved for system state. */
.operational-section,
.primary-analytics {
  min-width: 0;
  padding: 18px 0 20px;
  border-top: 1px solid var(--line-strong);
}

.dashboard > .operational-section:first-child { border-top: 0; padding-top: 0; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}

.section-heading h2 { margin-top: 2px; font-size: 18px; color: var(--ink); }
.section-heading p { margin: 4px 0 0; color: var(--ink-soft); font-size: 12.5px; }

.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }

.health-item { min-width: 0; padding: 16px 18px; border-left: 3px solid var(--line-strong); }
.health-item + .health-item { border-top: 0; border-left-width: 1px; }
.health-item--good { border-left-color: var(--good); }
.health-item--warn { border-left-color: var(--pending); }
.health-item--bad { border-left-color: var(--failed); }
.health-item--info { border-left-color: var(--accent); }
.health-item__head { display: flex; align-items: center; gap: 8px; }
.health-item__head h3 { font-size: 12px; color: var(--ink-soft); }
.health-item > strong { display: block; margin-top: 10px; font-size: 15px; }
.health-item p { min-height: 34px; margin: 5px 0 10px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.45; }
.health-item a { font-size: 11.5px; font-weight: 600; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.health-item--good .status-dot { background: var(--good); }
.health-item--warn .status-dot { background: var(--pending); }
.health-item--bad .status-dot { background: var(--failed); }
.health-item--info .status-dot { background: var(--accent); }

.operational-section > .freshness { display: block; margin-top: 8px; text-align: right; }

.attention-list { border-top: 1px solid var(--line); }
.attention-row { display: grid; grid-template-columns: 5px minmax(220px, 1fr) 52px minmax(150px, auto); gap: 14px; align-items: center; min-height: 58px; padding: 9px 6px 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.attention-row:hover { background: rgba(255, 255, 255, .72); text-decoration: none; }
.attention-row__signal { align-self: stretch; background: var(--line-strong); border-radius: 1px; }
.attention-row--warn .attention-row__signal { background: var(--pending); }
.attention-row--bad .attention-row__signal { background: var(--failed); }
.attention-row > span:nth-child(2) { display: grid; gap: 3px; }
.attention-row strong { font-size: 13px; }
.attention-row small { color: var(--ink-soft); font-size: 11.5px; }
.attention-row > b { text-align: right; font-size: 17px; font-variant-numeric: tabular-nums; }
.attention-row > span:last-child { color: var(--accent-ink); font-size: 11.5px; font-weight: 600; text-align: right; }
.attention-row--quiet .attention-row__signal { background: #aebbc1; }

.metric-grid--operations { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.metric-card--plain { display: flex; flex-direction: column; gap: 0; min-height: 122px; padding: 15px 16px; border-radius: 7px; box-shadow: none; }
.metric-card--plain strong { margin-top: 9px; font-size: 25px; font-variant-numeric: tabular-nums; }
.metric-card--plain small { white-space: normal; line-height: 1.35; }
.metric-card--attention { border-color: #ead49b; box-shadow: inset 0 3px 0 #e2b23b; }

.primary-analytics { padding-bottom: 0; }
.primary-analytics > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
.primary-analytics > summary::-webkit-details-marker { display: none; }
.primary-analytics > summary::after { content: "Show"; color: var(--accent-ink); font-size: 11.5px; font-weight: 650; }
.primary-analytics[open] > summary::after { content: "Hide"; }
.primary-analytics__body { margin-top: 14px; display: grid; gap: 14px; }
.analytics-toolbar { justify-content: flex-end; }
.analytics-toolbar .dashboard-export { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.primary-analytics .dashboard-card { border-radius: 7px; box-shadow: none; }

/* Collapsible hierarchy dropdowns. Primary analytics established the
   details/summary pattern; the operational sections and Recent payments
   now share it so the overview reads top-down and each level collapses. */
.collapsible-section > summary { list-style: none; cursor: pointer; }
.collapsible-section > summary::-webkit-details-marker { display: none; }
.collapsible-section > summary::after {
  content: "Show";
  flex: none;
  align-self: flex-start;
  margin-left: 12px;
  padding-top: 2px;
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 650;
}
.collapsible-section[open] > summary::after { content: "Hide"; }
.collapsible-section > summary::after { margin-left: auto; }
details.operational-section:not([open]) > summary.section-heading { margin-bottom: 0; }
.recent-card.collapsible-section > summary.recent-card__head::after { align-self: center; padding-top: 0; }
.recent-card__body { display: grid; gap: 0; }

.notice { border-radius: 10px; font-size: 12.5px; }

.dashboard-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}

.dashboard-card > h2 { margin-bottom: 10px; }

/* --------------------------------------------------------- metric cards   */

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.metric-card {
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card--highlight {
  background: linear-gradient(135deg, #ffffff 38%, #e9f7f2);
  border-color: #d5ebe4;
}

.metric-card__icon {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #eef3f5;
  color: #5a7883;
}

.metric-card--highlight .metric-card__icon { background: #e0f3ea; color: var(--good); }

.metric-card__icon svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.metric-card > div { display: flex; flex-direction: column; min-width: 0; padding-top: 1px; }
.metric-card__label { font-size: 13px; color: var(--ink-soft); }

.metric-card strong {
  margin-top: 4px;
  font-size: clamp(22px, 1.75vw, 29px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.032em;
  white-space: nowrap;
}

.metric-card small { margin-top: 7px; font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.metric-card small b { color: var(--good); font-size: 12.5px; font-weight: 600; margin-right: 7px; }
.metric-card small b.is-down { color: var(--failed); }

/* -------------------------------------------------------------- charts    */

.analytics-grid { display: grid; grid-template-columns: 2fr 1.25fr 1fr 1.5fr; gap: 16px; }
.analytics-grid .dashboard-card { min-height: 284px; }

.interactive-chart { display: flex; flex-direction: column; flex: 1; min-height: 0; justify-content: flex-end; }

.chart-frame {
  display: grid;
  grid-template-columns: var(--axis-w, 34px) minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
}

.chart-y {
  grid-area: 1 / 1;
  position: relative;
  height: var(--plot-h, 176px);
  font-size: 10.5px;
  color: var(--ink-faint);
}

.chart-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }

.chart-plot {
  grid-area: 1 / 2;
  position: relative;
  height: var(--plot-h, 176px);
  border-bottom: 1px solid var(--grid);
  background-image: repeating-linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px 25%);
}

.chart-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-area { stroke: none; }
.chart-line { fill: none; stroke: var(--teal-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.chart-x {
  grid-area: 2 / 2;
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.chart-x span { white-space: nowrap; }

/* Data points sit in HTML rather than inside the SVG: the plot is stretched
   to the card width, which would squash any circle drawn in user units. */
.chart-dot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.chart-dot::before {
  content: "";
  position: absolute;
  inset: 8.5px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--teal-1);
  transition: transform .12s ease;
}

.chart-dot:hover::before, .chart-dot:focus-visible::before { transform: scale(1.45); }
.chart-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 50%; }

.chart-empty { align-self: center; margin: auto; color: var(--ink-soft); font-size: 12px; text-align: center; }

.chart-bar {
  flex: 1;
  min-width: 0;
  max-width: 30px;
  height: var(--bar);
  min-height: 2px;
  padding: 0;
  border: 0;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #14989d, #2a8f94);
  cursor: pointer;
  transition: background .12s ease;
}

.chart-bar:hover, .chart-bar:focus-visible { background: linear-gradient(180deg, #0c7f84, #17797e); }

.chart-plot--bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 10px;
  padding: 0 6px;
}

.chart-tooltip {
  position: absolute;
  z-index: 30;
  padding: 5px 9px;
  border-radius: 7px;
  background: #10262c;
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(15, 27, 33, .22);
}

.chart-tooltip[hidden] { display: none; }

/* The accessible data table behind every chart. Present, but quiet. */
.chart-table { margin-top: 10px; }

.chart-table summary {
  font-size: 11.5px;
  color: var(--ink-faint);
  cursor: pointer;
  list-style: none;
  width: max-content;
}

.chart-table summary::-webkit-details-marker { display: none; }

.chart-table summary::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 5px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}

.chart-table[open] summary::after { transform: translateY(-1px) rotate(45deg); }
.chart-table .tablewrap { margin-top: 8px; max-height: 190px; overflow: auto; }
.chart-table table.data { font-size: 12px; }
.chart-table table.data th, .chart-table table.data td { padding: 5px 8px; }

.line-chart { --axis-w: 56px; --plot-h: 178px; }
.bar-chart { --axis-w: 36px; --plot-h: 178px; }
.retention-chart { --axis-w: 36px; --plot-h: 116px; }

.customer-activity { --axis-w: 0px; --plot-h: 64px; flex: none; }
.customer-activity .chart-frame { column-gap: 0; }
.customer-activity .chart-plot { border-bottom: 0; background-image: none; }
.customer-activity .chart-x { margin-top: 6px; }

/* -------------------------------------------------------------- segments  */

.segment-card { display: flex; flex-direction: column; }
.donut { flex: 1; display: grid; place-items: center; padding: 4px 0 10px; }

.donut__chart {
  width: 142px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}

.donut__chart::after {
  content: "";
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  background: var(--surface);
}

.donut__chart span { z-index: 1; text-align: center; display: flex; flex-direction: column; gap: 1px; }
.donut__chart strong { font-size: 16px; font-weight: 700; letter-spacing: -0.025em; }
.donut__chart small { font-size: 10.5px; color: var(--ink-faint); }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.legend li { display: grid; grid-template-columns: 9px 1fr auto; gap: 9px; align-items: center; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- customer  */

.customer-card { display: flex; flex-direction: column; gap: 11px; }

.customer-search {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  background: var(--surface);
}

.customer-search::before {
  content: "";
  width: 15px; height: 15px; flex: none;
  background: currentColor;
  color: var(--ink-faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.customer-search select { border: 0; padding: 0; background: transparent; font-size: 13px; font-weight: 500; cursor: pointer; }

.customer-stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.customer-stats div { padding-right: 10px; border-right: 1px solid var(--line); min-width: 0; }
.customer-stats div + div { padding-left: 12px; }
.customer-stats div:last-child { border-right: 0; padding-right: 0; }
.customer-stats dt { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }
.customer-stats dd { margin: 3px 0 0; font-size: 14.5px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.customer-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11.5px; color: var(--ink-soft); }
.customer-status b { padding: 4px 12px; color: var(--good); background: var(--good-soft); border-radius: 999px; font-size: 11.5px; font-weight: 600; }

.chart-caption { margin: 0; font-size: 11.5px; color: var(--ink-soft); }

/* ------------------------------------------------------------ comparison  */

.comparison-grid { display: grid; grid-template-columns: minmax(0, 2.55fr) minmax(320px, 1fr); gap: 16px; }
.comparison-grid .dashboard-card { min-height: 208px; }

.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.company-chips { display: flex; gap: 8px; margin: 14px 0 16px; flex-wrap: wrap; align-items: center; }

/* A visible select makes the add interaction explicit and keyboard-friendly. */
.chip-add { display: inline-flex; align-items: center; gap: 6px; }
.chip-add select { max-width: 160px; min-height: 32px; padding: 5px 24px 5px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; }
.chip-add select:focus-visible + .company-chip--add { outline: 2px solid var(--accent); outline-offset: 2px; }

.company-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef3f5;
  color: #4a5f68;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.company-chip__x { font-size: 14px; line-height: 1; opacity: .75; }
.company-chip:hover { background: #e3ebee; }
.company-chip:hover .company-chip__x { opacity: 1; }
.company-chip--active { background: var(--accent); color: #fff; }
.company-chip--active:hover { background: var(--accent-strong); }
.company-chip--add { background: var(--surface); border-color: var(--line-strong); color: var(--ink-soft); }
.company-chip--add:hover { background: var(--surface-sunk); border-color: var(--accent-line); color: var(--accent-ink); }

/* Full comparison: the add controls go inert instead of silently no-opping. */
.chip-add select:disabled { opacity: .5; cursor: not-allowed; }
.company-chip--add[disabled] { opacity: .5; cursor: not-allowed; }
.company-chip--add[disabled]:hover { transform: none; background: var(--surface); border-color: var(--line-strong); color: var(--ink-soft); }

/* The × is the only thing that removes; it gets its own hover target. */
.company-chip__x { cursor: pointer; border-radius: 50%; padding: 0 1px; }
.company-chip__x:hover, .company-chip__x:focus-visible { color: var(--failed); }
.company-chip--active .company-chip__x:hover, .company-chip--active .company-chip__x:focus-visible { color: #fff; }
.company-chip__x:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

.comparison-content { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); flex: 1; }

.spend-bars { padding-right: 30px; border-right: 1px solid var(--line); display: grid; gap: 14px; align-content: start; }
.spend-bars > div { display: grid; grid-template-columns: 132px minmax(0, 1fr) 74px; gap: 12px; align-items: center; }
.spend-bars > div > span { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.spend-bars i, .spend-breakdown i {
  height: 20px;
  border-radius: 4px;
  background: #edf2f4;
  overflow: hidden;
  display: block;
}

.spend-bars i b, .spend-breakdown i b {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #9ad3d6, #158e93);
}

.spend-bars strong { font-size: 12.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.spend-breakdown { padding-left: 26px; display: flex; flex-direction: column; gap: 12px; }
.spend-breakdown h3 { margin-bottom: 2px; }
.spend-breakdown [data-breakdown-bars] { display: grid; gap: 12px; }
.spend-breakdown [data-breakdown-bars] > div { display: grid; grid-template-columns: 92px minmax(0, 1fr) 46px; align-items: center; gap: 10px; }
.spend-breakdown [data-breakdown-bars] > div > span { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spend-breakdown i { height: 18px; }
.spend-breakdown strong { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- retention */

.retention-card header { display: flex; align-items: baseline; gap: 9px; margin-bottom: 4px; }
.retention-card header h2 { margin-right: auto; }
.retention-card header h2 span { color: var(--ink-faint); font-size: 11px; cursor: help; }
.retention-card header strong { font-size: 19px; font-weight: 700; letter-spacing: -0.028em; }
.retention-card header small { color: var(--good); font-size: 12.5px; font-weight: 600; }

/* ---------------------------------------------------------------- recent  */

.recent-card { padding: 0; }
/* The wrapper owns the horizontal scroll and is the containing block for the
   visually-hidden header inside it. Without this the absolutely-positioned
   .sr-only span resolves against .dashboard and drags the page wide. */
.recent-card .tablewrap { position: relative; }
.recent-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }

.recent-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.recent-table th {
  padding: 8px 18px 10px;
  text-align: left;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.recent-table td { padding: 11px 18px; border-bottom: 1px solid #eff3f4; vertical-align: middle; }
.recent-table tbody tr:last-child td { border-bottom: 0; }
.recent-table tbody tr:hover { background: #fafcfc; }

.recent-company { color: var(--ink); font-weight: 500; white-space: nowrap; }
.recent-amount { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.recent-status { white-space: nowrap; }
.recent-date { color: var(--ink-soft); white-space: nowrap; }
.recent-empty { color: var(--ink-faint); }

.table-link {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.table-link:hover { color: var(--accent); text-decoration: underline; }

.payment-status { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.payment-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.payment-status--good { color: var(--good); }
.payment-status--warn { color: var(--pending); }
.payment-status--bad { color: var(--failed); }

.row-menu { position: relative; display: inline-block; }

.row-menu summary {
  list-style: none;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
}

.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover { background: #eef3f5; color: var(--ink); }

.row-menu__actions {
  position: absolute;
  z-index: 20;
  right: 0;
  top: 30px;
  min-width: 158px;
  padding: 5px;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 12px 28px rgba(15, 27, 33, .14);
}

.row-menu__actions button {
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.row-menu__actions button:hover { background: #f1f5f6; }

.empty-table { padding: 26px 18px; text-align: center; color: var(--ink-faint); }

.is-updated { background: #fff5cf; border-radius: 3px; transition: background .5s ease; }

.btn { border-radius: 8px; font-weight: 550; }
.btn--primary { background: var(--accent); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.notice--info { background: var(--info-soft); border-color: var(--info); color: var(--info); }

/* ------------------------------------------------------------ motion
   Calm by default. Short ease-out feedback on things a person presses or
   opens, and no entrance animation on content seen many times a day
   (charts, sections, whole pages). Nothing here runs past 300ms except the
   fade on a polled value, which shows what changed. The
   prefers-reduced-motion guard at the end of this file collapses it all. */

:root { --ease-out: cubic-bezier(.23, 1, .32, 1); }

html { scroll-behavior: smooth; }

/* Interactive feedback: everything clickable eases between states, and a
   pressed button gives a little. */
.btn { transition: background-color .15s var(--ease-out), border-color .15s var(--ease-out), color .15s var(--ease-out), transform .12s var(--ease-out), box-shadow .15s var(--ease-out); }
.btn:active:not(:disabled) { transform: scale(.97); }
.nav__link { transition: background-color .15s ease, color .15s ease; }
.table-link, .health-item a { transition: color .15s ease; }
.company-chip { transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s var(--ease-out); }
.company-chip:hover { transform: translateY(-1px); }
.attention-row { transition: background-color .15s ease, transform .15s var(--ease-out), opacity .15s ease; }
.attention-row:hover { transform: translateX(2px); }
.range-control summary, .company-control { transition: border-color .15s ease, box-shadow .15s ease; }
.row-menu__actions button { transition: background-color .15s ease; }

/* Disclosure arrows ease between states instead of snapping. */
.nav__more summary::after { transition: transform .18s var(--ease-out); }
.chart-table summary { transition: color .15s ease; }
.chart-table summary:hover { color: var(--ink); }
.chart-table summary::after { transition: transform .18s var(--ease-out); }
.collapsible-section > summary h2 { transition: color .18s ease; }
.collapsible-section > summary:hover h2 { color: var(--accent-ink); }
.collapsible-section > summary::after { transition: color .15s ease; }
.range-control summary > span[aria-hidden] { display: inline-block; transition: transform .18s var(--ease-out); }
.range-control[open] summary > span[aria-hidden] { transform: rotate(180deg); }

/* Opening a section someone asked for: one quick fade, no stagger. */
@keyframes section-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.collapsible-section[open] > *:not(summary),
.chart-table[open] > .tablewrap { animation: section-in .2s var(--ease-out) both; }

/* Range popover: grows from its control, no overshoot. */
@keyframes pop-in {
  from { opacity: 0; transform: scale(.97) translateY(-3px); }
  to { opacity: 1; transform: none; }
}
.range-control[open] > .range-popover { animation: pop-in .15s var(--ease-out) both; transform-origin: top right; }

/* Charts draw straight away. They are on screen many times a day, and a
   redraw that animates every refresh reads as noise, not news. */

/* Polled values flash instead of jumping. */
@keyframes flash {
  0% { background-color: #fff5cf; }
  100% { background-color: transparent; }
}
.is-updated { background-color: transparent; animation: flash .65s ease-out; }

/* The first tooltip fades in; moving to the next mark swaps it instantly. */
@keyframes tip-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}
.chart-tooltip { animation: tip-in .125s var(--ease-out); }
.chart-tooltip[data-instant] { animation: none; }

/* ------------------------------------------------------------ responsive  */

@media (max-width: 1450px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comparison-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1150px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    gap: 14px;
  }

  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__link { min-height: 36px; min-width: 0; }
  .nav__more { width: 100%; }
  .nav__more-links { flex-direction: row; flex-wrap: wrap; }
  .sidebar__foot { margin-top: 0; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }

  .topbar { padding: 18px 16px 10px; flex-wrap: wrap; }
  .topbar__actions { width: 100%; }
  .content { padding: 0 16px 20px; }
  .dashboard-toolbar { width: 100%; flex-wrap: wrap; }
  .health-grid { grid-template-columns: 1fr; }
  .health-item + .health-item { border-top: 1px solid var(--line); border-left-width: 3px; }
  .attention-row { grid-template-columns: 5px minmax(0, 1fr) 44px; }
  .attention-row > span:last-child { grid-column: 2 / -1; text-align: left; }
  .primary-analytics > summary,
  .collapsible-section > summary { flex-wrap: wrap; }

  /* Stacked toolbar: the control is at the left edge, so a right-anchored
     popover hangs off the screen. Anchor it left and let it shrink. */
  .range-popover { right: auto; left: 0; width: min(258px, calc(100vw - 32px)); }
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-grid .dashboard-card { min-height: 0; }
  .comparison-content { grid-template-columns: 1fr; gap: 18px; }
  .spend-bars { border-right: 0; padding-right: 0; }
  .spend-breakdown { border-top: 1px solid var(--line); padding: 16px 0 0; }
}

@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card strong { font-size: 25px; }
  .range-control, .company-control { flex: 1 1 150px; }
  .range-control summary, .company-control { width: 100%; min-width: 0; }
  .dashboard-export { flex: 1 1 100%; }
  .section-heading { gap: 10px; }
  .section-heading h2 { font-size: 17px; }
  .section-heading p { max-width: 34ch; }
  .health-item { padding: 14px; }
  .attention-row { gap: 9px; }
  .attention-row small { display: block; }
  .operational-section, .primary-analytics { padding: 12px; }
  .primary-analytics__body { margin-left: 0; margin-right: 0; padding: 0; }
  .line-chart { --axis-w: 44px; }
  .chart-x span:nth-child(even) { display: none; }
  .spend-bars > div { grid-template-columns: 96px minmax(0, 1fr) 62px; }
  .recent-table { min-width: 640px; }

  /* Narrow screens: the nav is a wrapping row, so links must be allowed to
     shrink rather than forcing the sidebar wider than the viewport. */
  .nav__link { flex: 0 1 auto; padding: 8px 10px; }
  .nav__label { gap: 9px; }
  .topbar__title h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
  }
}

@media print {
  .sidebar, .topbar__actions, .btn, .row-menu { display: none; }
}
