/* src/styles.css */
/* Nexus Admin (SCR-002..017), redesign: IBM Plex Sans for the UI, IBM Plex Mono for figures,
   warm neutrals, one blue accent. Every colour is a custom property on :root; the dark palette
   applies under prefers-color-scheme unless data-theme="light" pins light, and under
   data-theme="dark" whatever the OS says (src/ui/theme.ts). Loaded from a file only: the CSP has
   style-src 'self', so there is no inline style anywhere, and SVG charts size themselves with
   attributes. */

/* ---- fonts (self-hosted, SIL OFL 1.1: /fonts/OFL.txt) ---- */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

/* ---- tokens ---- */

:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-subtle: #faf9f6;
  --surface-sunken: #f1efe9;
  --border: #e4e1d8;
  --border-subtle: #efede7;
  --border-input: #8f8a7d;
  --border-input-soft: #cfcabd;
  --ink: #1b1a17;
  --ink-2: #55524a;
  --ink-3: #6b675d;
  --accent: #2450c8;
  --accent-hover: #1a3c99;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefb;
  --accent-soft-ink: #1a3c99;
  --focus: #2450c8;
  --sidebar: #efede7;
  --sidebar-border: #e0dcd1;
  --nav-ink: #3a3833;
  --nav-current: #ffffff;
  --chart-cost: #a9a596;
  --chart-profit: #2450c8;
  --chart-bar: #2450c8;
  --chart-bar-muted: #7f97db;
  --chart-grid: #efede7;
  --chart-axis: #cfcabd;
  --chip-green-bg: #e3f2e9;
  --chip-green-ink: #1d6b40;
  --chip-amber-bg: #fdf0dc;
  --chip-amber-ink: #8a5300;
  --chip-grey-bg: #efede7;
  --chip-grey-ink: #55524a;
  --chip-red-bg: #fbe7e5;
  --chip-red-ink: #a2231a;
  --chip-blue-bg: #e8eefb;
  --chip-blue-ink: #1a3c99;
  --positive: #1d6b40;
  --danger: #a2231a;
  --danger-hover: #7f1b14;
  --danger-bg: #fbe7e5;
  --warning-bg: #fdf0dc;
  --warning-ink: #8a5300;
  --info-bg: #e8eefb;
  --info-ink: #1a3c99;
  --help-ring: #8f8a7d;
  --logo-ink: #231f20;
  --brand-red: #e62a22;
  --backdrop: rgb(27 26 23 / 0.45);
  --shadow-pop: 0 12px 32px rgb(27 26 23 / 0.18);
  --shadow-dialog: 0 16px 48px rgb(27 26 23 / 0.3);

  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-card: 12px;
  --radius-dialog: 14px;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --control-height: 36px;
  --control-height-sm: 32px;

  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
}

/* The dark palette, twice: following the OS unless light is pinned, and when dark is pinned. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151412;
    --surface: #1d1c19;
    --surface-subtle: #211f1c;
    --surface-sunken: #282622;
    --border: #33312c;
    --border-subtle: #2a2824;
    --border-input: #777266;
    --border-input-soft: #4a4740;
    --ink: #f1efea;
    --ink-2: #b3aea3;
    --ink-3: #a29d91;
    --accent: #7c9cf0;
    --accent-hover: #a3baf5;
    --accent-ink: #10131c;
    --accent-soft: #232f4d;
    --accent-soft-ink: #bccdf8;
    --focus: #8fabf3;
    --sidebar: #191815;
    --sidebar-border: #2a2824;
    --nav-ink: #d9d5cc;
    --nav-current: #26241f;
    --chart-cost: #6f6b61;
    --chart-profit: #7c9cf0;
    --chart-bar: #7c9cf0;
    --chart-bar-muted: #4f67a6;
    --chart-grid: #2a2824;
    --chart-axis: #4a4740;
    --chip-green-bg: #173524;
    --chip-green-ink: #93d7ab;
    --chip-amber-bg: #3b2b10;
    --chip-amber-ink: #f2c27d;
    --chip-grey-bg: #2c2a26;
    --chip-grey-ink: #cfcabe;
    --chip-red-bg: #401b18;
    --chip-red-ink: #f6a79f;
    --chip-blue-bg: #232f4d;
    --chip-blue-ink: #bccdf8;
    --positive: #93d7ab;
    --danger: #f6a79f;
    --danger-hover: #f9c4be;
    --danger-bg: #401b18;
    --warning-bg: #3b2b10;
    --warning-ink: #f2c27d;
    --info-bg: #232f4d;
    --info-ink: #bccdf8;
    --help-ring: #8a857a;
    --logo-ink: #f4f2ee;
    --backdrop: rgb(0 0 0 / 0.6);
    --shadow-pop: 0 12px 32px rgb(0 0 0 / 0.45);
    --shadow-dialog: 0 16px 48px rgb(0 0 0 / 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151412;
  --surface: #1d1c19;
  --surface-subtle: #211f1c;
  --surface-sunken: #282622;
  --border: #33312c;
  --border-subtle: #2a2824;
  --border-input: #777266;
  --border-input-soft: #4a4740;
  --ink: #f1efea;
  --ink-2: #b3aea3;
  --ink-3: #a29d91;
  --accent: #7c9cf0;
  --accent-hover: #a3baf5;
  --accent-ink: #10131c;
  --accent-soft: #232f4d;
  --accent-soft-ink: #bccdf8;
  --focus: #8fabf3;
  --sidebar: #191815;
  --sidebar-border: #2a2824;
  --nav-ink: #d9d5cc;
  --nav-current: #26241f;
  --chart-cost: #6f6b61;
  --chart-profit: #7c9cf0;
  --chart-bar: #7c9cf0;
  --chart-bar-muted: #4f67a6;
  --chart-grid: #2a2824;
  --chart-axis: #4a4740;
  --chip-green-bg: #173524;
  --chip-green-ink: #93d7ab;
  --chip-amber-bg: #3b2b10;
  --chip-amber-ink: #f2c27d;
  --chip-grey-bg: #2c2a26;
  --chip-grey-ink: #cfcabe;
  --chip-red-bg: #401b18;
  --chip-red-ink: #f6a79f;
  --chip-blue-bg: #232f4d;
  --chip-blue-ink: #bccdf8;
  --positive: #93d7ab;
  --danger: #f6a79f;
  --danger-hover: #f9c4be;
  --danger-bg: #401b18;
  --warning-bg: #3b2b10;
  --warning-ink: #f2c27d;
  --info-bg: #232f4d;
  --info-ink: #bccdf8;
  --help-ring: #8a857a;
  --logo-ink: #f4f2ee;
  --backdrop: rgb(0 0 0 / 0.6);
  --shadow-pop: 0 12px 32px rgb(0 0 0 / 0.45);
  --shadow-dialog: 0 16px 48px rgb(0 0 0 / 0.55);
}

/* ---- base ---- */

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

html,
body {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  color: var(--ink);
}

h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 15px;
  font-weight: 600;
}

h3 {
  font-size: 14px;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

.noscript {
  padding: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mono,
.numeric,
.money,
.figure {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted,
.status {
  color: var(--ink-3);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -3rem;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
}

.skip-link:focus {
  top: 12px;
}

/* ---- app frame ---- */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  /* The sidebar is sticky and one viewport tall: its colour continues down the column below it. */
  background: linear-gradient(
    to right,
    var(--sidebar) 0,
    var(--sidebar) calc(var(--sidebar-width) - 1px),
    var(--sidebar-border) calc(var(--sidebar-width) - 1px),
    var(--sidebar-border) var(--sidebar-width),
    var(--bg) var(--sidebar-width)
  );
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  flex: none;
  width: 30px;
  height: 30px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.logo-n {
  stroke: var(--logo-ink);
}

.logo-chevron {
  stroke: var(--brand-red);
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-heading {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--nav-ink);
  text-decoration: none;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}

.nav-link[aria-current="page"] {
  background: var(--nav-current);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--sidebar-border);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-height);
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.icon-button.menu-button {
  display: none;
}

.breadcrumb {
  min-width: 0;
  flex: 1 1 auto;
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.breadcrumb li + li::before {
  content: "/";
  padding: 0 8px;
  color: var(--ink-3);
}

.breadcrumb a {
  color: var(--ink-3);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.user-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta {
  font-size: 12px;
  color: var(--ink-3);
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  flex: 1 1 auto;
  padding: 24px 32px 48px;
  min-width: 0;
}

.content:focus {
  outline: none;
}

.sidebar-scrim {
  display: none;
}

/* Narrow windows: the sidebar becomes a drawer behind the Menu button. */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    background: var(--bg);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.16s ease-out, visibility 0.16s;
  }

  .app[data-nav-open="true"] .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-dialog);
  }

  .app[data-nav-open="true"] .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    border: 0;
    padding: 0;
    background: var(--backdrop);
  }

  .icon-button.menu-button {
    display: inline-flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 20px 16px 40px;
  }

  .user-meta {
    max-width: 14rem;
  }
}

/* ---- page scaffolding ---- */

.page,
.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1440px;
}

.page-header,
.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.page-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-lede,
.screen-header p {
  font-size: 14px;
  color: var(--ink-2);
  max-width: 72ch;
}

.page-actions,
.screen-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--ink-2);
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.card-note,
.hint,
.note {
  font-size: 12px;
  color: var(--ink-3);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 16px;
  align-items: start;
}

.split-even {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1280px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

.stat-grid,
.stat-row,
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card,
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-2);
}

.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.stat-value-accent {
  color: var(--accent);
}

.stat-value small,
.stat-value .stat-of {
  font-size: 16px;
  color: var(--ink-3);
}

.stat-pair {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.stat-pair .stat-secondary {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink-2);
}

.stat-note {
  font-size: 12px;
  color: var(--ink-3);
}

.stat-note-positive {
  color: var(--positive);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 14px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 500 14px/1.2 var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.button-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

.button-secondary {
  background: var(--surface);
}

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
  font-weight: 600;
}

.button-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--surface);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
}

.button-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.button-dark:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
  color: var(--bg);
}

.button-sm {
  min-height: var(--control-height-sm);
  padding: 0 12px;
  font-size: 13px;
}

.button-link {
  padding: 0;
  min-height: 24px;
  border: 0;
  background: none;
  color: var(--accent);
  font: 500 13px/1.2 var(--font-sans);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.button-link:hover {
  color: var(--accent-hover);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.icon {
  flex: none;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 12px;
  height: 12px;
}

.spinner {
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- chips ---- */

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--chip-grey-bg);
  color: var(--chip-grey-ink);
}

.chip-green,
.badge-active,
.badge-verified,
.badge-closed-ok {
  background: var(--chip-green-bg);
  color: var(--chip-green-ink);
}

.chip-amber,
.badge-warning,
.badge-open-month {
  background: var(--chip-amber-bg);
  color: var(--chip-amber-ink);
}

.chip-red,
.badge-failed,
.badge-error {
  background: var(--chip-red-bg);
  color: var(--chip-red-ink);
}

.chip-blue,
.badge-draft {
  background: var(--chip-blue-bg);
  color: var(--chip-blue-ink);
}

.chip-grey,
.badge-not-billed,
.badge-retired {
  background: var(--chip-grey-bg);
  color: var(--chip-grey-ink);
}

.env-chip-dev,
.env-chip-stage {
  background: var(--chip-amber-bg);
  color: var(--chip-amber-ink);
}

.env-chip-local {
  background: var(--chip-blue-bg);
  color: var(--chip-blue-ink);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 24px;
}

.field-label,
.field > label,
.field-label-row > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.field-compact .field-label,
.filter .field-label {
  font-size: 12px;
  color: var(--ink-2);
}

.field-hint {
  font-size: 12px;
  color: var(--ink-3);
}

.field-error {
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
  margin: 0;
}

.field-error:empty {
  display: none;
}

.input,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
.filters input:not([type="checkbox"]):not([type="radio"]),
.filters select {
  min-height: var(--control-height);
  padding: 0 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 400 14px/1.3 var(--font-sans);
  max-width: 100%;
}

.field textarea,
textarea.input {
  padding: 8px 10px;
  min-height: 5rem;
  resize: vertical;
}

.field select,
select.input {
  padding-right: 28px;
}

.input-mono,
.field input.input-mono {
  font-family: var(--font-mono);
}

.input:disabled,
.field input:disabled:not([type="checkbox"]):not([type="radio"]),
.field select:disabled,
.field textarea:disabled,
.input-affix:has(input:disabled) {
  background: var(--surface-sunken);
  border-color: var(--border-input-soft);
  color: var(--ink-2);
  cursor: not-allowed;
}

.input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--ink-3);
}

.input[aria-invalid="true"],
.field [aria-invalid="true"] {
  border-color: var(--danger);
}

.input-affix {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-height);
  padding: 0 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 100%;
}

.input-affix:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.input-affix input,
.field .input-affix input:not([type="checkbox"]) {
  border: 0;
  outline: 0;
  min-height: calc(var(--control-height) - 2px);
  padding: 0;
  width: 100%;
  min-width: 4ch;
  background: transparent;
  color: var(--ink);
  font: 400 14px var(--font-mono);
}

.input-affix-unit {
  color: var(--ink-3);
  font-size: 14px;
}

.field-inline {
  width: auto;
}

.field-narrow input,
.field-narrow .input-affix {
  width: 10rem;
}

.field-medium input,
.field-medium select,
.field-medium .input-affix {
  width: 18rem;
}

.field-checkbox,
.checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.field-checkbox input,
.checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fieldset-legend {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 20px;
  align-items: start;
}

.form-actions,
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-actions-start {
  justify-content: flex-start;
}

/* A repeating row of fields with a trailing action (AWS sign-in team mappings). */
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
}

.field-row .field {
  flex: 1 1 12rem;
}

/* The "?" beside every label: a 24px target around a 16px ring. */
.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: help;
  color: var(--ink-2);
  vertical-align: middle;
}

.help-button-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--help-ring);
  border-radius: 50%;
  font: 600 11px/1 var(--font-sans);
}

.help-button:hover .help-button-ring {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- filter bar ---- */

.filter-bar,
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.filters .field {
  flex: 0 0 auto;
}

.filters .field input:not([type="checkbox"]),
.filters .field select {
  min-height: 34px;
  width: auto;
  max-width: 16rem;
}

.filter-bar-end {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter .field-label-row {
  min-height: 22px;
}

/* A label over a non-input control (Segmented, the month-range button) lines up with a Field's. */
.filter-bar .field-label-row,
.filters .field-label-row {
  min-height: 24px;
}

.search-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  width: 20rem;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
}

.search-input:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.search-input input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 400 13px var(--font-sans);
  min-height: 32px;
}

/* A segmented control for a small enum (aria-pressed buttons in a group). */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 34px;
  background: var(--surface);
  width: fit-content;
  max-width: 100%;
  flex-wrap: nowrap;
}

.segmented button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--border-input-soft);
  background: transparent;
  color: var(--ink);
  font: 500 13px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button:hover {
  background: var(--surface-sunken);
}

.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"] {
  background: var(--ink);
  color: var(--bg);
}

.segmented-sm {
  min-height: 28px;
}

.segmented-sm button {
  min-height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

/* In the filter bar every control is one height, so the labels above them line up. */
.filter-bar .segmented,
.filters .segmented {
  min-height: 34px;
}

.filter-bar .segmented button,
.filters .segmented button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* A pill tab list (the breakdown switch on Revenue). */
.pill-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.pill-tabs button {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font: 500 12px var(--font-sans);
  cursor: pointer;
}

.pill-tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}

/* Underline tabs (the customer page's sections): links, one per URL. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- popovers: month range, customer picker, theme menu ---- */

.popover-anchor {
  position: relative;
  display: inline-flex;
}

.picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
}

.picker-button:hover {
  background: var(--surface-sunken);
}

.picker-button .icon {
  color: var(--ink-2);
}

.picker-button-wide {
  min-width: 13rem;
  font-weight: 400;
}

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 25;
  min-width: 16rem;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
}

.popover-end {
  left: auto;
  right: 0;
}

.month-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
}

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

.month-grid button {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: 500 13px var(--font-sans);
  cursor: pointer;
}

.month-grid button:hover:not(:disabled) {
  background: var(--surface-sunken);
}

.month-grid button:disabled {
  color: var(--ink-3);
  opacity: 0.5;
  cursor: not-allowed;
}

.month-grid button[data-in-range="true"] {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
}

.month-grid button[aria-pressed="true"],
.month-grid button[data-edge="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.month-grid button[data-today="true"] {
  border-color: var(--border-input);
}

.popover-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-3);
}

.popover-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.combobox {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  width: 18rem;
  max-width: 100%;
}

.combobox-input {
  width: 100%;
}

.combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 25;
  max-height: 18rem;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.combobox-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.combobox-option[aria-selected="true"],
.combobox-option:hover {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
}

.combobox-option-name {
  font-size: 13px;
  font-weight: 500;
}

.combobox-option-id {
  font: 400 11px var(--font-mono);
  color: var(--ink-3);
}

.combobox-option[aria-selected="true"] .combobox-option-id {
  color: inherit;
}

.combobox-empty {
  padding: 8px;
  font-size: 13px;
  color: var(--ink-3);
}

/* ---- ids ---- */

.id-chip,
.secondary-id,
.org-id {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font: 400 12px var(--font-mono);
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}

.copy-button:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.name-with-id {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

/* ---- tables ---- */

.table-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.table-scroll {
  overflow-x: auto;
  min-width: 0;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 4px 20px 8px;
}

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

.data-table caption {
  text-align: left;
  padding: 12px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.data-table caption.visually-hidden {
  padding: 0;
}

.data-table th,
.data-table td,
.diff-table th,
.diff-table td,
.rates-table th,
.rates-table td,
.tiers-table th,
.tiers-table td {
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
}

.data-table th:last-child,
.data-table td:last-child {
  padding-right: 0;
}

.data-table thead th,
.diff-table thead th,
.rates-table thead th,
.tiers-table thead th {
  padding-top: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  border-bottom-color: var(--border);
  white-space: nowrap;
}

.th-inner {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.data-table .numeric,
.data-table td.numeric,
.data-table th.numeric {
  text-align: right;
}

/* Figures are mono; their column headers stay in the UI face. */
.data-table th.numeric,
.data-table thead th {
  font-family: var(--font-sans);
}

.data-table th.numeric .th-inner {
  justify-content: flex-end;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: var(--surface-subtle);
}

.data-table code {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.data-table a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

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

.data-table a.button {
  font-weight: 500;
}

/* A table cell holding a few stacked lines (a date over who did it). */
.stack-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}

.cell-profit,
.money-profit {
  color: var(--accent);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  min-height: 24px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort-button:hover {
  color: var(--ink);
}

.sort-mark {
  font-size: 10px;
}

.table-footer {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.share-bar {
  display: block;
  width: 90px;
  height: 6px;
}

.share-bar-track {
  fill: var(--chip-grey-bg);
}

.share-bar-fill {
  fill: var(--accent);
}

.money-negative {
  color: var(--danger);
}

.diff-none,
.diff-absent {
  color: var(--ink-3);
}

.diff-remove td:first-child,
.diff-replace td:first-child {
  color: var(--danger);
  font-weight: 600;
}

/* ---- states ---- */

.state {
  padding: 16px 0;
}

.state h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

.state-forbidden,
.state-notfound {
  max-width: 40rem;
}

.state-forbidden p,
.state-notfound p {
  color: var(--ink-2);
}

.state-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 0;
  color: var(--ink-2);
}

.skeleton-row {
  height: 36px;
  margin-bottom: 6px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

/* A screen's first-run explanation: what it is for, the steps, the first action. */
.empty-state {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  max-width: 880px;
}

.empty-state h2 {
  font-size: 20px;
}

.empty-state-lede {
  font-size: 14px;
  color: var(--ink-2);
  max-width: 64ch;
}

.empty-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.empty-steps li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.empty-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  font-size: 12px;
  font-weight: 600;
}

.empty-step-title {
  font-weight: 600;
}

.empty-step-text {
  font-size: 13px;
  color: var(--ink-2);
}

.empty-state-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.banner p {
  margin: 0;
}

.banner-error {
  background: var(--danger-bg);
  border-color: var(--chip-red-ink);
  color: var(--chip-red-ink);
}

.banner-error .button {
  color: var(--ink);
}

.banner-warning {
  background: var(--warning-bg);
  border-color: var(--warning-ink);
  color: var(--warning-ink);
}

.banner-info {
  background: var(--info-bg);
  border-color: var(--info-ink);
  color: var(--info-ink);
}

.banner-success {
  background: var(--chip-green-bg);
  border-color: var(--chip-green-ink);
  color: var(--chip-green-ink);
}

.banner a {
  color: inherit;
  font-weight: 600;
}

.error-code,
.request-id code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.request-id {
  font-size: 12px;
  opacity: 0.9;
}

.error-details {
  margin: 4px 0 0;
  padding-left: 20px;
  width: 100%;
}

/* ---- dialogs ---- */

.dialog {
  width: min(32rem, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
}

.dialog-wide {
  width: min(44rem, calc(100vw - 32px));
}

.dialog::backdrop {
  background: var(--backdrop);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialog-message {
  color: var(--ink);
  line-height: 1.55;
}

.dialog-actions {
  margin-top: 20px;
}

.help-dialog .dialog-body p {
  line-height: 1.55;
}

.help-example {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  line-height: 1.55;
}

.help-example-label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.help-dialog-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ---- charts (SVG, sized by attributes; colours from tokens) ---- */

.chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-baseline {
  stroke: var(--chart-axis);
  stroke-width: 1;
}

.chart-tick,
.chart-label {
  fill: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
}

.chart-label {
  font-family: var(--font-sans);
  fill: var(--ink-2);
}

.chart-bar,
.series-bar {
  fill: var(--chart-bar);
}

.chart-bar-muted {
  fill: var(--chart-bar-muted);
}

.series-cost {
  fill: var(--chart-cost);
}

.series-profit {
  fill: var(--chart-profit);
}

.series-loss {
  fill: var(--danger);
}

.chart-hit:hover .chart-bar,
.chart-hit:hover rect,
.chart-hit:focus rect {
  opacity: 0.8;
}

.chart-hit:focus {
  outline: none;
}

.chart-hit:focus-visible rect.chart-focus-ring {
  stroke: var(--focus);
  stroke-width: 2;
}

.chart-focus-ring {
  fill: transparent;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--ink-2);
}

.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart .chart-legend .legend-swatch {
  width: 10px;
  height: 10px;
  max-height: none;
}

.chart-caption {
  font-size: 12px;
  color: var(--ink-3);
}

/* ---- sign-in ---- */

.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}

.signin-card {
  width: min(26rem, 100%);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.signin-mark {
  width: 56px;
  height: 56px;
}

.signin-card h1 {
  font-size: 22px;
}

.signin-message {
  color: var(--ink-2);
}

.signin-foot {
  font-size: 12px;
  color: var(--ink-3);
}

.tone-error .signin-message {
  color: var(--danger);
}

.tone-warning .signin-message {
  color: var(--warning-ink);
}

.wordmark {
  font-weight: 600;
}

/* ---- help section ---- */

.help-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-height) - 72px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.help-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface-subtle);
  overflow-y: auto;
}

.help-nav .search-input {
  width: 100%;
}

.help-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-nav-link {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--nav-ink);
  text-decoration: none;
}

.help-nav-link:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.help-nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  font-weight: 600;
}

.help-article {
  padding: 28px 40px 48px;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  line-height: 1.6;
  font-size: 15px;
}

.help-article-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.help-article h1 {
  font-size: 28px;
}

.help-article h2 {
  margin-top: 14px;
  font-size: 18px;
}

.help-article h3 {
  margin-top: 6px;
  font-size: 15px;
}

.help-article ul,
.help-article ol {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-article table {
  border-collapse: collapse;
  font-size: 14px;
  max-width: 100%;
}

.help-article th,
.help-article td {
  padding: 7px 16px 7px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}

.help-article th {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}

.help-article td.numeric {
  text-align: right;
}

.help-article pre {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
}

.help-article [id] {
  scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.help-callout {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg);
}

.help-related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.help-related-label {
  color: var(--ink-3);
}

.help-no-results {
  font-size: 13px;
  color: var(--ink-3);
  padding: 0 8px;
}

@media (max-width: 1100px) {
  .help-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .help-article {
    padding: 24px;
  }
}

/* ---- legacy screen parts kept styled while screens move to the new parts ---- */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.secret-value {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

/* ---- motion ---- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* src/help/content/help.css */
/* Help article extras: long code lines scroll inside their block instead of widening the page. */
.help-article pre {
  overflow-x: auto;
  max-width: 100%;
  line-height: 1.5;
}

.help-article code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.help-article pre code,
.help-article pre {
  overflow-wrap: normal;
  white-space: pre;
}

.help-article table {
  display: block;
  overflow-x: auto;
}

.help-article th.numeric {
  text-align: right;
}

/* src/screens/audit/audit.css */
/* Audit log: the table's time column, the event dialog's facts and its JSON detail. Tokens only. */

.audit-screen .nowrap {
  white-space: nowrap;
}

.audit-event-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 10px 20px;
  margin: 0;
}

.audit-event-facts div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.audit-event-facts dt {
  font-size: 12px;
  color: var(--ink-3);
}

.audit-event-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.audit-detail {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 12px;
  max-height: 50vh;
  overflow: auto;
}

.audit-target {
  max-width: 16rem;
}

.audit-target-id {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The filter bar stays one row at desktop widths: no control is full width. */
.audit-screen .filter-bar .combobox {
  width: 12rem;
}

.audit-screen .filter-bar select {
  width: 13rem;
}

.audit-screen .filter-bar input[type="search"] {
  width: 10rem;
}

.audit-when .segmented {
  min-height: var(--control-height);
}

/* src/screens/billing/billing.css */
/* Invoices list and the Close-month dialog. Colours come from tokens only (dark mode). */

.invoices-reason {
  max-width: 28ch;
  white-space: normal;
  font-style: italic;
}

.close-summary {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.close-summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.close-summary dt {
  font-size: 12px;
  color: var(--ink-2);
}

.close-summary dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.close-refusal ul {
  margin: 4px 0;
  padding-left: 20px;
}

.close-refusal p {
  margin: 0 0 4px;
}

/* src/screens/expense/expense.css */
/* AWS costs: the basis forms beside their tables, the month page's snapshot details. */
.basis-form h3,
.cur-source-form h3 {
  font-size: 14px;
}

.reconcile-form {
  align-items: flex-end;
}

.detail-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 24px;
  margin: 0;
  font-size: 14px;
}

.detail-list dt {
  color: var(--ink-3);
}

.detail-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .expense-screen .split-even {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* src/screens/home/home.css */
/* Overview: the attention list, the top customers, the chart's table disclosure. */
.attention-list,
.top-customers {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attention-list li + li,
.top-customers li + li {
  border-top: 1px solid var(--border-subtle);
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  color: var(--ink);
  text-decoration: none;
}

.attention-item:hover .attention-title {
  color: var(--accent);
  text-decoration: underline;
}

.attention-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.attention-title {
  font-size: 14px;
  font-weight: 500;
}

.attention-detail {
  font-size: 12px;
  color: var(--ink-3);
}

.top-customers li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 90px;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
}

.top-customer-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

a.top-customer-name {
  color: var(--ink);
  text-decoration: none;
}

a.top-customer-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.top-customer-amount {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.chart-table summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  min-height: 24px;
  display: list-item;
}

.chart-table[open] summary {
  margin-bottom: 4px;
}

/* src/screens/installer/installer.css */
/* Installer screens (session list, linked accounts, console, change approval). Tokens only. */

/* ---- console: the facts row ---- */

.console-header-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin: 0;
}

.console-header-facts div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.console-header-facts dt {
  font-size: 12px;
  color: var(--ink-3);
}

.console-header-facts dd {
  margin: 0;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* ---- console: transcript ---- */

.transcript-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
}

.transcript-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-subtle);
  min-width: 0;
}

.transcript-operator {
  background: var(--accent-soft);
  border-color: transparent;
}

.transcript-tool_call,
.transcript-tool_result,
.transcript-system_event {
  background: transparent;
}

.transcript-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.transcript-actor {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.transcript-operator .transcript-actor {
  color: var(--accent-soft-ink);
}

.transcript-time {
  font-size: 12px;
  color: var(--ink-3);
}

.transcript-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.transcript-tool summary {
  cursor: pointer;
  min-height: 24px;
  color: var(--ink-2);
  font-size: 13px;
}

.transcript-tool-detail {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 12px;
  max-height: 20rem;
  overflow: auto;
}

.composer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.composer textarea {
  width: 100%;
}

/* ---- console: side cards ---- */

.budget-figures {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.budget-meter {
  display: block;
  width: 100%;
  height: 8px;
}

.budget-meter-track {
  fill: var(--chip-grey-bg);
}

.budget-meter-fill {
  fill: var(--accent);
}

.budget-meter-full {
  fill: var(--warning-ink);
}

.proposal-fields {
  display: grid;
  grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
}

.proposal-field {
  display: contents;
}

.proposal-field dt {
  font-size: 13px;
  color: var(--ink-3);
}

.proposal-field dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.changes-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.changes-rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.verification-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.verification-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
}

.verification-steps li.verification-done {
  color: var(--ink);
}

.verification-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-input-soft);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.verification-done .verification-mark {
  background: var(--chip-green-bg);
  border-color: transparent;
  color: var(--chip-green-ink);
}

/* ---- credentials ---- */

.credentials-panel textarea {
  min-height: 4rem;
}

.idc-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.idc-steps a {
  overflow-wrap: anywhere;
}

.idc-accounts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.idc-accounts p {
  margin: 0 0 6px;
}

/* ---- accounts ---- */

.external-id-input {
  flex: 1 1 18rem;
  min-width: 0;
}

/* ---- change approval ---- */

.risk-flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.change-diff .diff-table caption {
  text-align: left;
  font-weight: 600;
  padding: 4px 0 8px;
}

.reject-form textarea {
  width: 100%;
}

@media (max-width: 720px) {
  .change-actions .split-even {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The new-session form: the customer picker fills its grid cell like the other inputs. */
#new-session-form .combobox {
  width: 100%;
}

/* src/screens/orgs/customers.css */
/* The Customers area: the customer page's header figure, compact tables in narrow cards, the
   usage-by-day table beside its chart, and the inline forms inside cards. Tokens only. */

.header-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding-left: 16px;
  margin-left: 8px;
  border-left: 1px solid var(--border);
}

.header-figure-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--ink-3);
}

.header-figure-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
}

.customer-page .page-meta .id-chip {
  font-size: 12px;
}

.usage-day-table {
  max-height: 300px;
  overflow-y: auto;
  min-width: 0;
}

.data-table-compact th,
.data-table-compact td {
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 13px;
}

.data-table-compact caption {
  padding: 8px 0 4px;
  font-size: 13px;
}

.lead-line {
  font-size: 14px;
  color: var(--ink);
}

.lead-link {
  font-size: 15px;
  font-weight: 600;
}

.subform {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.subform h3 {
  font-size: 14px;
  font-weight: 600;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.subform .form-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.subform .form-grid.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.subform .field input,
.subform .field select {
  width: 100%;
}

.cell-cost,
.data-table td.cell-cost {
  color: var(--ink-3);
}

.negative-margin-label {
  color: var(--danger);
  font-size: 12px;
}

.summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary dt {
  font-size: 12px;
  color: var(--ink-3);
}

.summary dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}

.trial-burndown {
  padding-top: 8px;
}

.billing-tab .row-actions {
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.billing-tab .row-actions a,
.invoice-month,
.billing-tab .chip {
  white-space: nowrap;
}

/* The list's search box: the icon and the input share one border. */
.field .search-input input:not([type="checkbox"]):not([type="radio"]) {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
}

.data-table-compact td:first-child {
  white-space: nowrap;
}

.name-with-id .cell-sub.mono {
  overflow-wrap: anywhere;
  max-width: 34rem;
}

/* src/screens/prices/prices.css */
/* Model prices. Colours come from tokens only (dark mode). */

.price-model {
  font-size: 13px;
  white-space: nowrap;
}

.price-valid {
  white-space: nowrap;
}

.price-source {
  max-width: 24ch;
  align-items: flex-start;
}

.price-source-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-form-top {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.price-rates .form-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.price-rates .input-affix {
  width: 100%;
}

@media (max-width: 640px) {
  .price-form-top {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* src/screens/rateplans/rateplans.css */
/* Rate plans list and editor. Colours come from tokens only (dark mode). */

.plan-description {
  max-width: 40ch;
  white-space: normal;
}

.plan-margin {
  white-space: nowrap;
}

.plan-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.plan-aside {
  position: sticky;
  top: calc(var(--topbar-height) + 16px);
}

.plan-about {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
}

.plan-pricing {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.plan-pricing .input-affix {
  width: 100%;
  max-width: 14rem;
}

.plan-static {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  color: var(--ink);
}

.plan-rows td {
  vertical-align: top;
}

.plan-rows .input-affix {
  width: 9rem;
}

.plan-rows input.input-mono {
  min-width: 16rem;
}

.worked-example .example-lines {
  margin: 12px 0 16px;
  display: flex;
  flex-direction: column;
}

.example-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

.example-line dt {
  color: var(--ink-2);
}

.example-line dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.example-sign {
  color: var(--ink-3);
}

.example-total {
  font-weight: 600;
  border-bottom: 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.example-total dt {
  color: var(--ink);
}

.example-profit {
  border-bottom: 0;
}

.example-profit dd {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.example-ratio {
  font-size: 12px;
  color: var(--ink-2);
}

@media (max-width: 1100px) {
  .plan-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .plan-aside {
    position: static;
  }
}

@media (max-width: 640px) {
  .plan-about,
  .plan-pricing {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* src/screens/reconciliation/reconciliation.css */
/* Reconciliation: keep days and installation names on one line. */
.reconciliation-screen .nowrap {
  white-space: nowrap;
}

/* src/screens/revenue/revenue.css */
/* Revenue & margin: the share column, the preview banner, the model filter. */
.cell-cost {
  color: var(--ink-3);
}

.share-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.share-text {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-3);
  min-width: 4ch;
  text-align: right;
}

.revenue-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
}

.model-filter {
  margin: 0;
}

.model-filter .input {
  width: 14rem;
  max-width: 100%;
}

.revenue-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .revenue-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The shared `.chart svg` rule (width 100%) also catches the legend swatches; keep them 10px. */
.chart .chart-legend .legend-swatch {
  width: 10px;
  height: 10px;
}

/* src/screens/signin/signin.css */
/* Sign-in page: the shared .signin / .signin-card come from styles.css; these centre the card's
   contents around the large Nexus mark and make the actions full width. Tokens only. */

.signin-card {
  align-items: stretch;
  text-align: center;
  gap: 14px;
}

.signin-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.signin-card .signin-mark {
  width: 72px;
  height: 72px;
}

.signin-message {
  margin: 0;
}

.signin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.signin-button {
  justify-content: center;
  width: 100%;
  min-height: 42px;
}

.signin-foot {
  margin: 8px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
