:root {
  color-scheme: dark;
  --bg: #050914;
  --panel: #0a1424;
  --panel-2: #0d1b2d;
  --line: #1d3350;
  --text: #e8f1ff;
  --muted: #8fa4bd;
  --muted-2: #647a94;
  --accent: #48a6ff;
  --accent-2: #6ee7f9;
  --danger: #ff6b7a;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--bg);
}

body {
  min-width: 0;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -10%, rgba(38, 122, 214, 0.22), transparent 36rem),
    linear-gradient(180deg, #07111f 0%, var(--bg) 38rem);
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 18px 34px;
}

.topbar,
.section-title-row,
.panel-heading,
.topbar-meta,
.control-row,
.legend,
.latest-metrics,
.detail-list div,
.category-row,
.cadence-row,
.month-axis,
.segmented {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1,
.section-title-row h2,
.latest-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 5vw, 40px);
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-meta {
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.source-pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  white-space: nowrap;
}

button,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #0b182a;
}

button {
  padding: 0 13px;
  cursor: pointer;
}

select {
  width: 100%;
  padding: 0 34px 0 12px;
}

button:hover,
select:hover,
button:focus-visible,
select:focus-visible {
  border-color: #3d7fbd;
  outline: none;
}

.latest-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(250px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel,
.latest-panel,
.summary-card {
  border: 1px solid rgba(84, 135, 188, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(15, 31, 51, 0.96), rgba(8, 18, 32, 0.96));
  box-shadow: var(--shadow);
}

.latest-panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.category-badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}

.category-badge::before,
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--dot, var(--accent));
  content: "";
}

.latest-panel h2 {
  max-width: 900px;
  font-size: clamp(24px, 5.4vw, 42px);
  line-height: 1.08;
}

.latest-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0 16px;
}

.latest-metrics > div,
.detail-list div,
.summary-card {
  background: rgba(255, 255, 255, 0.045);
}

.latest-metrics > div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 14px;
}

.metric-label,
.summary-card span,
.big-number span,
.chart-note {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.latest-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(24px, 5vw, 42px);
  line-height: 1;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-list div {
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  border-radius: var(--radius);
  padding: 12px;
}

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

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.summary-panel {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.summary-card {
  min-width: 0;
  padding: 18px;
}

.summary-card strong,
.big-number strong {
  display: block;
  margin-top: 4px;
  color: #ffffff;
  font-size: clamp(28px, 6vw, 48px);
  line-height: 1;
}

.panel {
  min-width: 0;
  padding: 18px;
  margin-bottom: 14px;
}

.section-title-row {
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title-row h2 {
  font-size: 20px;
}

.control-row {
  align-items: end;
  gap: 10px;
}

.control-row label {
  min-width: 132px;
  color: var(--muted);
  font-size: 12px;
}

.chart-box {
  width: 100%;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  background: rgba(2, 8, 18, 0.44);
}

.chart-box.compact {
  min-height: 280px;
}

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

.axis-label {
  fill: #8fa4bd;
  font-size: 12px;
}

.grid-line {
  stroke: rgba(143, 164, 189, 0.18);
  stroke-width: 1;
}

.forecast-label {
  fill: #d7e8ff;
  font-size: 12px;
  font-weight: 700;
}

.legend {
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.chart-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.prediction-card {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 13px;
  background: rgba(255, 255, 255, 0.045);
}

.prediction-card.dormant {
  border-color: rgba(143, 164, 189, 0.22);
}

.prediction-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.estimate-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 999px;
  padding: 4px 7px;
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.1);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.prediction-card strong {
  display: block;
  font-size: 17px;
  line-height: 1.35;
}

.prediction-range {
  margin-top: 8px;
  color: #ffffff;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.prediction-card p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.segmented {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #07111f;
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  color: #ffffff;
  background: #12345a;
}

.category-stats,
.cadence-table {
  display: grid;
  gap: 8px;
}

.category-row,
.cadence-row {
  min-width: 0;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.category-name,
.cadence-name {
  min-width: 136px;
  max-width: 200px;
  font-weight: 700;
}

.bar-track {
  position: relative;
  min-width: 70px;
  flex: 1 1 160px;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w, 0%);
  border-radius: inherit;
  background: var(--bar, var(--accent));
}

.stat-cells,
.cadence-cells {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 8px;
  min-width: 360px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.stat-cells strong,
.cadence-cells strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.rhythm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
}

.rhythm-grid .panel {
  margin-bottom: 0;
}

.aaip-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(110, 231, 249, 0.2);
}

.aaip-head {
  margin-bottom: 14px;
}

.aaip-latest-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.aaip-latest-grid > div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.aaip-latest-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: clamp(20px, 4vw, 32px);
  line-height: 1.05;
}

.aaip-stream-name {
  position: relative;
  padding-left: 16px;
}

.aaip-stream-name::before {
  position: absolute;
  top: 0.45em;
  left: 0;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--dot, var(--accent));
  content: "";
}

.aaip-stream-name span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pool-table {
  display: grid;
  gap: 8px;
}

.pool-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.pool-row span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  overflow-wrap: anywhere;
}

.pool-row strong {
  flex: 0 0 auto;
  font-size: 18px;
}

.big-number {
  text-align: right;
}

.empty-state,
.error-state {
  padding: 22px;
  color: var(--muted);
}

.error-state {
  color: #ffbcc4;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px 12px 26px;
  }

  .topbar,
  .section-title-row,
  .panel-heading,
  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-meta {
    justify-content: space-between;
  }

  .latest-grid,
  .rhythm-grid,
  .latest-metrics,
  .detail-list,
  .aaip-latest-grid {
    grid-template-columns: 1fr;
  }

  .latest-panel,
  .panel {
    padding: 14px;
  }

  .summary-panel {
    grid-template-columns: 1fr;
  }

  .control-row label {
    min-width: 0;
  }

  .category-row,
  .cadence-row {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .bar-track {
    flex: 0 0 auto;
    width: 100%;
    height: 11px;
  }

  .category-name,
  .cadence-name {
    max-width: none;
  }

  .stat-cells,
  .cadence-cells {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    text-align: left;
  }

  .prediction-grid {
    grid-template-columns: 1fr;
  }

  .prediction-top {
    align-items: stretch;
    flex-direction: column;
  }

  .estimate-badge {
    width: fit-content;
  }

  .chart-box {
    min-height: 270px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar h1 {
    font-size: 25px;
  }

  .latest-panel h2 {
    font-size: 25px;
  }

  .category-badge {
    font-size: 12px;
  }
}
