/* ============================================================
   HARDINGNEXT GRID WEATHER CONTROLS
   Shared design system — Stripe/Linear/Vercel aesthetic
   Supports light (default) + dark themes via data-theme attr
   ============================================================ */

:root,
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --bg-elev: #ffffff;
  --bg-hero: linear-gradient(180deg, #eff6ff 0%, #ffffff 70%);

  --text: #0f172a;
  --text-strong: #020617;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-on-primary: #ffffff;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-subtle: #eff6ff;
  --accent: #0ea5e9;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --divider: #f1f5f9;

  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger:  #ef4444;
  --danger-bg:  #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;

  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.10);
  --shadow-blue: 0 8px 24px rgba(37,99,235,.18);
}

html[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-subtle: #0f172a;
  --bg-muted: #1e293b;
  --bg-elev: #111827;
  --bg-hero: linear-gradient(180deg, #0f172a 0%, #0a0e1a 70%);

  --text: #f1f5f9;
  --text-strong: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a;
  --primary-subtle: #1e293b;

  --border: #1e293b;
  --border-strong: #334155;
  --divider: #1e293b;

  --success-bg: #064e3b;
  --warning-bg: #78350f;
  --danger-bg:  #7f1d1d;
  --info-bg: #1e3a8a;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

:root {
  --r-sm: 6px;  --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --r-full: 9999px;
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px; --s-20: 80px; --s-24: 96px;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* ============================================================ RESET ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .2s var(--ease), color .2s var(--ease);
}
a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img, svg { display: block; max-width: 100%; }
h1,h2,h3,h4,h5,h6 {
  color: var(--text-strong); font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.15;
}
code, pre, .mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
::selection { background: var(--primary); color: white; }

/* ============================================================ LAYOUT ============================================================ */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--s-6); }

/* ============================================================ BUTTONS ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  height: 44px; padding: 0 var(--s-6);
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 500;
  letter-spacing: -.005em;
  transition: all .18s var(--ease);
  white-space: nowrap; cursor: pointer;
}
.btn-primary { background: var(--text-strong); color: var(--bg); box-shadow: var(--shadow-sm); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); opacity: .9; }
.btn-blue { background: var(--primary); color: #fff; box-shadow: var(--shadow-blue); }
.btn-blue:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--bg-muted); }
.btn-sm { height: 36px; padding: 0 var(--s-4); font-size: 14px; }
.btn-lg { height: 52px; padding: 0 var(--s-8); font-size: 16px; }

/* ============================================================ STATUS PILLS ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 500; line-height: 1.4;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-online  { background: var(--success-bg); color: #047857; }
.pill-online  .pill-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.pill-offline { background: var(--danger-bg);  color: #b91c1c; }
.pill-offline .pill-dot { background: var(--danger); }
.pill-warning { background: var(--warning-bg); color: #b45309; }
.pill-warning .pill-dot { background: var(--warning); }
.pill-info    { background: var(--info-bg);    color: #1d4ed8; }
.pill-info    .pill-dot { background: var(--info); }
.pill-neutral { background: var(--bg-muted);   color: var(--text-secondary); }
.pill-neutral .pill-dot { background: var(--text-muted); }

html[data-theme="dark"] .pill-online  { color: #6ee7b7; }
html[data-theme="dark"] .pill-offline { color: #fca5a5; }
html[data-theme="dark"] .pill-warning { color: #fcd34d; }
html[data-theme="dark"] .pill-info    { color: #93c5fd; }

/* ============================================================ INPUTS ============================================================ */
.input {
  width: 100%; height: 40px; padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: all .15s var(--ease);
}
.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input::placeholder { color: var(--text-muted); }

/* ============================================================ UTILS ============================================================ */
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.eyebrow {
  font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary);
}

/* ============================================================ ANIMATIONS ============================================================ */
@keyframes fadeUp { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes pulse  { 0%,100% { opacity:1; } 50% { opacity:.5; } }
.reveal { animation: fadeUp .7s var(--ease-out) both; }
.reveal-1 { animation-delay: .08s; }
.reveal-2 { animation-delay: .16s; }
.reveal-3 { animation-delay: .24s; }
.reveal-4 { animation-delay: .32s; }

/* ============================================================ THEME TOGGLE ============================================================ */
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s var(--ease);
}
.theme-toggle:hover { background: var(--bg-muted); color: var(--text); }
html[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"]  .theme-toggle .icon-sun  { display: none; }
html[data-theme="dark"]  .theme-toggle .icon-moon { display: block; }

/* ============================================================
   v0.3.0 — WEATHER INTELLIGENCE STYLES
   ============================================================ */
.decision-banner {
  border-radius: var(--r-lg); padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-6); border: 1px solid var(--border);
  background: var(--bg-elev);
}
.decision-banner.good { border-color: var(--success); background: var(--success-bg); }
.decision-banner.warn { border-color: var(--warning); background: var(--warning-bg); }
.decision-banner.bad  { border-color: var(--danger);  background: var(--danger-bg); }
.decision-q { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); font-weight: 600; margin-bottom: 6px; }
.decision-a { font-size: 19px; font-weight: 600; color: var(--text-strong); letter-spacing: -.01em; line-height: 1.3; }
.decision-meta { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

.intel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.intel-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-5);
}
.intel-card h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin-bottom: var(--s-3); font-weight: 600; }
.intel-card .kv {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--divider);
  font-size: 13px; gap: var(--s-3);
}
.intel-card .kv:last-of-type { border-bottom: 0; }
.intel-card .kv > span:first-child { color: var(--text-muted); }
.intel-card .kv.emph > span { font-weight: 600; color: var(--text); }
.scada-card { grid-column: span 3; }

.scada-table { width: 100%; border-collapse: collapse; }
.scada-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.scada-table td { font-size: 12px; padding: 5px 8px; border-bottom: 1px solid var(--divider); }
.scada-table tr:last-child td { border-bottom: 0; }

.explainer { margin-top: var(--s-3); }
.explainer-toggle {
  font-size: 12px; color: var(--primary); font-weight: 500;
  padding: 4px 0; cursor: pointer;
}
.explainer-body {
  display: none; font-size: 12.5px; line-height: 1.55;
  color: var(--text-secondary);
  background: var(--bg-subtle); border-left: 3px solid var(--primary);
  padding: var(--s-3) var(--s-4); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-top: 6px;
}
.explainer-body.open { display: block; }

.sun-banner {
  display: flex; gap: var(--s-6); flex-wrap: wrap;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-4) var(--s-6);
  margin-bottom: var(--s-5); font-size: 14px;
}
.sun-item { color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.sun-item strong { color: var(--text-strong); font-family: var(--font-mono); }

.fcst-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s-3); }
.fcst-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-4); text-align: center;
}
.fcst-card.today { border-color: var(--primary); box-shadow: var(--shadow-blue); }
.fcst-day { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.fcst-icon { font-size: 28px; margin: 6px 0; }
.fcst-temp { font-size: 17px; font-weight: 600; margin-bottom: var(--s-3); }
.fcst-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); padding: 3px 0; border-top: 1px solid var(--divider); }
.fcst-row .mono { color: var(--text-secondary); }

@media (max-width: 1200px) { .intel-grid { grid-template-columns: repeat(2, 1fr); } .scada-card { grid-column: span 2; } .fcst-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px)  { .intel-grid { grid-template-columns: 1fr; } .scada-card { grid-column: span 1; } .fcst-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============ v0.3.1 FLEET MAP ============ */
.fleet-map {
  height: 520px; border-radius: var(--r-lg);
  border: 1px solid var(--border); overflow: hidden;
  background: var(--bg-muted); z-index: 1;
}
.map-legend {
  display: flex; gap: var(--s-5); align-items: center; flex-wrap: wrap;
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px var(--s-4); margin-bottom: var(--s-3);
}
.map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.map-legend .ring { background: transparent; border: 2.5px solid #ef4444; }
.map-pop { font-family: var(--font-sans); font-size: 12px; min-width: 200px; }
.map-pop strong { font-size: 13px; }
.map-pop table { width: 100%; margin-top: 6px; border-collapse: collapse; }
.map-pop td { padding: 2.5px 0; border-bottom: 1px solid #eee; }
.map-pop td:first-child { color: #64748b; }
.map-pop td:last-child { text-align: right; font-weight: 500; }
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip { background: #111827; color: #f1f5f9; }
html[data-theme="dark"] .map-pop td { border-bottom-color: #1e293b; }
html[data-theme="dark"] .map-pop td:first-child { color: #94a3b8; }
