:root {
  --bg: #0b1020;
  --bg-2: #131a36;
  --card: #1a2247;
  --text: #e8ecf8;
  --muted: #9aa3c7;
  --accent: #6ea8ff;
  --accent-2: #ff7eb6;
  --pos: #4ade80;
  --neg: #f87171;
  --border: #2a3470;
  --shadow: 0 12px 40px rgba(0,0,0,.35);
}
[data-theme="light"] {
  --bg: #f6f8ff;
  --bg-2: #ffffff;
  --card: #ffffff;
  --text: #0e1633;
  --muted: #5a6285;
  --accent: #2e6bff;
  --accent-2: #d6336c;
  --border: #e1e6f7;
  --shadow: 0 10px 30px rgba(20,30,80,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
em { font-style: normal; color: var(--accent-2); }

/* ----- HERO ----- */
.hero {
  position: relative;
  padding: 56px 24px 40px;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(110,168,255,.18), transparent 60%),
    radial-gradient(900px 400px at 10% 0%, rgba(255,126,182,.12), transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: 1180px; margin: 0 auto; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: .04em; text-transform: uppercase; font-size: 12px;
  color: var(--muted);
}
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.hero h1 {
  margin: 14px 0 12px; font-size: clamp(28px, 4vw, 46px); line-height: 1.15; letter-spacing: -.02em;
  max-width: 920px;
}
.hero .sub { color: var(--muted); max-width: 760px; margin: 0; font-size: 16px; }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-top: 28px;
}
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi .delta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi .delta.pos { color: var(--pos); }
.kpi .delta.neg { color: var(--neg); }

#themeToggle {
  position: absolute; top: 18px; right: 18px;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 18px;
}

/* ----- LAYOUT ----- */
main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 60px; display: grid; gap: 28px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px; box-shadow: var(--shadow);
}
.card-head { margin-bottom: 18px; }
.card-head h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.card-head p { margin: 0; color: var(--muted); }

.controls {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end;
  padding: 12px 14px; background: rgba(255,255,255,.02);
  border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px;
}
.controls label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.controls select, .controls input[type="month"] {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 200px;
}
button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:hover { filter: brightness(1.1); }

.chart-wrap { position: relative; height: 360px; }
.chart-wrap.tall { height: 460px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
  .chart-wrap { height: 300px; }
}

.meta-line { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ----- CORRELATION PANEL ----- */
.corr-panel { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 6px 4px; }
.corr-big {
  font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -.03em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.corr-strength { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.corr-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.corr-row span:first-child { color: var(--muted); }

/* ----- MATRIX ----- */
.matrix { display: grid; gap: 2px; overflow: auto; }
.matrix .cell {
  font-size: 11px; padding: 8px 4px; text-align: center; cursor: pointer;
  border-radius: 4px; user-select: none; transition: transform .12s;
  min-width: 70px;
}
.matrix .cell:hover { transform: scale(1.06); outline: 2px solid var(--text); z-index: 2; position: relative; }
.matrix .label { background: transparent !important; cursor: default; color: var(--muted); font-weight: 600; }
.matrix .label:hover { transform: none; outline: none; }
.legend { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.legend-bar {
  flex: 1; height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, #1f6feb 0%, #3f3f5a 50%, #ff5d8f 100%);
}

/* ----- FOOTER ----- */
footer { max-width: 1180px; margin: 0 auto; padding: 20px 24px 40px; color: var(--muted); font-size: 13px; }
footer .thin { opacity: .7; }
