/* ─────────────────────────────────────────────────────────────
   FIRE WATCH USA  —  strict black & white interface
   ───────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: #000;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 420px 1fr;
  grid-template-areas:
    'top top'
    'side map';
  height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #000;
  color: #fff;
  border-bottom: 1px solid #000;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 20px; }
.brand h1 {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 4px;
}

.topnav { display: flex; align-items: center; gap: 10px; margin-left: 24px; }
.topnav .who {
  font: 700 10px 'JetBrains Mono', monospace; letter-spacing: 1.5px;
  color: #aaa; margin-right: 8px;
}
.topnav .who .role {
  background: #444; color: #fff; padding: 2px 6px; margin-left: 6px;
  font-size: 9px; letter-spacing: 2px;
}
.topnav .who .role.admin   { background: #d11; }
.topnav .who .role.manager { background: #06f; }
.topnav .who .role.sales   { background: #777; }
.topnav .nav-btn {
  background: transparent; border: 1px solid #fff; color: #fff;
  padding: 5px 12px; font: 700 10px 'Inter', sans-serif; letter-spacing: 2px;
  text-decoration: none; cursor: pointer;
}
.topnav .nav-btn:hover { background: #fff; color: #000; }
.topnav .nav-btn.admin-only { border-color: #d11; color: #d11; }
.topnav .nav-btn.admin-only:hover { background: #d11; color: #fff; }

/* Location-tracking status pill (sales) */
.loc-pill {
  font: 700 10px 'JetBrains Mono', monospace;
  letter-spacing: 1px;
  padding: 5px 10px;
  border: 1px solid #555;
  color: #ddd;
  background: rgba(255,255,255,0.06);
  white-space: nowrap;
}
.loc-pill.ok      { color: #6cf; border-color: #6cf; }
.loc-pill.pending { color: #fc6; border-color: #fc6; }
.loc-pill.warn    { color: #fc6; border-color: #fc6; background: rgba(255, 200, 80, 0.08); }
.loc-pill.err     { color: #f66; border-color: #f66; background: rgba(255,80,80,0.08); }

/* Sales-rep marker on the map (admin / manager view) */
.sales-marker { background: transparent !important; border: none !important; }
.sales-pin {
  width: 28px; height: 28px; border-radius: 50%;
  background: #06f; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font: 700 11px 'JetBrains Mono', monospace; letter-spacing: 0.5px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #06f, 0 2px 6px rgba(0,0,0,0.4);
  position: relative;
}
.sales-pin::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(0, 102, 255, 0.5);
  animation: salesPing 1.8s ease-out infinite;
}
.sales-pin.stale {
  background: #888;
  box-shadow: 0 0 0 2px #888, 0 2px 6px rgba(0,0,0,0.4);
}
.sales-pin.stale::after { animation: none; opacity: 0; }
@keyframes salesPing {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* Privacy banner shown to sales on first visit */
.loc-banner {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: #000; color: #fff;
  border: 1px solid #d11;
  box-shadow: 4px 4px 0 #d11;
  padding: 14px 18px;
  z-index: 9999;
  display: flex; align-items: center; gap: 20px;
  max-width: 720px;
  font: 12px 'Inter', sans-serif; line-height: 1.4;
}
.loc-banner-body strong {
  display: block; font-size: 11px; letter-spacing: 3px;
  margin-bottom: 4px; color: #fc6;
}
.loc-banner-body span { color: #ddd; }
.loc-banner-close {
  background: #d11; color: #fff; border: 1px solid #d11;
  padding: 8px 14px;
  font: 700 10px 'Inter', sans-serif; letter-spacing: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.loc-banner-close:hover { background: #fff; color: #d11; }

.stats { display: flex; gap: 28px; align-items: center; }
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}
.stat .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
}
.stat .lbl {
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 2px;
  color: #888;
}
.live-dot {
  color: #fff;
  animation: blink 1.5s infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-area: side;
  background: #fff;
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.block {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.filters-block { flex: 0 0 42%; border-bottom: 1px solid #000; min-height: 0; }
.filters-block.hidden { display: none; }
.incidents-block { flex: 1 1 0; min-height: 0; }

/* ── Filter tab switcher ────────────────────────────────────────────── */
.filter-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #000;
  border-bottom: 1px solid #000;
}
.filter-tabs .tab {
  background: #000;
  color: #888;
  border: none;
  border-right: 1px solid #222;
  padding: 11px 14px;
  cursor: pointer;
  font: 700 10px 'Inter', sans-serif;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, color .15s;
}
.filter-tabs .tab:last-child { border-right: none; }
.filter-tabs .tab:hover { color: #fff; }
.filter-tabs .tab.active {
  background: #fff;
  color: #000;
}
.filter-tabs .t-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: #333;
  color: #fff;
  padding: 1px 6px;
  letter-spacing: 1px;
  min-width: 22px;
  text-align: center;
}
.filter-tabs .tab.active .t-count {
  background: #000;
  color: #fff;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #000;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
}
.block-head small {
  font-family: 'JetBrains Mono', monospace;
  color: #888;
  font-weight: 400;
  letter-spacing: 1px;
}
.block-head .ghost {
  background: transparent;
  border: 1px solid #fff;
  color: #fff;
  font: inherit;
  padding: 2px 8px;
  cursor: pointer;
  letter-spacing: 2px;
}
.block-head .ghost:hover { background: #fff; color: #000; }

.status-toggles { display: flex; gap: 12px; font-size: 9px; letter-spacing: 1px; }
.status-toggles label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.status-toggles input { accent-color: #fff; }

.search-row { padding: 8px 12px; border-bottom: 1px solid #ddd; }
.search-row input[type="text"] {
  width: 100%;
  border: 1px solid #000;
  padding: 6px 10px;
  font: 12px 'Inter', sans-serif;
  outline: none;
}
.search-row input[type="text"]:focus { background: #f5f5f5; }
.inline-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #666;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.inline-toggle input { accent-color: #000; cursor: pointer; }

/* Filter list */
.filter-list { overflow-y: auto; flex: 1; }
.filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 12px;
  transition: background .1s;
}
.filter:hover { background: #f5f5f5; }
.filter.active { background: #000; color: #fff; }
.filter input { accent-color: #000; cursor: pointer; }
.filter.active input { accent-color: #fff; }
.filter .name { flex: 1; }
.filter .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: #eee;
  padding: 2px 7px;
  min-width: 30px;
  text-align: center;
}
.filter.active .count { background: #fff; color: #000; }

/* Type filters: also surface the raw code (FA, ME, SF, ...) */
.filter .code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #999;
  letter-spacing: 1px;
  padding: 0 6px;
}
.filter.active .code { color: #aaa; }

/* Agency filter rows: two-line layout (name + city/state) */
.filter.agency { gap: 8px; }
.filter.agency .agency-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.filter.agency .name {
  flex: none;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter.agency .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #888;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter.agency.active .sub { color: #bbb; }
.filter.agency.empty-agency .count { background: #f0f0f0; color: #aaa; }

/* Address "approx." badge */
.approx {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #b00;
  border: 1px solid #b00;
  padding: 0 4px;
  margin-left: 4px;
  letter-spacing: 1px;
  vertical-align: 1px;
}
.incident.selected .approx { color: #ff8a8a; border-color: #ff8a8a; }

/* Incident list */
.incident-list { overflow-y: auto; flex: 1; }
.incident {
  padding: 11px 16px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background .1s;
}
.incident:hover { background: #f5f5f5; }
.incident.selected { background: #000; color: #fff; }
.incident.selected .meta { color: #aaa; }
.incident.selected .badge { border-color: #fff; background: #fff; color: #000; }

.incident .line1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.incident .type {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.incident .badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 1px 6px;
  border: 1px solid #000;
  letter-spacing: 1px;
  white-space: nowrap;
}
.incident .badge.active {
  background: #000;
  color: #fff;
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge { 50% { opacity: 0.5; } }
.incident .address { font-size: 12px; margin-bottom: 4px; line-height: 1.3; }
.incident .meta {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #666;
}

/* ── Map ────────────────────────────────────────────────────── */
.map-wrap { grid-area: map; position: relative; }
#map { width: 100%; height: 100%; background: #fff; }
.leaflet-container { background: #f7f7f7 !important; font-family: inherit; }

/* Map controls (top-right floating panel) */
.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}
.map-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #000;
  font: 700 10px 'Inter', sans-serif;
  letter-spacing: 1.5px;
  cursor: pointer;
  user-select: none;
}
.map-toggle input { accent-color: #000; cursor: pointer; }

/* ── Custom markers ─────────────────────────────────────────────────
   Visual language:
     · default      → white dot, black ring        (medical / non-fire)
     · .live        → solid black, animated ping   (call still active)
     · .fire        → solid red                    (fire-related code)
     · .live.fire   → red + ping
     · .approx      → dashed ring (location is the agency centroid,
                      not the actual address — HIPAA-masked incidents)
   ──────────────────────────────────────────────────────────────────── */
.fire-marker { position: relative; }
.fire-marker .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #000;
  box-sizing: border-box;
}
.fire-marker .dot.live    { background: #000; }
.fire-marker .dot.fire    { background: #d11; border-color: #d11; }
.fire-marker .dot.live.fire { background: #d11; border-color: #d11; }
.fire-marker .dot.approx  { border-style: dashed; opacity: 0.85; }

.fire-marker .dot.live::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #000;
  transform: translate(-50%, -50%);
  animation: ping 2.2s ease-out infinite;
  pointer-events: none;
}
.fire-marker .dot.live.fire::after { border-color: #d11; }
@keyframes ping {
  0%   { width: 12px; height: 12px; opacity: 0.5; }
  80%  { opacity: 0; }
  100% { width: 28px; height: 28px; opacity: 0; }
}

.fire-marker .dot.alert {
  background: #000;
  border: 2px solid #000;
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  border-radius: 0;
}

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: 0;
  background: #fff;
  border: 1px solid #000;
  box-shadow: 4px 4px 0 #000;
  padding: 0;
}
.leaflet-popup-content { margin: 12px 14px; font-family: inherit; min-width: 240px; }
.leaflet-popup-tip { background: #000; }
.leaflet-popup-close-button { color: #000 !important; font-size: 20px !important; }

.popup-type { font-weight: 700; letter-spacing: 1px; font-size: 12px; margin-bottom: 6px; text-transform: uppercase; }
.popup-address { font-size: 13px; margin-bottom: 8px; line-height: 1.3; }
.popup-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #666;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.popup-coord {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #888;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.popup-precision {
  font: 9px/1.2 'JetBrains Mono', monospace;
  color: #b00;
  margin-bottom: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.popup-actions { display: flex; gap: 6px; }
.popup-btn {
  background: #000;
  color: #fff;
  border: 1px solid #000;
  padding: 6px 12px;
  cursor: pointer;
  font: 700 10px 'Inter', sans-serif;
  letter-spacing: 1.5px;
}
.popup-btn:hover { background: #fff; color: #000; }
.popup-btn.secondary { background: #fff; color: #000; }
.popup-btn.secondary:hover { background: #000; color: #fff; }
.popup-btn.pinned   { background: #06f; color: #fff; border-color: #06f; }
.popup-btn.pinned:hover { background: #fff; color: #06f; }
.popup-btn.assign   { background: #fff; color: #d11; border-color: #d11; }
.popup-btn.assign:hover { background: #d11; color: #fff; }

.popup-sales {
  margin: 10px 0; padding: 10px; background: #f7f7f7; border: 1px solid #ddd;
}
.popup-sales .sales-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.popup-sales label {
  font: 700 9px 'Inter', sans-serif; letter-spacing: 2px; color: #777;
  min-width: 60px;
}
.popup-sales select {
  flex: 1; padding: 4px 8px; font: 11px 'JetBrains Mono', monospace;
  border: 1px solid #000; outline: none;
}

.pin-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  background: #06f;
  color: #fff;
  padding: 1px 6px;
  margin-left: 6px;
  letter-spacing: 1px;
  vertical-align: 1px;
}

.incident.pinned {
  background: #f0f6ff;
  border-left: 3px solid #06f;
}
.incident.pinned.selected {
  background: #06f;
  color: #fff;
}
.incident.pinned .meta { color: #335577; }
.incident.pinned.selected .meta { color: #cfe; }

/* ── Detail panel ───────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 420px;
  max-height: 70vh;
  background: #fff;
  border: 1px solid #000;
  box-shadow: 6px 6px 0 #000;
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}
.detail-panel.open { display: flex; }
.detail-panel .close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #000;
  z-index: 2;
}
#detailBody {
  padding: 20px;
  overflow-y: auto;
}
.detail-head {
  border-bottom: 1px solid #000;
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.detail-head .t {
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 700;
  margin-bottom: 4px;
}
.detail-head .a { font-size: 15px; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.detail-head .m {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #666;
}
.detail-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  padding: 7px 0;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}
.detail-row .k {
  font-size: 9px;
  letter-spacing: 2px;
  color: #999;
  font-weight: 700;
  padding-top: 2px;
}
.detail-row .v {
  font-family: 'JetBrains Mono', monospace;
  word-break: break-word;
}
.detail-units { margin-top: 12px; }
.detail-units h4 {
  font-size: 10px;
  letter-spacing: 3px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #000;
}
.unit {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border-bottom: 1px dotted #ddd;
}
.detail-audio { margin-top: 16px; }
.detail-audio h4 {
  font-size: 10px;
  letter-spacing: 3px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #000;
}
.detail-audio audio { width: 100%; }
.no-audio {
  font-size: 11px;
  color: #999;
  font-style: italic;
  padding: 8px 0;
}

/* ── Empty / loading ────────────────────────────────────────── */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: #999;
  font-size: 12px;
  letter-spacing: 1px;
}
.loading {
  padding: 20px;
  text-align: center;
  color: #999;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* Scrollbars (chrome) */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #fff; }
::-webkit-scrollbar-thumb { background: #ddd; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Responsive */
@media (max-width: 900px) {
  .app {
    grid-template-rows: 56px 280px 1fr;
    grid-template-columns: 1fr;
    grid-template-areas: 'top' 'side' 'map';
  }
  .filters-block { flex: 0 0 50%; }
  .detail-panel { width: calc(100vw - 32px); }
}
