:root {
  --bg: #06070d;
  --panel: #161528;
  --panel-soft: #1c1a31;
  --panel-deep: #11101d;
  --text: #eef2ff;
  --muted: #9aa1bc;
  --line: #2d2940;
  --good: #68e66b;
  --warn: #f59e0b;
  --bad: #ff5f7a;
  --accent: #8b7dff;
  --accent-soft: #27233d;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: radial-gradient(circle at top, rgba(139,125,255,.10), transparent 18%), linear-gradient(180deg, #05060b 0%, #0b0b14 100%);
  color: var(--text);
  overflow-x: hidden;
}
.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 28px clamp(18px, 2.2vw, 36px) 32px;
}
.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(24, 22, 40, .98), rgba(17, 16, 29, .98));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 18px 44px rgba(0,0,0,.34);
}
.card::before {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,125,255,.6), transparent);
}
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1.1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.hero > * {
  min-width: 0;
}
.hero-copy,
.controls,
.controls label {
  min-width: 0;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #8fb5ff;
  font-size: 12px;
  margin: 0 0 8px;
}
h1 { margin: 0 0 10px; font-size: 40px; line-height: 1.05; }
.subtitle { margin: 0; color: var(--muted); max-width: 860px; line-height: 1.7; }
.mini-desc {
  margin: 0 0 14px;
  color: #b6c2df;
  font-size: 14px;
  line-height: 1.55;
  max-width: 760px;
}
.hero-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(27, 25, 46, .92);
  border: 1px solid rgba(139,125,255,.16);
}
.tab-btn {
  appearance: none;
  border: 1px solid rgba(139,125,255,.16);
  background: rgba(139,125,255,.08);
  color: #eef2ff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}
.tab-btn.active {
  background: linear-gradient(180deg, #9a8cff, #7c6cff);
  color: #0b0b14;
  border-color: #8b7dff;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(139,125,255,.28);
}
.tab-panel { display: none; }
.tab-panel.active { display: grid; gap: 18px; }
.tab-panel.active > .card,
.tab-panel.active > .grid {
  content-visibility: auto;
  contain-intrinsic-size: 520px;
}
.primary-decisions { order: 1; }
.bucket-audit-layer { order: 2; }
.secondary-stats { order: 3; }
.meta-layer { order: 4; }
.rankings-block { order: 5; }
.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}
.controls label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
  background: rgba(26, 35, 68, .7);
  border: 1px solid var(--line);
  border-radius: 16px;
}
select, input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: rgba(8, 16, 31, .45);
  border: 1px solid rgba(151,163,196,.18);
  border-radius: 12px;
  color: var(--text);
  padding: 12px;
}
.controls small {
  color: var(--muted);
  line-height: 1.6;
  grid-column: 1 / -1;
  padding: 4px 2px 0;
}
.timezone-note {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(143, 181, 255, .18);
  background: rgba(143, 181, 255, .08);
  color: #d9e6ff;
  line-height: 1.55;
  font-size: 13px;
}
.timezone-note strong {
  color: #eef2ff;
}
.leads-toolbar {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.leads-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  min-width: 240px;
}
.grid { display: grid; gap: 16px; margin-bottom: 0; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.one-col { grid-template-columns: 1fr; }
.stat-card {
  padding: 18px;
  min-height: 148px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, rgba(31, 29, 53, .98), rgba(21, 20, 35, .98));
  border-color: rgba(139,125,255,.12);
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -26px;
  bottom: -30px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(139,125,255,.18), transparent 62%);
  pointer-events: none;
}
.stat-label {
  color: #b8bfd8;
  font-size: 12px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.stat-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -.03em;
}
.stat-sub { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.45; }
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(151,163,196,.10);
}
.section-head h2 { margin: 0; font-size: 20px; }
.section-head span { color: var(--muted); font-size: 13px; }
.decision {
  min-height: 260px;
}
.decision .section-head {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(151,163,196,.10);
}
.decision .section-head h2 {
  font-size: 20px;
  line-height: 1.2;
}
.decision .section-head span {
  color: var(--muted);
  font-size: 13px;
}
.decision .mini-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.decision-good { border-color: rgba(34,197,94,.22); }
.decision-good::before { background: linear-gradient(90deg, transparent, rgba(104,230,107,.55), transparent); }
.decision-warn { border-color: rgba(245,158,11,.22); }
.decision-warn::before { background: linear-gradient(90deg, transparent, rgba(245,158,11,.55), transparent); }
.decision-bad { border-color: rgba(239,68,68,.22); }
.decision-bad::before { background: linear-gradient(90deg, transparent, rgba(255,95,122,.55), transparent); }
.list-stack { display: grid; gap: 12px; }
.list-item {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(31, 29, 53, .92), rgba(23, 21, 38, .96));
  border: 1px solid rgba(72, 68, 99, .9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.list-item strong {
  display: block;
  margin-bottom: 10px;
  font-size: 15px;
  line-height: 1.35;
}
.list-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.info-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(139,125,255,.10);
  border: 1px solid rgba(139,125,255,.16);
  color: #d7ddf4;
  font-size: 12px;
  line-height: 1;
}
.info-chip.good {
  border-color: rgba(104,230,107,.25);
  color: #92f5a1;
  background: rgba(104,230,107,.08);
}
.info-chip.warn {
  border-color: rgba(245,158,11,.25);
  color: #ffd27a;
  background: rgba(245,158,11,.08);
}
.info-chip.bad {
  border-color: rgba(255,95,122,.25);
  color: #ff9aaa;
  background: rgba(255,95,122,.08);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.metric-pill {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12, 11, 21, .62);
  border: 1px solid rgba(72, 68, 99, .75);
}
.metric-pill span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.metric-pill strong {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}
.list-meta-primary {
  color: #d7ddf4;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 6px;
}
.list-meta-secondary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 8px;
}
.list-note {
  color: #eef2ff;
  font-size: 14px;
  line-height: 1.5;
}
.list-item small {
  color: var(--muted);
  line-height: 1.45;
  display: block;
  font-size: 12px;
}

#lowSourceBuckets,
#lowReviewList {
  margin-top: 14px;
}
.master-table-card {
  overflow: visible;
}
.master-level-tabs,
.master-presets,
.master-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.master-level-tabs {
  margin-bottom: 14px;
}
.master-toolbar {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  align-items: end;
}
.master-toolbar label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.master-toggle,
.master-preset-btn,
.master-chip,
.master-clear-btn {
  appearance: none;
  border: 1px solid rgba(139,125,255,.16);
  background: rgba(139,125,255,.08);
  color: #eef2ff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
}
.master-toggle.active,
.master-preset-btn.active {
  background: linear-gradient(180deg, #9a8cff, #7c6cff);
  color: #0b0b14;
  border-color: #8b7dff;
  font-weight: 700;
}
.master-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}
.master-clear-btn {
  padding: 2px 8px;
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.06);
}
.master-table-shell .table-wrap {
  max-height: none;
}
.master-mobile-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.master-mobile-head input {
  margin-top: 3px;
}
.master-mobile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.master-mobile-metric {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(17, 16, 29, .92);
  border: 1px solid rgba(72, 68, 99, .75);
}
.master-mobile-metric span {
  display: block;
  color: #b7bdd4;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.master-mobile-metric strong {
  display: block;
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}
.master-mobile-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  padding: 0 2px;
}
.master-table {
  min-width: 1220px;
}
.master-table th.sortable {
  cursor: pointer;
}
.master-table th.sortable span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.master-table th.sortable .sort-indicator {
  color: #8fb5ff;
  font-size: 11px;
}
.master-table .sticky-col,
.master-table .sticky-cell,
.master-table .totals-sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #18172a;
}
.master-table .sticky-cell {
  background: rgba(18, 17, 30, .98);
}
.master-table tbody tr:nth-child(even) .sticky-cell {
  background: rgba(27, 25, 46, .98);
}
.master-table tfoot td {
  position: sticky;
  bottom: 0;
  background: #12111f;
  border-top: 1px solid rgba(151,163,196,.14);
  font-weight: 700;
  z-index: 1;
}
.master-table .name-cell {
  min-width: 320px;
}
.master-name-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.master-name-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 3px;
}
.master-name-meta {
  display: grid;
  gap: 4px;
}
.master-name-meta .muted {
  font-size: 12px;
  line-height: 1.4;
}
.master-empty {
  padding: 18px;
  border: 1px dashed rgba(151,163,196,.16);
  border-radius: 16px;
  color: var(--muted);
}
.table-wrap {
  overflow: auto;
  max-height: 560px;
  border: 1px solid rgba(151,163,196,.10);
  border-radius: 16px;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: #c6cdea;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: #18172a;
  z-index: 1;
}
tbody tr:nth-child(odd) { background: rgba(17,16,29,.92); }
tbody tr:nth-child(even) { background: rgba(28,26,49,.92); }
tbody tr:hover { background: rgba(139,125,255,.08); }
tr:last-child td { border-bottom: none; }
tbody td strong { font-size: 15px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.good { background: rgba(34,197,94,.15); color: #7ff0a5; }
.badge.warn { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge.bad { background: rgba(239,68,68,.15); color: #fda4af; }
.muted { color: var(--muted); }
.metric-pair { display: flex; flex-wrap: wrap; gap: 8px; }
.metric-pill {
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--panel-soft);
  color: #d8e0f3;
  font-size: 12px;
}
.mobile-filters-toggle {
  display: none;
}
@media (max-width: 1180px) {
  .hero, .stats, .two-col, .three-col, .controls { grid-template-columns: 1fr; }
  .page { padding: 18px; }
  .master-toolbar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .page { padding: 10px; }
  .card { padding: 14px; border-radius: 18px; }
  .hero { gap: 12px; }
  h1 { font-size: 24px; }
  .subtitle { font-size: 14px; line-height: 1.45; }
  .hero .subtitle { display: block; }
  #highTab > .card .subtitle,
  #highTab > .card .mini-desc,
  #lowTab > .card .subtitle,
  #lowTab > .card .mini-desc,
  #leadsTab > .card .subtitle,
  #leadsTab > .card .mini-desc {
    display: none;
  }
  .stat-card {
    min-height: 128px;
    padding: 16px;
  }
  .stat-value {
    font-size: 36px;
  }
  .hero-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    margin-top: 14px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
  }
  .tab-btn {
    width: 100%;
    min-width: 0;
    white-space: normal;
    flex: 0 0 auto;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.15;
  }
  .mobile-filters-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(139,125,255,.18);
    background: rgba(139,125,255,.10);
    color: #eef2ff;
    font-size: 13px;
    font-weight: 700;
  }
  .controls {
    display: none;
    gap: 10px;
  }
  .hero.mobile-filters-open .controls {
    display: grid;
  }
  .controls label {
    padding: 0;
    background: none;
    border: none;
    gap: 6px;
  }
  .controls small {
    display: none;
  }
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }
  .decision {
    min-height: auto;
  }
  .decision .section-head h2 {
    font-size: 20px;
  }
  .decision .section-head span {
    font-size: 12px;
  }
  .decision .mini-desc {
    display: none;
  }
  .master-table-card {
    display: block;
  }
  .master-toolbar {
    grid-template-columns: 1fr;
  }
  .master-mobile-grid {
    grid-template-columns: 1fr;
  }
  .table-wrap {
    max-height: none;
    overflow: visible;
    border: none;
  }
  table, thead, tbody, th, td, tr {
    display: block;
  }
  thead {
    display: none;
  }
  table {
    min-width: 0;
  }
  tbody {
    display: grid;
    gap: 10px;
  }
  tr {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 10px;
    background: rgba(24, 22, 40, .98);
  }
  td {
    position: relative;
    padding: 10px 12px 10px 110px;
    border-bottom: none;
    border-radius: 14px;
    min-height: 40px;
    margin-bottom: 6px;
  }
  td:nth-child(odd) {
    background: rgba(16, 15, 28, .96);
  }
  td:nth-child(even) {
    background: rgba(27, 25, 46, .98);
  }
  td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    top: 11px;
    width: 88px;
    color: #b7bdd4;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
  }
  td:last-child {
    border-bottom: none;
  }
}
