/* ===============================================================
 * Yggdrasil Admin UI — component stylesheet.
 *
 * PLAIN, SELF-CONTAINED CSS. This file used to be read from disk on
 * every request and inlined into a `<style type="text/tailwindcss">`
 * block so the Tailwind Play CDN could expand its `@apply` / `theme()`
 * directives IN THE BROWSER. That meant: a third-party script had to
 * load and run a CSS compiler before the console could paint, the
 * ~38 KB of CSS shipped uncacheable inside every HTML response, and an
 * unpinned CDN sat in the critical path of an operator console. The
 * markup never used a single raw Tailwind utility class — the CDN
 * existed purely to compile this file — so the directives were expanded
 * once, by hand, and the CDN dropped. layout.php now serves this file
 * as a normal cacheable <link>.
 *
 * Design tokens live in `:root` below as real CSS custom properties.
 * That is also what makes the handful of `var(--line)` / `var(--page)` /
 * `var(--ink-muted)` references in the page-level inline styles resolve
 * — previously NOTHING defined them and they silently fell back (two of
 * them had no fallback at all, so no colour was applied).
 *
 * Editing: this is hand-written CSS. Use the tokens, not raw hex.
 * =============================================================== */


/* ===== Design tokens =========================================== */
:root {
  /* Brand — forest green. */
  --brand-50:  #F0FDF4;
  --brand-100: #DCFCE7;
  --brand-200: #BBF7D0;
  --brand-300: #86EFAC;
  --brand-400: #4ADE80;
  --brand-500: #1F8A4C;
  --brand-600: #15803D;
  --brand-700: #166534;
  --brand-800: #064E3B;
  --brand-900: #022C22;

  /* Surfaces + text. */
  --surface:   #FFFFFF;
  --page:      #F8FAFC;
  --ink:       #0F172A;
  --ink-muted: #64748B;
  --ink-soft:  #94A3B8;

  /* Borders. --border is a legacy alias used by a few inline styles. */
  --line:        #E2E8F0;
  --line-strong: #CBD5E1;
  --border:      #E2E8F0;

  /* Status palette. */
  --danger:        #DC2626;
  --danger-strong: #B91C1C;
  --danger-bg:     #FEF2F2;
  --danger-border: #FECACA;
  --danger-ink:    #991B1B;
  --warn-bg:       #FFFBEB;
  --warn-border:   #FDE68A;
  --warn-ink:      #92400E;
  --warn-ink-soft: #B45309;
  --info-bg:       #EFF6FF;
  --info-border:   #BFDBFE;
  --info-ink:      #1E40AF;
  --info-ink-soft: #1D4ED8;

  --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --shadow-card: 0 1px 2px 0 rgb(15 23 42 / 0.04), 0 1px 3px 0 rgb(15 23 42 / 0.06);
  --shadow-pop:  0 8px 24px -8px rgb(15 23 42 / 0.12), 0 2px 6px -2px rgb(15 23 42 / 0.06);
  --shadow-modal: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  --focus-ring: 0 0 0 1px var(--page), 0 0 0 3px rgb(31 138 76 / 0.4);
}


/* ===== Base reset ==============================================
 * The subset of Tailwind Preflight the layout actually depends on.
 * Kept deliberately small and explicit rather than pulling a whole
 * vendor reset in: every rule here exists because a component below
 * (or a page template) assumes it. */
*,
*::before,
*::after {
  box-sizing: border-box;
  border: 0 solid var(--line);   /* width 0 + style solid: `border-width` alone is enough to draw one */
}
html {
  -webkit-text-size-adjust: 100%;
  line-height: 1.5;
  -moz-tab-size: 4;
  tab-size: 4;
}
body {
  margin: 0;
  line-height: inherit;
  background-color: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 13.5px;
  font-feature-settings: 'cv11', 'ss01';  /* Inter tweaks: clearer 1/I, single-storey a */
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-size: inherit; font-weight: inherit; }
p, blockquote, dl, dd, figure, pre { margin: 0; }
ol, ul, menu { margin: 0; padding: 0; list-style: none; }
hr { height: 0; color: inherit; border-top-width: 1px; }
img, svg, video, canvas, audio, iframe, embed, object { display: block; vertical-align: middle; }
img, video { max-width: 100%; height: auto; }
table { text-indent: 0; border-color: inherit; border-collapse: collapse; }
button, input, optgroup, select, textarea {
  font-family: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}
/* Form controls must not inherit an ancestor's uppercase transform. */
button, select { text-transform: none; }
button, [type='button'], [type='reset'], [type='submit'] {
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
}
button, [role='button'] { cursor: pointer; }
::placeholder { opacity: 1; color: var(--ink-soft); }
textarea { resize: vertical; }
summary { display: list-item; }
[hidden] { display: none; }

h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: 0.875rem; line-height: 1.25rem; font-weight: 600; letter-spacing: -0.025em; }
h3 {
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
p { line-height: 1.625; }
hr { margin: 1rem 0; border-color: var(--line); }
a {
  color: var(--brand-600);
  text-decoration-line: none;
  transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1),
              background-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
a:hover { color: var(--brand-700); }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 1em; }
code {
  font-size: 11.5px;
  background-color: var(--page);
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
  color: var(--ink);
}
pre {
  background-color: var(--page);
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.75rem;
  overflow-x: auto;
  border-width: 1px;
  border-color: var(--line);
  line-height: 1.625;
}
*:focus-visible {
  /* A TRANSPARENT outline rather than `outline: none`: Windows
     High-Contrast mode forces outline colours but cannot resurrect an
     outline that was removed, so `none` would leave those users with no
     focus indicator at all (the box-shadow ring is dropped in forced-
     colours mode). */
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}
/* Tabular numbers for stats / counts / IDs anywhere. */
.stat .value, td code, th + th, .meta-chip .meta-value {
  font-variant-numeric: tabular-nums;
}


/* ===== App shell =============================================== */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border-right-width: 1px;
  border-right-color: var(--line);
  height: 100vh;
  padding: 18px 12px;
  gap: 1px;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0 0.5rem 16px;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.sidebar .brand:hover { color: inherit; }
.sidebar .brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
}
/* yggdrasil-logo-color.png is a full-colour mark on transparent — show
   it as-is on the light sidebar (no badge backing needed). */
.sidebar .brand-mark .brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.sidebar .brand-text {
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar nav {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 1px;
}
.sidebar .nav-section {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 1rem 0.625rem 0.375rem;
  letter-spacing: 0.08em;
}
.sidebar .nav-section:first-child { padding-top: 4px; }
.sidebar .nav-item {
  display: flex;
  align-items: center;
  position: relative;
  border-radius: 0.375rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  gap: 10px;
  padding: 6px 10px;
  transition: background-color 120ms ease, color 120ms ease;
}
.sidebar .nav-item:hover { background-color: var(--page); color: var(--ink); }
.sidebar .nav-item.active {
  background-color: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.sidebar .nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background-color: var(--brand-500);
}
.sidebar .nav-item.active:hover { background-color: var(--brand-100); }
.sidebar .nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 2;
}
.sidebar-foot {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line);
}
.sidebar-foot .user-row {
  display: flex;
  align-items: center;
  padding: 0 0.25rem;
  gap: 8px;
}
.sidebar-foot .user-avatar {
  border-radius: 9999px;
  background-color: var(--brand-100);
  color: var(--brand-700);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.sidebar-foot .user-email {
  font-size: 11.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 0%;
}
.sidebar-foot form button { width: 100%; }

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background-color: var(--surface);
  gap: 24px;
  padding: 24px 32px 18px;
  border-bottom: 1px solid var(--line);
}
.page-header h1 {
  font-weight: 600;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.page-header .crumb {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-header .crumb a { color: var(--ink-muted); transition: color 120ms; }
.page-header .crumb a:hover { color: var(--ink); }
.page-header .subtitle {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.page-header .actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}
.page-content {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  padding: 24px 32px 32px;
  gap: 20px;
  max-width: 1440px;
  width: 100%;
}


/* ===== Cards =================================================== */
.card {
  background-color: var(--surface);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
}
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background-color: var(--surface);
  padding: 14px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.card-header h2 {
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  font-size: 13.5px;
  letter-spacing: -0.005em;
}
.card-header .hint {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 400;
}
.card-body { padding: 20px; }
.card-body.flush { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card-body.flush > table { min-width: 100%; }
/* Tighter card-body when stacking forms — fields breathe enough at p-5;
 * this just removes the bottom-padding doubling when a card has only one
 * card-body element followed by a card-body.flush. */
.card > .card-body + .card-body.flush {
  border-top: 1px solid var(--line);
}
details.card > summary.card-header,
.card > details > summary.card-header {
  cursor: pointer;
  /* .card-header is display:flex, which suppresses the native ::marker —
     and `list-style` can't bring it back, because it doesn't affect
     display. Draw the triangle ourselves.
     It is positioned ABSOLUTELY, not added as a flex item: .card-header
     is justify-content:space-between, and a third flex item would change
     how the existing children distribute (totp.php's summary has an <h2>
     AND a .hint that are meant to sit at opposite edges). */
  position: relative;
  list-style: none;
  padding-left: 34px;
}
details.card > summary.card-header::-webkit-details-marker,
.card > details > summary.card-header::-webkit-details-marker {
  display: none;
}
details.card > summary.card-header::before,
.card > details > summary.card-header::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid var(--ink-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: translateY(-50%);
  transition: transform 120ms ease;
}
details.card[open] > summary.card-header::before,
.card > details[open] > summary.card-header::before {
  transform: translateY(-50%) rotate(90deg);
}
details.card[open] > summary.card-header {
  border-bottom: 1px solid var(--line);
}
details.card:not([open]) > summary.card-header {
  border-bottom: none;
}


/* ===== Buttons ================================================= */
.btn, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  border-radius: 0.375rem;
  color: var(--ink);
  text-decoration-line: none;
  cursor: pointer;
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn:hover, button:hover, input[type="submit"]:hover {
  background: var(--page);
  border-color: var(--line-strong);
}
.btn[disabled], button[disabled], input[type="submit"][disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
/* Submit buttons default to primary unless a variant is set. */
button[type="submit"]:not(.btn-ghost):not(.btn-danger):not(.btn-sm):not(.btn-small),
.btn-primary {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: white;
}
button[type="submit"]:not(.btn-ghost):not(.btn-danger):not(.btn-sm):not(.btn-small):hover,
.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
}
.btn-ghost,
button[type="submit"].btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-muted);
}
.btn-ghost:hover,
button[type="submit"].btn-ghost:hover {
  background: var(--page);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-danger,
button[type="submit"].btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.btn-danger:hover,
button[type="submit"].btn-danger:hover {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: white;
}
.btn-sm,
button.btn-sm,
.btn-small,
button.btn-small,
.actions-cell .btn-sm {
  height: 26px;
  padding: 0 8px;
  font-size: 11.5px;
  gap: 4px;
}
.btn svg, button svg { width: 14px; height: 14px; flex-shrink: 0; stroke-width: 2; }
.btn-sm svg, .btn-small svg, .actions-cell .btn-sm svg { width: 12px; height: 12px; }

/* Read-only role: the backend 403s every write, so the UI renders the
 * control inert rather than inviting a click that can only fail. */
.btn.is-readonly-locked,
button.is-readonly-locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}


/* ===== Forms ===================================================
 * Every text-entry control across the admin UI shares the same
 * 32px height, 12.5px font, 1px line border, brand-tinted focus
 * halo. Listed explicitly so we don't pick up `type="hidden"` or
 * `type="submit"` (those are handled separately). */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input:not([type]),
select,
textarea {
  background-color: var(--surface);
  color: var(--ink);
  border-radius: 0.375rem;
  width: 100%;
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  font-family: var(--font-sans);
  border: 1px solid var(--line);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  line-height: 30px;     /* h-32 minus 2×1 border so text vertically centers */
  box-sizing: border-box;
}
input::placeholder, textarea::placeholder { color: var(--ink-soft); }
input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="tel"]:hover,
input[type="date"]:hover,
input[type="time"]:hover,
input[type="datetime-local"]:hover,
input[type="month"]:hover,
input[type="week"]:hover,
input:not([type]):hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgb(31 138 76 / 0.12);
}
/* WebKit's native date / time picker indicators inherit colour from
 * `color-scheme`; force a neutral cursor stroke that matches the
 * select chevron and the rest of the palette. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  filter: grayscale(1);
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 0.9;
}
/* Trim Firefox's default inner padding on number inputs so they line
 * up with text inputs on the same row. */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
textarea {
  height: auto;
  padding: 8px 11px;
  min-height: 80px;
  font-family: var(--font-mono);
  line-height: 1.625;
  font-size: 12px;
}
select {
  padding-right: 32px;
  appearance: none;
  background-repeat: no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-position: right 10px center;
  background-size: 12px;
  cursor: pointer;
}
input[type="checkbox"], input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-500);
  cursor: pointer;
}

label {
  display: block;
  font-weight: 500;
  color: var(--ink);
  font-size: 11.5px;
  margin: 0 0 5px 0;
  letter-spacing: 0.003em;
}
label .hint, label small {
  display: block;
  margin: 0 0 4px 0;
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-muted);
}

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.form-inline label { margin-bottom: 0; }
/* Footer button row under a stacked form. */
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.form-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.form-section > *:not(.form-section-label, summary) + * { margin-top: 12px; }
.form-section:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.form-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 10px;
}


/* ===== Tables ================================================== */
table {
  width: 100%;
  background: var(--surface);
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.075em;
  color: var(--ink-muted);
  text-align: left;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  line-height: 1.45;
}
tbody tr {
  transition: background-color 80ms ease;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--page); }
tbody td code { font-size: 11.5px; background: transparent; padding: 0; }
tbody td small { display: inline; font-size: 11.5px; color: var(--ink-muted); margin: 0; }
tbody td strong { font-weight: 600; color: var(--ink); }

/* Action cells are <td> elements — keep them as table-cells so the
 * table layout algorithm computes their column width correctly. Lay
 * out children inline-block (right-aligned) instead of flex. Using
 * `display: flex` on a <td> takes it out of the table grid and the
 * cell content can drift far past the column boundary. */
td.actions-cell,
.actions-cell {
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}
td.actions-cell > form,
td.actions-cell form[style*="display:inline"],
.actions-cell > form,
.actions-cell form[style*="display:inline"] {
  display: inline-block !important;
  margin: 0;
  vertical-align: middle;
}
td.actions-cell > *,
.actions-cell > * {
  vertical-align: middle;
}
td.actions-cell > * + *,
.actions-cell > * + * {
  margin-left: 4px;
}
.actions-cell .btn,
.actions-cell button,
.actions-cell a.btn {
  white-space: nowrap;
}
.actions-cell .actions-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
  vertical-align: middle;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cell-stack > * { line-height: 1.4; }
.cell-stack .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
  margin-right: 6px;
}

/* `<td class="row-id">` — sources / credentials list. Stacks display
 * name (bold), an inline `#id` tag, and a muted URL on the next line. */
td.row-id strong {
  font-weight: 600;
  color: var(--ink);
  font-size: 13.5px;
}
td.row-id small {
  font-size: 11px;
  color: var(--ink-soft);
  margin-left: 6px;
  font-family: var(--font-mono);
}
td.row-id .url {
  display: block;
  font-size: 11.5px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 520px;
}


/* ===== Status badges =========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.badge svg { width: 11px; height: 11px; }
.badge-active   { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.badge-success  { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.badge-inactive { background: var(--page); color: var(--ink-muted); border-color: var(--line); }
.badge-neutral  { background: var(--page); color: var(--ink-muted); border-color: var(--line); }
.badge-warning  { background: var(--warn-bg); color: var(--warn-ink-soft); border-color: var(--warn-border); }
.badge-danger   { background: var(--danger-bg); color: var(--danger-strong); border-color: var(--danger-border); }
.badge-info     { background: var(--info-bg); color: var(--info-ink-soft); border-color: var(--info-border); }


/* ===== Notices / flash messages ================================ */
.notice,
.err {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.notice::before,
.err::before {
  /* Inline SVG icon as ::before pseudo. Each variant picks its own icon
   * via the URL below. Sized to match the 13px text baseline. */
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px;
}
.notice-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-ink);
}
.notice-info::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231E40AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
}
.notice-success {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-800);
}
.notice-success::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23064E3B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.801 10A10 10 0 1 1 17 3.335'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E");
}
.notice-warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}
.notice-warning::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2392400E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' x2='12' y1='9' y2='13'/%3E%3Cline x1='12' x2='12.01' y1='17' y2='17'/%3E%3C/svg%3E");
}
.notice-error,
.err {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-ink);
}
.notice-error::before,
.err::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23991B1B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='15' y1='9' x2='9' y2='15'/%3E%3Cline x1='9' y1='9' x2='15' y2='15'/%3E%3C/svg%3E");
}
.notice strong,
.err strong { font-weight: 600; color: inherit; }
.notice code,
.err code { background: rgb(15 23 42 / 0.05); color: inherit; }
/* Notice content can grow — flex child sizing so any nested content
 * (icon-prefix is the first ::before, then real markup follows) wraps. */
.notice > *,
.err > * { min-width: 0; }


/* ===== Empty state ============================================= */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-muted);
}
.empty .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--page);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.empty .icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.75;
}
.empty p { margin: 0; line-height: 1.6; }
.empty p:first-of-type {
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 500;
}
.empty p + p { margin-top: 6px; font-size: 12.5px; }
.empty strong { color: var(--ink); font-weight: 600; }
.empty .btn { margin-top: 16px; }


/* ===== Stat grid (metrics) ===================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  transition: border-color 120ms ease;
}
.stat:hover { border-color: var(--line-strong); }
.stat .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat .value {
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.stat .hint { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; }


/* ===== KV grid (definition list) =============================== */
/* `<dl class="kv">` — preferred form. Grid layout, label left / value right. */
dl.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  column-gap: 0.75rem;
  row-gap: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}
dl.kv dt {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
dl.kv dd { margin: 0; color: var(--ink); }

/* `<table class="kv">` — same idea, but built on table rows (article.php).
 * The table layout handles long values + wraps gracefully on narrow widths. */
table.kv {
  font-size: 0.875rem;
  line-height: 1.25rem;
  width: auto;
}
table.kv th {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  text-align: left;
  padding: 0.25rem 1rem 0.25rem 0;
  vertical-align: top;
  width: 160px;
  white-space: nowrap;
  background: transparent;
  border-bottom: none;
  position: static;
}
table.kv td {
  color: var(--ink);
  padding: 0.25rem 0;
  vertical-align: top;
  border-bottom: none;
}
table.kv tr:hover { background: transparent; }


/* ===== Row utility =============================================
 * `.row` is a flex row of equal-width columns. When children are
 * <label>s with varying-length `<small>` help text, the inputs
 * would otherwise sit at different vertical positions inside their
 * label (right after the help). Making each label a flex column
 * with the input pushed to the bottom (`margin-top: auto`) gives
 * every input/select/textarea in the row a single shared baseline. */
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: stretch;
}
.row > * { flex: 1 1 0; min-width: 200px; }
.row > label {
  display: flex;
  flex-direction: column;
}
.row > label > input,
.row > label > select,
.row > label > textarea,
.row > label > .ts-wrapper {
  margin-top: auto;
}
.spacer { flex: 1; }
.muted { color: var(--ink-muted); }
.hint,
.help,
p.help {
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--ink-muted);
}
p.help { margin-top: 0.5rem; }

/* `<label class="checkbox">` — inline label with checkbox inside (test.php). */
label.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 0;
}
label.checkbox input { margin: 0; }


/* ===== Page header crumb hint ================================== */
.crumb { font-size: 0.75rem; line-height: 1rem; color: var(--ink-muted); }


/* ===== URL tags (source_map.php Discovered URLs) =============== */
.url-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  height: 22px;
  border-radius: 11px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none !important;
  background: transparent;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.url-tag-article {
  color: var(--brand-700);
  border-color: var(--brand-200);
  background: var(--brand-50);
}
.url-tag-article:hover {
  background: var(--brand-100);
  color: var(--brand-800);
}
.url-tag-promote {
  color: var(--brand-800);
  border-color: var(--brand-500);
  background: var(--brand-50);
}
.url-tag-promote:hover {
  background: var(--brand-200);
  border-color: var(--brand-600);
}
.url-tag-inclues {
  color: var(--ink-soft);
  border-color: var(--line);
  background: var(--page);
  font-weight: 500;
  cursor: default;
}


/* ===== Links table specifics (source_map.php) ==================
 * `table-layout: fixed` is essential here. Without it, the URL
 * column's `max-width: 0` is treated as a hint and the cell's
 * natural (unbreakable, nowrap'd) URL content dictates column
 * width — which pushes every other column out of the visible
 * card. With fixed layout, the explicit widths below are
 * authoritative and the URL column absorbs the remainder. */
.links-table {
  table-layout: fixed;
  width: 100%;
}
.links-table thead th,
.links-table tbody td {
  vertical-align: middle;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Column widths set on the header row only — fixed layout reads
 * widths from the first row exclusively. */
.links-table thead th:nth-child(1) { width: auto; }            /* URL — absorbs remainder */
.links-table thead th:nth-child(2) { width: 110px; }           /* Status badge */
.links-table thead th:nth-child(3) { width: 120px; }           /* Page type badge */
.links-table thead th:nth-child(4) { width: 150px; }           /* Discovered at */
.links-table thead th:nth-child(5) { width: 150px; }           /* Published at */
.links-table thead th.actions-col   { width: 92px; }           /* Action pill */

.links-table td.url-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  padding-right: 16px;
}
.links-table td.url-cell > a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  color: var(--ink);
}
.links-table td.url-cell > a:hover {
  color: var(--brand-700);
  text-decoration: underline;
}
.links-table tbody td small {
  display: inline;
  margin: 0;
  vertical-align: middle;
}
.links-table td.actions-cell {
  padding-right: 16px;
  text-align: right;
}


/* ===== Sources table sub-row meta strip ======================== */
.sources-table tr.src-main-row > td {
  border-bottom: none;
  padding-bottom: 8px;
}
.sources-table tr.src-meta-row > td.src-meta-cell {
  background: var(--page);
  border-top: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 14px;
}
.src-meta-bar {
  display: flex;
  flex-wrap: wrap;
  column-gap: 18px;
  row-gap: 6px;
  font-size: 11.5px;
  align-items: center;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  line-height: 1.4;
}
.meta-chip .meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
}
.meta-chip .meta-value {
  font-weight: 600;
  color: var(--ink);
}
.meta-chip .badge { margin: 0; }


/* ===== Pagination ============================================== */
.pagination, .pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.pagination .btn-sm,
.pagination span.btn-sm { min-width: 28px; padding: 0 6px; justify-content: center; }
.pagination .muted { padding: 0 4px; }


/* ===== Modal =================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 0.4);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-dialog {
  background-color: var(--surface);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 640px;
}
.modal-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2,
.modal-header h3 { font-size: 1rem; line-height: 1.5rem; font-weight: 600; margin: 0; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background-color: var(--page);
}


/* ===== Prompt-field block (configs.php Rune prompts) ===========
 * Each Rune mode (ANL / DETECT_LANG / REF / CLEAN) is a labelled
 * textarea preceded by a header with the mode name + description on
 * the left and the default/custom state + Reset button on the right.
 * CSS-grid keeps the label and description on their own rows so
 * the description never runs into the bold mode name. */
.prompt-field {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.prompt-field:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}
.prompt-field-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  margin-bottom: 14px;
}
.prompt-field-header > strong {
  grid-row: 1;
  grid-column: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.prompt-field-header > small {
  grid-row: 2;
  grid-column: 1 / -1;
  display: block;
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  color: #475569;          /* slate-600 — warmer and more readable than ink-muted */
  line-height: 1.55;
  max-width: 880px;        /* prevent over-wide single-line descriptions */
}
.prompt-field-header > small code {
  font-size: 11px;
  padding: 1px 5px;
  background: var(--brand-50);
  color: var(--brand-800);
  border: 1px solid var(--brand-200);
  border-radius: 3px;
}
.prompt-field-header > .rune-prompt-state {
  grid-row: 1;
  grid-column: 2;
  display: inline-flex;
  align-items: center;
}
.prompt-field-header > button {
  grid-row: 1;
  grid-column: 3;
  margin: 0;
}
.prompt-field > textarea {
  font-size: 12px;
  line-height: 1.6;
  padding: 12px 14px;
  background: #FAFBFC;
  border-color: var(--line);
}
.prompt-field > textarea:focus {
  background: var(--surface);
}


/* ===== Tom Select skin (recoloured + sized to match inputs) ====
 * Match the 32px height, 12.5px font, 1px line border, brand-tinted
 * focus halo of native inputs above. Multi-select chips use a
 * compact pill so the wrapper stays at 32px when empty + grows
 * only when chips wrap to a second line.
 * (.ts-* classes are created at runtime by tomselect.min.js — they
 * never appear in the PHP markup.) */
.ts-wrapper { width: 100%; }
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: var(--font-sans);
  color: var(--ink);
  min-height: 32px;
  padding: 3px 8px;
  line-height: 1.4;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
.ts-wrapper.single .ts-control {
  position: relative;
  padding: 0 32px 0 11px;
  line-height: 30px;
  display: block;
}
.ts-wrapper.single .ts-control::after {
  /* native-select chevron, same SVG as <select> above */
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat center / 12px;
}
.ts-wrapper:hover .ts-control { border-color: var(--line-strong); }
.ts-wrapper.focus .ts-control,
.ts-wrapper.focus.single .ts-control {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgb(31 138 76 / 0.12);
  outline: none;
}
.ts-wrapper.multi .ts-control > div {
  background: var(--brand-500);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 0;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.5;
}
.ts-wrapper.multi .ts-control > div.active { background: var(--brand-700); }
.ts-wrapper.multi .ts-control > div .remove {
  color: rgba(255, 255, 255, 0.75);
  border: 0;
  padding: 0 0 0 4px;
  margin-left: 4px;
  font-size: 12px;
  line-height: 1;
}
.ts-wrapper.multi .ts-control > div .remove:hover {
  color: #fff;
  background: transparent;
}
.ts-wrapper .ts-control > input {
  font-size: 12.5px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  flex: 1 1 80px;
  min-width: 60px;
  line-height: 22px;
  padding: 0;
}
.ts-wrapper .ts-control > input::placeholder { color: var(--ink-soft); }
.ts-dropdown {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow-pop);
  background: var(--surface);
  font-size: 12.5px;
  overflow: hidden;
  z-index: 50;
}
.ts-dropdown .option {
  padding: 7px 12px;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.4;
}
.ts-dropdown .option.active {
  background: var(--brand-50);
  color: var(--brand-800);
}
.ts-dropdown .option.selected { font-weight: 600; }
.ts-dropdown .option.selected.active { background: var(--brand-100); }
.ts-dropdown .no-results {
  padding: 7px 12px;
  color: var(--ink-muted);
  font-style: italic;
}


/* ===== Login page ============================================== */
body.login-page {
  background-color: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-card);
  padding: 2rem;
  width: 400px;
  max-width: 92vw;
}
.login-card .brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.login-card .logo {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-card .logo .brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-card h1 { font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; margin: 0; }
.login-card .lede {
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--ink-muted);
  margin: 0.25rem 0 1.5rem;
}
.login-card form { display: flex; flex-direction: column; gap: 0.875rem; }
.login-card form button {
  width: 100%;
  margin-top: 0.5rem;
  background-color: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
}
.login-card form button:hover {
  background-color: var(--brand-600);
  border-color: var(--brand-600);
}


/* ===== Misc page-specific bits ================================= */
/* Article title link (articles.php list rows). */
.article-title-link {
  color: var(--ink);
  font-weight: 500;
  text-decoration-line: none;
}
.article-title-link:hover { color: var(--brand-700); text-decoration-line: underline; }

/* Audit log: collapsible JSON details. */
details.audit-detail > summary {
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--brand-600);
}
details.audit-detail[open] > summary { color: var(--ink); }
details.audit-detail pre { margin-top: 0.5rem; font-size: 11px; max-height: 20rem; }

/* Article body iframe (article.php). */
/* Sits in a .card-body.flush (padding 0), so it takes the card's own
   edges: no radius of its own, and only a top rule to separate it from
   the header. (These used to be a 1px box + 6px radius that article.php
   then overrode inline on every render.) */
iframe.article-body {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background-color: var(--surface);
  min-height: 520px;
}

/* Relatedness bar (article.php analyses card — visual score). */
.rel-bar {
  display: inline-block;
  width: 6rem;
  height: 0.5rem;
  border-radius: 9999px;
  background-color: var(--page);
  border: 1px solid var(--line);
  overflow: hidden;
  vertical-align: middle;
}
.rel-bar-fill {
  display: block;
  height: 100%;
  background-color: var(--brand-500);
}

/* Rune prompt state (configs.php — "default" / "customised" pill). */
.rune-prompt-state {
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--ink-muted);
  font-weight: 500;
}
.rune-prompt-state .badge { margin-left: 0.25rem; }


/* ===== Narrow viewports ========================================
 * The console is a desktop tool, but an operator checking a crawl
 * from a tablet/phone previously got a 248px sidebar column crushing
 * the content pane (the grid had no breakpoints and the page padding
 * was a fixed 32px). Collapse to a single column and tighten the
 * gutters instead. */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar .nav-section { width: 100%; padding-top: 0.5rem; }
  .sidebar .nav-item.active::before { display: none; }
  .page-header { padding: 16px 16px 14px; flex-wrap: wrap; }
  .page-content { padding: 16px 16px 24px; gap: 16px; }
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  dl.kv { grid-template-columns: 1fr; row-gap: 0.125rem; }
  dl.kv dd { margin-bottom: 0.5rem; }
}


/* ===== Print =================================================== */
@media print {
  .sidebar, .page-header .actions, .pagination, .pager { display: none !important; }
  .app-shell { display: block; }
  .page-content { padding: 0; }
}
