/* Google-Charts-inspired look: clean whites/greys, soft shadows, Roboto. */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Roboto+Mono&display=swap');

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e1e5ea;
  --text: #202124;
  --text-muted: #5f6368;
  --accent: #1a73e8;
  --accent-hover: #1765cc;
  --green: #0f9d58;
  --yellow: #f4b400;
  --red: #db4437;
  --shadow-sm: 0 1px 2px rgba(60,64,67,0.08), 0 1px 3px rgba(60,64,67,0.05);
  --shadow-md: 0 2px 6px rgba(60,64,67,0.10), 0 1px 2px rgba(60,64,67,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LOADING OVERLAY ── */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(245,247,250,0.92);
  z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  transition: opacity 0.3s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
#load-status { color: var(--text-muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOP BAR ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.brand-mark { font-size: 20px; }
.meta-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px 100px;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
  position: sticky; top: 56px;
}
.sidebar h1 { font-size: 18px; font-weight: 500; margin-bottom: 4px; }
.lede { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

fieldset {
  border: 0;
  margin-bottom: 18px;
  padding: 0;
}
legend {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
fieldset input[type="radio"] { accent-color: var(--accent); }
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-marks {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}

button.primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled { background: var(--text-muted); cursor: not-allowed; opacity: 0.6; }

/* ── RESULTS ── */
.results { padding: 24px; overflow-y: auto; }
.hidden { display: none !important; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty h2 { font-weight: 500; font-size: 18px; margin-bottom: 8px; color: var(--text); }

.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.summary-card .label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.summary-card .value {
  font-size: 22px; font-weight: 500;
  font-family: 'Roboto Mono', monospace;
}
.summary-card .value.green  { color: var(--green); }
.summary-card .value.red    { color: var(--red); }
.summary-card .value.yellow { color: var(--yellow); }
.summary-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.summary-card .tip {
  position: absolute; top: 8px; right: 10px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  cursor: help;
  border: 1px solid var(--border);
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.chart-wide { grid-column: 1 / -1; }
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.chart-card h3 { font-size: 13px; font-weight: 500; }
.chart { width: 100%; height: 320px; }
.chart-wide .chart { height: 260px; }

.section-head {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin: 24px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.cite {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  font-style: italic;
}
.sub-radio {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.sub-radio.hidden { display: none; }
.sub-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.toggle button {
  background: var(--surface); border: 0; padding: 4px 10px;
  font-size: 12px; cursor: pointer; color: var(--text-muted);
}
.toggle button.active { background: var(--accent); color: white; }

.recommendations {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.recommendations h3 { font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.recommendations ol { padding-left: 20px; }
.recommendations li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.recommendations li:last-child { border-bottom: 0; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 24px;
  }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: auto; }
}
