/* TSMAgro portal — design tokens and layout from design_handoff_tsmagro. */

:root {
  --primary: #3B6E4F;
  --primary-dark: #24422F;
  --primary-light: #E4EDE7;
  --bg: #F6F7F3;
  --surface: #FFFFFF;
  --surface-alt: #EEF1EB;
  --text: #1B2119;
  --text-dim: #5B6459;
  --border: #DCE1D7;
  --accent-blue: #3E6FA6;
  --accent-amber: #C0801F;
  --accent-purple: #6B5CA5;
  --danger: #B23A3A;
  --sidebar-bg: #1E2E22;
  --sidebar-text: #C9D6CC;
  --font-heading: 'Manrope', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

input, select, button, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3 { font-family: var(--font-heading); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
}
.btn-primary { color: var(--surface); background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--text-dim); cursor: default; }
.btn-ghost {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
}
.btn-ghost:hover { border-color: var(--primary); }
.btn-light {
  font-size: 13px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 8px 14px;
}
.btn-lg { font-size: 16px; padding: 14px 26px; }
.btn-invert { color: var(--primary-dark); background: var(--surface); white-space: nowrap; }
.btn-link {
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { color: var(--primary); }

.field-input, .field-select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
}
.field-select { padding: 8px 12px; font-size: 14px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 100px;
}
.pill-available { background: var(--primary-light); color: var(--primary-dark); }
.pill-soon { background: var(--surface-alt); color: var(--text-dim); }

/* ---------- marketing ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.wordmark {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 22px;
  color: var(--primary-dark);
}
.wordmark-sub { font-size: 12px; color: var(--text-dim); letter-spacing: 0.02em; }
.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-links a { font-size: 15px; font-weight: 500; color: var(--text); }

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 64px;
  align-items: center;
  padding: 96px 48px;
  max-width: 1280px;
  margin: 0 auto;
}
.eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 16px;
}
.hero h1 {
  font-size: 52px;
  line-height: 1.08;
  font-weight: 800;
  margin: 0 0 24px;
}
.hero p { font-size: 18px; line-height: 1.6; color: var(--text-dim); max-width: 520px; margin: 0 0 36px; }
.hero-actions { display: flex; gap: 16px; }

.readout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 12px 32px -12px rgba(30, 46, 34, 0.18);
}
.readout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.readout-title { font-family: var(--font-heading); font-weight: 700; font-size: 15px; }
.live-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}
.live-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}
.live-dot.offline { color: var(--text-dim); }
.live-dot.offline::before { background: var(--text-dim); }

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--surface-alt); border-radius: 8px; padding: 14px; }
.tile-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tile-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.readout-note { margin-top: 14px; font-size: 12px; color: var(--text-dim); }

.section { padding: 80px 48px; max-width: 1280px; margin: 0 auto; }
.section-surface { padding: 80px 48px; background: var(--surface); }
.section-surface > div { max-width: 1280px; margin: 0 auto; }
.section h2, .section-surface h2 { font-size: 32px; font-weight: 800; margin: 0 0 8px; }
.section-lede { font-size: 16px; color: var(--text-dim); margin: 0 0 40px; max-width: 680px; }
.section-tight h2 { margin-bottom: 40px; }

.service-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.service-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  cursor: default;
}
.service-card.available { cursor: pointer; }
.service-card.available:hover { border-color: var(--primary); }
.service-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  margin: 16px 0 8px;
  color: var(--text);
}
.service-desc { font-size: 14px; line-height: 1.55; color: var(--text-dim); }

.spec-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.spec-table th {
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--text-dim);
}
.spec-table thead tr { border-bottom: 2px solid var(--border); }
.spec-table tbody tr { border-bottom: 1px solid var(--border); }
.spec-table td { padding: 14px 16px; color: var(--text-dim); }
.spec-table td:first-child { font-weight: 600; font-family: var(--font-heading); color: var(--text); }
.spec-table td.num { font-variant-numeric: tabular-nums; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  margin-bottom: 16px;
}
.step-title { font-family: var(--font-heading); font-weight: 700; font-size: 17px; margin-bottom: 8px; }
.step-body { font-size: 14px; color: var(--text-dim); line-height: 1.55; }

.cta-band { padding: 64px 48px; background: var(--primary-dark); }
.cta-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.cta-title { font-family: var(--font-heading); font-size: 26px; font-weight: 800; color: var(--surface); margin-bottom: 6px; }
.cta-sub { font-size: 15px; color: #B9CBBD; }

.footer { padding: 40px 48px; background: var(--surface); border-top: 1px solid var(--border); }
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-mark { font-family: var(--font-heading); font-weight: 800; font-size: 16px; color: var(--primary-dark); }
.footer-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.footer-links { display: flex; gap: 28px; font-size: 14px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-back { padding: 24px 48px; }
.login-back a { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.login-body { flex: 1; display: flex; align-items: center; justify-content: center; padding-bottom: 80px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 12px 32px -12px rgba(30, 46, 34, 0.18);
}
.login-card .wordmark { font-size: 20px; margin-bottom: 4px; }
.login-sub { font-size: 15px; color: var(--text-dim); margin-bottom: 28px; }
.login-card .field-input { width: 100%; margin-bottom: 16px; }
.login-card .field-input.last { margin-bottom: 24px; }
.login-card .btn-primary { width: 100%; padding: 12px; }
.login-error {
  font-size: 13px;
  color: var(--danger);
  background: #F7EAEA;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.login-hint { font-size: 12px; color: var(--text-dim); margin-top: 14px; text-align: center; }

/* ---------- portal shell ---------- */
.portal { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--primary-dark);
  color: var(--sidebar-text);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .wordmark { color: var(--surface); font-size: 18px; padding: 0 8px; margin-bottom: 32px; }
.nav-item {
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  margin-bottom: 4px;
}
.nav-item.active { background: var(--primary); color: #FFFFFF; }
.sidebar-spacer { flex: 1; }
.logout {
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #33463A;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
}
.portal-main { background: var(--bg); min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.topbar-title { font-family: var(--font-heading); font-weight: 700; font-size: 17px; }
.badge-live {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-blue);
  background: #E7EEF5;
  padding: 5px 12px;
  border-radius: 100px;
  white-space: nowrap;
}
.badge-live.warn { color: var(--accent-amber); background: #F6EEDD; }
.badge-live.down { color: var(--danger); background: #F7EAEA; }
.tab-body { padding: 32px 40px; }
.tab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.tab-head h2 { font-size: 22px; font-weight: 800; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ---------- devices ---------- */
.devices-split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.device-list { display: flex; flex-direction: column; gap: 14px; }
.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  cursor: pointer;
}
.device-card.active { border-color: var(--primary); }
.device-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.device-name { font-family: var(--font-heading); font-weight: 700; font-size: 16px; }
.device-name-input {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 4px 8px;
  min-width: 0;
  flex: 1;
}
.device-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.device-chips { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.chip {
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chip b { font-weight: 700; }
.chip-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 6px 10px;
}
.chip-alert { background: #F7EAEA; color: var(--danger); }
/* Activated-but-not-yet-signed-in. Tinted from --primary, the same green the
   live indicator uses for a healthy station, so "fine" reads the same way in
   both places. */
.chip-ok { background: #E6EFE4; color: var(--primary); }
.chip-spacer { margin-left: auto; }
.map-panel { position: relative; height: 420px; overflow: hidden; padding: 0; }
.map-canvas { width: 100%; height: 100%; }
.map-layers {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 400;
  display: flex;
  gap: 6px;
}
.map-layers button {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.map-layers button.active { background: var(--primary); color: var(--surface); border-color: var(--primary); }

/* ---------- tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead tr { background: var(--surface-alt); }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
.data-table th.right, .data-table td.right { text-align: right; }
.data-table tbody tr { border-top: 1px solid var(--border); }
.data-table td { padding: 8px 16px; }
.data-table td.dim { color: var(--text-dim); }
.table-wrap { overflow: hidden; }
.table-scroll { max-height: 420px; overflow-y: auto; }
.table-scroll thead tr { position: sticky; top: 0; z-index: 1; }
.scroll-x { overflow-x: auto; }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.chart-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 12px;
}
.chart-label { font-family: var(--font-heading); font-weight: 700; font-size: 14px; }
.chart-current { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-current span { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.chart-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
/* The hovered sample's date, centred between min and max. Only present while
   hovering; min/max hold their positions either way because the row is
   space-between, so the card does not reflow as it appears. */
.chart-foot-at { color: var(--text); font-weight: 600; }

.chart-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.chart-controls select { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; min-width: 0; }
.chart-remove {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.chart-add {
  border: 1px dashed var(--border);
  background: none;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 120px;
}
.chart-add:hover { border-color: var(--primary); color: var(--primary); }
.chart-empty { font-size: 12px; color: var(--text-dim); height: 70px; display: flex; align-items: center; justify-content: center; }

/* ---------- query ---------- */
.query-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.query-bar label.small {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field-checks { display: flex; gap: 12px; flex-wrap: wrap; max-width: 620px; }
.field-checks label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}
.query-actions { margin-left: auto; display: flex; gap: 10px; }
.agg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.agg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.agg-label { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; }
.agg-values {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  gap: 8px;
}
.query-count { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 22, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
  width: 360px;
  max-width: 100%;
  box-shadow: 0 20px 48px -16px rgba(20, 30, 22, 0.35);
}
.modal-title { font-family: var(--font-heading); font-weight: 700; font-size: 17px; margin-bottom: 18px; }
.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.modal select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
}
.modal select.last { margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-cancel {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: var(--surface);
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 12px 32px -12px rgba(20, 30, 22, 0.5);
  z-index: 100;
}
.toast.error { background: var(--danger); }
[hidden] { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 56px 24px; }
  .hero h1 { font-size: 40px; }
  .service-grid { grid-template-columns: 1fr 1fr; }
  .devices-split, .chart-grid { grid-template-columns: 1fr; }
  .agg-grid { grid-template-columns: 1fr 1fr; }
  .section, .section-surface { padding: 56px 24px; }
  .nav, .cta-band, .footer { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 720px) {
  .nav-links { gap: 16px; }
  .nav-links a { display: none; }
  .service-grid, .agg-grid, .steps { grid-template-columns: 1fr; }
  .portal { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; gap: 8px; overflow-x: auto; padding: 12px; }
  .sidebar .wordmark { margin-bottom: 0; }
  .sidebar-spacer { flex: 0 0 auto; }
  .nav-item { margin-bottom: 0; white-space: nowrap; }
  .tab-body { padding: 20px 16px; }
  .topbar { padding: 16px 20px; }
  .cta-inner, .footer-inner { flex-direction: column; align-items: flex-start; gap: 20px; }
  .login-back { padding: 16px 20px; }
}

/* ---------- charts: scope toggle and grouped sections ---------- */
.chart-head-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Segmented control. Two exclusive views of the same tab, so a pair of
 * joined buttons reads better than a dropdown holding two items. */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border: none;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--primary); color: #FFFFFF; }

.chart-section { margin-bottom: 26px; }
.chart-section-head {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 22px 0 10px;
}

/* ---- Time zone switch, dual clock, outage notifications ---- */

.zone-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  margin-left: auto;
}

.zone-switch button {
  border: 0;
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  cursor: pointer;
}

.zone-switch button + button { border-left: 1px solid var(--border); }
.zone-switch button:hover { background: var(--surface-alt); }

.zone-switch button.active {
  background: var(--primary);
  color: #fff;
}

/* Only rendered when the station and viewer clocks actually differ, so it
   never competes for space in the common single-zone case. */
.dual-clock {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface-alt);
  border-radius: 7px;
}

.dual-clock em {
  font-style: normal;
  opacity: 0.65;
  font-size: 11px;
}

.dual-sep { opacity: 0.4; }

.zone-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}

.notif-bell {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.notif-bell:hover { background: var(--surface-alt); }
.notif-bell.has-unread { border-color: var(--danger); color: var(--danger); }

.notif-count {
  display: inline-block;
  margin-left: 6px;
  min-width: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}

.notif-panel {
  position: absolute;
  right: 24px;
  top: 58px;
  z-index: 40;
  width: min(430px, calc(100vw - 40px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.notif-head button {
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
}

.notif-empty {
  padding: 20px 14px;
  color: var(--text-dim);
  font-size: 13px;
}

.outage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.outage {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--border);
  font-size: 13px;
}

.outage:last-child { border-bottom: 0; }

/* Cause is carried by colour as well as text, but never by colour alone --
   the cause is always spelled out in .outage-cause. */
.outage.network { border-left-color: var(--accent-amber); }
.outage.restart { border-left-color: var(--accent-blue); }
.outage.power { border-left-color: var(--danger); }
.outage.fault { border-left-color: var(--accent-purple); }
.outage.ongoing { border-left-color: var(--danger); background: #FCF4F4; }

.outage-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.outage-cause {
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}

.outage-when {
  color: var(--text-dim);
  font-size: 12px;
}

.outage-recovery {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text);
}

.outage-detail {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-dim);
}

/* The panel anchors to this. */
.portal-main { position: relative; }

@media (max-width: 720px) {
  .dual-clock { display: none; }
  .zone-switch button { padding: 5px 8px; }
}

/* ---- Recovered readings, waveform, fleet diagnostics ---- */

/* A reading replayed from the station's card after an outage. Marked rather
   than hidden: it arrived late but carries the time it was MEASURED, and a
   three-hour-old reading sitting inline with live ones would otherwise read
   as current. */
.recovered-tag {
  margin-left: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent-amber);
  background: #F7F0E1;
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

.chip-warn { background: #F7F0E1; color: var(--accent-amber); }

.tab-intro {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0 0 24px;
  max-width: 760px;
  text-wrap: pretty;
}

.waveform-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.waveform-card { padding: 20px 22px; }

.waveform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.waveform-title { font-family: var(--font-heading); font-weight: 700; font-size: 15px; }
.waveform-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.waveform-legend { display: flex; gap: 14px; font-size: 12px; }
.waveform-legend span { display: inline-flex; align-items: center; gap: 6px; }
.waveform-legend i {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}

.waveform-side { display: flex; flex-direction: column; gap: 12px; }

.stat-card { padding: 16px 18px; }
.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
}

.stat-row {
  padding: 14px 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.stat-label { font-size: 12px; color: var(--text-dim); }
.stat-note { font-size: 11px; color: var(--text-dim); opacity: 0.75; margin-top: 1px; }
.stat-num {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-card {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 900px) {
  .waveform-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Manual position ---- */

/* Says the coordinate is hand-placed, so nobody reads it as a GPS fix. */
.pos-pinned {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #EAF0EA;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pos-edit { margin-left: 8px; font-size: 12px; }

.pos-editor {
  margin: 8px 0 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: default;
}

.pos-fields { display: flex; gap: 10px; }
.pos-fields label { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.pos-fields span { font-size: 11.5px; color: var(--text-dim); }
.pos-fields input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pos-actions { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
.pos-actions .btn { padding: 6px 14px; font-size: 13px; }
.pos-clear { font-size: 12.5px; }

.pos-error { margin-top: 7px; font-size: 12.5px; color: var(--danger); }
.pos-note { margin-top: 7px; font-size: 11.5px; color: var(--text-dim); line-height: 1.45; }

/* ---- Interactive charts: axes, hover readout, drag-to-pan ---- */

.chart-plot {
  position: relative;
  cursor: grab;
  touch-action: pan-y;   /* horizontal drag is ours; vertical scroll stays the page's */
  user-select: none;
}
.chart-plot:active { cursor: grabbing; }

.chart-svg { display: block; overflow: visible; }

.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .grid-v { stroke-dasharray: 2 3; opacity: 0.7; }
.chart-svg .axis { stroke: #C9D0C4; stroke-width: 1; }
.chart-svg .axis-label {
  font-size: 10px;
  fill: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---- Hover tooltip, drawn at the pointer inside the plot ---- */

/* Non-interactive: the plot underneath owns drag, and a tooltip that ate
   pointer events would stall a pan the moment the box slid under the cursor. */
.chart-svg .chart-tip { pointer-events: none; }

.chart-svg .chart-tip-box {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1;
  /* Lifts the box off the grid lines and the shaded outage bands it sits over. */
  filter: drop-shadow(0 1px 3px rgba(27, 33, 25, 0.18));
}
.chart-svg .chart-tip-value {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-heading);
  fill: var(--text);
  font-variant-numeric: tabular-nums;
}
.chart-svg .chart-tip-time {
  font-size: 10px;
  fill: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.chart-crosshair { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }

/*
 * While the charts are synced the crosshair appears on every card at once,
 * and four dashed lines of the same weight read as four separate cursors
 * rather than one rule down the column. Solid and slightly lighter is what
 * makes the eye join them into a single vertical line across the grid.
 */
.chart-plot-linked .chart-crosshair {
  stroke: var(--primary);
  stroke-dasharray: none;
  opacity: 0.55;
}

/*
 * The compact readout on synced companion cards.
 *
 * Value only, no timestamp -- so it stays slightly quieter than the box on
 * the card the pointer is actually in, and the eye can still tell which
 * chart it is driving.
 */
.chart-tip-compact .chart-tip-box { opacity: 0.94; }
.chart-tip-compact .chart-tip-value { font-size: 11px; }

.chart-range {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.chart-now {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.chart-now:hover { background: var(--primary-light); }

/* Replaces the min/max footer while the pointer is on the series, so the
   card never grows or shrinks as the readout appears. */
/* ---- Marketing: outage resilience section ---- */

.resilience-head { text-align: center; max-width: 680px; margin: 0 auto 48px; }
.resilience-head h2 { margin: 0 0 16px; }

.resilience-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 48px;
}

.resilience-pane { padding: 30px 32px; background: var(--surface); }
.resilience-offline { background: #FBF6EA; border-right: 1px solid var(--border); }

.resilience-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8A5C13;
  margin-bottom: 16px;
}
.resilience-kicker-on { color: var(--primary); }

.resilience-title {
  font-family: var(--font-heading);
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 10px;
}

.resilience-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0 0 20px;
  text-wrap: pretty;
}
.resilience-offline .resilience-body { color: #6B4A10; }

.resilience-rows { display: flex; flex-direction: column; gap: 8px; }
.resilience-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid #E8DCC0;
  border-radius: 7px;
  padding: 9px 13px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.resilience-row .dim { color: var(--text-dim); }
.resilience-row .strong { font-weight: 600; }
.resilience-saved { font-size: 11px; font-weight: 600; color: #8A5C13; }

.resilience-chart { background: var(--surface-alt); border-radius: 9px; padding: 16px 16px 12px; }

.resilience-proof {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  background: var(--primary-light);
  border-radius: 8px;
  padding: 11px 14px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 600;
}

.resilience-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.resilience-point-title { font-family: var(--font-heading); font-size: 16px; font-weight: 700; margin-bottom: 7px; }
.resilience-point-body { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0; text-wrap: pretty; }

@media (max-width: 860px) {
  .resilience-split { grid-template-columns: 1fr; }
  .resilience-offline { border-right: 0; border-bottom: 1px solid var(--border); }
  .resilience-points { grid-template-columns: 1fr; }
}

/* ---- Zone picker on the tabs that draw a time axis ---- */

.zone-picker { display: inline-flex; align-items: center; gap: 8px; }

.zone-picker-label {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Sized down from the standard .seg: this sits in a row of chart controls,
   not as a primary page action. */
.seg-zone button { font-size: 12px; padding: 6px 11px; }

@media (max-width: 720px) {
  .zone-picker-label { display: none; }
}

/* ---- Outage bands on charts ---- */

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.check-inline input { accent-color: var(--primary); cursor: pointer; margin: 0; }

/* Low opacity so the series stays the subject; the band is context, not data.
   Colour alone never carries the meaning -- each band is labelled. */
.chart-outage { opacity: 0.13; }
.chart-outage-lost { opacity: 0.16; }
.chart-outage-edge { stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.55; }
.chart-outage-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chart-legend-outage {
  display: flex;
  align-items: center;
  /* Wraps because the trailing footnote is a full sentence: on a narrow
     viewport it must drop below the swatches rather than squeeze them. */
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-dim);
}
.chart-legend-outage span { display: inline-flex; align-items: center; gap: 6px; }

/* The footnote explaining WHY enclosure charts keep a gap that weather
   charts do not. Full width so it reads as a sentence, not a fourth key. */
.chart-legend-outage .chart-legend-foot {
  flex-basis: 100%;
  display: block;
  line-height: 1.5;
  max-width: 78ch;
}

/* Same explanation, on the one card that is showing the gap. */
.chart-note {
  margin: 8px 10px 10px;
  padding: 7px 9px;
  border-left: 2px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 4px 4px 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
}
.chart-legend-outage i {
  width: 12px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* ---- Chart zoom controls ---- */

.chart-range-actions { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }

.chart-zoom {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  border-radius: 5px;
  cursor: pointer;
}
.chart-zoom:hover { background: var(--surface-alt); }

.chart-span {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-alt);
  font-weight: 600;
}

/* Stated inside the plot so the frame and axes stay put while panning across
   an empty stretch -- a collapsing card mid-drag is disorienting. */
.chart-empty-note {
  font-size: 12px;
  fill: var(--text-dim);
}

/* A break in the data that no outage record explains -- usually a gap that
   predates this browser session, since outage history is observed live.
   Neutral grey, distinct from the amber/red outage bands. */
.chart-gap { fill: #5B6459; opacity: 0.07; }
.chart-gap-label { font-size: 9px; font-weight: 600; fill: #5B6459; opacity: 0.75; }

/* ---- Query table sorting ---- */

.sort-head {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.sort-head:hover { color: var(--text); }
.sort-arrow { font-size: 9px; opacity: 0.8; }

/* The Query controls row lays its groups out with a label above each; the
   zone picker follows that shape rather than the inline form used on tabs
   where it sits beside a heading. */
.query-controls .seg-zone { margin-top: 2px; }
