:root {
  color-scheme: light dark;
  --bg: #eef4f8;
  --bg2: #d9e8f1;
  --panel: rgba(255, 255, 255, 0.82);
  --text: #10202b;
  --muted: #5d6f7b;
  --border: rgba(34, 65, 83, 0.12);
  --accent: #176b87;
  --accent2: #64a8bf;
  --danger: #b54747;
  --ok: #2d8a58;
  --shadow: 0 18px 50px rgba(28, 58, 74, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c151b;
    --bg2: #13252e;
    --panel: rgba(20, 34, 43, 0.82);
    --text: #edf7fb;
    --muted: #9fb3bf;
    --border: rgba(220, 240, 250, 0.12);
    --accent: #77c8e5;
    --accent2: #2f7d98;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(100,168,191,.28), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg2));
  color: var(--text);
  min-height: 100vh;
}

.hero, .layout, footer {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-top: 44px;
  padding-bottom: 28px;
  align-items: flex-end;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
  margin: 0 0 10px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(32px, 5vw, 58px); line-height: .98; margin-bottom: 16px; max-width: 820px; }
h2 { font-size: 20px; margin-bottom: 6px; }
.subtitle { color: var(--muted); max-width: 680px; font-size: 17px; line-height: 1.55; margin-bottom: 0; }

.status-card, .panel, .card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 24px;
}

.status-card {
  min-width: 250px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
}
.status-card small { display: block; color: var(--muted); margin-top: 3px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #d49a33; box-shadow: 0 0 0 6px rgba(212,154,51,.14); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 6px rgba(45,138,88,.14); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 6px rgba(181,71,71,.14); }

.layout { display: grid; gap: 18px; padding-bottom: 32px; }
.panel { padding: 18px; }
.controls { display: grid; grid-template-columns: minmax(220px, 1fr) 180px minmax(260px, auto) auto; gap: 14px; align-items: end; }
label { color: var(--muted); font-weight: 700; font-size: 13px; display: grid; gap: 7px; }
select, input, button {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255,255,255,.52);
  color: var(--text);
  font: inherit;
}
@media (prefers-color-scheme: dark) { select, input { background: rgba(0,0,0,.18); } }
button { background: var(--accent); color: white; border: none; cursor: pointer; font-weight: 800; }
button:hover { filter: brightness(1.05); }
.custom-period { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 10px; }
.custom-period[hidden] { display: none; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card { padding: 18px; }
.card .label { color: var(--muted); font-size: 13px; font-weight: 800; }
.card .value { font-size: 28px; font-weight: 900; margin-top: 8px; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.chart-header, .table-header { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px; }
.chart-header p { color: var(--muted); margin: 0; }
.metric { font-size: 34px; font-weight: 950; color: var(--accent); white-space: nowrap; }
.chart-wrap { height: 390px; width: 100%; position: relative; touch-action: pan-y; }
#chart { width: 100%; height: 100%; display: block; overflow: visible; }
.data-point { cursor: pointer; outline: none; }
.data-point-hit { fill: transparent; stroke: transparent; }
.data-point-dot { transition: r .12s ease, filter .12s ease; }
.chart-touch-layer { cursor: crosshair; touch-action: none; }
#chart.is-touching { cursor: grabbing; }
.data-point:hover .data-point-dot,
.data-point:focus .data-point-dot { filter: drop-shadow(0 0 6px var(--accent)); }
.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
}
.chart-tooltip.visible { opacity: 1; transform: translateY(0); }
.chart-tooltip strong { display: block; color: var(--accent); font-size: 20px; line-height: 1.1; }
.chart-tooltip span,
.chart-tooltip small { display: block; color: var(--muted); margin-top: 3px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 13px; }
td strong { font-weight: 900; }
footer { color: var(--muted); padding-bottom: 32px; font-size: 13px; }
code { font-size: 12px; }

@media (max-width: 850px) {
  .hero { display: block; padding-top: 24px; padding-bottom: 18px; }
  .status-card { margin-top: 18px; min-width: 0; }
  .controls { grid-template-columns: 1fr; gap: 10px; }
  .custom-period { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-header, .table-header { display: block; }
  .metric { margin-top: 8px; }
  .chart-wrap { height: 340px; }
}

@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  h1 { font-size: 32px; }
  .hero, .layout, footer { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 14px; border-radius: 18px; }
  .chart-wrap { height: 320px; }
  .metric { font-size: 28px; }
  th, td { padding: 11px 8px; }
}
