/* ==========================================================================
   Recon Console Kit — the admin/auth interface language for this app.
   One file, no build step, no dependencies beyond the IBM Plex webfont link
   in base.html.twig.

   Everything below is prefixed `rc-` so it cannot collide with the
   customer-facing pages (public/embed/**, exam/**, unsubscribe/**, buy/**)
   that carry their own separate look.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────
   Three theme states. The bare :root carries the COMPLETE light palette;
   the media query is guarded so an explicit light choice beats a dark OS;
   the attribute selector lets the toggle win in both directions. */
:root {
  --ink:        #1d2327;
  --ink-muted:  #5a6672;
  --ink-faint:  #7d8894;
  --ground:     #f2f4f7;
  --surface:    #ffffff;
  --surface-2:  #f7f9fb;
  --line:       #d7dde5;
  --line-soft:  #e6ebf1;

  --accent:      #2271b1;
  --accent-ink:  #135e96;
  --accent-wash: #eaf2f9;

  --critical:      #b32d2e;
  --critical-wash: #fbeaea;
  --warn:          #8a5d00;
  --warn-wash:     #fbf3e2;
  --good:          #00795b;
  --good-wash:     #e6f4ef;

  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0:  0.9375rem;
  --step-1:  1.0625rem;
  --step-2:  1.375rem;
  --step-3:  1.875rem;
  --step-4:  2.5rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius:    3px;
  --radius-lg: 6px;
  --shadow:    0 1px 2px rgba(29, 35, 39, .08);
  --label-col: 220px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:        #dfe5ec;
    --ink-muted:  #98a4b2;
    --ink-faint:  #78848f;
    --ground:     #10141a;
    --surface:    #181d25;
    --surface-2:  #1e242d;
    --line:       #2f3742;
    --line-soft:  #262d36;

    --accent:      #6aa9dc;
    --accent-ink:  #8dc0e8;
    --accent-wash: #16283a;

    --critical:      #f08a8a;
    --critical-wash: #331b1c;
    --warn:          #ddb161;
    --warn-wash:     #33280f;
    --good:          #5fc3a4;
    --good-wash:     #122c25;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --ink:        #dfe5ec;
  --ink-muted:  #98a4b2;
  --ink-faint:  #78848f;
  --ground:     #10141a;
  --surface:    #181d25;
  --surface-2:  #1e242d;
  --line:       #2f3742;
  --line-soft:  #262d36;

  --accent:      #6aa9dc;
  --accent-ink:  #8dc0e8;
  --accent-wash: #16283a;

  --critical:      #f08a8a;
  --critical-wash: #331b1c;
  --warn:          #ddb161;
  --warn-wash:     #33280f;
  --good:          #5fc3a4;
  --good-wash:     #122c25;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

/* ── Base ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.rc-mono { font-family: var(--font-mono); }

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

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

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

/* ══ THE KIT ═════════════════════════════════════════════════════════ */

/* Headings and help text */
.rc-h1 { margin: 0 0 var(--space-2); font-size: var(--step-3); font-weight: 600; letter-spacing: -0.02em; }
.rc-h2 {
  margin: var(--space-5) 0 var(--space-3); font-size: var(--step-1); font-weight: 600;
  padding-bottom: var(--space-2); border-bottom: 1px solid var(--line);
}
.rc-h2:first-child { margin-top: 0; }
.rc-h3 { margin: var(--space-5) 0 var(--space-2); font-size: var(--step-0); font-weight: 600; }
.rc-desc { margin: var(--space-2) 0 0; font-size: var(--step--1); color: var(--ink-muted); max-width: 68ch; }
.rc-desc strong.rc-flag { color: var(--critical); font-weight: 500; }

/* Inline code */
.rc-code {
  font-family: var(--font-mono); font-size: 0.8125em;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 1px 5px;
}

/* Form table */
.rc-form { border-collapse: collapse; width: 100%; }
.rc-form th {
  width: var(--label-col); text-align: left; vertical-align: top;
  font-weight: 500; font-size: var(--step-0);
  padding: var(--space-4) var(--space-4) var(--space-4) 0;
}
.rc-form td { padding: var(--space-4) 0; vertical-align: top; }
.rc-form tr + tr th, .rc-form tr + tr td { border-top: 1px solid var(--line-soft); }

/* Fields */
.rc-input, .rc-select, .rc-textarea {
  font-family: var(--font-sans); font-size: var(--step-0); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 10px; width: 100%; max-width: 340px;
}
.rc-textarea { font-family: var(--font-mono); font-size: var(--step--1); max-width: 100%; resize: vertical; }
.rc-input:focus, .rc-select:focus, .rc-textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash);
}
.rc-input::placeholder { color: var(--ink-faint); font-family: var(--font-mono); }
.rc-check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--step--1); color: var(--ink-muted); }

/* Buttons */
.rc-btn {
  font: 500 var(--step-0)/1 var(--font-sans);
  border-radius: var(--radius); padding: 8px 14px; cursor: pointer;
  border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.rc-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rc-btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.rc-btn-secondary { background: var(--surface); border-color: var(--line); color: var(--accent-ink); }
.rc-btn-secondary:hover { border-color: var(--accent); }
.rc-btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Tables */
.rc-table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
.rc-table th, .rc-table td {
  text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.rc-table thead th {
  font-weight: 500; font-size: 0.6875rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-faint); border-bottom: 1px solid var(--line);
}
.rc-table tbody tr:nth-child(even) { background: var(--surface-2); }
.rc-table td.rc-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Key/value table */
.rc-kv { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
.rc-kv th {
  width: var(--label-col); text-align: left; font-weight: 500; color: var(--ink-muted);
  padding: var(--space-3); border-bottom: 1px solid var(--line-soft); vertical-align: top;
}
.rc-kv td { padding: var(--space-3); border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.rc-kv tbody tr:nth-child(even) { background: var(--surface-2); }
.rc-empty { color: var(--ink-faint); }

/* Pills */
.rc-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.75rem; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.rc-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.rc-pill-neutral  { color: var(--ink-muted); background: var(--surface-2); border-color: var(--line); }
.rc-pill-good     { color: var(--good);      background: var(--good-wash);     border-color: var(--good); }
.rc-pill-warn     { color: var(--warn);      background: var(--warn-wash);     border-color: var(--warn); }
.rc-pill-critical { color: var(--critical);  background: var(--critical-wash); border-color: var(--critical); }
.rc-pill-info     { color: var(--accent-ink);background: var(--accent-wash);   border-color: var(--accent); }

/* Notices — the stripe carries the severity, so the fill can stay quiet */
.rc-notice {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--ink-faint);
  border-radius: var(--radius);
  font-size: var(--step--1);
}
.rc-notice b { font-weight: 600; }
.rc-notice p { margin: 0; }
.rc-notice-good     { border-left-color: var(--good);     background: var(--good-wash); }
.rc-notice-warn     { border-left-color: var(--warn);     background: var(--warn-wash); }
.rc-notice-critical { border-left-color: var(--critical); background: var(--critical-wash); }
.rc-notice-stack { display: flex; flex-direction: column; gap: var(--space-3); }

/* Stat row */
.rc-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px;
  background: var(--line-soft); border: 1px solid var(--line-soft);
  border-radius: var(--radius); overflow: hidden;
}
.rc-stat { background: var(--surface); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.rc-stat b { font-size: var(--step-2); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.rc-stat span { font-size: 0.6875rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-faint); }
.rc-stat-critical b { color: var(--critical); }

/* ══ APPLICATION CHROME ══════════════════════════════════════════════
   Everything below is this app's own, built on the kit's tokens and
   kept behind the same `rc-` prefix so nothing can collide. */

/* Page frame */
.rc-page {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  gap: var(--space-6);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
  align-items: start;
}

/* The console is full of wide tables, so the main column takes every pixel the
   viewport offers; only the rail is a fixed width. Prose keeps its own measure
   through the max-width on .rc-desc / .rc-lede. */
.rc-page--plain {
  grid-template-columns: minmax(0, 1fr);
  max-width: 640px;
}
.rc-main { min-width: 0; }

@media (max-width: 860px) {
  .rc-page { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .rc-rail { position: static; }
}

/* Rail */
.rc-rail { position: sticky; top: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.rc-rail-brand { display: flex; flex-direction: column; gap: var(--space-1); }
.rc-rail-brand b { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.01em; }
.rc-rail-brand span { font-size: var(--step--1); color: var(--ink-faint); font-family: var(--font-mono); }

.rc-rail-nav { display: flex; flex-direction: column; gap: 1px; }
.rc-rail-nav h2 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-faint);
}
.rc-rail-nav h2:first-child { margin-top: 0; }
.rc-rail-nav a {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: var(--step--1);
  padding: var(--space-1) var(--space-2);
  border-left: 2px solid var(--line-soft);
  transition: color .12s, border-color .12s;
}
.rc-rail-nav a:hover { color: var(--accent-ink); border-left-color: var(--accent); }
.rc-rail-nav a.rc-active { color: var(--accent-ink); font-weight: 500; border-left-color: var(--accent); background: var(--accent-wash); }
.rc-rail-divider { height: 1px; background: var(--line); margin: var(--space-3) 0 var(--space-2); }

.rc-theme-toggle {
  align-self: start;
  font: 500 var(--step--1)/1 var(--font-sans);
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 11px;
  cursor: pointer;
}
.rc-theme-toggle:hover { border-color: var(--accent); color: var(--accent-ink); }

/* Anonymous pages: the toggle sits on its own bar above the card */
.rc-topbar { display: flex; justify-content: flex-end; margin-bottom: var(--space-4); }

/* Impersonation banners — a session-wide state, so it spans the viewport */
.rc-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: var(--step--1);
  background: var(--warn-wash); color: var(--warn);
  border-bottom: 1px solid var(--warn);
}
.rc-banner form { margin: 0; }

/* Panels */
.rc-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
.rc-panel + .rc-panel { margin-top: var(--space-5); }

/* Screen header */
.rc-head { margin-bottom: var(--space-5); }
.rc-eyebrow {
  font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 var(--space-2);
}
.rc-lede { margin: var(--space-2) 0 0; color: var(--ink-muted); max-width: 68ch; }
.rc-lede--mono { font-family: var(--font-mono); font-size: var(--step--1); }

/* Vertical rhythm helpers */
.rc-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.rc-gap { margin-top: var(--space-4); }
.rc-muted { color: var(--ink-muted); }

/* Stacked fields — for auth screens, where a two-column label rail is overkill */
.rc-field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.rc-field > label { font-size: var(--step--1); font-weight: 500; }
.rc-field .rc-input, .rc-field .rc-select, .rc-field .rc-textarea { max-width: 100%; }
.rc-field-error { font-size: var(--step--1); color: var(--critical); }
.rc-hint { display: block; font-size: var(--step--1); color: var(--ink-muted); max-width: 68ch; }

/* Grouped checkbox / radio lists */
.rc-fieldset {
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--surface-2);
  padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4);
}
.rc-fieldset legend {
  font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-faint); padding: 0 var(--space-2);
}
.rc-choices { display: flex; flex-direction: column; gap: var(--space-2); max-height: 380px; overflow-y: auto; }
.rc-choice { display: flex; align-items: flex-start; gap: var(--space-2); font-size: var(--step--1); }
.rc-choice input { margin-top: 3px; flex: none; }

/* Toolbar — filter bars and "new record" rows */
.rc-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.rc-toolbar-field { display: flex; flex-direction: column; gap: var(--space-1); }
.rc-toolbar-field label { font-size: 0.6875rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-faint); }
.rc-toolbar .rc-input { max-width: 190px; }

/* Tables scroll inside their own container, never the page */
.rc-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.rc-table-wrap > .rc-table > tbody > tr:last-child > td { border-bottom: 0; }

/* Answer key inside a table cell — the full option list for a multiple-choice question,
   so the pool can be proof-read without opening every row's edit form. */
.rc-answers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.rc-answers li {
  display: flex; align-items: baseline; gap: var(--space-2);
  color: var(--ink-muted); max-width: 62ch;
}
.rc-answers li.is-correct { color: var(--ink); font-weight: 500; }
.rc-answers__letter {
  flex: none; width: 1.35em; height: 1.35em; display: inline-flex;
  align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.6875rem; line-height: 1;
  border: 1px solid var(--line); border-radius: 50%; color: var(--ink-faint);
}
.rc-answers li.is-correct .rc-answers__letter {
  border-color: var(--good); color: var(--good); background: var(--good-wash);
}

/* Row actions: several tiny forms living side by side in one cell */
.rc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.rc-actions form { display: inline; margin: 0; }
.rc-btn-sm { font-size: var(--step--1); padding: 4px 9px; }
.rc-btn-danger { background: var(--surface); border-color: var(--line); color: var(--critical); }
.rc-btn-danger:hover { border-color: var(--critical); }

/* Pagination */
.rc-pager { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-4); }
.rc-pager a {
  font-size: var(--step--1); text-decoration: none; color: var(--ink-muted);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}
.rc-pager a:hover { border-color: var(--accent); color: var(--accent-ink); }
.rc-pager a[aria-current="page"] { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-ink); font-weight: 500; }

/* Machine output */
.rc-pre {
  margin: 0; padding: var(--space-3);
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: var(--step--1); line-height: 1.6;
  color: var(--ink-muted); overflow-x: auto; white-space: pre; tab-size: 2;
}
.rc-pre--wrap { white-space: pre-wrap; word-break: break-word; }

/* Back links / footer links under a screen */
.rc-backlink { margin: var(--space-5) 0 0; font-size: var(--step--1); }

/* Auth screens */
.rc-auth { max-width: 420px; margin: 0 auto; }
.rc-auth-brand { text-align: center; margin-bottom: var(--space-5); }
.rc-auth-brand b { display: block; font-size: var(--step-1); font-weight: 600; letter-spacing: -0.01em; }
.rc-auth-brand span { font-size: var(--step--1); color: var(--ink-faint); font-family: var(--font-mono); }
.rc-auth .rc-links { margin-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--step--1); }
.rc-auth .rc-links p { margin: 0; }

/* Two-factor setup */
.rc-qr {
  display: block; background: #fff; padding: var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.rc-secret {
  display: inline-block; font-family: var(--font-mono); font-size: var(--step-0);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: var(--space-2) var(--space-3);
  word-break: break-all;
}

/* The popup preview hosts the embed widget; give it room without styling into it */
.rc-embed-host { margin: var(--space-4) 0; }

/* Public lead-facing pages (exam, unsubscribe, buy) keep their own separate
   brand look; this reproduces the padding the previous layout gave them so
   restyling the console changed nothing there. */
.rc-legacy-main { padding: 1.5rem 2rem; }

/* ── Full-width console adjustments ──────────────────────────────────
   The main column is unconstrained so wide tables get every pixel. These
   two keep the things that are NOT tables from stretching with it. */
.rc-page .rc-stats { max-width: 760px; }
.rc-page .rc-notice > span,
.rc-page .rc-notice > p { max-width: 92ch; }
