/* macro.css — Macro Analysis page (#macro). Theme-driven via CSS vars in
 * styles.css, so it adapts to dark / blue / light automatically. No bright-blue
 * fills on dark; positive = var(--green), negative = var(--red). */

/* Full-width page; not symbol-driven so hide the global instrument bar. */
body.page-macro .instr-bar { display: none !important; }
.mac-wrap { max-width: none; margin: 0; padding: 4px 16px 40px; }
.mac-intro { color: var(--text-2); font-size: 13px; margin: 2px 0 14px; line-height: 1.5; }
.mac-intro b { color: var(--text); font-weight: 600; }

/* ── Hero: regime gauge + rationale ─────────────────────────────────────────*/
.mac-hero {
  display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 20px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px;
}
.mac-gauge-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.mac-regime { font-size: 26px; font-weight: 700; letter-spacing: .01em; line-height: 1; }
.mac-regime .mac-score { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 8px; }
.mac-regime.mac-on   { color: var(--green); }
.mac-regime.mac-off  { color: var(--red); }
.mac-regime.mac-neu  { color: var(--text-2); }
.mac-regime.mac-stress { color: var(--red); }

.mac-meter { width: 100%; max-width: 320px; }
.mac-meter-track {
  position: relative; height: 12px; border-radius: 7px;
  background: linear-gradient(90deg, var(--red) 0%, #d9a441 50%, var(--green) 100%);
  opacity: .92;
}
.mac-meter-mark {
  position: absolute; top: 50%; width: 4px; height: 22px; border-radius: 3px;
  background: var(--text); transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px var(--panel);
}
.mac-meter-scale { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10px; color: var(--muted); }

.mac-gauge-note { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.4; max-width: 320px; }

.mac-rationale { display: flex; flex-direction: column; gap: 7px; justify-content: center; }
.mac-rationale h3 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mac-rationale ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.mac-rationale li { font-size: 13.5px; color: var(--text); padding-left: 16px; position: relative; line-height: 1.4; }
.mac-rationale li::before { content: "▸"; position: absolute; left: 0; color: var(--muted); }
.mac-rationale li.mac-warn { color: var(--red); font-weight: 600; }
.mac-asof { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ── Legend ─────────────────────────────────────────────────────────────────*/
.mac-legend {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 11.5px; color: var(--muted); margin: -4px 0 16px; line-height: 1.5;
}
.mac-legend b { color: var(--text-2); font-weight: 600; }
.mac-lg-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 4px; background: var(--muted); }
.mac-lg-dot.mac-pos { background: var(--green); }
.mac-lg-dot.mac-neg { background: var(--red); margin-left: 10px; }
.mac-lg-sep { color: var(--border); margin: 0 2px; }

/* ── Sections & tiles ───────────────────────────────────────────────────────*/
.mac-section { margin-bottom: 20px; }
.mac-section h2 {
  font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .05em; margin: 0 0 9px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.mac-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }

.mac-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 5px;
  transition: border-color .15s ease;
}
.mac-tile:hover { border-color: var(--muted); }
.mac-tile.mac-clickable { cursor: pointer; }
.mac-tile.mac-clickable:hover { border-color: var(--accent); }
.mac-tile.mac-dead { opacity: .5; }

.mac-tile-top { display: flex; align-items: center; gap: 7px; }
.mac-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--muted); }
.mac-dot.mac-pos { background: var(--green); }
.mac-dot.mac-neg { background: var(--red); }
.mac-tile-label { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.2; }

.mac-tile-vals { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.mac-last { font-size: 21px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.mac-pill {
  font-size: 12px; font-weight: 650; padding: 2px 7px; border-radius: 5px;
  font-variant-numeric: tabular-nums; background: var(--panel-2); color: var(--muted);
}
.mac-pill.mac-pos { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.mac-pill.mac-neg { color: var(--red);   background: color-mix(in srgb, var(--red) 14%, transparent); }

.mac-sub { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* ── "Why it matters" expander ──────────────────────────────────────────────*/
.mac-why {
  margin-top: 2px; align-self: flex-start; background: none; border: 0; padding: 2px 0;
  font: inherit; font-size: 10.5px; font-weight: 600; color: var(--accent); cursor: pointer;
  display: inline-flex; align-items: center; gap: 3px; letter-spacing: .01em;
}
.mac-why:hover { text-decoration: underline; }
.mac-chev { font-size: 9px; transition: transform .15s ease; }
.mac-tile.open .mac-chev { transform: rotate(180deg); }
.mac-explain {
  display: none; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 11.5px; line-height: 1.5; color: var(--text-2);
}
.mac-tile.open .mac-explain { display: block; }
.mac-tile.open { border-color: var(--muted); }
.mac-5d { font-size: 10.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mac-5d .mac-pos { color: var(--green); }
.mac-5d .mac-neg { color: var(--red); }
.mac-err { font-size: 11px; color: var(--muted); font-style: italic; }

/* ── FII / DII flow tile ────────────────────────────────────────────────────*/
.mac-flow {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px;
}
.mac-flow-cell { display: flex; flex-direction: column; gap: 3px; align-items: center; text-align: center; }
.mac-flow-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.mac-flow-v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mac-flow-v.mac-pos { color: var(--green); }
.mac-flow-v.mac-neg { color: var(--red); }
.mac-flow-date { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: right; }

.mac-loading, .mac-fail { padding: 40px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.mac-refresh-note { font-size: 11px; color: var(--muted); text-align: right; margin-top: 4px; }

/* ── Central banks ──────────────────────────────────────────────────────────*/
.mac-cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.mac-cb {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; display: flex; flex-direction: column; gap: 3px;
}
.mac-cb-bank { font-size: 12.5px; font-weight: 600; color: var(--text); }
.mac-cb-rate { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.mac-cb-stance { font-size: 12px; font-weight: 650; color: var(--muted); }
.mac-cb-stance.mac-pos { color: var(--green); }
.mac-cb-stance.mac-neg { color: var(--red); }
.mac-cb-chg { font-weight: 500; color: var(--muted); font-size: 11px; }

/* ── Correlation heatmap ────────────────────────────────────────────────────*/
.mac-wins, .mac-corr-windows { display: inline-flex; gap: 4px; margin-left: 10px; vertical-align: middle; }
.mac-wbtn {
  font: inherit; font-size: 10.5px; font-weight: 600; padding: 2px 9px; cursor: pointer; text-transform: none;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); border-radius: 6px;
}
.mac-wbtn:hover { color: var(--text); }
.mac-wbtn.active { color: var(--text); border-color: var(--muted); font-weight: 700; }
.mac-corr-row { display: grid; grid-template-columns: 130px 1fr 52px; align-items: center; gap: 10px; padding: 4px 0; }
.mac-corr-label { font-size: 12.5px; color: var(--text); }
.mac-corr-track { position: relative; height: 16px; background: var(--panel-2); border-radius: 4px; }
.mac-corr-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border); }
.mac-corr-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.mac-corr-fill.mac-pos { background: var(--green); }
.mac-corr-fill.mac-neg { background: var(--red); }
.mac-corr-val { font-size: 12.5px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.mac-corr-val.mac-pos { color: var(--green); }
.mac-corr-val.mac-neg { color: var(--red); }

/* ── Upcoming macro events ──────────────────────────────────────────────────*/
.mac-lnk { font-size: 11px; font-weight: 600; color: var(--accent); cursor: pointer; text-transform: none; letter-spacing: 0; margin-left: 8px; }
.mac-lnk:hover { text-decoration: underline; }
.mac-ev { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.mac-ev:last-child { border-bottom: 0; }
.mac-ev-when { display: flex; flex-direction: column; }
.mac-ev-day { font-size: 12px; font-weight: 650; color: var(--text); }
.mac-ev-time { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mac-ev-body { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mac-ev-title { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mac-ev-exch { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; flex: 0 0 auto; }
.mac-dot.mac-warn-dot { background: #d9a441; }

/* ── Click-through chart modal ──────────────────────────────────────────────*/
.mac-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.mac-modal[hidden] { display: none; }
.mac-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.mac-modal-box {
  position: relative; width: min(920px, 94vw); background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.4);
  padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px;
}
.mac-modal-head { display: flex; align-items: center; gap: 12px; }
.mac-modal-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1 1 auto; min-width: 0; }
.mac-modal-ranges { display: flex; gap: 4px; }
.mac-rbtn {
  font: inherit; font-size: 11.5px; font-weight: 600; padding: 3px 10px; cursor: pointer;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); border-radius: 6px;
}
.mac-rbtn:hover { color: var(--text); }
.mac-rbtn.active { background: var(--panel-2); color: var(--text); border-color: var(--muted); font-weight: 700; }
.mac-modal-close {
  font: inherit; font-size: 15px; line-height: 1; cursor: pointer; color: var(--muted);
  background: none; border: 0; padding: 4px 6px; border-radius: 6px;
}
.mac-modal-close:hover { color: var(--text); background: var(--panel-2); }
.mac-modal-chart { width: 100%; height: 360px; }
.mac-modal-note { font-size: 11px; color: var(--muted); text-align: right; min-height: 14px; }

@media (max-width: 720px) {
  .mac-hero { grid-template-columns: 1fr; gap: 16px; }
  .mac-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .mac-last { font-size: 19px; }
  .mac-modal-chart { height: 300px; }
  .mac-modal-head { flex-wrap: wrap; }
}
