/* ── custom properties ── */
:root {
  --bg:           #0d1117;
  --card:         #161b22;
  --border:       #30363d;
  --text:         #e6edf3;
  --muted:        #8b949e;
  --accent-blue:  #58a6ff;
  --accent-amber: #d29922;
  --accent-red:   #f85149;
  --accent-green: #3fb950;
  --accent-orange: #e3a750;

  --radius: 6px;
  --font:   'Menlo', 'Consolas', 'DejaVu Sans Mono', monospace, system-ui;
}

/* ── reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
}

/* ── utilities ── */
.hidden { display: none !important; }

/* ── header ── */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-meta {
  font-size: 11px;
  color: var(--muted);
}

/* ── stage toggle ── */
.stage-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-option {
  cursor: pointer;
}

.toggle-option input[type="radio"] {
  display: none;
}

.toggle-option span {
  display: block;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.toggle-option input[type="radio"]:checked + span {
  background: var(--accent-blue);
  color: #fff;
}

.toggle-option:not(:last-child) span {
  border-right: 1px solid var(--border);
}

/* ── error banner ── */
.error-banner {
  margin: 24px auto;
  max-width: 680px;
  border: 1px solid var(--accent-red);
  border-radius: var(--radius);
  background: rgba(248, 81, 73, 0.08);
  padding: 16px 20px;
}

.error-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.error-icon {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-red);
  line-height: 1;
  flex-shrink: 0;
}

.error-title {
  font-weight: 700;
  color: var(--accent-red);
  margin-bottom: 4px;
}

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

.error-body code {
  color: var(--text);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.retry-btn {
  margin-left: auto;
  flex-shrink: 0;
  padding: 5px 14px;
  background: var(--accent-red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.retry-btn:hover { opacity: 0.8; }

/* ── main content ── */
#main-content {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── headline cards ── */
.cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

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

.card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 4px;
}

.card-value.green  { color: var(--accent-green); }
.card-value.amber  { color: var(--accent-amber); }
.card-value.red    { color: var(--accent-red); }

.card-sub {
  font-size: 10px;
  color: var(--muted);
}

/* ── chart sections ── */
.chart-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.chart-section h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Section header with inline toggles (CTA usage view + grouping) */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.section-head h2 { margin-bottom: 0; }

.toggle-cluster {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Same pill look as the header stage toggle */
.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sub-section-title {
  margin-top: 20px !important;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.chart-wrap-small {
  height: 160px;
}

/* ── incident callout ── */
.incident-callout {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent-amber);
  background: rgba(210, 153, 34, 0.07);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.incident-callout strong {
  color: var(--accent-amber);
  display: block;
  margin-bottom: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── product analytics divider ── */
.section-group-head {
  margin: 32px 0 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-group-head h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.section-group-note {
  font-size: 11px;
  color: var(--muted);
}

/* ── telemetry empty-state ── */
.telemetry-empty {
  padding: 12px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.telemetry-empty code {
  color: var(--text);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ── no-errors placeholder ── */
.no-errors {
  padding: 12px 16px;
  text-align: center;
  color: var(--accent-green);
  font-size: 12px;
  border: 1px solid rgba(63, 185, 80, 0.25);
  border-radius: var(--radius);
  margin-top: 10px;
}

/* ── cost section extras ── */
.cost-totals {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cost-totals table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.cost-totals th,
.cost-totals td {
  padding: 7px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.cost-totals th {
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.cost-totals td { color: var(--text); }
.cost-totals tr:last-child td { border-bottom: none; }

.cost-disclaimer {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(210, 153, 34, 0.06);
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: var(--radius);
  font-size: 10px;
  color: var(--accent-amber);
  font-style: italic;
  line-height: 1.6;
}

/* ── footer ── */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

/* ── responsive ── */
@media (max-width: 900px) {
  .cards-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .cards-row {
    grid-template-columns: 1fr;
  }

  .chart-wrap { height: 200px; }
  .chart-wrap-small { height: 130px; }

  #main-content { padding: 12px; }

  .footer { flex-direction: column; gap: 6px; }
}
