/* ============================================================================
   NexusCore Operations — Component System
   ----------------------------------------------------------------------------
   Everything a page needs. A new page should require zero new CSS; if it does
   need some, that is a signal a component is missing here, not that the page
   should grow its own <style> block.

   Depends on tokens.css. Load order: tokens → system → shell → page.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   1. Reset and base
   ------------------------------------------------------------------------ */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, ul, ol, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}

::selection {
  background: var(--accent-quiet);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------------------
   2. Typography

   Card titles are ONE size. Section headings are ONE size. The previous build
   rendered same-level <h2> at 13.6px, 14.4px and 24px on a single page; these
   classes exist so that cannot recur.
   ------------------------------------------------------------------------ */

.t-page {
  font-size: var(--text-page);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.t-section {
  font-size: var(--text-section);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.t-title {
  font-size: var(--text-title);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.t-body { font-size: var(--text-body); }
.t-meta { font-size: var(--text-meta); color: var(--text-secondary); }

/* The only uppercase treatment in the system. Reserved for labels that name a
   value directly beneath them — never as a decorative kicker over a heading. */
.t-label {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-tertiary);
}

/* Machine-generated strings: IDs, keys, endpoints, timestamps, counts. */
.t-mono {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  letter-spacing: 0;
}

.t-prose {
  max-width: 68ch;
  line-height: var(--leading-prose);
  color: var(--text-secondary);
}

.t-secondary { color: var(--text-secondary); }
.t-tertiary  { color: var(--text-tertiary); }
.t-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Long machine strings (URLs, ARNs) break at any character rather than
   overflowing their container. */
.t-break {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------------------------------------------------------------------------
   3. Status — the system's signature

   State is expressed with a 2px rail plus a written label, never with colour
   alone. Set `data-status` on any surface and it inherits the right colour:

     <article class="card" data-status="warn"> …
     <tr class="row" data-status="danger"> …

   Valid values: ok | warn | danger | info | idle. There is no sixth.
   ------------------------------------------------------------------------ */

[data-status] {
  --status: var(--status-idle);
  --status-quiet: var(--status-idle-quiet);
}

[data-status="ok"]     { --status: var(--status-ok);     --status-quiet: var(--status-ok-quiet); }
[data-status="warn"]   { --status: var(--status-warn);   --status-quiet: var(--status-warn-quiet); }
[data-status="danger"] { --status: var(--status-danger); --status-quiet: var(--status-danger-quiet); }
[data-status="info"]   { --status: var(--status-info);   --status-quiet: var(--status-info-quiet); }
[data-status="idle"]   { --status: var(--status-idle);   --status-quiet: var(--status-idle-quiet); }

/* The rail itself. Scanning a queue vertically shows the shape of the
   workload before any text is read. */
.rail {
  position: relative;
  padding-left: var(--space-4);
}

.rail::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 0;
  width: 2px;
  background: var(--status, var(--status-idle));
}

/* Status chip: dot + word. The word is what makes it accessible. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.15rem var(--space-2);
  border: 1px solid color-mix(in srgb, var(--status, var(--status-idle)) 35%, transparent);
  background: var(--status-quiet, var(--status-idle-quiet));
  color: var(--status, var(--status-idle));
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  white-space: nowrap;
}

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

.chip--plain::before { display: none; }

/* A neutral chip for non-state metadata: product keys, categories, versions.
   Deliberately colourless so it can never be mistaken for a status. */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem var(--space-2);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   4. Buttons

   .btn / .btn-primary keep their existing names so pages that have not been
   migrated yet continue to render.
   ------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.4rem var(--space-3);
  min-height: 32px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  border-radius: var(--radius);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              color var(--duration) var(--ease);
}

#edit-content-btn[hidden] { display: none; }

.btn:hover {
  background: var(--border);
  border-color: var(--text-tertiary);
  color: var(--text);
  text-decoration: none;
}

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

/* Dark ink on accent. White on this teal is 1.86:1 and fails AA; this is
   11.6:1. Do not change --accent-ink to a light value. */
.btn-primary,
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

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

.btn-secondary,
.btn--quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-secondary:hover,
.btn--quiet:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.btn--danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--status-danger) 45%, transparent);
  color: var(--status-danger);
}

.btn--danger:hover {
  background: var(--status-danger-quiet);
  border-color: var(--status-danger);
  color: var(--status-danger);
}

.btn--sm { padding: 0.25rem var(--space-2); min-height: 26px; font-size: var(--text-meta); }
.btn--lg { padding: 0.6rem var(--space-5); min-height: 40px; font-size: var(--text-title); }
.btn--block { width: 100%; }

.btn--icon {
  padding: 0;
  width: 32px;
  min-height: 32px;
  flex: none;
}

/* A row of buttons is horizontal. The previous build stacked page-header
   actions vertically, which read as a menu rather than a toolbar. */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* ---------------------------------------------------------------------------
   5. Cards and panels
   ------------------------------------------------------------------------ */

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}

.panel__head-text { min-width: 0; }

.panel__head-text > p {
  margin-top: var(--space-1);
  font-size: var(--text-meta);
  color: var(--text-secondary);
}

.panel__body { padding: var(--space-5); }
.panel__body--flush { padding: 0; }

.panel__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: var(--text-meta);
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------------
   6. Page header

   One page title per page, with its actions on the same line. Note there is
   no eyebrow/kicker slot: the previous build put a teal uppercase label over
   every card ("OPERATOR CONSOLE", "CORE SIGNALS", "PLANS", "DISTRIBUTION")
   which carried no information. Labels earn their place beside data, not
   above headings.
   ------------------------------------------------------------------------ */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.page-head__text { min-width: 0; flex: 1 1 24rem; }

.page-head__text > p {
  margin-top: var(--space-2);
  font-size: var(--text-meta);
  color: var(--text-secondary);
  max-width: 72ch;
}

.page-head__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-meta);
  color: var(--text-secondary);
}

.page-head__back:hover { color: var(--accent); text-decoration: none; }

/* ---------------------------------------------------------------------------
   7. Stat tiles

   One design, replacing the five that had accumulated. Label above value,
   left aligned, value in mono. `data-status` tints the value when a number
   carries state; without it the number is neutral, which is the default —
   a count is not a status.
   ------------------------------------------------------------------------ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-3);
}

.stat {
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  box-shadow: inset 0 2px var(--border-strong);
}

.stat[data-status] { box-shadow: inset 0 2px var(--status); }

.stat__label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-tertiary);
}

.stat__value {
  display: block;
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-metric);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.stat[data-status]:not([data-status="idle"]) .stat__value { color: var(--status); }

.stat__note {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-meta);
  color: var(--text-secondary);
}

/* Selectable stat — used as a filter control on the ticket list. */
.stat--action { cursor: pointer; text-align: left; width: 100%; display: block; }
.stat--action:hover { border-color: var(--border-strong); background: var(--surface-raised); }
.stat--action[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-quiet); }

/* ---------------------------------------------------------------------------
   8. Toolbars and filters

   A filter bar is a single row that wraps. The previous build gave the
   support queue six always-expanded controls occupying a full band above the
   data; keep filters compact and let the data start higher.
   ------------------------------------------------------------------------ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toolbar__spacer { margin-left: auto; }

.toolbar__search {
  flex: 1 1 16rem;
  min-width: 12rem;
}

/* Segmented control: mutually exclusive views or ranges. */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented > * {
  padding: 0.3rem var(--space-3);
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-meta);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.segmented > *:last-child { border-right: 0; }
.segmented > *:hover { background: var(--surface-raised); color: var(--text); text-decoration: none; }
.segmented > [aria-pressed="true"],
.segmented > [aria-current="true"],
.segmented > .is-active {
  background: var(--accent-quiet);
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   9. Forms
   ------------------------------------------------------------------------ */

.field { display: block; margin-bottom: var(--space-4); }

.field__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-meta);
  font-weight: 500;
  color: var(--text);
}

.field__hint {
  margin-top: var(--space-2);
  font-size: var(--text-meta);
  color: var(--text-tertiary);
}

.field__error {
  margin-top: var(--space-2);
  font-size: var(--text-meta);
  color: var(--status-danger);
}

.field__req { color: var(--status-danger); margin-left: 2px; }

/* Element selectors are wrapped in :where() so they carry ZERO specificity.
   Pages not yet migrated keep their own control styling and are not
   overridden by the system's defaults. Opt-in classes below keep normal
   specificity so a migrated page can rely on them. */
.input,
.select,
.textarea,
:where(
  input[type="text"],
  input[type="email"],
  input[type="search"],
  input[type="password"],
  input[type="date"],
  input[type="number"],
  select,
  textarea
) {
  width: 100%;
  padding: 0.4rem var(--space-3);
  min-height: 32px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-body);
  font-family: inherit;
  transition: border-color var(--duration) var(--ease);
}

:where(textarea) { min-height: 7rem; resize: vertical; line-height: var(--leading-normal); }
.textarea { min-height: 7rem; resize: vertical; line-height: var(--leading-normal); }

.input::placeholder,
:where(textarea, input)::placeholder { color: var(--text-tertiary); }

.input:hover,
:where(select, textarea, input):hover { border-color: var(--text-tertiary); }

.input:focus-visible,
:where(select, textarea, input):focus-visible { border-color: var(--accent); box-shadow: var(--focus-ring); }

/* Selects inside a dense table row must still show their full value. The
   previous build clipped these to "PEN", "MEDIU", "Unassig". */
:where(select) {
  color-scheme: dark;
  min-width: 0;
  padding-right: var(--space-5);
  text-overflow: ellipsis;
}

.select--inline {
  min-height: 26px;
  padding: 0.15rem var(--space-4) 0.15rem var(--space-2);
  font-size: var(--text-meta);
  background-color: transparent;
  border-color: var(--border);
  width: auto;
  min-width: 7.5rem;
}

/* Choice cards: a radio group presented as selectable panels. */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-2);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.choice:hover { border-color: var(--border-strong); background: var(--surface-raised); }
.choice:has(:checked) { border-color: var(--accent); background: var(--accent-quiet); }
.choice:has(:focus-visible) { box-shadow: var(--focus-ring); }
.choice input { margin-top: 0.2rem; flex: none; accent-color: var(--accent); }
.choice__title { font-weight: 500; }
.choice__note {
  display: block;
  margin-top: 2px;
  font-size: var(--text-meta);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   10. Tables

   Below 900px a `.table--cards` table reflows to one card per row using the
   data-label attribute on each cell, rather than scrolling 3.5x horizontally
   with no affordance.
   ------------------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-meta);
}

.table th {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-tertiary);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--duration) var(--ease); }
.table tbody tr:hover { background: var(--surface-raised); }

/* The primary column carries the most weight and gets the remaining width. */
.table__primary { font-size: var(--text-body); font-weight: 500; color: var(--text); width: 40%; }
.table__primary a { color: var(--text); }
.table__primary a:hover { color: var(--accent); text-decoration: none; }
.table__sub {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--text-tertiary);
}

.table td.table__num { font-family: var(--font-mono); text-align: right; }
.table td.table__fit { width: 1%; white-space: nowrap; }

/* Status rail on a table row. */
.table tbody tr[data-status] > td:first-child {
  box-shadow: inset 2px 0 0 var(--status, var(--status-idle));
}

@media (max-width: 900px) {
  .table--cards { display: block; }
  .table--cards thead { display: none; }
  .table--cards tbody,
  .table--cards tr,
  .table--cards td { display: block; width: auto; }

  .table--cards tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }

  .table--cards tr[data-status] { border-left: 2px solid var(--status, var(--status-idle)); }
  /* Must match the base rule's specificity or higher — the base selector
     includes `tbody`, which outranked an earlier version of this reset and
     left both rails drawn at once. */
  .table--cards tbody tr[data-status] > td:first-child { box-shadow: none; }

  .table--cards td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-1) 0;
    border: 0;
  }

  .table--cards td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--font-mono);
    font-size: var(--text-label);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-tertiary);
  }

  .table--cards td.table__primary {
    display: block;
    width: auto;
    padding-bottom: var(--space-2);
  }

  .table--cards td.table__primary::before { display: none; }
}

/* ---------------------------------------------------------------------------
   11. Empty states

   Every list, table and panel that can be empty gets one. The previous build
   rendered blank voids on the admin overview and analytics page.
   ------------------------------------------------------------------------ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.empty-state__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-tertiary);
  font-size: 1rem;
}

.empty-state__title { font-size: var(--text-title); font-weight: 600; }

.empty-state__body {
  font-size: var(--text-meta);
  color: var(--text-secondary);
  max-width: 44ch;
}

.empty-state--inline { padding: var(--space-5) var(--space-4); }
.empty-state[hidden] { display: none; }

/* ---------------------------------------------------------------------------
   12. Notices
   ------------------------------------------------------------------------ */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--status-quiet, var(--surface-raised));
  border: 1px solid color-mix(in srgb, var(--status, var(--border-strong)) 30%, transparent);
  border-left-width: 2px;
  border-radius: var(--radius);
  font-size: var(--text-meta);
  color: var(--text-secondary);
}

.notice__icon { color: var(--status, var(--text-tertiary)); flex: none; margin-top: 0.15rem; }

/* ---------------------------------------------------------------------------
   13. Definition lists — labelled facts
   ------------------------------------------------------------------------ */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-4) var(--space-5);
}

.fact__label {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-tertiary);
}

.fact__value { margin-top: var(--space-1); font-size: var(--text-body); overflow-wrap: anywhere; }

/* Compact key/value rows for a detail sidebar. */
.facts--rows { display: block; }
.facts--rows > div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.facts--rows > div:last-child { border-bottom: 0; }
.facts--rows .fact__value { margin-top: 0; text-align: right; }

/* ---------------------------------------------------------------------------
   14. Modals and drawers
   ------------------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(4, 7, 9, 0.72);
}

.modal.is-open,
.modal.show,
.modal.open { display: flex; }

.modal__panel {
  width: min(38rem, 100%);
  max-height: min(85vh, 46rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.modal__body { padding: var(--space-5); overflow-y: auto; }

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}

.modal__panel--wide { width: min(60rem, 100%); }

/* ---------------------------------------------------------------------------
   15. Toasts
   ------------------------------------------------------------------------ */

#toast-container {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-width: 16rem;
  max-width: 26rem;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left: 2px solid var(--status, var(--accent));
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  font-size: var(--text-meta);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
  pointer-events: auto;
}

.toast.show { opacity: 1; transform: none; }
.toast.success { --status: var(--status-ok); }
.toast.error   { --status: var(--status-danger); }
.toast.info    { --status: var(--status-info); }
.toast i { color: var(--status, var(--accent)); }

/* ---------------------------------------------------------------------------
   16. Spinner
   ------------------------------------------------------------------------ */

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex: none;
}

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

/* ---------------------------------------------------------------------------
   17. Layout utilities
   ------------------------------------------------------------------------ */

.stack       { display: flex; flex-direction: column; gap: var(--space-5); }
.stack--tight { gap: var(--space-3); }
.stack--loose { gap: var(--space-6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.row--tight { gap: var(--space-2); }
.row--top { align-items: flex-start; }
.row--between { justify-content: space-between; }
.push { margin-left: auto; }

/* Asymmetric split for a main column plus a detail rail. `align-items: start`
   stops the short column from stretching to match the tall one and leaving
   several hundred pixels of empty card, which the previous admin overview did. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

@media (min-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
  .split--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); }

.hide { display: none !important; }
@media (max-width: 800px) { .hide-sm { display: none !important; } }
@media (min-width: 801px) { .only-sm { display: none !important; } }

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

/* Skip link — first tab stop on every page. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 400;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-weight: 600;
  transition: top var(--duration) var(--ease);
}

.skip-link:focus { top: var(--space-4); text-decoration: none; }

/* ---------------------------------------------------------------------------
   18. Announcements dock

   Collapsed to a pill in the corner; expands to a panel. Ships maintenance
   notices without interrupting whatever the operator is doing.
   ------------------------------------------------------------------------ */

/* An author `display` wins over the UA rule for [hidden], so it must be
   restated here or the dock renders even when there is nothing to show. */
.announce-fab[hidden] { display: none; }

.announce-fab {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 180;
  width: min(23rem, calc(100vw - var(--space-6)));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-end;
}

.announce-fab__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left: 2px solid var(--status-info);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  color: var(--text);
  font-size: var(--text-meta);
  cursor: pointer;
}

.announce-fab__toggle:hover { border-color: var(--status-info); }
.announce-fab__toggle i { color: var(--status-info); }

.announce-fab__count {
  padding: 0 var(--space-2);
  min-width: 1.25rem;
  text-align: center;
  background: var(--status-info-quiet);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--status-info);
}

.announce-fab__panel {
  order: -1;
  width: 100%;
  max-height: 55vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.announce-fab.collapsed .announce-fab__panel { display: none; }

/* Forms and reports keep notices in the header, clear of their action buttons. */
.inline-announcements { min-width: 0; max-width: 100%; }
.inline-announcements .announce-fab {
  position: static;
  inset: auto;
  z-index: auto;
  width: min(23rem, 100%);
  align-items: stretch;
}
.inline-announcements .announce-fab__toggle { min-height: 44px; }
.inline-announcements .announce-fab__panel {
  order: initial;
  max-height: min(35vh, 18rem);
  overflow-y: auto;
}

.announce-item { padding: var(--space-4); border-bottom: 1px solid var(--border); }
.announce-item:last-child { border-bottom: 0; }
.announce-item h4 { font-size: var(--text-body); font-weight: 600; margin-bottom: var(--space-2); }
.announce-item__body { font-size: var(--text-meta); color: var(--text-secondary); }
.announce-item__body :where(p, ul, ol) { margin-bottom: var(--space-2); }

/* ---------------------------------------------------------------------------
   19. Drawer

   A panel that slides in from the right for secondary detail — a ticket queue,
   a record preview — without leaving the page.
   ------------------------------------------------------------------------ */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  width: min(30rem, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-panel);
  transform: translateX(101%);
  transition: transform var(--duration) var(--ease);
  visibility: hidden;
}

.drawer.open { transform: none; visibility: visible; }

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.drawer__body { padding: var(--space-5); overflow-y: auto; flex: 1; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(4, 7, 9, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration) var(--ease);
}

.drawer-backdrop.open { opacity: 1; visibility: visible; }

/* Directional change on a metric. This is genuinely state, so it draws on the
   status palette; the caret carries the direction so it is never colour alone. */
.trend-up,
.trend-down {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-label);
}

.trend-up { color: var(--status-ok); }
.trend-down { color: var(--status-danger); }

/* ---------------------------------------------------------------------------
   20. Bar series

   A small discrete-period chart (weekly intake, daily counts). One series, so
   no legend — the panel title names it — and every bar is directly labelled,
   which is legible at this size and removes the need for a hover layer.
   2px gaps between bars; rounded data-ends anchored to the baseline.
   ------------------------------------------------------------------------ */

.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 150px;
}

.bars__col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
}

.bars__value {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--text-secondary);
}

.bars__bar {
  width: 100%;
  min-height: 2px;
  background: var(--chart-1);
  border-radius: var(--radius) var(--radius) 0 0;
  transition: background var(--duration) var(--ease);
}

.bars__col:hover .bars__bar { background: var(--chart-2); }

/* An all-zero series still needs a baseline, or the panel reads as broken. */
.bars__bar--empty { background: var(--border-strong); }

.bars__axis {
  display: flex;
  gap: 2px;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--chart-grid);
}

.bars__axis > * {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Eight date labels do not fit on a phone — they all ellipsis to nothing.
   Hide alternates with visibility so the columns stay aligned to their bars. */
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .bars__axis > *:nth-child(even) { visibility: hidden; }
  /* The surviving labels keep their track width but may spill into the hidden
     neighbour's space, otherwise they ellipsis away to nothing. */
  .bars__axis > *:nth-child(odd) { overflow: visible; text-overflow: clip; }
}

/* ---------------------------------------------------------------------------
   21. File upload

   A drop target plus the list of chosen files. `.drag-over` and the counter's
   limit classes are set by page scripts; keep those names if you touch this.
   ------------------------------------------------------------------------ */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-quiet);
}

.dropzone__icon { font-size: 1.1rem; color: var(--text-tertiary); }

.filerow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filerow__name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-meta);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Validation. The message is always present in the markup and revealed here,
   so a failing field is never announced by colour alone. */
.field.has-error :where(.input, input, select, textarea) {
  border-color: var(--status-danger);
}

.field .field__error { display: none; }
.field.has-error .field__error { display: block; }

/* Character counters: neutral until the limit is close. */
.counter { font-family: var(--font-mono); font-size: var(--text-label); color: var(--text-tertiary); }
.counter.near-limit { color: var(--status-warn); }
.counter.at-limit { color: var(--status-danger); }

/* ---------------------------------------------------------------------------
   22. Tabs

   A write/preview pair or any small in-panel switch. `.active` is the class
   page scripts already toggle, so it is what this responds to.
   ------------------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.tab {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: var(--text-meta);
  cursor: pointer;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------------------------------------------------------------------------
   23. Score dial

   A single headline number with its scale drawn around it. Inherits its colour
   from data-status like everything else, so a failing score reads as failing
   without a second palette.
   ------------------------------------------------------------------------ */

.dial { position: relative; width: 120px; height: 120px; flex: none; }

.dial__svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.dial__track { fill: none; stroke: var(--surface-raised); stroke-width: 8; }

.dial__fill {
  fill: none;
  stroke: var(--status, var(--accent));
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 1.2s var(--ease);
}

.dial__value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-metric);
  font-weight: 500;
  color: var(--text);
}

/* ---------------------------------------------------------------------------
   24. Dot bar

   A compact pass/fail strip: one dot per check. Always paired with a written
   count, so it is a density aid rather than the only signal.
   ------------------------------------------------------------------------ */

.dotbar { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }

.dotbar__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-idle);
}

.dotbar__dot--pass { background: var(--status-ok); }
.dotbar__dot--fail { background: var(--status-danger); }

/* ---------------------------------------------------------------------------
   25. Disclosure

   An expandable row. `open` is the class the SEO script already toggles.
   ------------------------------------------------------------------------ */

.disclosure { border-bottom: 1px solid var(--border); }
.disclosure:last-child { border-bottom: 0; }

.disclosure__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.disclosure__head:hover { background: var(--surface-raised); }

.disclosure__chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  transition: transform var(--duration) var(--ease);
}

.disclosure.open .disclosure__chevron { transform: rotate(90deg); }

.disclosure__body { display: none; padding: 0 var(--space-4) var(--space-4); }
.disclosure.open .disclosure__body { display: block; }

/* ---------------------------------------------------------------------------
   26. Row links

   The whole row opens the record, not just the title text — a title is a poor
   tap target on a phone. Implemented as a stretched link rather than an
   onclick so the row keeps real anchor behaviour: keyboard focus, middle-click
   to open in a tab, copy link address, and text selection elsewhere in the row.
   ------------------------------------------------------------------------ */

.table tbody tr:has(.rowlink) { position: relative; }

.rowlink::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Anything genuinely interactive in the row must sit above the stretched
   link, or it becomes unclickable. */
.table td :where(a:not(.rowlink), button, select, input, label:not(.sr-only)) { position: relative; z-index: 2; }
.panel__body--flush:has(> .table) { overflow-x: auto; }

@media (max-width: 900px) {
  .table--cards tbody tr:has(.rowlink) { position: relative; }
}

/* ---------------------------------------------------------------------------
   27. Attachments

   A scanned-clean image renders inline; everything else is a labelled file
   row. Scan state is always shown, so an unscanned or infected file can never
   be mistaken for a safe one.
   ------------------------------------------------------------------------ */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-start;
}

.attachment {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 16rem;
  color: var(--text);
}

.attachment:hover { border-color: var(--border-strong); text-decoration: none; }

.attachment__thumb {
  display: block;
  width: 100%;
  max-height: 12rem;
  object-fit: contain;
  background: var(--surface-sunken);
  border-radius: var(--radius);
}

.attachment__name {
  font-size: var(--text-meta);
  overflow-wrap: anywhere;
}

/* A file still being scanned is not downloadable yet. */
.attachment.pending-download { opacity: 0.7; cursor: not-allowed; }

/* ---------------------------------------------------------------------------
   28. Icons

   Inline SVG sprite (templates/_icons.html), replacing the Font Awesome CDN.
   Icons inherit currentColor, so they take their colour from the status
   system, the accent, or muted text with no per-icon rules.
   ------------------------------------------------------------------------ */

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
  overflow: visible;
}

/* A filled glyph (the trend carets) opts out of the stroke treatment. */
.icon [fill="currentColor"] { stroke: none; }

.icon--lg { width: 1.25em; height: 1.25em; }
.icon--spin { animation: spin 700ms linear infinite; }

/* An icon alone inside a bordered placeholder should not look cramped. */
.empty-state__icon .icon { width: 1.1em; height: 1.1em; }

/* Ranked traffic lists share the same compact data treatment as tables. */
.page-item + .page-item { margin-top: var(--space-4); }
.page-info { display: flex; justify-content: space-between; gap: var(--space-4); }
.page-path { min-width: 0; overflow-wrap: anywhere; color: var(--text-secondary); }
.page-count { font-family: var(--font-mono); flex: none; }
.page-bar-wrap { height: 4px; background: var(--surface-raised); margin-top: var(--space-2); }
.page-bar { height: 100%; background: var(--chart-1); }
.location-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); font-size: var(--text-meta); overflow-wrap: anywhere; }
.location-row > :last-child { font-family: var(--font-mono); }
.location-row:last-child { border-bottom: 0; }
.tag > .icon { display: inline-block; vertical-align: middle; margin-right: var(--space-2); }

.monitor-card, .bk-item, .bk-summary-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.monitor-card:last-child, .bk-item:last-child { border-bottom: 0; }
.monitor-left, .monitor-right { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.monitor-right { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-meta); }
.monitor-name { overflow-wrap: anywhere; }
.monitor-response, .bk-item-label, .bk-summary-bar { color: var(--text-secondary); font-size: var(--text-meta); }
.monitor-status-dot, .bk-status-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--status-idle); }
.monitor-status-dot.up, .bk-status-dot.succeeded { background: var(--status-ok); }
.monitor-status-dot.down, .bk-status-dot.failed { background: var(--status-danger); }
.bk-item-badge { margin-left: auto; font-size: var(--text-meta); }
.bk-item-badge.succeeded { color: var(--status-ok); }
.bk-item-badge.failed { color: var(--status-danger); }
.bk-empty { display: grid; justify-items: center; gap: var(--space-4); padding: var(--space-5); text-align: center; color: var(--text-secondary); }
fieldset.field { margin: 0; padding: var(--space-4); border: 1px solid var(--border); }

@media (max-width: 640px) {
  .stat { padding: var(--space-4); }
  .stat__value { font-size: 1.5rem; overflow-wrap: anywhere; }
  .stat__note { font-size: var(--text-label); }
  .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .page-head { padding-bottom: var(--space-5); margin-bottom: var(--space-5); }
  .btn { white-space: normal; line-height: 1.3; }
}

/* Native popup menus need their own opaque surface on Windows browsers. */
:where(select option, select optgroup) {
  background-color: var(--surface);
  color: var(--text);
}
