/* Outage Scout FL — TAG Marketing brand system
   cream + ink + one orange accent, Geist type, Georgia-italic emphasis,
   blueprint hairlines, lucide icons, hand-made tape/marker touches. */
:root {
  --cream: #F7F5F0;
  --surface: #FFFFFF;
  --ink: #191919;
  --ink-soft: #4A4A4A;
  --muted: #7B7B7B;
  --orange: #FF5C00;
  --orange-press: #E24E00;
  --charcoal: #313131;
  --charcoal-soft: #3F3F3F;
  --line: #E1E1E1;
  --line-dark: #585858;
  --peach: #FFDECC;
  --shadow-card: 0 18px 40px -24px rgba(25, 25, 25, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  letter-spacing: -0.015em;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.lucide, [data-lucide] { width: 1em; height: 1em; stroke-width: 2; display: inline-block; vertical-align: -0.12em; }

/* ---- header ---- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  z-index: 1001;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-chip {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--peach); color: var(--orange); font-size: 17px;
}
.brand-name {
  position: relative;
  font-size: 19px; font-weight: 700; letter-spacing: -0.022em; color: var(--ink);
  line-height: 1.03;
}
.brand-name .fl { color: var(--orange); }
.top-right { display: flex; align-items: center; gap: 12px; }
#updated { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
#refresh {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 9px; width: 34px; height: 34px; font-size: 16px; cursor: pointer;
  display: grid; place-items: center;
}
#refresh:active { background: var(--cream); }
#refresh.spin i { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- mode + range segments ---- */
#modebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 8px; background: var(--cream);
  border-bottom: 1px solid var(--line); z-index: 1001;
}
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg-btn {
  border: none; background: transparent; color: var(--ink-soft);
  padding: 7px 18px; border-radius: 8px; font-family: var(--font-sans);
  font-size: 13px; font-weight: 500; letter-spacing: -0.01em; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg.small .seg-btn { padding: 7px 13px; font-size: 12px; }
.seg-btn.active { background: var(--orange); color: #fff; }

/* ---- utility filter chips ---- */
#chips {
  display: flex; gap: 7px; overflow-x: auto; padding: 10px 16px;
  background: var(--cream); border-bottom: 1px solid var(--line);
  z-index: 1001; scrollbar-width: none;
}
#chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); color: var(--muted);
  background: var(--surface); border-radius: 10px; padding: 6px 12px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.chip.on { color: var(--ink); border-color: var(--chip-color); }
.chip .dot { width: 9px; height: 9px; border-radius: 2px; background: var(--chip-color); opacity: 0.3; transition: opacity 0.15s; }
.chip.on .dot { opacity: 1; }
.chip .cnt { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---- map ---- */
#map { flex: 1; z-index: 1; background: var(--cream); }
/* Kill the browser's default focus outline on map vector shapes — on an SVG
   <path> that outline is drawn around the bounding box, which reads as a square
   over a county. The perimeter highlight (selectCounty) is our real feedback. */
.leaflet-interactive:focus,
.leaflet-container svg path:focus { outline: none !important; }
.leaflet-interactive { -webkit-tap-highlight-color: transparent; }
/* warm the light basemap toward the cream brand; markers stay crisp (own pane) */
.leaflet-tile-pane { filter: sepia(0.12) saturate(0.9) brightness(1.03) contrast(0.97); }
.leaflet-container { background: var(--cream); font-family: var(--font-sans); }
.leaflet-bar a {
  background: var(--surface); color: var(--ink); border-bottom-color: var(--line) !important;
}
.leaflet-bar a:hover { background: var(--cream); }
.leaflet-control-attribution { font-size: 9px !important; background: rgba(247,245,240,0.8) !important; }

/* hotspot bins (history mode) */
.bin {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; border-radius: 50%;
  background: rgba(255, 92, 0, 0.82); border: 2px solid #fff;
  box-shadow: 0 4px 14px -6px rgba(25,25,25,0.5);
  color: #fff; line-height: 1;
}
.bin b { font-family: var(--font-sans); font-weight: 700; font-size: 12px; letter-spacing: -0.01em; }
.bin i { font-style: normal; font-size: 9px; font-weight: 500; opacity: 0.9; margin-top: 1px; }
.bin.multi { background: rgba(226, 78, 0, 0.88); }
.bin-utils { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
a.bin-util { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-soft); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.bin-util .dot { width: 8px; height: 8px; border-radius: 2px; }

/* locate control */
.locate-ctl a { display: grid !important; place-items: center; font-size: 15px; }
.locate-ctl.busy a i { animation: spin 0.8s linear infinite; }

/* ---- stats bar (the type moment) ---- */
#statsbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--cream); border-top: 1px solid var(--line); z-index: 1001;
}
#stats-main { font-size: 15px; font-weight: 500; color: var(--ink); line-height: 1.2; min-width: 0; }
#stats-main .big { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
#stats-main .em { font-weight: 600; color: var(--orange); }
#stats-main .sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
#stats-toggle {
  position: relative;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 13px; font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
#stats-toggle.open { border-color: var(--ink); }
#stats-toggle.filtered::after {
  content: ""; position: absolute; top: -4px; right: -4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange); border: 2px solid var(--cream);
}

/* ---- county panel (white card w/ torn tape) ---- */
#county-panel {
  position: absolute; bottom: calc(58px + var(--safe-bottom)); left: 12px; right: 12px;
  max-height: 62%; overflow-y: auto; z-index: 1002;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 18px 16px 8px; box-shadow: var(--shadow-card);
}
.tape {
  position: absolute; top: -13px; left: 24px; width: 92px; height: 30px;
  background: var(--orange); transform: rotate(-4deg);
  clip-path: polygon(3% 22%, 12% 8%, 26% 20%, 38% 6%, 52% 22%, 66% 8%, 79% 22%, 92% 9%, 98% 26%, 95% 72%, 99% 90%, 84% 80%, 70% 94%, 55% 80%, 42% 94%, 28% 80%, 15% 93%, 4% 78%, 1% 50%);
  box-shadow: 0 6px 14px -8px rgba(25,25,25,0.5); opacity: 0.92;
}
#county-panel h3 {
  font-size: 12px; color: var(--muted); margin: 2px 0 10px; font-weight: 600;
  letter-spacing: 0.01em;
}
.county-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
  font-size: 15px; cursor: pointer;
}
.county-row b { font-weight: 600; color: var(--ink); }
.county-row .nums { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.county-row .nums strong { color: var(--ink); font-weight: 700; }
.county-row .rank { color: var(--orange); font-weight: 700; margin-right: 9px; font-variant-numeric: tabular-nums; }
.county-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.county-base { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--muted); }
.county-base .spark { flex: 0 0 auto; }

/* filters inside the sheet */
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 0 10px; }
.filter-label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.cchips { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
.cchip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-family: var(--font-sans);
  font-size: 11.5px; font-weight: 500; cursor: pointer;
}
.cchip.on { background: var(--peach); border-color: var(--orange); color: var(--ink); }

/* top outage / hotspot list rows */
.top-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.top-row .dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.top-row .top-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.top-row .top-main b { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.top-row .top-main span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-row i { color: var(--muted); width: 15px; height: 15px; flex: 0 0 auto; }
.panel-note { font-size: 10.5px; color: var(--muted); padding: 8px 4px 2px; line-height: 1.4; }

/* ---- notice toast ---- */
#notice {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--charcoal); color: #fff; padding: 13px 16px;
  border-radius: 14px; font-size: 13px; line-height: 1.45; z-index: 1003;
  max-width: 330px; box-shadow: var(--shadow-card);
  border: 1px solid var(--line-dark);
}
#notice .em { font-weight: 600; color: var(--orange); }
.hidden { display: none !important; }

/* ---- popups ---- */
.leaflet-popup-content-wrapper {
  background: var(--surface); color: var(--ink); border-radius: 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow-card);
}
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 14px 16px; font-size: 13px; line-height: 1.5; min-width: 210px; }
.pop-util { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; color: var(--ink-soft); }
.pop-util .dot { width: 9px; height: 9px; border-radius: 2px; }
.pop-cust { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.pop-cust .em { font-weight: 500; font-size: 13px; color: var(--muted); }
.pop-dur {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 8px 0 2px; padding: 6px 10px; border-radius: 9px;
  background: var(--peach); color: var(--ink); font-size: 13px;
}
.pop-dur i { width: 15px; height: 15px; color: var(--orange); flex: 0 0 auto; }
.pop-dur b { font-weight: 700; font-variant-numeric: tabular-nums; }
.pop-dur em { font-style: normal; color: var(--muted); font-size: 11px; }
.pop-dur.est { background: #F1EEE7; }
.pop-meta { color: var(--ink-soft); font-size: 12.5px; margin: 8px 0; }

/* rich labeled detail list (Duke-style) */
.pop-detail { margin: 10px 0 2px; }
.pd-row { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; border-top: 1px solid var(--line); }
.pd-row:first-child { border-top: none; }
.pd-row > i { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; margin-top: 2px; }
.pd-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pd-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.pd-val { font-size: 13px; color: var(--ink); font-weight: 500; }
.pop-loading {
  display: flex; align-items: center; gap: 7px; margin: 8px 0 2px;
  font-size: 12px; color: var(--muted);
}
.pop-loading i { width: 14px; height: 14px; animation: spin 0.9s linear infinite; }
.pop-meta div { display: flex; align-items: center; gap: 7px; margin-top: 4px; }
.pop-meta i { color: var(--muted); width: 14px; height: 14px; flex: 0 0 auto; }
.pop-actions { display: flex; gap: 8px; margin-top: 12px; }
.pop-actions a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  text-decoration: none; font-family: var(--font-sans); font-weight: 500; font-size: 12.5px;
  padding: 10px; border-radius: 10px;
}
.pop-actions a.primary { background: var(--orange); color: #fff; }
.pop-actions a.primary:active { background: var(--orange-press); }
.pop-actions a.alt { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.pop-actions i { width: 15px; height: 15px; }
/* a.* selectors so these beat Leaflet's own `.leaflet-container a` blue link color */
a.pop-zoom {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin-top: 9px; color: var(--muted); text-decoration: none;
  font-size: 12px; font-weight: 500;
}
a.pop-zoom i { width: 13px; height: 13px; }
a.pop-source {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  color: var(--ink-soft); text-decoration: none; font-size: 12px; font-weight: 500;
}
a.pop-source i { width: 14px; height: 14px; color: var(--orange); }
a.pop-source:active { color: var(--orange); }

/* data-sources list in the panel */
.sources { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.src-link {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 7px 11px; font-size: 12px; font-weight: 500;
  text-decoration: none;
}
.src-link .dot { width: 8px; height: 8px; border-radius: 2px; }
.src-link i { width: 13px; height: 13px; color: var(--muted); }

/* county tooltip with baseline history */
.leaflet-tooltip { font-family: var(--font-sans); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-card); }
.tt-base { font-size: 10.5px; color: var(--muted); font-weight: 400; }
