/* Macro Monitor — serious, data-first */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #fafafa;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #111111;
  --text-muted: #6b6b6b;
  --text-faint: #9a9a9a;
  --accent: #0B3D91;
  --accent-hover: #0A3478;
  --good: #1a7f3c;
  --bad: #b42318;
  --neutral: #6b6b6b;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-subtle: 0 1px 0 rgba(0,0,0,0.02);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --surface: #151619;
    --surface-alt: #1a1c20;
    --border: #2a2d32;
    --border-strong: #3a3d42;
    --text: #ececec;
    --text-muted: #9ca0a8;
    --text-faint: #6a6e76;
    --accent: #6d9ff0;
    --accent-hover: #8ab4f8;
    --good: #3fb96a;
    --bad: #ef6b5a;
    --neutral: #9ca0a8;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.tnum, .value, .delta, .sub-metric, .updated, .as-of {
  font-variant-numeric: tabular-nums lining-nums;
}

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.gate-form {
  width: 100%;
  max-width: 340px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
.gate-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.gate-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
  margin-bottom: 8px;
}
.gate-input {
  font-family: var(--sans);
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.gate-input:focus { border-color: var(--accent); }
.gate-button {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}
.gate-button:hover { background: var(--accent-hover); }
.gate-error {
  font-size: 13px;
  color: var(--bad);
  min-height: 18px;
}

/* ---------- App ---------- */
.app {
  display: none;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 32px 64px;
}
.app[data-visible="true"] { display: block; }

.masthead {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 32px;
}
.masthead-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}
.masthead-meta {
  font-size: 12px;
  color: var(--text-faint);
}
.updated { font-family: var(--mono); font-size: 11.5px; }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
@media (max-width: 780px) {
  .grid { grid-template-columns: 1fr; }
  .app { padding: 28px 18px 48px; }
  .title { font-size: 24px; }
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.card-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}
.card-series {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.card-note {
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
  margin-top: -6px;
}
.card-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.value-unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}
.as-of {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}
.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.metric-label {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
  font-weight: 500;
}
.metric-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.neutral { color: var(--neutral); }
.delta .arrow { font-size: 11px; line-height: 1; }

.chart {
  margin-top: 4px;
  height: 110px;
  width: 100%;
}

.card.loading .value { color: var(--text-faint); }
.card.error .value { color: var(--bad); font-size: 16px; font-weight: 500; }
.card.error .chart { display: none; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}
.footer a { color: var(--text-muted); text-decoration: underline; text-decoration-color: var(--border-strong); }
.footer a:hover { color: var(--accent); }
.sep { margin: 0 8px; color: var(--border-strong); }

/* Plotly cleanup */
.js-plotly-plot .plotly .modebar { display: none !important; }
