:root {
  color-scheme: light;
  --ink: #142233;
  --muted: #687485;
  --paper: #f4f7f9;
  --panel: #ffffff;
  --line: #dce3e8;
  --l1: #1878c7;
  --l2: #e98a24;
  --l3: #2f9a63;
  --accent: #095b87;
  --shadow: 0 18px 55px rgba(31, 56, 75, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(24, 120, 199, 0.08), transparent 32rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.hero { padding: 54px 0 72px; color: #fff; background: linear-gradient(120deg, #10293c, #075679 72%, #087a87); }
.hero__inner { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 8px; color: #6b8798; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.hero .eyebrow { color: #8dd6e0; }
h1, h2, p { margin-top: 0; }
/* Keep the location title legible without letting it dominate wide desktop layouts. */
h1 { max-width: 820px; margin-bottom: 4px; font-size: clamp(1.8rem, 3vw, 2.65rem); line-height: 1.08; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: clamp(1.3rem, 2.2vw, 2rem); letter-spacing: -0.025em; }
h3 { margin: 0; font-size: 1rem; letter-spacing: -.01em; }
.hero__place { margin: 0; color: #c9dce6; font-size: 1rem; }
.connection { display: inline-flex; align-items: center; gap: 10px; min-width: max-content; padding: 11px 15px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(4,24,36,.32); font-size: .88rem; font-weight: 700; }
.connection__dot { width: 9px; height: 9px; border-radius: 50%; background: #f2b84b; box-shadow: 0 0 0 5px rgba(242,184,75,.13); }
.connection[data-state="live"] .connection__dot { background: #58d68d; box-shadow: 0 0 0 5px rgba(88,214,141,.14); }
.connection[data-state="stale"] .connection__dot { background: #ff9f43; }

main { position: relative; margin-top: -36px; padding-bottom: 40px; }
.live-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric, .panel { border: 1px solid rgba(192,205,214,.78); border-radius: 18px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.metric { position: relative; overflow: hidden; padding: 22px; }
.metric::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--metric-color); content: ""; }
.metric--l1 { --metric-color: var(--l1); }
.metric--l2 { --metric-color: var(--l2); }
.metric--l3 { --metric-color: var(--l3); }
.metric--frequency { --metric-color: #7b61a8; }
.metric__label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .82rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.metric strong { font-size: clamp(1.75rem, 3vw, 2.45rem); letter-spacing: -.04em; }
.metric small { color: var(--muted); font-size: .9rem; font-weight: 650; }

.chart-panel { margin-top: 18px; padding: clamp(20px, 3vw, 30px); }
.panel__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.range-switch { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #f5f7f8; }
.range-switch button { border: 0; border-radius: 8px; padding: 8px 12px; color: var(--muted); background: transparent; font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer; }
.range-switch button.is-active { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(25,48,66,.1); }
.range-switch button:focus-visible { outline: 3px solid rgba(24,120,199,.28); outline-offset: 2px; }
.history-navigation { margin-top: 18px; }
.time-range { display: grid; grid-template-columns: minmax(235px, 1fr) minmax(235px, 1fr) auto auto; gap: 8px; }
.datetime-field { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: #f5f7f8; font-size: .74rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.datetime-field input { width: 100%; min-width: 0; border: 0; color: var(--ink); background: transparent; font: inherit; font-size: .84rem; font-weight: 700; color-scheme: light; }
.datetime-field input:focus { outline: 0; }
.datetime-field:focus-within, .time-range__button:focus-visible { outline: 3px solid rgba(24,120,199,.22); outline-offset: 2px; }
.time-range__button { border: 1px solid rgba(9,91,135,.25); border-radius: 10px; padding: 8px 12px; color: var(--accent); background: rgba(9,91,135,.06); font: inherit; font-size: .78rem; font-weight: 800; cursor: pointer; }
.time-range__button--primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.range-feedback { display: flex; align-items: center; gap: 12px; margin-top: 8px; min-height: 20px; }
.period-context { color: var(--muted); font-size: .78rem; font-weight: 700; }
.range-error { color: #a33f30; font-size: .78rem; font-weight: 700; }
.timezone-note { margin-left: auto; color: #8a969f; font-size: .72rem; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 22px 0 9px; color: var(--muted); font-size: .78rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend__filters { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f5f7f8; }
.legend__filter { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; border: 0; border-radius: 6px; padding: 4px 8px; color: var(--muted); background: transparent; font: inherit; font-weight: 750; cursor: pointer; }
.legend__filter:hover { color: var(--ink); background: rgba(255,255,255,.75); }
.legend__filter.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(25,48,66,.12); }
.legend__filter:focus-visible { outline: 3px solid rgba(24,120,199,.25); outline-offset: 2px; }
.legend__line { width: 22px; border-top: 3px solid; }
.legend__line--l1 { border-color: var(--l1); }
.legend__line--l2 { border-color: var(--l2); }
.legend__line--l3 { border-color: var(--l3); }
.legend__band { width: 22px; height: 9px; border-radius: 3px; background: rgba(47,154,99,.12); border: 1px solid rgba(47,154,99,.25); }
.legend__limit { width: 22px; border-top: 2px dashed #b54936; }
.chart-wrap { position: relative; height: clamp(300px, 42vw, 470px); }
#voltageChart { width: 100%; height: 100%; display: block; }
.chart-tooltip { position: absolute; z-index: 3; min-width: 176px; max-width: 230px; padding: 10px 12px; border: 1px solid rgba(123,135,147,.38); border-radius: 10px; color: var(--ink); background: rgba(255,255,255,.96); box-shadow: 0 10px 28px rgba(24,45,60,.16); font-size: .78rem; pointer-events: none; backdrop-filter: blur(5px); }
.chart-tooltip[hidden] { display: none; }
.chart-tooltip__time { margin-bottom: 7px; color: #526171; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.chart-tooltip__row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 2px 0; }
.chart-tooltip__phase { display: inline-flex; align-items: center; gap: 7px; font-weight: 750; }
.chart-tooltip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--phase-color); }
.chart-tooltip__value { font-variant-numeric: tabular-nums; font-weight: 850; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 700; background: repeating-linear-gradient(-45deg, rgba(244,247,249,.7), rgba(244,247,249,.7) 10px, rgba(255,255,255,.55) 10px, rgba(255,255,255,.55) 20px); border-radius: 12px; }
.chart-empty[hidden] { display: none; }
.chart-note { margin: 8px 0 0; color: var(--muted); font-size: .78rem; text-align: right; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.stat { padding: 20px 22px; box-shadow: none; }
.stat span, .stat small { display: block; color: var(--muted); }
.stat span { font-size: .78rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.stat strong { display: block; margin: 4px 0 1px; font-size: 1.7rem; }
.stat small { font-size: .76rem; }

.deviations { margin-top: 18px; padding: clamp(22px, 3vw, 30px); box-shadow: none; }
.deviations__head { align-items: center; }
.reference-badge { display: inline-flex; min-width: max-content; padding: 7px 11px; border: 1px solid rgba(181,73,54,.28); border-radius: 999px; color: #963e31; background: rgba(181,73,54,.07); font-size: .82rem; font-weight: 800; }
.deviation-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; }
.deviation-summary article { padding: 17px 18px; border: 1px solid var(--line); border-radius: 14px; background: #f8fafb; }
.deviation-summary span, .deviation-summary small { display: block; color: var(--muted); }
.deviation-summary span { font-size: .75rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.deviation-summary strong { display: block; margin: 3px 0 1px; font-size: 1.55rem; }
.deviation-summary small { font-size: .74rem; }
.phase-shares { font-size: clamp(.96rem, 2vw, 1.28rem) !important; letter-spacing: -.02em; }
.events-wrap { margin-top: 20px; overflow-x: auto; }
.events-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.events-table th, .events-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.events-table th { color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.events-table tr[data-direction="low"] td:nth-child(3) { color: #1e6698; font-weight: 750; }
.events-table tr[data-direction="high"] td:nth-child(3) { color: #a34b33; font-weight: 750; }
.events-empty { margin: 0; padding: 18px; border-radius: 12px; color: var(--muted); background: #f8fafb; text-align: center; }
.events-empty[hidden], .events-table[hidden] { display: none; }
.method-note, .norm-links { margin: 14px 0 0; color: var(--muted); font-size: .78rem; }
.norm-links { padding-top: 12px; border-top: 1px solid var(--line); }
.norm-links a { color: var(--accent); text-underline-offset: 2px; }

.guide { margin-top: 28px; }
.section-heading { max-width: 760px; margin-bottom: 16px; }
.section-heading > p:last-child { margin: 9px 0 0; color: var(--muted); }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.guide-card { position: relative; min-height: 210px; padding: 22px; box-shadow: none; }
.guide-card__number { display: inline-block; margin-bottom: 22px; color: #9aa6ae; font-size: .72rem; font-weight: 850; letter-spacing: .12em; }
.guide-card p { margin: 9px 0 0; color: #526171; font-size: .88rem; }
.device-info { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.6fr); gap: 30px; margin-top: 18px; padding: clamp(22px, 3vw, 32px); box-shadow: none; }
.device-info__content p { margin: 0; color: #526171; }
.device-info__content p + p { margin-top: 12px; }
.device-info__links { padding-top: 12px; border-top: 1px solid var(--line); font-size: .86rem; }
.device-info__links a { color: var(--accent); text-underline-offset: 2px; }
.methodology { margin-top: 18px; padding: clamp(22px, 3vw, 32px); box-shadow: none; }
.methodology-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin-top: 20px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.methodology-grid > div { padding: 20px; background: #fbfcfd; }
.methodology-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
.methodology-grid > div:nth-child(n+3) { border-top: 1px solid var(--line); }
.methodology-grid p { margin: 8px 0 0; color: #526171; font-size: .88rem; }

.notice { display: grid; grid-template-columns: auto 1fr; gap: 18px; margin-top: 18px; padding: clamp(22px, 3vw, 32px); box-shadow: none; }
.notice__mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; background: var(--accent); font-family: Georgia, serif; font-weight: 700; }
.notice p { max-width: 920px; margin: 12px 0 0; color: #4c5a69; }
.notice__privacy { padding-top: 12px; border-top: 1px solid var(--line); font-size: .87rem; }
.footer { display: flex; justify-content: space-between; gap: 20px; padding: 4px 0 30px; color: var(--muted); font-size: .76rem; }

@media (max-width: 780px) {
  .shell { width: min(100% - 24px, 1180px); }
  .hero { padding: 36px 0 62px; }
  .hero__inner, .panel__head { align-items: flex-start; flex-direction: column; }
  .connection { align-self: flex-start; }
  .live-grid { grid-template-columns: repeat(2, 1fr); }
  .range-switch { width: 100%; }
  .range-switch button { flex: 1; padding-inline: 8px; }
  .time-range { grid-template-columns: 1fr 1fr; }
  .datetime-field { grid-column: 1 / -1; }
  .time-range__button { min-height: 40px; }
  .range-feedback { flex-wrap: wrap; }
  .timezone-note { margin-left: auto; }
  .stats { grid-template-columns: 1fr; }
  .deviation-summary { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: 1fr 1fr; }
  .device-info { grid-template-columns: 1fr; gap: 16px; }
  .chart-wrap { height: 330px; }
  .footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 430px) {
  .live-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { padding: 17px 15px; }
  .metric strong { font-size: 1.55rem; }
  .legend { gap: 10px; }
  .legend__filters { width: 100%; }
  .legend__filter { flex: 1; justify-content: center; }
  .notice { grid-template-columns: 1fr; }
  .guide-grid, .methodology-grid { grid-template-columns: 1fr; }
  .methodology-grid > div:nth-child(odd) { border-right: 0; }
  .methodology-grid > div + div { border-top: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
