/* The TypeScript admin's styles (apps/admin/app/globals.css, then
   apps/admin/app/referrals.css with its assets under /static), so both
   admins look the same, and the Go pages' class equivalents of the TS
   components' inline styles at the end. Keep in step with those files. */
:root {
  --background: #0b0f14;
  --surface: #131a22;
  --border: #24303c;
  --text: #e7edf3;
  --muted: #93a4b5;
  --accent: #3b82f6;
  --danger: #f87171;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 20px;
  position: relative;
}

.brand {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  flex: 1 1 auto;
}

.nav-groups,
.nav-menu,
.nav-sheet-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-groups {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-group {
  position: relative;
}

.nav-link {
  border-radius: 6px;
  color: var(--muted);
  display: block;
  font-size: 14px;
  padding: 6px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link[aria-current='page'],
.nav-link[data-current] {
  background: var(--border);
  color: var(--text);
}

/* A group's button: a summary with a chevron that turns when it is open. */
.nav-dropdown > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-dropdown > summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown > summary::after {
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  content: '';
  display: inline-block;
  height: 6px;
  margin-left: 8px;
  transform: translateY(-3px) rotate(45deg);
  width: 6px;
}

.nav-dropdown[open] > summary::after {
  transform: translateY(1px) rotate(225deg);
}

.nav-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 40%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  left: 0;
  min-width: 180px;
  padding: 6px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 20;
}

.sign-out {
  margin: 0;
}

/* Narrow screens: the groups and the account move into one Menu. */
.nav-compact {
  display: none;
  margin-left: auto;
}

.nav-compact > summary {
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.nav-compact > summary::-webkit-details-marker {
  display: none;
}

.nav-compact-current {
  color: var(--muted);
}

.nav-sheet {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 16px 32px rgb(0 0 0 / 40%);
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  left: 0;
  padding: 16px 20px 20px;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
}

.nav-sheet-heading {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
  padding: 0 10px;
  text-transform: uppercase;
}

.nav-sheet-who {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  grid-column: 1 / -1;
  justify-content: space-between;
  padding-top: 12px;
}

.nav-sheet-who form {
  margin: 0;
}

@media (max-width: 860px) {
  .nav-wide,
  .topbar > .who,
  .sign-out {
    display: none;
  }

  .nav-compact {
    display: block;
  }
}

.who {
  color: var(--muted);
  font-size: 13px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.page {
  margin: 0 auto;
  max-width: 960px;
  padding: 28px 20px 48px;
}

/* What a console action left to say, above the page it returned to. */
.page-flash {
  padding-bottom: 0;
}

.page-flash .notice {
  margin: 0;
}

.page-narrow {
  max-width: 560px;
}

h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

h2 {
  font-size: 16px;
  margin: 28px 0 12px;
}

.panel h2 {
  margin-top: 0;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-top: 20px;
  padding: 20px;
}

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

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px 16px;
}

.row-quiet {
  background: transparent;
}

.row-main {
  flex: 1 1 240px;
  min-width: 0;
}

.title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 600;
}

.wrap {
  overflow-wrap: anywhere;
  min-width: 0;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  white-space: nowrap;
}

/* A badge in a list wraps its words once it alone is wider than the card, as a
   long permission label is on a phone, instead of pushing the page sideways. */
.badges .badge {
  border-radius: 12px;
  max-width: 100%;
  overflow-wrap: break-word;
  white-space: normal;
}

.badge-muted {
  color: var(--muted);
}

.badge-ok {
  border-color: #2f6f4e;
  color: #86efac;
}

.badge-danger {
  border-color: #7f2d2d;
  color: var(--danger);
}

.badge-warning {
  border-color: #7a5a1c;
  color: #fcd34d;
}

/* A relative time names its exact UTC time on hover. */
time[title] {
  text-decoration: underline dotted;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.action {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: 100%;
}

.button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button-quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.button-danger {
  background: transparent;
  border-color: #7f2d2d;
  color: var(--danger);
}

.button:disabled {
  cursor: default;
  opacity: 0.6;
}

.error {
  color: var(--danger);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-inline {
  margin-top: 10px;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

input,
select {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  min-width: 0;
  padding: 8px 10px;
  width: 100%;
}

input[type='checkbox'] {
  width: auto;
}

.checks {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  padding: 10px 12px;
}

.checks legend {
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

/* A long label wraps beside its checkbox rather than squeezing it. */
.check input {
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.notice {
  border: 1px solid #2f6f4e;
  border-radius: 8px;
  padding: 12px;
}

.notice p {
  margin: 0 0 10px;
}

.copy {
  display: flex;
  gap: 8px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.details {
  margin-top: 10px;
}

.details summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.panel > .form-actions {
  margin: 16px 0 8px;
}

:root {
  /* Chart series, validated for the dark surface (dataviz palette, slots 1-3). */
  --series-pulse: #3987e5;
  --series-deep: #d95926;
  --series-brute: #199e70;
  --series-other: #6b7785;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.segmented a {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  text-decoration: none;
}

.segmented a[aria-current='page'] {
  background: var(--border);
  color: var(--text);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.tiles-compact {
  margin: 0 0 12px;
}

.tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  text-decoration: none;
  min-width: 0;
}

a.tile:hover {
  border-color: var(--accent);
}

.tile-label {
  color: var(--muted);
  font-size: 12px;
}

.tile-value {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.tile-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  margin-left: 6px;
}

.chart {
  margin: 0;
}

.chart-scroll {
  overflow-x: auto;
  /* Starts scrolled to the newest days on narrow screens. */
  direction: rtl;
}

.chart-scroll > svg {
  direction: ltr;
}

.chart svg {
  display: block;
  height: auto;
  min-width: 560px;
  width: 100%;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  border-radius: 3px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.grid {
  stroke: var(--border);
  stroke-width: 1;
}

.axis {
  fill: var(--muted);
  font-size: 11px;
}

.table-wrap {
  max-height: 320px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: right;
}

th:first-child {
  text-align: left;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 20px;
  margin: 16px 0 0;
}

.fact dt {
  color: var(--muted);
  font-size: 12px;
}

.fact dd {
  margin: 2px 0 0;
  font-size: 14px;
}

.plain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.muted-inline {
  color: var(--muted);
  font-size: 12px;
}

.filters-search {
  grid-template-columns: minmax(0, 1fr) auto;
}

.notice-danger {
  border-color: #7f2d2d;
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
}

textarea {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  min-width: 0;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.panel-danger {
  border-color: #7f2d2d;
}

.row-main > p {
  margin: 0;
}

.row-main > p + p {
  margin-top: 4px;
}

/* Breathing room between blocks inside a panel. */
.panel > * + h2 {
  margin-top: 28px;
}

.panel > p.muted + form,
.panel > p.muted + .form {
  margin-top: 16px;
}

.or {
  color: var(--muted);
  font-size: 12px;
  margin: 14px 0;
}

/* Scan intelligence */
.page-wide {
  max-width: 1120px;
}

.intel-head {
  margin-bottom: 16px;
}

.intel-head h1 {
  font-size: 28px;
  letter-spacing: -0.01em;
}

.provenance {
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  gap: 10px 24px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 0 0 16px;
  padding: 12px 16px;
}

.provenance dt {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.provenance dd {
  font-size: 13px;
  margin: 2px 0 0;
  min-width: 0;
}

.filter-bar {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 16px;
}

.filter-bar .filters {
  align-items: end;
  margin: 0;
}

.filter-actions {
  min-height: 38px;
}

.filter-more .filters {
  margin-top: 10px;
}

.filter-more > .muted-inline {
  display: block;
  margin-top: 6px;
}

.cohort-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-size: 14px;
  margin: 18px 0 0;
}

.section-index {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.section-index a {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  text-decoration: none;
}

.section-index a:hover {
  border-color: var(--accent);
  color: var(--text);
}

.section-head {
  margin-bottom: 16px;
}

.section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}

.section-title h2 {
  font-size: 18px;
  margin: 0;
  scroll-margin-top: 16px;
}

.section-head > .muted {
  max-width: 72ch;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  margin: 0;
  padding: 16px;
  text-align: center;
}

.chart-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin: 18px 0 8px;
  text-transform: uppercase;
}

/* Bars: a track with fills; 2px surface gaps between stacked segments. */
.bar-track {
  background: var(--border);
  border-radius: 4px;
  display: flex;
  gap: 2px;
  height: 10px;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.bar-lg {
  height: 18px;
}

.bar-fill {
  display: block;
  flex: none;
  height: 100%;
  min-width: 3px;
}

.bar-fill:last-child {
  border-radius: 0 4px 4px 0;
}

.tone-pulse {
  background: var(--series-pulse);
}

.tone-deep {
  background: var(--series-deep);
}

.tone-accent {
  background: var(--accent);
}

.tone-completed {
  background: #0ca30c;
}

.tone-stopped {
  background: #9085e9;
}

/* Status warning: a check needs attention. */
.tone-attention {
  background: #fab219;
}

/* No information (unknown, not recorded): neutral grey with a 45° hatch, never a hue. */
.tone-unknown {
  background: repeating-linear-gradient(45deg, #6b7785 0 3px, #4b5563 3px 6px);
}

.tone-track {
  background: var(--border);
}

.tone-heat {
  background: linear-gradient(90deg, #1c3a5e, #3987e5);
}

.tone-access-absent {
  background: #6b7785;
}

.tone-access-redirect {
  background: #3987e5;
}

.tone-access-error {
  background: #e66767;
}

.tone-access-auth {
  background: #199e70;
}

.tone-access-open {
  background: #d95926;
}

.tone-access-shell {
  background: #9085e9;
}

.tone-access-key {
  background: #c98500;
}

.level-tag {
  align-items: center;
  display: inline-flex;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
  white-space: nowrap;
}

.level-pulse .swatch {
  background: var(--series-pulse);
}

.level-deep .swatch {
  background: var(--series-deep);
}

@media (forced-colors: active) {
  .bar-fill,
  .swatch {
    forced-color-adjust: none;
  }
}

/* Cohort cards */
.cohort-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.cohort-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
  padding: 16px;
}

.cohort-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.cohort-head .level-tag {
  font-size: 16px;
}

.cohort-counts {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.cohort-counts strong {
  color: var(--text);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}

.cohort-card .legend {
  margin-top: 8px;
}

.cohort-card .legend strong {
  color: var(--text);
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meter {
  align-items: center;
  display: grid;
  gap: 4px 12px;
  grid-template-columns: minmax(110px, 9rem) minmax(60px, 1fr) minmax(
      88px,
      auto
    );
  font-size: 13px;
}

.meter-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.meter-note {
  color: var(--muted);
  font-size: 12px;
  grid-column: 1 / -1;
}

/* Ranked bars (findings, checks) */
.rank-list {
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank-item {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.rank-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.rank-name {
  font-size: 14px;
  margin: 0 0 8px;
  min-width: 0;
}

.rank-name code:first-child {
  color: var(--text);
  font-size: 13px;
}

.rank-row {
  align-items: center;
  display: grid;
  gap: 4px 12px;
  grid-template-columns: 64px minmax(80px, 1fr) minmax(150px, auto);
}

.rank-row + .rank-row {
  margin-top: 6px;
}

.rank-value {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.rank-value a {
  text-decoration: none;
}

.rank-value a:hover {
  text-decoration: underline;
}

.rank-value strong {
  color: var(--text);
}

.rank-value-split {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  justify-content: flex-end;
}

.rank-note {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 4px 8px;
  grid-column: 2 / -1;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 11px;
  padding: 0 6px;
}

.chip-high {
  border-color: #7f2d2d;
  color: var(--danger);
}

/* Routes and ledger */
.two-up {
  display: grid;
  gap: 0 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  align-items: start;
}

.route-level + .route-level {
  margin-top: 20px;
}

.route-summary {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}

.stat strong {
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.class-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  margin: 14px 0 10px;
  padding: 0;
}

.class-bar {
  align-items: center;
  display: grid;
  font-size: 13px;
  gap: 10px;
  grid-template-columns: 7.5rem minmax(40px, 1fr) 4.5rem;
}

.class-name {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.class-track {
  display: flex;
  height: 10px;
}

.class-track .bar-fill {
  border-radius: 0 4px 4px 0;
}

.class-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.matrix-block + .matrix-block {
  margin-top: 20px;
}

.matrix {
  border-collapse: separate;
  border-spacing: 3px;
}

.matrix th,
.matrix td {
  border: 0;
}

.matrix thead th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  text-transform: capitalize;
  vertical-align: bottom;
}

.table-scroll .matrix th[scope='row'] {
  font-weight: 400;
  min-width: 0;
}

.matrix code {
  hyphens: manual;
}

/* A wide day chart keeps legible labels by scrolling on narrow screens. */
.chart-wide svg {
  min-width: 940px;
}

.matrix-cell {
  background: color-mix(
    in srgb,
    #3987e5 calc(var(--heat) * 70% + 14%),
    var(--surface)
  );
  border-radius: 6px;
  text-align: center;
}

.matrix-cell strong {
  display: block;
  font-size: 16px;
}

.matrix-sub {
  color: var(--text);
  display: block;
  font-size: 11px;
  opacity: 0.8;
}

.matrix-empty {
  color: var(--muted);
  text-align: center;
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll th[scope='row'] {
  font-weight: 400;
  min-width: 160px;
}

.ratio {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 64px;
}

.ratio-bar {
  background: var(--border);
  border-radius: 3px;
  display: block;
  height: 4px;
  overflow: hidden;
  width: 64px;
}

.ratio-bar > span {
  background: var(--accent);
  display: block;
  height: 100%;
}

@media (max-width: 600px) {
  .page-wide {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel {
    padding: 16px 14px;
  }

  .rank-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .rank-value,
  .rank-value-split {
    grid-column: 2;
    justify-content: flex-start;
    text-align: left;
  }

  .rank-note {
    grid-column: 2;
  }

  .meter {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .meter .bar-track,
  .meter .meter-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .class-bar {
    grid-template-columns: 6.5rem minmax(30px, 1fr) 4rem;
  }

  .cohort-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .matrix {
    border-spacing: 2px;
  }

  .matrix th,
  .matrix td {
    padding: 4px 3px;
  }

  .matrix code,
  .matrix thead th {
    font-size: 10px;
  }
}

.analysis {
  margin-top: 16px;
}

.analysis h3 {
  font-size: 14px;
  margin: 18px 0 0;
}

.analysis-item p {
  margin: 4px 0;
}

.evidence-text {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Phones: each table row becomes a labelled card instead of scrolling sideways. */
@media (max-width: 600px) {
  .table-cards thead {
    display: none;
  }

  .table-cards,
  .table-cards tbody,
  .table-cards tr {
    display: block;
  }

  .table-cards tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }

  .table-cards th[scope='row'] {
    border: 0;
    display: block;
    min-width: 0;
    padding: 0 0 4px;
    text-align: left;
  }

  .table-cards td {
    align-items: center;
    border: 0;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 3px 0;
    text-align: right;
  }

  .table-cards td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    text-align: left;
  }
}

/* AI tool consent */
.consent-list {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
}

/* Loading placeholders */
.skeleton {
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  background: var(--border);
  border-radius: 8px;
  opacity: 0.5;
}

.skeleton-strip {
  height: 56px;
  margin-top: 16px;
}

.skeleton-title {
  height: 18px;
  margin-bottom: 16px;
  width: 40%;
}

@keyframes skeleton-pulse {
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* Scoring weights editor */
.scoring-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.scoring-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  grid-template-areas:
    'name weight'
    'impact critical'
    'cap cap'
    'bar bar';
  align-items: center;
  gap: 6px 12px;
  border-top: 1px solid var(--border);
  padding: 10px 0;
}

.scoring-name {
  grid-area: name;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.scoring-id {
  font-size: 12px;
}

.scoring-weight {
  grid-area: weight;
  text-align: right;
}

.scoring-impact {
  grid-area: impact;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.scoring-cap {
  grid-area: cap;
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.scoring-cap input {
  width: 72px;
  text-align: right;
}

.scoring-critical {
  grid-area: critical;
  justify-self: end;
  font-size: 13px;
}

.scoring-bar {
  grid-area: bar;
  height: 6px;
}

.scoring-bar .bar-fill {
  background: var(--accent);
  min-width: 0;
}

.scoring-bar .scoring-bar-critical {
  background: var(--danger);
}

.scoring-group {
  font-size: 13px;
  color: var(--muted);
  margin: 20px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scoring-preview li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.scoring-preview-scores {
  display: inline-flex;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.scoring-down {
  color: var(--danger);
}

.scoring-up {
  color: #4ade80;
}

.scoring-history {
  margin-top: 14px;
}

.scoring-history .row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scoring-legend {
  margin: 12px 0 0;
  font-size: 13px;
}

@media (min-width: 720px) {
  .scoring-item {
    grid-template-columns: minmax(0, 1fr) 96px 150px 90px 130px;
    grid-template-areas:
      'name weight impact critical cap'
      'bar bar bar bar bar';
  }
}

/* Data browser: wide tables scroll inside their own box, never the page. */
.data-scroll {
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 70vh;
  max-width: 100%;
  overflow: auto;
}

.data-table {
  min-width: 100%;
  width: max-content;
}

.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface);
  position: sticky;
  top: 0;
}

.data-table th .badge {
  margin-left: 6px;
}

.data-table .num {
  text-align: right;
}

.data-table .cell {
  display: block;
  max-height: 6em;
  max-width: 40ch;
  width: max-content;
  overflow: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.data-filter {
  border: 0;
  display: grid;
  gap: 6px;
  margin: 0;
  min-width: 0;
  padding: 0;
}

/* Runs: each card leads with the run's stored score out of 100. */
.run-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.page > .muted + .filter-bar {
  margin-top: 14px;
}

.run-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 56px;
  padding: 6px 4px;
  text-align: center;
}

.run-score-value {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.run-score-scale {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.run-score-none .run-score-value {
  color: var(--muted);
}

.run-score-a {
  border-color: #2f6f4e;
  color: #86efac;
}

.run-score-b {
  border-color: #2c4f7c;
  color: #93c5fd;
}

.run-score-c {
  border-color: #6b5317;
  color: #fcd34d;
}

.run-score-d {
  border-color: #7f2d2d;
  color: var(--danger);
}

.run-score-legacy {
  border-style: dashed;
}

.runs-search {
  grid-column: span 2;
}

.score-bands {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 12px 0;
}

.score-band {
  text-decoration: none;
}

.score-band[aria-current='true'] {
  background: var(--surface);
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.score-bands + .muted-inline {
  display: block;
  margin: -4px 0 12px;
}

@media (max-width: 600px) {
  .runs-search {
    grid-column: 1 / -1;
  }

  .run-row {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .run-score-value {
    font-size: 20px;
  }
}

@font-face {
  font-family: 'Referral Archivo';
  src: url('/static/fonts/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
/* The new financial console follows the product brand without restyling other sections. */
:root:has(.referral-console) {
  --background: #ed6c4f;
  --surface: #f28a72;
  --border: rgba(23, 20, 18, 0.18);
  --text: #171412;
  --muted: #40251f;
  --accent: #171412;
  --danger: #171412;
}
body:has(.referral-console) {
  font-family: 'Referral Archivo', sans-serif;
}
body:has(.referral-console) .brand {
  font-size: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
body:has(.referral-console) .brand::before {
  content: '';
  display: block;
  width: 105px;
  height: 28px;
  background: url('/static/brand/lockpick-wordmark.svg') center / contain
    no-repeat;
}
body:has(.referral-console) .brand::after {
  content: 'Admin';
  font-size: 14px;
}
.referral-console h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.045em;
}
.referral-console h2 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.referral-console p {
  line-height: 1.5;
}
.referral-console .row-main {
  display: grid;
  gap: 6px;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.referral-console .button {
  background: #171412;
  color: #fff0eb;
  border-radius: 999px;
  white-space: normal;
}
.referral-console input {
  background: #f8b5a3;
  border-color: rgba(23, 20, 18, 0.38);
  font-size: 16px;
}
.referral-console code {
  display: block;
  overflow-wrap: anywhere;
}

/* Go admin: what the TS components set inline, as classes, so the CSP
   allows only 'self' styles. */
.swatch-pulse,
.fill-pulse {
  background: var(--series-pulse);
  fill: var(--series-pulse);
}
.swatch-deep,
.fill-deep {
  background: var(--series-deep);
  fill: var(--series-deep);
}
.swatch-brute,
.fill-brute {
  background: var(--series-brute);
  fill: var(--series-brute);
}
.swatch-other,
.fill-other {
  background: var(--series-other);
  fill: var(--series-other);
}
.chart svg .hit {
  fill: transparent;
}
.scoring-bar .bar-fill-svg {
  fill: var(--accent);
}
.scoring-bar .bar-fill-svg.scoring-bar-critical {
  fill: var(--danger);
}
svg.scoring-bar {
  display: block;
  width: 100%;
}

/* A TS confirm() without scripts: the action's button opens its question,
   and the form inside it makes the change. */
.confirm > summary {
  display: inline-block;
  list-style: none;
  cursor: pointer;
}

.confirm > summary::-webkit-details-marker {
  display: none;
}

.confirm[open] > form {
  margin-top: 8px;
}

/* Growth page meters: the TS page's StackedBar sets its width inline; here
   it is an SVG rect's width, which the CSP allows. */
.meter-bar {
  border-radius: 4px;
  display: block;
  height: 10px;
  width: 100%;
}
.meter-track {
  fill: var(--border);
}
.meter-fill {
  fill: var(--accent);
}

/* Scan intelligence bars without inline styles: a segment is an <svg> whose
 width attribute is its share, and a packet cell takes one of eleven heat
 steps (0 to 1 in tenths) in place of the TS --heat style. */
.bar-fill .hit {
  fill: transparent;
}
.ratio-bar > svg {
  background: var(--accent);
  display: block;
  height: 100%;
}
.heat-0 {
  --heat: 0;
}
.heat-1 {
  --heat: 0.1;
}
.heat-2 {
  --heat: 0.2;
}
.heat-3 {
  --heat: 0.3;
}
.heat-4 {
  --heat: 0.4;
}
.heat-5 {
  --heat: 0.5;
}
.heat-6 {
  --heat: 0.6;
}
.heat-7 {
  --heat: 0.7;
}
.heat-8 {
  --heat: 0.8;
}
.heat-9 {
  --heat: 0.9;
}
.heat-10 {
  --heat: 1;
}

/* A panel whose form staff open when they need it (Invite staff), its
   heading the button. */
.panel-disclosure > summary {
  cursor: pointer;
  list-style: none;
}

.panel-disclosure > summary::-webkit-details-marker {
  display: none;
}

.panel-disclosure > summary h2 {
  display: inline;
  margin: 0;
}

.panel-disclosure > summary::before {
  color: var(--muted);
  content: '+ ';
}

.panel-disclosure[open] > summary::before {
  content: '− ';
}

.panel-disclosure[open] > summary {
  margin-bottom: 16px;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
