html { scroll-padding-top: 84px; }
:root {
  color-scheme: light dark;
  /* One accent, one neutral ramp, one radius scale. Every value below is used
     by more than one component; none of them is decoration. */
  --bg: #f2f1ec;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --panel-2: #f7f6f1;
  --inset: #f4f2ec;
  --line: #e7e4db;
  --line-soft: #f0eee7;
  --line-strong: #d7d3c8;
  --ink: #16150f;
  --ink-dim: #5b574d;
  --ink-faint: #8b8578;
  --accent: #17160f;
  --accent-ink: #ffffff;
  --accent-soft: #efede5;
  --ok: #2c6748;
  --ok-soft: #e8f1ea;
  --warn: #7f5c14;
  --warn-soft: #f8f0d9;
  --bad: #96352a;
  --bad-soft: #f9e8e4;
  --chart-1: #d2d0c9;
  --chart-2: #b8b5ad;
  --chart-3: #9a978f;
  --chart-4: #7d7a72;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 18px;
  --pad: 26px;
  --rail: 258px;
  --shadow-sm: 0 1px 2px rgba(22, 21, 15, 0.05);
  --shadow: 0 1px 2px rgba(22, 21, 15, 0.05), 0 8px 20px -14px rgba(22, 21, 15, 0.22);
  --ring: 0 0 0 3px rgba(22, 21, 15, 0.14);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0f;
    --paper: #131315;
    --panel: #17171a;
    --panel-2: #1d1d21;
    --inset: #1a1a1e;
    --line: #2a2a30;
    --line-soft: #222228;
    --line-strong: #383840;
    --ink: #f4f2ed;
    --ink-dim: #a9a49a;
    --ink-faint: #7c776d;
    --accent: #f4f2ed;
    --accent-ink: #14140f;
    --accent-soft: #24242a;
    --ok: #7fc79b;
    --ok-soft: #17251d;
    --warn: #d9b66a;
    --warn-soft: #262013;
    --bad: #e08578;
    --bad-soft: #2a1715;
    --chart-1: #4a4a52;
    --chart-2: #5c5c66;
    --chart-3: #71717d;
    --chart-4: #8a8a96;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 26px -18px rgba(0, 0, 0, 0.8);
    --ring: 0 0 0 3px rgba(244, 242, 237, 0.18);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14.5px/1.55 var(--font);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.018em; line-height: 1.25; }
h1 { font-size: 34px; letter-spacing: -0.03em; }
h2 { font-size: 12.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
p.sub { color: var(--ink-dim); font-size: 13px; }
p.sub.tight { margin: 4px 0 0; }
.lede { color: var(--ink-dim); font-size: 15px; max-width: 74ch; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* ---- Shell ---------------------------------------------------------------
   A paper rail on the left, a paper bar across the top, and the page's cards
   on the desk between them. The bar is part of the frame, not the page: it
   never scrolls away, so an operator always knows where they are. */

.skip { position: absolute; left: -9999px; top: 8px; z-index: 20; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 13px; text-decoration: none; }
.skip:focus { left: 16px; }

/* The rail's paper and its divider continue past the last nav item, so a long
   page does not end with the sidebar stopping halfway down the window. */
.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
  background-image: linear-gradient(
    90deg,
    var(--paper) 0,
    var(--paper) var(--rail),
    var(--line) var(--rail),
    var(--line) calc(var(--rail) + 1px),
    transparent calc(var(--rail) + 1px)
  );
}

.side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px 18px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 12px; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; color: var(--ink); display: block; }
.brand-mark .brand-face { fill: var(--paper); }
.brand-mark .brand-mouth { stroke: var(--paper); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 15.5px; font-weight: 650; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.02em; }
.brand:hover .brand-sub { color: var(--ink-dim); }

.nav { display: flex; flex-direction: column; gap: 18px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { margin: 0 0 4px; padding: 0 8px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink-faint); }
.nav-note { display: none; margin: 0 0 4px; padding: 0 8px; color: var(--ink-faint); font-size: 11.5px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-size: 13.5px;
  text-decoration: none;
  line-height: 1.3;
}
.nav-item:hover { background: var(--inset); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--panel); color: var(--ink); font-weight: 550; box-shadow: var(--shadow-sm); }
.nav-icon { display: flex; flex: none; width: 16px; height: 16px; color: var(--ink-faint); }
.nav-icon svg { width: 16px; height: 16px; }
.nav-item:hover .nav-icon, .nav-item[aria-current="page"] .nav-icon { color: var(--ink); }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.who { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 0 8px; font-size: 12.5px; flex-wrap: wrap; }
.who-email { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.side-links { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 12.5px; }
.side-links a { color: var(--ink-dim); text-decoration: none; }
.side-links a:hover { color: var(--ink); text-decoration: underline; }
.side-links form { margin: 0; }
.side-links button { font-size: 12.5px; padding: 0; border: 0; background: transparent; color: var(--ink-dim); }
.side-links button:hover { opacity: 1; background: transparent; color: var(--ink); text-decoration: underline; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px var(--pad);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 58px;
}
.topbar-brand { display: none; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 650; letter-spacing: -0.02em; text-decoration: none; }
.topbar-brand .brand-mark { width: 22px; height: 22px; }
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--ink-faint); min-width: 0; }
.crumb-group { white-space: nowrap; }
.crumb-sep { color: var(--line-strong); }
.crumb-current { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px var(--pad) 8px; }
.foot { max-width: 1180px; width: 100%; margin: 0 auto; padding: 8px var(--pad) 34px; color: var(--ink-faint); font-size: 11.5px; }

/* The sign-in page has no session and therefore no rail: one column, one card,
   and the same bar on top so it does not look like another product. */
.head { display: flex; align-items: center; gap: 10px; padding: 14px var(--pad); background: var(--paper); border-bottom: 1px solid var(--line); }
.mark { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 650; letter-spacing: -0.02em; }
.head .mark .brand-mark { width: 22px; height: 22px; }
.tagline { margin-left: auto; color: var(--ink-faint); font-size: 11.5px; letter-spacing: 0.03em; }
/* The sign-in page is a single centred column: there is nothing else on it to
   line up with, and a form stranded at the left edge of a wide window reads as
   a page that failed to load. The :has selector is the whole condition — no
   extra class in the markup, and the older fallback is the left-aligned column
   it replaces. */
main:has(> .signin) { max-width: 520px; margin: 0 auto; padding-top: 46px; }
.signin { max-width: 440px; margin-top: 10px; }

.notice { margin: 0 auto 20px; max-width: 1180px; padding: 11px 14px; border-radius: var(--radius); font-size: 13px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-sm); }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); background: var(--ok-soft); color: var(--ok); }
.notice.error { border-color: color-mix(in srgb, var(--bad) 32%, var(--line)); background: var(--bad-soft); color: var(--bad); }
main > .notice { max-width: none; margin: 0 0 20px; }

/* ---- Page head ---------------------------------------------------------- */

.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px 20px; margin-bottom: 22px; }
.page-head .back { grid-column: 1 / -1; justify-self: start; margin-bottom: 6px; font-size: 12.5px; color: var(--ink-dim); text-decoration: none; }
.page-head .back:hover { color: var(--ink); }
.page-title { grid-column: 1; min-width: 0; }
.page-title h1 { font-size: clamp(26px, 2.6vw, 34px); }
.page-meta { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.page-actions { grid-column: 2; justify-self: end; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions a, .page-actions button { font-size: 12.5px; }
.lede { grid-column: 1 / -1; margin: 4px 0 0; max-width: 82ch; }
.page-nav { grid-column: 1 / -1; margin-top: 14px; }
.page-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 8px; }
.page-gap { margin-top: 20px; }

.section-nav { display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; gap: 6px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 999px; }
.section-nav a { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; color: var(--ink-dim); text-decoration: none; }
.section-nav a:hover { color: var(--ink); background: var(--panel); }
.section-nav a[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---- Tiles ---------------------------------------------------------------
   The number is the point. Label above it in caps, the reading under it small,
   and a comparison where one exists. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 18px; }
.tiles.wide { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 17px 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.tile-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.tile-value { font-size: clamp(23px, 2.3vw, 29px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.tile-hint { color: var(--ink-dim); font-size: 12px; }
.tile-delta { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-variant-numeric: tabular-nums; background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line-soft); }
.tile-delta.better { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 24%, var(--line)); }
.tile-delta.worse { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 24%, var(--line)); }
.tile-delta.flat { background: var(--panel-2); color: var(--ink-faint); }
.spark { display: block; width: 100%; height: 30px; margin-top: 4px; overflow: visible; }
.spark polyline { stroke: var(--ink-faint); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--ink); }

/* ---- Panels -------------------------------------------------------------- */
.panel { padding: 18px 20px 20px; margin: 0 0 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.panel.wide { width: 100%; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-head > div { min-width: 0; }
.panel-actions { display: flex; align-items: center; gap: 12px; flex: none; font-size: 12.5px; }
.panel-actions a { color: var(--ink-dim); text-decoration: none; }
.panel-actions a:hover { color: var(--ink); text-decoration: underline; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.split > .panel { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 0 0 16px; }
.card { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card .k { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.card .v { margin-top: 4px; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* Needs attention: a list of counts, each one a link to where it is worked. */
.attention { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.attention li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.attention li:last-child { border-bottom: 0; padding-bottom: 0; }
.attention-count { min-width: 30px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.attention-text { flex: 1; color: var(--ink-dim); }
.attention li a.chip { flex: none; }

/* ---- Charts --------------------------------------------------------------
   Bars are a soft neutral so the one thing that matters — the number in the
   label, the caption's peak — reads first. Grid lines are the desk showing
   through, not a frame. */
.chart { margin: 0; }
.chart svg.columns { display: block; width: 100%; height: auto; overflow: visible; }
.columns .grid { stroke: var(--line-soft); stroke-width: 1; }
.columns .bar rect { transition: opacity 120ms ease; }
.columns .bar:hover rect { opacity: 0.75; }
.columns .bar-label { fill: var(--ink-faint); font: 500 9px var(--font); }
.columns .axis, .axis { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.chart figcaption { margin-top: 10px; font-size: 12px; color: var(--ink-dim); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 11.5px; color: var(--ink-dim); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; background: var(--chart-1); display: inline-block; }
.swatch[data-tone="1"] { background: var(--chart-2); }
.swatch[data-tone="2"] { background: var(--chart-3); }
.swatch[data-tone="3"] { background: var(--chart-4); }

.mix { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mix-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(80px, 2.2fr) auto auto; align-items: center; gap: 12px; font-size: 13px; }
.mix-label { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-track { display: block; height: 8px; border-radius: 999px; background: var(--inset); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-soft); }
.mix-fill { display: block; height: 100%; border-radius: 999px; background: var(--chart-1); min-width: 2px; }
.mix-fill[data-tone="1"] { background: var(--chart-2); }
.mix-fill[data-tone="2"] { background: var(--chart-3); }
.mix-fill[data-tone="3"] { background: var(--chart-4); }
.mix-value, .mix-share { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-dim); font-size: 12px; }
.mix-value { color: var(--ink); font-weight: 550; min-width: 34px; text-align: right; }
.mix-share { min-width: 64px; text-align: right; }

/* ---- Tables -------------------------------------------------------------- */
.scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px 9px 0; vertical-align: middle; }
th { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); border-bottom: 1px solid var(--line); padding-top: 0; white-space: nowrap; }
td { border-bottom: 1px solid var(--line-soft); color: var(--ink-dim); }
td:first-child { color: var(--ink); }
/* A plan's name, with its id under it: the name is what an operator reads, the
   id is what a subscription row points at, so one is ink and one is a note. */
.plan-name { font-weight: 550; }
.plan-id { color: var(--ink-faint); }
tbody tr:hover td { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, td .num { font-variant-numeric: tabular-nums; color: var(--ink); }
/* A row's controls, on one line however many there are. The table builder
   gives every cell a bare td element, so this is the div inside it rather than
   a cell class: without it each form takes its own block line and a
   three-control row grows three times as tall as its neighbours. */
.cell-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.cell-actions form { display: inline; margin: 0; }
.cell-actions button { padding: 4px 9px; font-size: 12px; }
.cell-actions a { color: var(--ink-dim); text-decoration: none; padding: 0 4px; font-size: 12.5px; }
.cell-actions a:hover { color: var(--ink); text-decoration: underline; }

.empty-state { padding: 26px 4px; }
.empty-title { margin: 0; font-size: 14px; color: var(--ink); }
.empty-note { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-dim); }
.empty { color: var(--ink-faint); font-size: 13px; margin: 0; }
.restricted { padding: 12px 14px; background: var(--panel-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---- Tags ---------------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 550; letter-spacing: 0.01em; background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, var(--line)); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 24%, var(--line)); }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 24%, var(--line)); }
.tag.accent { background: var(--accent-soft); color: var(--ink); border-color: var(--line); }
.tag.muted { background: var(--panel-2); color: var(--ink-faint); }

a.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 12.5px; text-decoration: none; box-shadow: var(--shadow-sm); }
a.chip:hover { border-color: var(--line-strong); text-decoration: none; }

/* ---- Forms --------------------------------------------------------------- */
label { font-size: 12.5px; color: var(--ink-dim); }
input, select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  min-width: 0;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-faint); box-shadow: var(--ring); }
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { opacity: 0.88; }
button.quiet { background: transparent; border-color: var(--line-strong); color: var(--ink-dim); }
button.quiet:hover { opacity: 1; border-color: var(--ink-faint); color: var(--ink); background: var(--inset); }
button.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad); }
button.danger:hover { opacity: 1; background: var(--bad-soft); }
td input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }
.inline-form { display: inline; margin: 0; }
.page-actions .row { margin: 0; }
.selection-bar { margin-bottom: 12px; }
.bulk-actions { margin-top: 14px; }
.approval-actions { align-items: flex-end; }
.approval-actions label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-dim); }
.approval-actions .inline-form { display: inline-flex; align-items: flex-end; gap: 8px; margin: 0; }
.approval-actions input[name="note"] { min-width: 190px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin: 0 0 16px; }
.form-grid.wide { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid > label { display: flex; flex-direction: column; gap: 5px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 2px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.form-grid .form-actions .form-note { margin-right: auto; max-width: 64ch; }
.form-grid .form-actions button { flex: none; }
.form-grid .submit { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.form-grid label.check { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.form-grid label.check input { width: auto; margin: 0; accent-color: var(--accent); }
.form-note { color: var(--ink-faint); font-size: 12px; }
.permissions { display: flex; flex-direction: column; gap: 14px; }
.permission-group { margin: 0; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.permission-group legend { padding: 0 6px; font-weight: 600; font-size: 12.5px; }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 16px; margin-top: 8px; }
.form-grid label.check.permission { align-items: flex-start; }
.form-grid label.check.permission input { margin-top: 2px; }
.form-grid label.check.permission .form-note { display: block; margin-top: 2px; line-height: 1.45; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 0 0 16px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.toolbar .field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; flex: 1 1 150px; }
.field-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.toolbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.toolbar-actions a.clear { font-size: 12.5px; color: var(--ink-dim); text-decoration: none; }
.toolbar-actions a.clear:hover { color: var(--ink); text-decoration: underline; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; }
.row a.cancel { font-size: 12.5px; color: var(--ink-dim); text-decoration: none; }
.row a.cancel:hover { color: var(--ink); text-decoration: underline; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 999px; }
.seg { padding: 4px 11px; border-radius: 999px; font-size: 12px; color: var(--ink-dim); text-decoration: none; white-space: nowrap; }
.seg:hover { color: var(--ink); }
.seg.current { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 550; }

.fieldset { margin: 0 0 16px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.fieldset > h2:first-child { margin-bottom: 10px; }
.fieldset-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.fieldset-head > div { min-width: 0; }
.fieldset-head h2 { margin-bottom: 4px; }
.fieldset-head .sub { margin: 0; }

/* The account page's overview: identity and plan side by side, compact enough
   that the forms below are the next thing an operator sees. */
.account-overview { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr); gap: 16px; align-items: stretch; margin: 0 0 16px; }
.account-overview > .panel { display: flex; flex-direction: column; margin: 0; }
.identity-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.identity-name { margin: 0; color: var(--ink); font-size: 21px; font-weight: 600; letter-spacing: -0.025em; }
.identity-email { margin: 3px 0 0; color: var(--ink-dim); font-size: 13px; overflow-wrap: anywhere; }
.identity-email .tag { margin-left: 6px; vertical-align: middle; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.fact { min-width: 0; }
.fact.span-2 { grid-column: 1 / -1; }
.fact-label { display: block; margin-bottom: 3px; color: var(--ink-faint); font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; }
.fact-value { color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.fact-value.mono { font-size: 12px; }
.plan-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.plan-name { margin: 0; color: var(--ink); font-size: 23px; font-weight: 600; letter-spacing: -0.03em; }
.plan-price { color: var(--ink-dim); font-size: 12.5px; text-align: right; }
.plan-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; padding-top: 16px; }
.plan-actions .sub { margin: 0; }

.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.quick-action { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-sm); text-decoration: none; }
.quick-action:hover { border-color: var(--line-strong); text-decoration: none; }
.quick-action-title { color: var(--ink); font-size: 13.5px; font-weight: 600; }
.quick-action-note { color: var(--ink-dim); font-size: 12px; }
.quick-action.danger { border-color: color-mix(in srgb, var(--bad) 24%, var(--line)); }
.quick-action.danger .quick-action-title { color: var(--bad); }

.action-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.action-row:first-of-type { padding-top: 0; border-top: 0; }
.action-row:last-child { padding-bottom: 0; }
.action-copy { min-width: 0; }
.action-copy strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.action-copy .sub { max-width: 70ch; margin: 0; }
.action-row > form { flex: none; margin: 0; }
.action-row .inline-control { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.action-row .inline-control label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.action-row .inline-control input { width: 110px; }
.fieldset.danger-zone { border-color: color-mix(in srgb, var(--bad) 24%, var(--line)); border-top: 3px solid var(--bad); }
.danger-zone h2 { color: var(--bad); }


details.meta > summary, details.create > summary { cursor: pointer; font-size: 12.5px; color: var(--ink-dim); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.meta > summary::-webkit-details-marker, details.create > summary::-webkit-details-marker { display: none; }
details.meta > summary::before, details.create > summary::before { content: "▸"; font-size: 10px; color: var(--ink-faint); }
details.meta[open] > summary::before, details.create[open] > summary::before { content: "▾"; }
details.meta { margin-top: 10px; }
details.meta pre { margin: 8px 0 0; padding: 12px; background: var(--inset); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
details.create { margin: 0 0 16px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
details.create[open] > summary { margin-bottom: 12px; }

dl { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 8px 18px; margin: 0; font-size: 13px; }
dt { color: var(--ink-faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding-top: 2px; }
dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.sub + dl { margin-top: 12px; }

/* ---- Callouts ------------------------------------------------------------ */
.callout { margin: 0 0 16px; padding: 13px 16px; border-radius: var(--radius); border: 1px solid var(--line); border-left-width: 3px; background: var(--panel-2); }
.callout.info { border-left-color: var(--line-strong); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.callout-title { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; }
.callout-body { font-size: 13px; color: var(--ink-dim); }
.callout-body p:last-child { margin-bottom: 0; }

/* ---- Pager --------------------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 12.5px; }
.pager-note { color: var(--ink-faint); }
.pager-links { display: flex; gap: 8px; }
.pager-link { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; box-shadow: var(--shadow-sm); }
.pager-link:hover { border-color: var(--line-strong); }

h2.heading-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Sign-in is the one page with a card of its own. */
.signin .fieldset { padding: 24px 24px 22px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.signin label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.signin input { margin-top: 2px; }

@media (max-width: 970px) {
  :root { --rail: 224px; --pad: 20px; }
  .split, .account-overview { grid-template-columns: minmax(0, 1fr); }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .facts { grid-template-columns: minmax(0, 1fr); }
  .action-row { flex-direction: column; align-items: stretch; }
  .action-row > form { align-self: flex-start; }
}

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

@media (max-width: 760px) {
  :root { --pad: 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side, .foot, .notice, .skip, button, .segmented, .toolbar, .pager { display: none; }
  .topbar-brand { display: inline-flex; }
  .topbar { gap: 10px; }
  .page-head { grid-template-columns: minmax(0, 1fr); }
  .page-actions { grid-column: 1; justify-self: start; margin-top: 6px; }
  .mix-row { grid-template-columns: minmax(0, 1fr) auto; }
  .mix-track { grid-column: 1 / -1; order: 3; }
  .mix-share { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

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

@media print {
  :root {
    --bg: #ffffff;
    --paper: #ffffff;
    --panel: #ffffff;
    --panel-2: #ffffff;
    --inset: #ffffff;
    --ink: #000000;
    --ink-dim: #333333;
    --ink-faint: #555555;
    --line: #cccccc;
    --line-soft: #dddddd;
    --line-strong: #bbbbbb;
    --shadow-sm: none;
    --shadow: none;
  }
  .side, .topbar, .foot, .notice, .skip, button, .segmented, .toolbar, .pager { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  main { max-width: none; padding: 0; }
  .panel, .tile, .fieldset { break-inside: avoid; box-shadow: none; }
  th { position: static; }
  .columns .bar rect, .mix-fill { print-color-adjust: exact; }
}

/* Widths for the mix bars. Generated, because the CSP refuses inline styles. */
.mix-fill[data-fill="0"] { width: 0%; }
.mix-fill[data-fill="1"] { width: 1%; }
.mix-fill[data-fill="2"] { width: 2%; }
.mix-fill[data-fill="3"] { width: 3%; }
.mix-fill[data-fill="4"] { width: 4%; }
.mix-fill[data-fill="5"] { width: 5%; }
.mix-fill[data-fill="6"] { width: 6%; }
.mix-fill[data-fill="7"] { width: 7%; }
.mix-fill[data-fill="8"] { width: 8%; }
.mix-fill[data-fill="9"] { width: 9%; }
.mix-fill[data-fill="10"] { width: 10%; }
.mix-fill[data-fill="11"] { width: 11%; }
.mix-fill[data-fill="12"] { width: 12%; }
.mix-fill[data-fill="13"] { width: 13%; }
.mix-fill[data-fill="14"] { width: 14%; }
.mix-fill[data-fill="15"] { width: 15%; }
.mix-fill[data-fill="16"] { width: 16%; }
.mix-fill[data-fill="17"] { width: 17%; }
.mix-fill[data-fill="18"] { width: 18%; }
.mix-fill[data-fill="19"] { width: 19%; }
.mix-fill[data-fill="20"] { width: 20%; }
.mix-fill[data-fill="21"] { width: 21%; }
.mix-fill[data-fill="22"] { width: 22%; }
.mix-fill[data-fill="23"] { width: 23%; }
.mix-fill[data-fill="24"] { width: 24%; }
.mix-fill[data-fill="25"] { width: 25%; }
.mix-fill[data-fill="26"] { width: 26%; }
.mix-fill[data-fill="27"] { width: 27%; }
.mix-fill[data-fill="28"] { width: 28%; }
.mix-fill[data-fill="29"] { width: 29%; }
.mix-fill[data-fill="30"] { width: 30%; }
.mix-fill[data-fill="31"] { width: 31%; }
.mix-fill[data-fill="32"] { width: 32%; }
.mix-fill[data-fill="33"] { width: 33%; }
.mix-fill[data-fill="34"] { width: 34%; }
.mix-fill[data-fill="35"] { width: 35%; }
.mix-fill[data-fill="36"] { width: 36%; }
.mix-fill[data-fill="37"] { width: 37%; }
.mix-fill[data-fill="38"] { width: 38%; }
.mix-fill[data-fill="39"] { width: 39%; }
.mix-fill[data-fill="40"] { width: 40%; }
.mix-fill[data-fill="41"] { width: 41%; }
.mix-fill[data-fill="42"] { width: 42%; }
.mix-fill[data-fill="43"] { width: 43%; }
.mix-fill[data-fill="44"] { width: 44%; }
.mix-fill[data-fill="45"] { width: 45%; }
.mix-fill[data-fill="46"] { width: 46%; }
.mix-fill[data-fill="47"] { width: 47%; }
.mix-fill[data-fill="48"] { width: 48%; }
.mix-fill[data-fill="49"] { width: 49%; }
.mix-fill[data-fill="50"] { width: 50%; }
.mix-fill[data-fill="51"] { width: 51%; }
.mix-fill[data-fill="52"] { width: 52%; }
.mix-fill[data-fill="53"] { width: 53%; }
.mix-fill[data-fill="54"] { width: 54%; }
.mix-fill[data-fill="55"] { width: 55%; }
.mix-fill[data-fill="56"] { width: 56%; }
.mix-fill[data-fill="57"] { width: 57%; }
.mix-fill[data-fill="58"] { width: 58%; }
.mix-fill[data-fill="59"] { width: 59%; }
.mix-fill[data-fill="60"] { width: 60%; }
.mix-fill[data-fill="61"] { width: 61%; }
.mix-fill[data-fill="62"] { width: 62%; }
.mix-fill[data-fill="63"] { width: 63%; }
.mix-fill[data-fill="64"] { width: 64%; }
.mix-fill[data-fill="65"] { width: 65%; }
.mix-fill[data-fill="66"] { width: 66%; }
.mix-fill[data-fill="67"] { width: 67%; }
.mix-fill[data-fill="68"] { width: 68%; }
.mix-fill[data-fill="69"] { width: 69%; }
.mix-fill[data-fill="70"] { width: 70%; }
.mix-fill[data-fill="71"] { width: 71%; }
.mix-fill[data-fill="72"] { width: 72%; }
.mix-fill[data-fill="73"] { width: 73%; }
.mix-fill[data-fill="74"] { width: 74%; }
.mix-fill[data-fill="75"] { width: 75%; }
.mix-fill[data-fill="76"] { width: 76%; }
.mix-fill[data-fill="77"] { width: 77%; }
.mix-fill[data-fill="78"] { width: 78%; }
.mix-fill[data-fill="79"] { width: 79%; }
.mix-fill[data-fill="80"] { width: 80%; }
.mix-fill[data-fill="81"] { width: 81%; }
.mix-fill[data-fill="82"] { width: 82%; }
.mix-fill[data-fill="83"] { width: 83%; }
.mix-fill[data-fill="84"] { width: 84%; }
.mix-fill[data-fill="85"] { width: 85%; }
.mix-fill[data-fill="86"] { width: 86%; }
.mix-fill[data-fill="87"] { width: 87%; }
.mix-fill[data-fill="88"] { width: 88%; }
.mix-fill[data-fill="89"] { width: 89%; }
.mix-fill[data-fill="90"] { width: 90%; }
.mix-fill[data-fill="91"] { width: 91%; }
.mix-fill[data-fill="92"] { width: 92%; }
.mix-fill[data-fill="93"] { width: 93%; }
.mix-fill[data-fill="94"] { width: 94%; }
.mix-fill[data-fill="95"] { width: 95%; }
.mix-fill[data-fill="96"] { width: 96%; }
.mix-fill[data-fill="97"] { width: 97%; }
.mix-fill[data-fill="98"] { width: 98%; }
.mix-fill[data-fill="99"] { width: 99%; }
.mix-fill[data-fill="100"] { width: 100%; }
