/* LA Fires — destroyed structures. Explore surface: map-first, dense chrome. */

:root {
  --bg:        #0a0a0a;
  --panel:     #121212;
  --panel-2:   #1a1a1a;
  --line:      #2b2b2b;
  --line-soft: #1e1e1e;
  --ink:       #f4f4f4;
  --ink-dim:   #b0b0b0;
  --muted:     #757575;
  --accent:    #ffffff;

  --eaton:     #f2622e;
  --palisades: #3fa9dc;

  --r: 0px;

  --rail-w: 340px;
  --row-h: 30px;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: 52px minmax(0, 1fr);
  overflow: hidden;
}

.app-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 52px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.app-bar h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.view-tabs { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.view-tabs a { color: var(--muted); text-decoration: none; }
.view-tabs span { color: var(--line); }
.view-tabs a:hover, .view-tabs a[aria-current="page"] { color: var(--ink); }
.view-tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ------------------------------------------------------------------ rail */

#rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 18px 18px 22px;
}

.brand .sub {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.stat-row {
  border-radius: var(--r);
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
}
.stat {
  background: var(--panel-2);
  padding: 9px 10px 10px;
}
.stat b {
  display: block;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat span {
  display: block;
  margin-top: 1px;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ------------------------------------------------------------------ fields */

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 10.5px; }

input[type="search"], select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  font: inherit;
  padding: 7px 9px;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}
input:focus-visible, select:focus-visible, button:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input::placeholder { color: #4d5865; }

.suggest {
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  max-height: 232px;
  overflow-y: auto;
}
.suggest li {
  padding: 6px 8px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.suggest li:hover, .suggest li[aria-selected="true"] { background: #1e2630; }
.suggest li em { font-style: normal; color: var(--muted); font-size: 11px; }

.chips { display: flex; gap: 6px; }
.chip {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.chip.on {
  color: var(--ink);
  border-color: #4a5665;
  background: #212a35;
  box-shadow: inset 0 0 0 1px rgba(245, 165, 36, .16);
}
.chip:not(.on) { opacity: .42; background: transparent; }
.chip:not(.on) .dot { filter: grayscale(1); }
.chip:hover { opacity: 1; }
.chip .n { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.dot.eaton { background: var(--eaton); }
.dot.palisades { background: var(--palisades); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 2px 0;
}
.check input { accent-color: var(--accent); width: 14px; height: 14px; }

/* --------------------------------------------------------------- basemaps */

.basemaps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bm {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--ink-dim);
  font: inherit;
  font-size: 11.5px;
  text-align: left;
  transition: border-color .12s;
}
.bm .thumb {
  display: block;
  height: 54px;
  background-size: cover;
  background-position: center;
  background-color: #1c1c1c;
  filter: grayscale(1) contrast(1.18);
  transition: filter .18s;
}
.bm .name {
  display: block;
  padding: 5px 7px 6px;
  font-size: 11px;
  letter-spacing: .01em;
}
.bm:hover .thumb { filter: grayscale(0) brightness(1.04); }
.bm.on { border-color: var(--ink); color: var(--ink); }
.bm:not(.on) .name { color: var(--muted); }
.bm.on::after {
  content: "";
  position: absolute; inset: 0;
  border: 1px solid var(--ink);
  pointer-events: none;
}

/* ----------------------------------------------------------------- legend */

.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-dim); }
.legend .sw { width: 11px; height: 11px; border-radius: 0; flex: none;
               box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.legend .sw.line { background: none !important; border: 1.5px solid; }
.legend .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }

.btn {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #1e2630; border-color: #313b47; }
.btn.ghost { width: auto; padding: 5px 11px; font-size: 12px; }

.foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.foot p { margin: 0 0 7px; font-size: 11px; line-height: 1.55; color: var(--ink-dim); }
.foot .note { color: var(--muted); }

/* ---------------------------------------------------------------- exports */

.exports { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.exports .btn { padding: 7px 4px; font-size: 11.5px; }
.export-note {
  margin: 2px 0 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* --------------------------------------------------------------- print report */

#report { display: none; }

@media print {
  @page { size: A4 portrait; margin: 14mm 12mm 16mm; }

  body { display: block !important; background: #fff !important; color: #111 !important; height: auto; }
  .app-bar, #rail, #mapWrap, #inspector, #tableDrawer, .rail-toggle, .hover-tip { display: none !important; }

  #report {
    display: block !important;
    font: 10pt/1.45 -apple-system, "Helvetica Neue", Arial, sans-serif;
    color: #111;
  }
  #report h1 { margin: 0 0 2mm; font-size: 17pt; letter-spacing: -0.01em; }
  #report .rep-sub { margin: 0 0 5mm; font-size: 9pt; color: #555; }
  #report .rep-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3mm;
    margin: 0 0 5mm;
    padding: 3mm 0;
    border-top: 1.5pt solid #111;
    border-bottom: 0.5pt solid #999;
  }
  #report .rep-stat b { display: block; font-size: 14pt; font-variant-numeric: tabular-nums; }
  #report .rep-stat span { font-size: 8pt; color: #555; text-transform: uppercase; letter-spacing: .04em; }
  #report .rep-caveat {
    margin: 0 0 5mm;
    padding: 2.5mm 3mm;
    background: #f4f4f2;
    border-left: 2pt solid #111111;
    border-top: 0.3pt solid #ddd;
    border-right: 0.3pt solid #ddd;
    border-bottom: 0.3pt solid #ddd;
    font-size: 8.5pt;
    line-height: 1.5;
    color: #333;
  }
  #report table { width: 100%; border-collapse: collapse; font-size: 8pt; table-layout: fixed; }
  #report th:nth-child(1), #report td:nth-child(1) { width: 26%; }
  #report th:nth-child(2), #report td:nth-child(2) { width: 15%; }
  #report th:nth-child(3), #report td:nth-child(3) { width: 7%; }
  #report th:nth-child(4), #report td:nth-child(4) { width: 9%; }
  #report th:nth-child(5), #report td:nth-child(5) { width: 15%; }
  #report th:nth-child(6), #report td:nth-child(6) { width: 6%; }
  #report th:nth-child(7), #report td:nth-child(7) { width: 6%; }
  #report th:nth-child(8), #report td:nth-child(8) { width: 16%; }
  #report thead th {
    text-align: left;
    font-size: 7.5pt;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #444;
    border-bottom: 1pt solid #111;
    padding: 1.5mm 1.5mm;
  }
  #report tbody td { padding: 1.2mm 1.5mm; border-bottom: 0.3pt solid #ddd; vertical-align: top;
                     overflow-wrap: anywhere; }
  #report tbody tr:nth-child(even) { background: #fafafa; }
  #report thead { display: table-header-group; }
  #report tr, #report td { page-break-inside: avoid; }
  #report .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  #report .rep-foot { margin-top: 4mm; font-size: 7.5pt; color: #666; }
  #report .rep-trunc { margin-top: 3mm; font-size: 8.5pt; font-style: italic; color: #444; }
}

/* ------------------------------------------------------------------- map */

#mapWrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #10151a; }

.hover-tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: rgba(11,13,16,.94);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 5px 8px;
  font-size: 11.5px;
  color: var(--ink);
  max-width: 280px;
  transform: translate(10px, -50%);
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
.hover-tip .tip-sub { color: var(--muted); font-size: 10.5px; }

.rail-toggle {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 15;
  display: none;
  width: 38px; height: 38px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: rgba(17,21,26,.94);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
}

/* -------------------------------------------------------------- inspector */

#inspector {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  z-index: 18;
  background: rgba(13,16,20,.97);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px 18px 28px;
  animation: slideIn .16s ease-out;
}
#mapWrap:has(#tableDrawer:not([hidden])) #inspector { bottom: 54%; }
@keyframes slideIn { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #inspector { animation: none; } }

#inspClose {
  position: absolute;
  top: 10px; right: 12px;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: none;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
#inspClose:hover { color: var(--ink); border-color: var(--line); }

.insp-fire {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 8px;
}
.insp-addr {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.insp-city { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.insp-apn {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 2px 6px;
}

.insp-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 14px 0 0;
  padding: 13px 0 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
}
.insp-grid dt { color: var(--ink-dim); font-size: 11.5px; }
.insp-grid dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.insp-sect {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.insp-sect h3 {
  margin: 0 0 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
}
.status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  padding: 3px 0;
}
.status span:first-child { color: var(--ink-dim); }
.status span:last-child { color: var(--ink); text-align: right; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r);
  font-size: 10.5px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.badge.warn { border-color: #6b4a1d; color: #e0b060; background: #241a0d; }

/* ----------------------------------------------------------------- table */

#tableDrawer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 54%;
  z-index: 16;
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  animation: slideUp .16s ease-out;
}
@keyframes slideUp { from { transform: translateY(18px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #tableDrawer { animation: none; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.drawer-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }

.table-scroll { overflow-y: auto; flex: 1; position: relative; }
.table-inner { position: relative; }

.thead, .trow {
  display: grid;
  grid-template-columns: 2.3fr .8fr 1.15fr .55fr .65fr 1.35fr;
  gap: 10px;
  align-items: center;
  padding: 0 16px;
}
.thead {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.thead button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.thead button:hover { color: var(--ink); }
.thead .sorted { color: var(--accent); }

.tbody { position: relative; }
.trow {
  position: absolute;
  left: 0; right: 0;
  height: var(--row-h);
  border-bottom: 1px solid #14191f;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.trow:hover { background: var(--panel-2); }
.trow.sel { background: #1d2634; box-shadow: inset 2px 0 0 var(--accent); }
.trow .addr { overflow: hidden; text-overflow: ellipsis; }
.trow .apn { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.trow .num { font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.trow .firecell { display: flex; align-items: center; gap: 6px; }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* --------------------------------------------------------------- maplibre */

.maplibregl-ctrl-attrib { font-size: 10px !important; }
.maplibregl-popup-content {
  background: var(--panel) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font: 12px var(--sans);
  padding: 7px 10px;
}
.maplibregl-popup-tip { border-top-color: var(--panel) !important; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  #rail {
    position: absolute;
    inset: 52px auto 0 0;
    width: min(340px, 88vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  body.rail-open #rail { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .rail-toggle { display: block; }
  body.rail-open .rail-toggle { left: auto; right: 12px; z-index: 31; }
  #inspector { width: min(340px, 92vw); }
  .thead, .trow { grid-template-columns: 2fr .9fr 1fr .5fr; }
  .col-apn, .col-rebuild { display: none; }
}
