/* Beacon shell + components — the one stylesheet every page links.

   There used to be two: beacon-core.css (check-in-health) and
   beacon-redesign.css (everything else), the second a copy of the first
   minus a top nav retired in the 2026-05 rebrand. They drifted, as two
   copies of one file do. This is the survivor; if a component belongs to
   more than one page, it belongs in here.

   Colour is NOT defined here. Tokens come from styles/ds-tokens.css and
   Beacon's legacy variable names are aliased onto them in
   styles/ds-alias.css. Both must be linked BEFORE this file.

   Rules:
   - Never write a raw colour literal in this file. Use a var().
   - Light mode only. No dark variants.

   Spec: ato-hq/playbook 03-react-frontend/design-system.md
*/

/* ─── Reset ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* Body sits on the design-system default (0.9375rem / 15px), the same as the
     Pulse console. Beacon ran a step down until 2026-09-03 and read as cramped
     next to it; web/src/styles/app.css sets the identical size for the React
     pages - change the two together. */
  font-size: var(--ds-size-body);
  line-height: var(--ds-leading-body);
}

a { color: inherit; text-decoration: none; }

/* Links that read as links use deep lagoon, never brand teal. */
a.link, .link {
  color: var(--text-link);
}
a.link:hover, .link:hover {
  color: var(--text-link-hover);
  text-decoration: underline;
}

/* Focus is never removed — accessibility floor. */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ─── Standalone pages ───
   Sign-in and 403 have no rail: a single card centred on the canvas. They
   used to carry their own `body` rule to do it, which is a page redefining
   an element the shared sheet also styles - so it is a class here instead.
   Body text runs one step up from the compact shell, because these pages
   are read once rather than scanned. */
body.page-centred {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-7);
  font-size: var(--ds-size-body);
}

/* ─── Typography ─── */
.headline {
  font-size: var(--ds-size-h1);
  font-weight: 700;
  letter-spacing: var(--ds-tracking-display);
  line-height: var(--ds-leading-heading);
  color: var(--text);
}

.headline-sm {
  font-size: var(--ds-size-h3);
  font-weight: 700;
  letter-spacing: var(--ds-tracking-heading);
  line-height: var(--ds-leading-heading);
}

.label {
  font-size: var(--ds-size-overline);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--ds-tracking-overline);
  color: var(--text-muted);
}

/* The brand is always lowercase "ato" — never "ATO", never "Ato".
   text-transform on a descendant beats the ancestor's, so this keeps the
   wordmark lowercase even inside an uppercase overline. */
.brand {
  text-transform: lowercase;
}

/* Data is mono — metric values, counts, timestamps, IDs. */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ─── Sidebar Nav ───
   "Sharp shell": chrome is dense and quiet — reduced padding, small pill
   nav items, no decorative rules. Active state is a primary-subtle fill +
   primary text + weight 500, never colour alone and never a left bar. */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 210px;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--ds-z-sticky);
}

.sidebar-brand {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

/* The ato logo icon. Real brand artwork (ato-mark.svg, vectors extracted
   from the brand guidelines) — NOT a CSS approximation. Painted as a
   background so the nine pages carrying <span class="dot"> need no markup
   change. Aspect ratio 196.72:240.09, so keep width:height at ~1:1.22. */
.brand-mark { display: flex; align-items: center; gap: 9px; }
.brand-mark .dot {
  width: 18px;
  height: 22px;
  flex-shrink: 0;
  background: url("/static/ato-mark.svg") center / contain no-repeat;
}

.sidebar-brand-name {
  font-size: var(--ds-size-h4);
  font-weight: 700;
  letter-spacing: var(--ds-tracking-heading);
  color: var(--text);
}

/* Attribution, not a category label — and "BY ato" reads badly with the
   brand forced lowercase inside an uppercase transform. Set in lower case
   with the tracking eased, since overline tracking is tuned for caps. */
.sidebar-brand-sub {
  font-size: var(--ds-size-overline);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 10px;
  padding: 6px 12px;
  font-size: var(--ds-size-body-sm);
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-control);
  transition: background var(--ds-duration-fast) var(--ds-ease-standard),
              color var(--ds-duration-fast) var(--ds-ease-standard);
}

.nav-item:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.nav-item.active {
  color: var(--accent);
  font-weight: 500;
  background: var(--accent-muted);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.nav-item.active svg {
  color: var(--accent);
}

/* Rail groups (Operate / Growth / Money / System), rendered from the `group`
   on each beacon-nav.js item. A quiet sentence-case label, inset to line up
   with the item icons (item margin + padding). */
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-label {
  padding: 0 22px 4px;
  font-size: var(--ds-size-caption);
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shown by beacon-user.js when a user's grants hide every rail item — an
   MCP-only account on /dashboard/account, for instance. A blank strip
   between the brand and the footer reads as a broken page; this says what
   is actually true. Hidden on the collapsed rail, where there is no room. */
.sidebar-nav-empty {
  margin: 4px 16px;
  font-size: var(--ds-size-caption);
  line-height: 1.4;
  color: var(--text-muted);
}

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

/* ─── Main Content ─── */
.main-content {
  margin-left: 210px;
  min-height: 100vh;
}

.page-header {
  padding: 26px 34px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--ds-space-5);
  flex-wrap: wrap;
}

.page-header .label {
  margin-bottom: 4px;
}

.page-header .headline {
  font-size: var(--ds-size-h2);
  letter-spacing: var(--ds-tracking-heading);
}

.page-header .subtitle {
  font-size: var(--ds-size-body-sm);
  color: var(--text-secondary);
  margin-top: 4px;
}

.content {
  padding: 28px 34px;
}

/* Breadcrumbs are mono at caption size — data, not prose. */
.breadcrumbs {
  font-family: var(--font-mono);
  font-size: var(--ds-size-caption);
  color: var(--text-muted);
}

/* ─── Cards ───
   "Soft cards": no visible border at rest. A transparent 1px border keeps
   layout stable so hover/selected states can draw one without reflow. */
.card {
  background: var(--bg-raised);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--ds-space-7);
}

/* A card's heading row: a quiet icon tile, then the card's name as an
   overline. Two pages had byte-identical copies of this with different
   margins, which is exactly the kind of drift a shared sheet exists to
   stop. */
.card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}

.card-title .ci {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-title .ci svg { width: 15px; height: 15px; }
.card-title .label { margin: 0; }
.card-title .spacer { flex: 1; }

/* Outlined variant — for when a drawn line is genuinely needed. */
.card.outlined {
  border-color: var(--border);
  box-shadow: none;
}

.card-grid {
  display: grid;
  gap: 16px;
}

.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ─── Stat Card ─── */
.stat-card {
  background: var(--bg-raised);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--ds-space-7);
}

/* Metric values are data — mono, tabular. */
.stat-card .value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* A status word ("OK" / "Down" / "Healthy") is a word, not data. Mono is
   for numerals, counts, durations, timestamps and IDs — never prose. */
.stat-card .value.word {
  font-family: var(--font-ui);
  letter-spacing: var(--ds-tracking-heading);
}

/* Loud only when it is bad. A healthy service is not news, so the ok state
   steps back and lets the real metrics hold the eye; a failure keeps the
   full display size. The word itself is always present, so the state is
   never carried by size or colour alone. */
.stat-card .value.word.ok {
  font-size: var(--ds-size-h4);
  font-weight: 500;
}

.stat-card .label {
  font-size: var(--ds-size-overline);
}

.stat-card .hint {
  font-size: var(--ds-size-caption);
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card .value.ok     { color: var(--status-ok); }
.stat-card .value.warn   { color: var(--status-warn); }
.stat-card .value.danger { color: var(--status-danger); }

.stat-card.mini { padding: var(--ds-space-5); }
.stat-card.mini .value { font-size: 1.375rem; margin-bottom: 4px; }

.stat-card.actionable {
  /* Also styles a <button>, which is what a stat card that filters the
     table below it should be — hence the display/width/font resets. */
  display: block;
  width: 100%;
  cursor: pointer;
  transition: box-shadow var(--ds-duration-fast) var(--ds-ease-standard);
  text-align: left;
  font-family: inherit;
  border: 1px solid transparent;
}
.stat-card.actionable:hover { box-shadow: var(--shadow-hover); }
.stat-card.actionable:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* A stat card that is currently filtering the view below it draws its
   border - it is selected, not merely hoverable. Declared after
   .actionable, whose transparent border it has to beat. */
.stat-card.active { border-color: var(--accent); }

/* ─── Buttons ───
   Controls are pills. One primary per view; primary sits last in the
   action row with Cancel to its left. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-3);
  height: var(--ds-control-height-md);
  padding: 0 var(--ds-space-6);
  border-radius: var(--radius-control);
  font-size: var(--ds-size-body-sm);
  font-weight: 500;
  font-family: var(--font-ui);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--ds-duration-fast) var(--ds-ease-standard),
              color var(--ds-duration-fast) var(--ds-ease-standard),
              box-shadow var(--ds-duration-fast) var(--ds-ease-standard);
  white-space: nowrap;
}

.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.btn-primary {
  background: var(--accent);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-dark); box-shadow: none; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-surface);
  color: var(--text);
}

/* Subtle — primary-subtle fill with teal-800 text. */
.btn-subtle {
  background: var(--accent-muted);
  color: var(--accent-ink);
}
.btn-subtle:hover { background: var(--accent-muted-hover); }

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.btn-danger {
  background: var(--status-danger-muted);
  color: var(--status-danger);
  border-color: var(--status-danger-border);
}
.btn-danger:hover {
  background: var(--status-danger);
  border-color: var(--status-danger);
  color: var(--text-on-brand);
}

.btn-sm {
  height: var(--ds-control-height-sm);
  padding: 0 var(--ds-space-5);
  font-size: var(--ds-size-caption);
}

/* ─── Form Elements ───
   Inputs stay rectangular — pill inputs hurt dense forms. Every control
   gets a real <label for>; a placeholder is never the label. */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: var(--ds-size-overline);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--ds-tracking-overline);
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  height: var(--ds-control-height-md);
  padding: 0 var(--ds-space-5);
  font-size: var(--ds-size-body-sm);
  font-family: var(--font-ui);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  outline: none;
  transition: border-color var(--ds-duration-fast) var(--ds-ease-standard),
              box-shadow var(--ds-duration-fast) var(--ds-ease-standard);
}

.input:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.input:focus { border-color: var(--border-focus); }
.input::placeholder { color: var(--text-disabled); }
.input.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
textarea.input { height: auto; padding: var(--ds-space-4) var(--ds-space-5); }

/* Error state = danger border + icon + message, never colour alone. */
.input.is-error { border-color: var(--status-danger); }
.field-error {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  margin-top: var(--ds-space-2);
  font-size: var(--ds-size-caption);
  color: var(--status-danger);
}

select.input { appearance: none; cursor: pointer; }

/* ─── Table ───
   Header sits on the sunken surface; wide tables scroll inside their own
   container so the page never scrolls sideways. */
.table-wrap {
  background: var(--bg-raised);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: var(--ds-size-overline);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--ds-tracking-overline);
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: var(--ds-space-4) var(--ds-space-5);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody td {
  font-size: var(--ds-size-body-sm);
  padding: var(--ds-space-4) var(--ds-space-5);
  color: var(--text);
  white-space: nowrap;
  border-top: 1px solid var(--border-subtle);
  border-bottom: none;
}

/* Numeric cells are data — mono, tabular, right-aligned. The matching
   header is a LABEL, so it only inherits the alignment: a column heading
   set in mono reads as data it isn't. */
td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
th.num { text-align: right; }

tbody tr {
  transition: background var(--ds-duration-fast) var(--ds-ease-standard);
  cursor: pointer;
}

tbody tr:hover { background: var(--bg-surface); }
tbody tr:first-child td { border-top: none; }

/* The row whose drawer is currently open. A hover fill is never darker
   than the sunken surface, so selected reuses it rather than going a step
   darker — the open drawer is the louder signal. */
tbody tr.selected { background: var(--bg-surface); }

/* Sortable columns. The arrow is always in the DOM so the header does not
   reflow when a column becomes the sort key; it is simply invisible until
   that column is the one sorting. */
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th.sorted { color: var(--accent); }
thead th .sort-arrow svg { opacity: 0; }
thead th.sorted .sort-arrow svg { opacity: 1; }

/* ─── Money ───
   Money is data: mono + tabular, symbol tight to the number, negatives as
   a real minus sign in danger — never parentheses, never colour alone. */
.money {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money.is-negative { color: var(--status-danger); }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--ds-size-caption);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.badge.grow      { background: var(--tier-grow-bg); color: var(--tier-grow-text); }
.badge.essential { background: var(--tier-essential-bg); color: var(--tier-essential-text); }
.badge.ok        { background: var(--status-ok-muted); color: var(--status-ok); }
.badge.warn      { background: var(--status-warn-muted); color: var(--status-warn); }
.badge.danger    { background: var(--status-danger-muted); color: var(--status-danger); }
.badge.info      { background: var(--status-info-muted); color: var(--status-info); }
.badge.neutral   { background: var(--bg-surface); color: var(--text-secondary); }

/* ─── Status Dot ───
   A dot never carries status on its own — it always sits beside a word.
   Glows removed: elevation in this system is charcoal-tinted shadow only. */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.ok      { background: var(--status-ok); }
.status-dot.warn    { background: var(--status-warn); }
.status-dot.danger  { background: var(--status-danger); }
.status-dot.neutral { background: var(--band-none); }

/* No data = hollow ring, never 0 and never red. */
.status-dot.none {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--band-none);
}

/* ─── Score bands ───
   Standing state, not events. <60 At risk · 60-79 Watch · 80+ Healthy.
   The band label always accompanies the colour. */
.band {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--ds-size-caption);
  font-weight: 500;
}
.band .score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.band.high { background: var(--band-high-subtle); color: var(--accent-ink); }
.band.mid  { background: var(--band-mid-subtle);  color: var(--band-mid); }
.band.low  { background: var(--band-low-subtle);  color: var(--band-low); }
.band.none { background: var(--bg-surface);       color: var(--text-secondary); }

/* ─── Health bar (left edge of table row) ─── */
td.health-bar {
  width: 4px;
  padding: 0 !important;
  position: relative;
}
td.health-bar::before {
  content: '';
  position: absolute;
  inset: 6px 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
}
tr[data-health="ok"]      td.health-bar::before { background: var(--status-ok); }
tr[data-health="partial"] td.health-bar::before { background: var(--status-warn); }
tr[data-health="missing"] td.health-bar::before { background: var(--status-danger); }
tr[data-health="inactive"] td.health-bar::before { background: var(--text-faint); }

/* ─── Search + Filter Controls ─── */
.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus { outline: none; border-color: var(--border-focus); }
.search-box input::placeholder { color: var(--text-faint); }

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

/* Wraps — the filter row is the widest thing on a narrow viewport and was
   pushing the whole page sideways rather than folding onto a second line. */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Filter group is a segmented control, so the items are pills. */
.filter-btn {
  padding: 6px 14px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--ds-size-caption);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ds-duration-fast) var(--ds-ease-standard),
              color var(--ds-duration-fast) var(--ds-ease-standard);
}

.filter-btn:hover { color: var(--text); background: var(--bg-surface); }
.filter-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.filter-btn.active {
  background: var(--accent-muted);
  border-color: transparent;
  color: var(--accent);
}

/* ─── Drawer ─── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-raised);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.4s var(--ease);
  box-shadow: var(--shadow-drawer);
  border-left: 1px solid var(--border);
  /* A column, so the header stays put and only the body scrolls - a long
     diagnosis should not scroll the ticket's title off the top. */
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.drawer-close {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.drawer-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ─── Detail Rows (drawer content) ─── */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-row .detail-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.detail-row .detail-value {
  font-size: 0.84rem;
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

/* ─── Reasoning Panel (reports) ─── */
.reasoning-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-card);
  border-left: 3px solid var(--accent);
  overflow: hidden;
}

.reasoning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.reasoning-body { padding: 16px 20px; }

.reasoning-section { margin-bottom: 14px; }
.reasoning-section:last-child { margin-bottom: 0; }

.reasoning-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.reasoning-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* No glow - elevation is charcoal-tinted shadow and nothing else. Same
   ruling as .status-dot above, which lost its glow first. */
.reasoning-dot.good    { background: var(--status-ok); }
.reasoning-dot.bad     { background: var(--status-danger); }
.reasoning-dot.aware   { background: var(--status-warn); }
.reasoning-dot.gaps    { background: var(--text-faint); }

.reasoning-bullets { list-style: none; padding: 0; margin: 0; }
.reasoning-bullets li {
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 2px 0 2px 16px;
  position: relative;
}
.reasoning-bullets li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

/* ─── Toggle Switch ─── */
.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--bg-deepest);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(16px); }

/* ─── Empty / Loading / Error ─── */
.empty-state,
.loading-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-faint);
  font-size: 0.84rem;
}

.error-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--status-danger);
  font-size: 0.84rem;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   SHARED FURNITURE
   ───────────────────────────────────────────────────────────────────
   Everything below used to be pasted into each page's own <style>
   block, which is how five different segmented controls and four
   different footer avatars ended up shipping at once. A component
   lives here or it does not exist; a page's <style> block is for
   that page's own layout, never for furniture another page also has.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Page header actions ─── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── Sidebar footer user ───
   Name + email of the logged-in operator. beacon-user.js fills .nm / .rl
   and the avatar initial from /dashboard/api/me; the markup ships with a
   neutral fallback so a failed session call degrades to placeholder text
   rather than an empty rail. A long contractor email would stretch .who
   past the 200px rail, so it clamps with an ellipsis — flex items do not
   shrink below their content without min-width: 0. */
.footer-user {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
}

.footer-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

/* The avatar + name/email block is a link to /dashboard/account (My
   account). It is in the footer, not the nav rail, because the account
   page is behind requireAuth ONLY — the rail is section-gated and would
   hide it from exactly the MCP-only users who need to change a seeded
   password. Styled as the identity block it already was: no underline, no
   accent, just a hover fill so it reads as pressable. */
.footer-account {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 3px 5px;
  margin: -3px -5px;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.footer-account:hover { background: var(--bg-surface); }
.footer-account:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.footer-account[aria-current="page"] .who .nm { color: var(--accent); }

.footer-user .who {
  min-width: 0;
  flex: 1;
  line-height: 1.2;
}

.footer-user .who .nm,
.footer-user .who .rl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-user .who .nm { font-size: 0.74rem; font-weight: 500; color: var(--text); }
.footer-user .who .rl { font-size: 0.62rem; color: var(--text-secondary); }

/* Sign out. Icon-only because the rail is 200px and the email beside it
   already has to clamp - so the affordance is the title + aria-label, and
   the icon is the only thing that fits. A ghost control: hover is a fill
   step to the sunken surface, never an opacity change. */
.footer-signout {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--ds-duration-fast) var(--ds-ease-standard),
              color var(--ds-duration-fast) var(--ds-ease-standard);
}

.footer-signout svg { width: 15px; height: 15px; }
.footer-signout:hover { background: var(--bg-surface); color: var(--text); }
.footer-signout:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.footer-signout:disabled { opacity: 0.5; cursor: not-allowed; }

/* Says what failed and what is still true, rather than "something went
   wrong". Only ever shown after a failed sign-out. */
.footer-signout-error {
  margin-top: 8px;
  font-size: 0.62rem;
  line-height: 1.4;
  color: var(--status-danger);
}

/* ─── Segmented control ───
   One row of mutually exclusive views ("30d / 90d / All"). A sunken well
   with pill buttons; the selected one takes the primary-subtle fill and
   primary ink — never colour alone, the button also carries its own word.

   There is ONE size. The five page-local copies this replaces ran at
   0.75rem / 0.76rem with four different paddings, which read as sloppiness
   rather than intent. Add `.block` when the control has to fill its
   container (inside a drawer field, or a two-up tier picker). */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

.seg button {
  padding: 6px 13px;
  border: none;
  background: none;
  border-radius: var(--radius-control);
  font-family: var(--font-ui);
  font-size: var(--ds-size-caption);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--ds-duration-fast) var(--ds-ease-standard),
              color var(--ds-duration-fast) var(--ds-ease-standard);
}

.seg button:hover { color: var(--text); }
.seg button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.seg button.active { background: var(--accent-muted); color: var(--accent); }

/* Full-width variant — the buttons share the row equally. */
.seg.block { display: flex; width: 100%; }
.seg.block button { flex: 1; padding: 8px 10px; text-align: center; }

/* An invalid required choice borders red AND the field prints a message;
   the border is never the only signal. */
.seg.is-error { border-color: var(--status-danger); }

/* ─── Sub-tabs ───
   In-page navigation: one screen, several views of it (Credits' Wallets /
   Usage / Pricing, P&L's five panes, Settings' four groups). An underline
   rail directly under the page header, never a second sidebar.

   The active tab carries THREE signals — primary ink, the 2px underline,
   and weight 500 — so it survives both a colour-blind reader and a
   greyscale print. Overflows horizontally on a narrow rail instead of
   wrapping into a second row, which would push the content down a line
   depending on tab count. */
.subtabs {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.subtabs::-webkit-scrollbar { display: none; }

.subtab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 15px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--font-ui);
  font-size: var(--ds-size-body-sm);
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--ds-duration-fast) var(--ds-ease-standard);
}

.subtab svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transition: color var(--ds-duration-fast) var(--ds-ease-standard);
}

.subtab:hover { color: var(--text); }
.subtab:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.subtab.active {
  font-weight: 500;
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.subtab.active svg { color: var(--accent); }

/* A count beside a tab label is data — mono, tabular. */
.subtab .count-badge {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.64rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-muted);
}

.subtab.active .count-badge { background: var(--accent-muted); color: var(--accent); }

/* A tab pane is hidden, not unmounted — scroll position and any half-typed
   input survive a round trip to another tab and back. */
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ─── Toolbar ───
   The filter / action row that sits above a table or a card grid. */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar .tb-note {
  font-size: 0.76rem;
  line-height: 1.5;
  max-width: 560px;
  color: var(--text-muted);
}

/* ─── Key / value rows ───
   Drawer and panel detail rows: label left, value right. The value can be
   a long ID or URL, so it breaks rather than widening the drawer. */
.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 4px 0;
  font-size: 0.78rem;
}

/* Inside a drawer's detail list the rows are ruled and the keys become
   overlines — same component, denser reading. The wrapper carries it, so
   no caller has to remember a modifier class. */
.drawer-detail-rows { margin-top: 4px; }
.drawer-detail-rows .kv {
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}
.drawer-detail-rows .kv:last-child { border-bottom: none; }
.drawer-detail-rows .kv .k {
  font-size: var(--ds-size-overline);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--ds-tracking-overline);
  color: var(--text-muted);
}
.drawer-detail-rows .kv .v { word-break: normal; }

.kv .k { flex-shrink: 0; color: var(--text-secondary); }
.kv .v { text-align: right; word-break: break-all; color: var(--text); }
.kv .v.muted { color: var(--text-muted); font-style: italic; }
.kv code { font-family: var(--font-mono); font-size: 0.72rem; }
.kv a { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); }
.kv a:hover { text-decoration: underline; }
.kv a svg { width: 11px; height: 11px; }

/* ─── Integration chip ───
   A compact status pill carrying an icon and a count. Status is never the
   colour alone: the icon names the integration and the count is printed. */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 52px;
  padding: 6px 8px;
  border-radius: var(--radius-control);
  background: var(--bg-surface);
}

.chip svg.ico { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-secondary); }
.chip .n {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.chip.connected { background: var(--accent-muted); }
.chip.connected svg.ico { color: var(--accent); }
.chip.partial { background: var(--status-warn-muted); }
.chip.partial svg.ico { color: var(--status-warn); }
.chip.missing { opacity: 0.35; }

/* ─── Tag chip ───
   A quiet mono pill naming one thing: an n8n tag, an MCP tool, a ticket
   category. NOT .chip - that one carries integration status and a count.
   Two different ideas that had the same class name on different pages. */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Inside a table cell's second line it runs tighter. */
.cell-sub .tag-chip { padding: 1px 6px; }

/* ─── Form field ───
   A label + control + hint stack. `.input` styles the control itself; this
   is the wrapper that spaces them. */
.field { margin-bottom: 13px; }

.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: var(--ds-size-overline);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--ds-tracking-overline);
  color: var(--text-muted);
}

.field .hint { margin-top: 5px; font-size: 0.6rem; color: var(--text-muted); }
.field .input-wrap { position: relative; }

/* ─── Meter ───
   A 0-100 bar. Fills from the band the score sits in — under 60 at risk,
   60-79 watch, 80+ healthy — and the caller prints the number beside it,
   because a bar length is not a readable figure. Growth animates over
   --ds-duration-slow; no-data draws the track alone. */
.meter {
  position: relative;
  height: 6px;
  border-radius: var(--ds-radius-xs);
  background: var(--bg-surface);
  overflow: hidden;
}

.meter .fill {
  height: 100%;
  border-radius: inherit;
  background: var(--band-none);
  transition: width var(--ds-duration-slow) var(--ds-ease-standard);
}

.meter .fill.high { background: var(--band-high); }
.meter .fill.mid  { background: var(--band-mid); }
.meter .fill.low  { background: var(--band-low); }

/* ─── Trend chip ───
   A direction plus the word for it — "▲ rising" — never an arrow alone.
   Direction is not health: a rising ticket count is bad and a rising
   wallet balance is good, so the caller chooses the tone. */
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.65rem;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.trend-chip svg { width: 11px; height: 11px; }
.trend-chip.good { background: var(--status-ok-muted); color: var(--status-ok); }
.trend-chip.bad  { background: var(--status-danger-muted); color: var(--status-danger); }

/* ─── Alert ───
   A banner explaining a condition the operator has to know about before
   reading the page. Tone is carried by an icon and the sentence, with the
   tint as reinforcement — never the tint alone. One per view; if you need
   two, the page is telling two stories. */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert .alert-title { display: block; font-weight: 500; margin-bottom: 2px; color: var(--text); }

/* Tone is carried by the icon AND the title, with the tint reinforcing -
   never the tint alone. The body stays muted so the sentence reads. */
.alert.info   { border-color: var(--status-info-border);   background: var(--status-info-muted); }
.alert.info svg,   .alert.info .alert-title   { color: var(--status-info); }
.alert.ok     { border-color: var(--status-ok-border);     background: var(--status-ok-muted); }
.alert.ok svg,     .alert.ok .alert-title     { color: var(--status-ok); }
.alert.warn   { border-color: var(--status-warn-border);   background: var(--status-warn-muted); }
.alert.warn svg,   .alert.warn .alert-title   { color: var(--status-warn); }
.alert.danger { border-color: var(--status-danger-border); background: var(--status-danger-muted); }
.alert.danger svg, .alert.danger .alert-title { color: var(--status-danger); }

/* ─── Dialog ───
   A modal confirm. Used where an action is destructive or moves money and
   the operator needs to re-read what they are about to do. Anything that
   is a form rather than a decision belongs in the Drawer instead. */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--ds-z-overlay);
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ds-duration-base) var(--ds-ease-standard),
              visibility var(--ds-duration-base) var(--ds-ease-standard);
}

.dialog-overlay.open { opacity: 1; visibility: visible; }

.dialog {
  width: 100%;
  max-width: 420px;
  padding: 22px 24px 20px;
  border-radius: var(--ds-radius-xl);
  background: var(--bg-deepest);
  box-shadow: var(--shadow-modal);
  transform: translateY(8px);
  transition: transform var(--ds-duration-base) var(--ds-ease-standard);
}

.dialog-overlay.open .dialog { transform: translateY(0); }

.dialog-title {
  font-size: var(--ds-size-h4);
  font-weight: 700;
  letter-spacing: var(--ds-tracking-heading);
  color: var(--text);
  margin-bottom: 8px;
}

.dialog-body { font-size: 0.8rem; line-height: 1.6; color: var(--text-secondary); }

/* One primary action, last in the row, Cancel to its left. */
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ─── Skeleton ───
   A loading placeholder shaped like the content it is standing in for.
   Preferred over a spinner wherever the shape is known — the page does
   not jump when the data lands. */
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-hover) 37%, var(--bg-surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* ─── Sprite icon sizing ───
   Inline sprite icons (<svg><use href="#i-…"/></svg>) carry no intrinsic
   size, so without an explicit width they render at the SVG default —
   which is enormous. Sized here once for the two that appear in chrome. */
.search-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.sort-arrow {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
}

.sort-arrow svg { width: 12px; height: 12px; vertical-align: middle; }

/* ─── Animations ─── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

.animate-in {
  opacity: 0;
  animation: fadeSlideIn var(--duration) var(--ease) forwards;
}

.stagger-1 { animation-delay: 0s; }
.stagger-2 { animation-delay: var(--stagger); }
.stagger-3 { animation-delay: calc(var(--stagger) * 2); }
.stagger-4 { animation-delay: calc(var(--stagger) * 3); }
.stagger-5 { animation-delay: calc(var(--stagger) * 4); }

/* ─── Focus ───
   Handled once, near the top of this file, as box-shadow: var(--shadow-focus).
   A blanket `*:focus-visible { outline: … }` used to live here too: same
   specificity, later in the file, so it did not replace the ring — it drew a
   second one on top of it. Both were legible (--accent is deep lagoon at
   6.91:1, not the turquoise the spec retired), so this was doubled-up
   decoration rather than an accessibility fault. One indicator is correct. */

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar { width: 56px; overflow: hidden; }
  .sidebar .nav-item span:not(svg) { display: none; }
  /* No room for group words on a 56px rail: a hairline marks the break. */
  .nav-group-label { height: 1px; margin: 0 12px 4px; padding: 0; background: var(--border-subtle); color: transparent; }
  .nav-group:first-child .nav-group-label { background: none; }
  /* The rail is 56px — the brand wordmark does not fit and was spilling out
     over the page heading. Keep the mark, drop the words. */
  .sidebar-brand { padding: 14px 0; text-align: center; }
  .sidebar-brand-name, .sidebar-brand-sub { display: none; }
  .sidebar-footer .who, .sidebar-footer .nm, .sidebar-footer .rl { display: none; }
  .sidebar-footer { padding: 12px 0; text-align: center; }
  /* With .who hidden the account link is just the avatar — it must not
     stretch down the column the footer becomes below. */
  .sidebar-footer .footer-account { flex: 0 0 auto; padding: 0; margin: 0; }
  /* No room for prose on a 56px rail. */
  .sidebar-nav-empty { display: none; }
  /* 28px avatar + 28px button + 9px gap does not fit a 56px rail, so they
     stack. The avatar stays: with the name hidden, its initial is the only
     thing left saying who is signed in. */
  .sidebar-footer .footer-user { flex-direction: column; gap: 6px; }
  .main-content { margin-left: 56px; }
  .content { padding: 16px; }
  .card-grid.cols-2,
  .card-grid.cols-3,
  .card-grid.cols-4 { grid-template-columns: 1fr; }
  .controls { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
  .drawer { width: 100vw; }
  .headline { font-size: 1.5rem; }
}
