/* =============================================================================
   RTC theme — the premium design layer, applied app-wide.

   WHY THIS RESTYLES BOOTSTRAP RATHER THAN REPLACING IT. Twenty-odd pages are
   built on Bootstrap's components, and the app shell (navbar, offcanvas
   sidenav, theme toggle) depends on its JS as well as its CSS. Rewriting every
   template to a new class vocabulary would be a week of churn with a fresh bug
   in each page. Restyling the components those templates already use upgrades
   all of them at once and cannot desynchronise from the markup.

   The rule this file follows: change APPEARANCE, never LAYOUT. Colour, radius,
   shadow, border, typography and spacing inside a component are fair game. The
   grid, flex utilities, display and position classes are untouched, because
   those are what the pages rely on to hold their shape.

   Tokens mirror screener-ui.css so the redesigned screener and the rest of the
   app cannot drift apart. Dark mode follows the shell's data-bs-theme.
   ========================================================================== */

/* The brand colour DERIVES from the admin-selected site theme (--accent, set by
   SITE_THEME_CSS) and only falls back to the spec green when none is chosen.
   Hard-coding it here would silently override whatever the operator picked in
   the admin, which is a setting they can see and would expect to win. */
:root {
  --rtc-primary: var(--accent, #00C853);
  --rtc-primary-dark: var(--accent-hover, #00A344);
  --rtc-primary-wash: rgba(0, 200, 83, .10);
  --rtc-primary-ring: rgba(0, 200, 83, .22);

  --rtc-bg: #F8FAFC;
  --rtc-card: #FFFFFF;
  --rtc-card-alt: #FCFDFE;
  --rtc-border: #E5E7EB;
  --rtc-border-strong: #D5DAE1;

  --rtc-text: #0F172A;
  --rtc-text-2: #64748B;
  --rtc-text-3: #94A3B8;

  /* Semantic status colours — the single definition for the whole app. */
  --rtc-pos: #00A344;
  --rtc-neg: #E5484D;
  --rtc-warn: #D97706;
  --rtc-info: #2563EB;

  --rtc-r-sm: 10px;
  --rtc-r: 14px;
  --rtc-r-lg: 18px;

  --rtc-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --rtc-shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
  --rtc-shadow-lg: 0 12px 28px rgba(16, 24, 40, .10), 0 4px 8px rgba(16, 24, 40, .05);
  --rtc-t: 220ms cubic-bezier(.4, 0, .2, 1);
}

[data-bs-theme="dark"] {
  --rtc-primary: var(--accent, #22E06B);
  --rtc-primary-dark: var(--accent-hover, #16A34A);
  --rtc-primary-wash: rgba(34, 224, 107, .12);
  --rtc-primary-ring: rgba(34, 224, 107, .26);

  --rtc-bg: #0B1220;
  --rtc-card: #131C2E;
  --rtc-card-alt: #172136;
  --rtc-border: #253048;
  --rtc-border-strong: #33415C;

  --rtc-text: #F1F5F9;
  --rtc-text-2: #94A3B8;
  --rtc-text-3: #64748B;

  --rtc-pos: #22E06B;
  --rtc-neg: #FF6369;
  --rtc-warn: #F59E0B;
  --rtc-info: #60A5FA;

  --rtc-shadow: 0 1px 2px rgba(0, 0, 0, .30);
  --rtc-shadow-md: 0 4px 12px rgba(0, 0, 0, .36);
  --rtc-shadow-lg: 0 12px 28px rgba(0, 0, 0, .44);
}

/* ------------------------------------------------------------ typography */
body.app-body {
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 500;
  background: var(--rtc-bg);
  color: var(--rtc-text);
  font-feature-settings: "cv02", "cv03", "cv04";
}
.app-body h1, .app-body h2, .app-body h3,
.app-body h4, .app-body h5, .app-body h6 {
  font-weight: 700; letter-spacing: -.02em; color: var(--rtc-text);
}
.app-body .fw-bold, .app-body .fw-semibold { letter-spacing: -.01em; }
.app-body .tabular, .app-body .text-end { font-variant-numeric: tabular-nums; }
.app-body .text-muted { color: var(--rtc-text-2) !important; }

/* ----------------------------------------------------------------- cards */
.app-body .card {
  background: var(--rtc-card);
  border: 1px solid var(--rtc-border);
  border-radius: var(--rtc-r-lg);
  box-shadow: var(--rtc-shadow);
  transition: box-shadow var(--rtc-t), transform var(--rtc-t), border-color var(--rtc-t);
}
/* Cards that are links or carry .card-hover lift; static ones must not move
   under the cursor, or a dashboard full of panels feels unstable. */
.app-body a.card:hover, .app-body .card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--rtc-shadow-md);
  border-color: var(--rtc-border-strong);
}
.app-body .card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--rtc-border);
  padding: 16px 20px;
  font-weight: 600;
}
.app-body .card-footer { background: transparent !important; border-top: 1px solid var(--rtc-border); }
.app-body .card-body { padding: 20px; }
.app-body .shadow-sm { box-shadow: var(--rtc-shadow) !important; }
.app-body .shadow { box-shadow: var(--rtc-shadow-md) !important; }

/* --------------------------------------------------------------- buttons */
.app-body .btn {
  border-radius: var(--rtc-r);
  font-weight: 600;
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 20px;
  transition: transform var(--rtc-t), box-shadow var(--rtc-t),
              background var(--rtc-t), border-color var(--rtc-t), color var(--rtc-t);
}
.app-body .btn-sm { min-height: 40px; border-radius: var(--rtc-r-sm); padding: 0 14px; font-size: .82rem; }
.app-body .btn-lg { min-height: 56px; border-radius: var(--rtc-r-lg); padding: 0 28px; }
/* Icon-only actions in table rows must stay square, not stretch to a pill. */
.app-body td .btn.py-0 { min-height: 32px; padding: 0 10px; }

.app-body .btn-primary {
  background: linear-gradient(180deg, var(--rtc-primary), var(--rtc-primary-dark));
  border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(0, 120, 50, .26), 0 4px 12px rgba(0, 200, 83, .20);
}
.app-body .btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--rtc-primary), var(--rtc-primary-dark));
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 120, 50, .28), 0 10px 22px rgba(0, 200, 83, .30);
}
.app-body .btn-primary:active:not(:disabled) { transform: translateY(0); }

.app-body .btn-outline-primary {
  color: var(--rtc-primary); border-color: var(--rtc-border); background: var(--rtc-card);
}
.app-body .btn-outline-primary:hover:not(:disabled) {
  background: var(--rtc-primary-wash); border-color: var(--rtc-primary);
  color: var(--rtc-primary); transform: translateY(-1px);
}
.app-body .btn-outline-secondary {
  color: var(--rtc-text); border-color: var(--rtc-border); background: var(--rtc-card);
}
.app-body .btn-outline-secondary:hover:not(:disabled) {
  background: var(--rtc-primary-wash); border-color: var(--rtc-primary);
  color: var(--rtc-primary); transform: translateY(-1px);
}
.app-body .btn:focus-visible { box-shadow: 0 0 0 4px var(--rtc-primary-ring); outline: none; }
.app-body .btn:disabled { opacity: .55; transform: none !important; box-shadow: none !important; }

/* ---------------------------------------------------------------- inputs */
.app-body .form-control, .app-body .form-select {
  background: var(--rtc-card);
  border: 1px solid var(--rtc-border);
  border-radius: var(--rtc-r);
  color: var(--rtc-text);
  height: 52px;                     /* the screener's input height, everywhere */
  padding: 0 14px;
  font-weight: 500;
  transition: border-color var(--rtc-t), box-shadow var(--rtc-t);
}
/* `-sm` is used by every dense filter bar in the app. Matching the full 52px
   there would push a six-field row off the screen, so it gets 44px — still a
   comfortable tap target and still the same visual language, just tighter. */
.app-body .form-control-sm, .app-body .form-select-sm {
  height: 44px; border-radius: var(--rtc-r-sm); padding: 0 12px; font-size: .84rem;
}
/* Height is meaningless on these and would clip them. */
.app-body textarea.form-control { height: auto; padding: 12px 14px; min-height: 96px; }
.app-body .form-control[type="file"] { height: auto; padding: 11px 14px; }
.app-body .input-group > .form-control, .app-body .input-group > .form-select { height: 52px; }
.app-body .input-group-sm > .form-control, .app-body .input-group-sm > .form-select { height: 44px; }
.app-body .input-group-text {
  background: var(--rtc-card-alt); border-color: var(--rtc-border);
  color: var(--rtc-text-2); border-radius: var(--rtc-r);
}
.app-body .form-control:hover, .app-body .form-select:hover { border-color: var(--rtc-border-strong); }
.app-body .form-control:focus, .app-body .form-select:focus {
  border-color: var(--rtc-primary);
  box-shadow: 0 0 0 4px var(--rtc-primary-ring);
  background: var(--rtc-card);
  color: var(--rtc-text);
}
.app-body .form-control::placeholder { color: var(--rtc-text-3); }
.app-body .form-label { font-weight: 600; color: var(--rtc-text-2); font-size: .8rem; }

/* Native arrow replaced so selects match the rest of the system. */
.app-body .form-select {
  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='%2364748B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
[data-bs-theme="dark"] .app-body .form-select {
  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='%2394A3B8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Checkboxes become switches, matching the screener. Only type=checkbox —
   radios stay circular, because a radio that looks like a toggle implies it can
   be turned off independently, which is exactly what a radio cannot do. */
.app-body .form-check-input[type="checkbox"]:not(.btn-check) {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 42px; height: 24px; margin-top: 0; border-radius: 999px;
  background: var(--rtc-border-strong); border: 0;
  cursor: pointer; transition: background var(--rtc-t);
}
.app-body .form-check-input[type="checkbox"]:not(.btn-check)::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .3);
  transition: transform var(--rtc-t);
}
.app-body .form-check-input[type="checkbox"]:not(.btn-check):checked {
  background: var(--rtc-primary);
}
.app-body .form-check-input[type="checkbox"]:not(.btn-check):checked::after { transform: translateX(18px); }
/* Bootstrap reserves 1.5em of left padding for a 1em box; a 42px switch needs
   more, or the label sits on top of it. */
.app-body .form-check:has(.form-check-input[type="checkbox"]) { padding-left: 52px; min-height: 24px; }
.app-body .form-check-input[type="checkbox"]:not(.btn-check) { margin-left: -52px; }
.app-body .form-switch .form-check-input { margin-left: -52px; }

.app-body .form-check-input[type="radio"] {
  width: 20px; height: 20px; border-color: var(--rtc-border-strong);
  transition: background var(--rtc-t), border-color var(--rtc-t);
}
.app-body .form-check-input[type="radio"]:checked {
  background-color: var(--rtc-primary); border-color: var(--rtc-primary);
}
.app-body .form-check-input:focus-visible { box-shadow: 0 0 0 4px var(--rtc-primary-ring); }
.app-body .form-check-label { font-weight: 500; line-height: 24px; }

/* Chip-style radio/checkbox groups (the rotation and screener filters). */
.app-body .btn-check + .btn {
  border-radius: var(--rtc-r-sm); border-color: var(--rtc-border);
  color: var(--rtc-text-2); background: var(--rtc-card); font-weight: 600;
}
.app-body .btn-check:checked + .btn {
  background: var(--rtc-primary-wash); border-color: var(--rtc-primary);
  color: var(--rtc-primary);
}
.app-body .btn-check:focus-visible + .btn { box-shadow: 0 0 0 4px var(--rtc-primary-ring); }
.app-body .btn-group > .btn:not(:first-child) { margin-left: -1px; }

/* ---------------------------------------------------------------- tables */
.app-body .table { --bs-table-bg: transparent; color: var(--rtc-text); font-size: .86rem; }
.app-body .table > thead > tr > th {
  background: var(--rtc-card-alt);
  color: var(--rtc-text-2);
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--rtc-border);
  padding: 12px;
  white-space: nowrap;
}
.app-body .table > tbody > tr > td { padding: 12px; border-color: var(--rtc-border); vertical-align: middle; }
.app-body .table > tbody > tr:nth-child(even) > * { background: var(--rtc-card-alt); }
.app-body .table-hover > tbody > tr { transition: background var(--rtc-t); }
.app-body .table-hover > tbody > tr:hover > * {
  background: var(--rtc-primary-wash); --bs-table-accent-bg: transparent; color: var(--rtc-text);
}
.app-body .table-light > :not(caption) > * > * { background: var(--rtc-card-alt); color: var(--rtc-text-2); }
/* Sticky header inside any scrolling table container. */
.app-body .table-responsive { border-radius: var(--rtc-r); overflow: auto; }
.app-body .table > :not(caption) > * > * { box-shadow: none; }
.app-body .table-responsive > .table > thead > tr > th { position: sticky; top: 0; z-index: 2; }

/* ---------------------------------------------------------------- badges */
.app-body .badge {
  border-radius: 999px; font-weight: 600; font-size: .68rem;
  padding: 4px 10px; letter-spacing: .01em;
}
.app-body .text-bg-success { background: rgba(0, 163, 68, .12) !important; color: #00A344 !important; }
.app-body .text-bg-danger  { background: rgba(229, 72, 77, .12) !important; color: #E5484D !important; }
.app-body .text-bg-warning { background: rgba(217, 119, 6, .12) !important; color: #D97706 !important; }
.app-body .text-bg-info    { background: rgba(37, 99, 235, .12) !important; color: #2563EB !important; }
.app-body .text-bg-primary { background: var(--rtc-primary-wash) !important; color: var(--rtc-primary-dark) !important; }
.app-body .text-bg-secondary { background: rgba(100, 116, 139, .12) !important; color: var(--rtc-text-2) !important; }
.app-body .text-bg-light { background: var(--rtc-card-alt) !important; color: var(--rtc-text-2) !important; }
[data-bs-theme="dark"] .app-body .text-bg-primary { color: var(--rtc-primary) !important; }

/* -------------------------------------------------------------- progress */
.app-body .progress { background: var(--rtc-border); border-radius: 999px; }
.app-body .progress-bar { background: linear-gradient(90deg, var(--rtc-primary), var(--rtc-primary-dark)); }

/* --------------------------------------------------------------- alerts */
.app-body .alert { border-radius: var(--rtc-r); border-width: 1px; font-weight: 500; }
.app-body .alert-warning { background: rgba(217, 119, 6, .08); border-color: rgba(217, 119, 6, .24); color: var(--rtc-text); }
.app-body .alert-info    { background: rgba(37, 99, 235, .08); border-color: rgba(37, 99, 235, .24); color: var(--rtc-text); }
.app-body .alert-danger  { background: rgba(229, 72, 77, .08); border-color: rgba(229, 72, 77, .24); color: var(--rtc-text); }
.app-body .alert-success { background: var(--rtc-primary-wash); border-color: var(--rtc-primary-ring); color: var(--rtc-text); }

/* ------------------------------------------------------------- accents */
.app-body .text-primary { color: var(--rtc-primary) !important; }
.app-body .text-success { color: #00A344 !important; }
.app-body .text-danger  { color: #E5484D !important; }
[data-bs-theme="dark"] .app-body .text-success { color: #22E06B !important; }
[data-bs-theme="dark"] .app-body .text-danger  { color: #FF6369 !important; }
.app-body a { color: var(--rtc-primary-dark); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.app-body a:hover { color: var(--rtc-primary); }
[data-bs-theme="dark"] .app-body a { color: var(--rtc-primary); }
.app-body hr { border-color: var(--rtc-border); opacity: 1; }
.app-body .border, .app-body .border-top, .app-body .border-bottom,
.app-body .border-start, .app-body .border-end { border-color: var(--rtc-border) !important; }

/* --------------------------------------------------------------- sidenav */
.app-body .sn-link {
  border-radius: var(--rtc-r-sm); font-weight: 500;
  transition: background var(--rtc-t), color var(--rtc-t);
}
.app-body .sn-link:hover { background: var(--rtc-primary-wash); color: var(--rtc-primary); }
.app-body .sn-link.active {
  background: var(--rtc-primary-wash); color: var(--rtc-primary); font-weight: 600;
}
.app-body .sn-group {
  font-size: .64rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--rtc-text-3);
}

/* -------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  .app-body *, .app-body *::before, .app-body *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}

/* =============================================================================
   Shared components — the vocabulary every authenticated page draws from.
   Markup lives in templates/components/; this is only their appearance.
   ========================================================================== */

/* ---------------------------------------------------------- page header */
.rtc-pagehead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.rtc-pagehead__main { min-width: 0; }
.rtc-pagehead__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.rtc-crumb ol {
  display: flex; align-items: center; gap: 6px;
  list-style: none; margin: 0 0 6px; padding: 0;
  font-size: .72rem; font-weight: 600; color: var(--rtc-text-3);
}
.rtc-crumb a { color: var(--rtc-text-2); text-decoration: none; }
.rtc-crumb a:hover { color: var(--rtc-primary); }
.rtc-crumb i { font-size: .6rem; }
.rtc-crumb [aria-current] { color: var(--rtc-text-2); }

.rtc-pagetitle {
  display: flex; align-items: center; gap: 12px; margin: 0;
  font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em;
}
.rtc-pagetitle__ico {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: var(--rtc-r-sm);
  color: var(--rtc-primary); background: var(--rtc-primary-wash);
  font-size: 1.1rem;
}
.rtc-pagesub {
  margin: 8px 0 0; max-width: 78ch;
  color: var(--rtc-text-2); font-size: .875rem; line-height: 1.6;
}

/* ----------------------------------------------------------- stat cards */
/* A grid the caller drops stats into; auto-fit means one component works for
   two cards or six without the page choosing column counts. */
.rtc-stats {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.rtc-stat {
  display: block; text-decoration: none; color: inherit;
  background: var(--rtc-card); border: 1px solid var(--rtc-border);
  border-radius: var(--rtc-r); padding: 16px 20px;
  box-shadow: var(--rtc-shadow);
  transition: transform var(--rtc-t), box-shadow var(--rtc-t), border-color var(--rtc-t);
}
/* Only linked stats lift. A dashboard where every static panel moves under the
   cursor reads as unstable rather than responsive. */
.rtc-stat--link:hover {
  transform: translateY(-2px); box-shadow: var(--rtc-shadow-md);
  border-color: var(--rtc-border-strong); color: inherit;
}
.rtc-stat__top {
  display: flex; align-items: center; gap: 8px;
  color: var(--rtc-text-2); font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
}
.rtc-stat__top i { font-size: .85rem; color: var(--rtc-text-3); }
.rtc-stat__val {
  margin-top: 8px; font-size: 1.6rem; font-weight: 700;
  letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums;
}
.rtc-stat__val--pos    { color: var(--rtc-pos); }
.rtc-stat__val--neg    { color: var(--rtc-neg); }
.rtc-stat__val--warn   { color: var(--rtc-warn); }
.rtc-stat__val--accent { color: var(--rtc-primary); }
.rtc-stat__sub { margin-top: 2px; color: var(--rtc-text-3); font-size: .74rem; font-weight: 500; }

@media (max-width: 768px) {
  .rtc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .rtc-stat { padding: 12px 14px; }
  .rtc-stat__val { font-size: 1.3rem; }
  .rtc-pagehead__actions { width: 100%; }
  .rtc-pagehead__actions > .btn { flex: 1 1 auto; }
}

/* --------------------------------------------------- screener scan meta */
.rtc-scanmeta {
  margin: 10px 0 0; color: var(--rtc-text-3);
  font-size: .75rem; font-weight: 500;
}
.rtc-scanmeta strong { color: var(--rtc-text-2); font-weight: 700; }
.rtc-scanmeta__sep { margin: 0 8px; opacity: .5; }

/* ---------------------------------------------------------- empty state */
.rtc-empty { padding: 48px 24px; text-align: center; }
.rtc-empty > i { font-size: 2.25rem; color: var(--rtc-text-3); opacity: .5; }
.rtc-empty__title {
  margin: 14px 0 0; color: var(--rtc-text); font-size: .95rem; font-weight: 600;
}
.rtc-empty__hint {
  margin: 6px auto 16px; max-width: 52ch;
  color: var(--rtc-text-2); font-size: .82rem; line-height: 1.6;
}
.rtc-empty__hint:last-child { margin-bottom: 0; }

/* =============================================================================
   Screener framework — filter area, toolbar, chips, skeletons.

   These are STYLING PRIMITIVES, not a fixed markup contract. Every screener
   filters on different fields, and forcing them into identical HTML would mean
   rewriting forms — which is functionality, not presentation. A screener opts
   in by putting `rtc-filters` on the card it already has; its fields keep
   whatever grid they were using.
   ========================================================================== */

.rtc-filters {
  background: var(--rtc-card); border: 1px solid var(--rtc-border);
  border-radius: var(--rtc-r-lg); box-shadow: var(--rtc-shadow); margin-bottom: 16px;
}
.rtc-filters__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--rtc-border); flex-wrap: wrap;
}
.rtc-filters__title {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--rtc-text-2);
}
.rtc-filters__title i { color: var(--rtc-primary); font-size: .9rem; }
.rtc-filters__body { padding: 20px; }
/* A labelled section inside the filter body — screeners group fields how they
   like, this only makes the grouping look the same everywhere. */
.rtc-filters__group + .rtc-filters__group { margin-top: 20px; }
.rtc-filters__grouplabel {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--rtc-border);
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--rtc-text);
}
.rtc-filters__actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rtc-border);
}
.rtc-filters__actions .rtc-spacer { margin-left: auto; }

/* --------------------------------------------------------------- toolbar */
.rtc-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 12px 20px;
  background: var(--rtc-card-alt); border: 1px solid var(--rtc-border);
  border-radius: var(--rtc-r) var(--rtc-r) 0 0; border-bottom: 0;
}
.rtc-toolbar__count { font-size: .84rem; font-weight: 700; letter-spacing: -.01em; }
.rtc-toolbar__count span { color: var(--rtc-text-2); font-weight: 500; }
.rtc-toolbar__meta { color: var(--rtc-text-3); font-size: .72rem; font-weight: 500; }
.rtc-toolbar__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* A toolbar sits directly on the results card, so that card loses its own top
   rounding rather than stacking two radii. */
.rtc-toolbar + .card, .rtc-toolbar + .scr-card {
  border-top-left-radius: 0; border-top-right-radius: 0;
}

/* ----------------------------------------------------------------- chips */
.rtc-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rtc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--rtc-primary-wash); border: 1px solid var(--rtc-primary-ring);
  color: var(--rtc-text); font-size: .7rem; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.rtc-chip__key { color: var(--rtc-text-2); font-weight: 500; }
.rtc-chip--clear {
  background: transparent; border-color: var(--rtc-border); color: var(--rtc-text-2);
  transition: color var(--rtc-t), border-color var(--rtc-t);
}
.rtc-chip--clear:hover { color: var(--rtc-neg); border-color: var(--rtc-neg); }

/* ------------------------------------------------------------- skeleton */
/* Purely presentational: rendered server-side in place of a table the page
   knows will be slow, and never swapped out by JS — there is no async layer
   here to hook into, and inventing one would change behaviour. */
.rtc-skel { display: block; border-radius: 6px; background: var(--rtc-border);
            position: relative; overflow: hidden; }
.rtc-skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  animation: rtc-shimmer 1.4s infinite;
}
[data-bs-theme="dark"] .rtc-skel::after {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
}
@keyframes rtc-shimmer { to { transform: translateX(100%); } }
.rtc-skel-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--rtc-border); }
.rtc-skel-row .rtc-skel { height: 12px; }

@media (max-width: 768px) {
  .rtc-filters__body { padding: 14px; }
  .rtc-filters__actions > .btn { flex: 1 1 auto; }
  .rtc-toolbar { padding: 10px 14px; }
  .rtc-toolbar__actions { width: 100%; }
  .rtc-toolbar__actions > .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { .rtc-skel::after { animation: none; } }

/* ================================================= research & valuation ==
   Company identity and metric grids. Tokens only — no new visual language.
   ======================================================================== */

.rtc-cohead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 20px; margin-bottom: 16px;
  background: var(--rtc-card); border: 1px solid var(--rtc-border);
  border-radius: var(--rtc-r-lg); box-shadow: var(--rtc-shadow);
}
.rtc-cohead__symline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rtc-cohead__sym {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
}
.rtc-cohead__exch {
  padding: 2px 8px; border-radius: 6px;
  background: var(--rtc-card-alt); border: 1px solid var(--rtc-border);
  color: var(--rtc-text-3); font-size: .62rem; font-weight: 700; letter-spacing: .06em;
}
.rtc-cohead__name { margin-top: 4px; color: var(--rtc-text-2); font-size: .95rem; font-weight: 500; }
.rtc-cohead__meta { margin-top: 6px; color: var(--rtc-text-3); font-size: .76rem; font-weight: 500; }
.rtc-cohead__dot { margin: 0 7px; opacity: .55; }
.rtc-cohead__price { text-align: right; }
.rtc-cohead__amt {
  font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.rtc-cohead__delta { margin-top: 4px; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.rtc-cohead__delta .text-muted { font-weight: 500; font-size: .72rem; }

/* Values first: a reader scanning a row of ratios should not have to re-anchor
   on each cell, so every one is identical apart from its numbers. */
.rtc-metrics {
  display: grid; gap: 1px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--rtc-border);
  border: 1px solid var(--rtc-border); border-radius: var(--rtc-r); overflow: hidden;
}
.rtc-metric { background: var(--rtc-card); padding: 14px 16px; }
.rtc-metrics--compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.rtc-metrics--compact .rtc-metric { padding: 10px 12px; }
.rtc-metric__label {
  color: var(--rtc-text-3); font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
}
.rtc-metric__value {
  margin-top: 6px; font-size: 1.15rem; font-weight: 700;
  letter-spacing: -.01em; font-variant-numeric: tabular-nums;
}
.rtc-metrics--compact .rtc-metric__value { font-size: 1rem; }
.rtc-metric__sub { margin-top: 2px; color: var(--rtc-text-3); font-size: .7rem; font-weight: 500; }

@media (max-width: 768px) {
  .rtc-cohead { padding: 14px; }
  .rtc-cohead__price { text-align: left; }
  .rtc-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media print {
  .rtc-cohead, .rtc-metrics { box-shadow: none; break-inside: avoid; }
  .rtc-metrics { gap: 0; }
}

/* ------------------------------------------------- comparison tables ---
   The financial-table foundation: a row label followed by value columns.
   Presentation only — precision, units and signs stay with the page.
   ---------------------------------------------------------------------- */
.rtc-fintable { font-variant-numeric: tabular-nums; }
.rtc-fintable > thead > tr > th {
  background: var(--rtc-card-alt); color: var(--rtc-text-2);
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap; padding: 10px 12px;
  border-bottom: 1px solid var(--rtc-border);
}
.rtc-fintable > tbody > tr > td { padding: 10px 12px; border-color: var(--rtc-border); }
/* The row label is the anchor a reader scans down; it stays legible while the
   value columns scroll under it on a narrow screen. */
.rtc-fintable > tbody > tr > td:first-child,
.rtc-fintable > thead > tr > th:first-child {
  position: sticky; left: 0; z-index: 1;
  background: var(--rtc-card); font-weight: 600;
}
.rtc-fintable > thead > tr > th:first-child { background: var(--rtc-card-alt); z-index: 3; }
.rtc-fintable > tbody > tr:nth-child(even) > td { background: var(--rtc-card-alt); }
.rtc-fintable > tbody > tr:nth-child(even) > td:first-child { background: var(--rtc-card-alt); }
.rtc-fintable > tbody > tr:hover > td { background: var(--rtc-primary-wash); }

/* Emphasis rows the page opts into. */
.rtc-fintable tr.rtc-row--highlight > td { background: var(--rtc-primary-wash) !important; }
.rtc-fintable tr.rtc-row--total > td {
  border-top: 2px solid var(--rtc-border-strong); font-weight: 700;
}
.rtc-fintable tr.rtc-row--group > td {
  background: var(--rtc-card-alt) !important;
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--rtc-text-3);
}
.rtc-fintable .rtc-cell--muted { color: var(--rtc-text-3); }
.rtc-fintable .rtc-cell--note { font-weight: 500; color: var(--rtc-text-2); white-space: normal; }

@media print {
  /* Sticky positioning confuses paginated output; a printed table has no
     horizontal scroll to anchor against in the first place. */
  .rtc-fintable > tbody > tr > td:first-child,
  .rtc-fintable > thead > tr > th:first-child { position: static; }
  .rtc-fintable { break-inside: avoid; font-size: 8.5pt; }
  .rtc-fintable > tbody > tr:hover > td { background: transparent; }
}

/* --------------------------------------------------------- inline icons */
/* Inline SVGs carry only a viewBox, which gives them no intrinsic size — a
   browser then falls back to 100% of the container and the icon fills the card.
   The templates now set width/height attributes too; these rules size them per
   context and are the safety net if a future edit drops the attributes.
   Scoped to icon containers so chart canvases and embedded graphics are
   untouched. */
.rtc-stat__top svg,
.rtc-metric__label svg { width: 15px; height: 15px; flex: none; }
.rtc-pagetitle__ico svg { width: 20px; height: 20px; }
.btn > svg { width: 16px; height: 16px; flex: none; }
.rtc-toolbar svg, .rtc-filters__title svg,
.rtc-filters__grouplabel svg { width: 15px; height: 15px; flex: none; }
.rtc-empty > svg { width: 40px; height: 40px; }
.card-header > .fw-semibold > svg { width: 17px; height: 17px; flex: none; }


/* ============================================ authenticated app palette ==
   The public marketing pages and the logged-in app share base.html, so a
   single SITE_THEME_CSS preset used to govern both — turning the app navy
   turned the marketing site navy too.

   These declarations sit on `.app-authed` (body), overriding the :root values
   the site theme sets, for the logged-in subtree only. The public pages keep
   whatever brand palette the admin has chosen; the app is navy regardless.

   Green and red are deliberately NOT overridden here — they carry meaning on
   a screener and are set once, in the semantic block above.
   ======================================================================== */
.app-authed {
  --rtc-primary: #1E3A5F;
  --rtc-primary-dark: #16304E;
  --rtc-primary-wash: rgba(30, 58, 95, .07);
  --rtc-primary-ring: rgba(30, 58, 95, .18);
}
[data-bs-theme="dark"] .app-authed {
  /* Mid steel, not a pale tint: buttons put white text on this. */
  --rtc-primary: #4A7AB8;
  --rtc-primary-dark: #3B6396;
  --rtc-primary-wash: rgba(74, 122, 184, .14);
  --rtc-primary-ring: rgba(74, 122, 184, .30);
}

/* ------------------------------------------------- solid button contrast */
/* `.app-body a { color: … }` (0,2,0) outranks Bootstrap's `.btn-dark { color:
   #fff }` (0,1,0), so any solid button rendered as an <a> lost its white text
   and became dark-on-dark — the PDF report button was invisible. Restated here
   at matching specificity for every solid variant, links and buttons alike. */
.app-body a.btn-primary, .app-body a.btn-dark, .app-body a.btn-secondary,
.app-body a.btn-success, .app-body a.btn-danger, .app-body a.btn-info,
.app-body .btn-primary, .app-body .btn-dark, .app-body .btn-secondary,
.app-body .btn-success, .app-body .btn-danger, .app-body .btn-info {
  color: #fff;
}
.app-body a.btn-primary:hover, .app-body a.btn-dark:hover,
.app-body a.btn-success:hover, .app-body a.btn-danger:hover,
.app-body .btn-primary:hover, .app-body .btn-dark:hover,
.app-body .btn-success:hover, .app-body .btn-danger:hover { color: #fff; }
/* Amber needs dark text — white on amber fails contrast. */
.app-body a.btn-warning, .app-body .btn-warning { color: var(--rtc-text); }
/* Outline variants stay on their own colour, not the link colour. */
.app-body a.btn-outline-primary { color: var(--rtc-primary); }
.app-body a.btn-outline-secondary { color: var(--rtc-text); }
.app-body a.btn-outline-success { color: var(--rtc-pos); }
.app-body a.btn-outline-danger { color: var(--rtc-neg); }
