:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ef;
  --border: #dddcd7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #2a78d6;
  /* Hail size bands: one violet hue, light to dark (ordinal). */
  --band-1: #a17adf;
  --band-2: #8654cc;
  --band-3: #6b30af;
  --band-4: #4c1b82;
  /* Hurricane wind bands (39, 58, 74 mph): one orange hue, light to dark.
     Not blue, which reads as water on the basemap. */
  --wind-1: #f7c48e;
  --wind-2: #e5782c;
  --wind-3: #9c3f0e;
  /* Roof age in five-year bands (0-4 to 30+): one crimson hue, light to dark.
     Older roofs, the better leads, read darkest. */
  --roof-1: #fbd5dc;
  --roof-2: #f4a5b5;
  --roof-3: #e8738c;
  --roof-4: #d24768;
  --roof-5: #b02a4d;
  --roof-6: #861a39;
  --roof-7: #5c0f27;
  /* Status colors, always paired with an icon and label. */
  --good: #0ca30c;
  --warning: #fab219;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--surface-1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body[data-hazard="wind"] .hail-only, body:not([data-hazard="wind"]) .wind-only { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; }

.bar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.bar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
label { color: var(--text-secondary); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
select, input, button {
  font: inherit; color: var(--text-primary); background: #fff;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;
}
button { cursor: pointer; background: var(--surface-2); }
button:hover { border-color: var(--text-muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

main { flex: 1; display: flex; min-height: 0; }
.side {
  width: 360px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface-1);
}
.map { flex: 1; }

.search { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--border); }
.search input { flex: 1; }
.list-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; color: var(--text-secondary); font-size: 13px;
}
.notice { margin: 0 12px 8px; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); color: var(--text-secondary); font-size: 13px; }
.help { margin: 0; padding: 10px 12px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; }

.days { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; }
.days[aria-busy="true"] { opacity: 0.5; }
.day {
  display: block; width: 100%; text-align: left; margin: 0 0 6px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.day[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day .date { font-weight: 600; }
.day .size { font-weight: 650; font-size: 15px; }
.day .meta { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }
.badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; background: var(--surface-1);
}
.badge .icon {
  width: 14px; height: 14px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 700; line-height: 1;
}
.badge.confirmed .icon { background: var(--good); color: #fff; }
.badge.warned .icon { background: var(--warning); color: var(--text-primary); }
.badge.radar .icon, .badge.report .icon, .badge.gap .icon { background: var(--surface-2); color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border); }
.badge.gust .icon { background: var(--good); color: #fff; }
.badge.damage .icon, .badge.hurricane .icon { background: var(--warning); color: var(--text-primary); }
.badge.wind-warned .icon { background: var(--surface-2); color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border); }

/* Evidence filter: one toggle per badge, above the list. */
.tier-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.tier-filter button.badge { cursor: pointer; font: inherit; font-size: 12px; min-height: 28px; padding: 2px 10px; }
.tier-filter button.badge .count { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tier-filter button.badge[aria-pressed="false"] { background: transparent; color: var(--text-muted); border-style: dashed; }
.tier-filter button.badge[aria-pressed="false"] .icon { opacity: 0.4; }
.tier-filter button.badge[aria-pressed="false"] .label { text-decoration: line-through; }

.legend {
  background: rgba(252, 252, 251, 0.95); padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); line-height: 1.6;
}
.legend h2 { font-size: 12px; margin: 0 0 4px; color: var(--text-primary); font-weight: 600; }
.legend .item { display: flex; align-items: center; gap: 8px; }
.legend .swatch { width: 16px; height: 12px; border-radius: 2px; opacity: 0.8; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: #1f1f1f; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #999; margin: 0 3px; }
.legend .dash { width: 16px; border-top: 2px dashed var(--text-secondary); }
.legend .track { width: 16px; border-top: 3px solid #1f1f1f; }
.legend .square { width: 10px; height: 10px; background: #1f1f1f; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #999; margin: 0 3px; }
.legend .tri { width: 0; height: 0; border: 6px solid transparent; border-bottom: 11px solid #1f1f1f; border-top: 0; margin: 0 2px; }
.legend .dot.light { background: #fff; box-shadow: 0 0 0 2px #1f1f1f; }
.wind-icon { display: block; }
.legend input[type="range"] { width: 90px; padding: 0; }

.legend details > summary { cursor: pointer; list-style-position: inside; }
.legend details > summary h2 { display: inline; }
.legend details[open] > summary { margin-bottom: 4px; }

/* Door knocking plan: replaces the day list while open. */
.plan-bar { padding: 8px 12px 0; }
.plan-bar button { width: 100%; font-weight: 600; }
body.planning .list-head, body.planning .tier-filter, body.planning .days, body.planning .plan-bar { display: none !important; }
.plan { display: flex; flex-direction: column; min-height: 0; flex: 1; padding: 8px 12px 0; }
.plan-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plan-head h2 { font-size: 15px; margin: 0; }
.plan-sub { margin: 4px 0 8px; color: var(--text-secondary); font-size: 12.5px; }
.plan-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-exports { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.plan-exports a {
  font-size: 12.5px; color: var(--text-primary); text-decoration: none;
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; background: var(--surface-2);
}
.plan-summary { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.plan-summary .counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.plan-areas { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; flex: 1; }
.plan-areas > li { border: 1px solid var(--border); border-radius: 8px; background: #fff; margin-bottom: 6px; }
.plan-areas summary { cursor: pointer; padding: 8px 10px; }
.plan-areas .area-name { font-weight: 600; }
.plan-areas .area-meta { color: var(--text-secondary); font-size: 12.5px; }
.plan-street { padding: 4px 10px 8px; border-top: 1px solid var(--surface-2); }
.plan-street h3 { font-size: 13px; margin: 4px 0; display: flex; justify-content: space-between; gap: 8px; }
.plan-street h3 a { font-weight: 400; font-size: 12px; color: var(--accent); }
.plan-street ol { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.plan-street li { display: flex; gap: 8px; align-items: center; padding: 2px 0; cursor: pointer; }
.plan-street li .num { min-width: 44px; font-variant-numeric: tabular-nums; font-weight: 600; }
.plan-street li .hit { margin-left: auto; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.roof-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); }
.roof-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px #fff, 0 0 0 2px #bbb; }
.roof-dot.ring { background: #fff !important; box-shadow: inset 0 0 0 3px var(--ring); }
.badge.old .icon { background: var(--roof-6); color: #fff; }
.badge.maybe .icon { background: #fff; color: var(--roof-6); box-shadow: inset 0 0 0 2px var(--roof-6); }
.badge.newer .icon { background: var(--surface-2); color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border); }

/* Accounts: sign-in buttons, the account menu and the admin page. */
a.button {
  display: inline-flex; align-items: center; font-size: 13px; color: var(--text-primary); text-decoration: none;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; background: var(--surface-2); white-space: nowrap;
}
a.button:hover { border-color: var(--text-muted); }
a.button .with { margin-left: 0.3em; }
.account { margin-left: auto; position: relative; }
.account-menu > summary {
  cursor: pointer; list-style: none; font-size: 13px; color: var(--text-secondary);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary::after { content: " ▾"; }
.account-menu .count, .admin .count {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; text-align: center;
  background: var(--warning); color: var(--text-primary); font-size: 11.5px; font-weight: 650;
}
.account-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1002; width: 240px;
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}
.account-menu .menu a { color: var(--accent); }
.account-menu .note { margin: 0; color: var(--text-secondary); font-size: 12.5px; }
button.quiet { background: transparent; color: var(--text-secondary); }
.plan-signin { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.admin, .auth-page main { display: block; flex: none; width: 100%; max-width: 900px; margin: 0 auto; padding: 16px; }
body:has(main.admin) { overflow-y: auto; }
.admin h1, .auth-page h1 { font-size: 18px; }
.admin table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin th, .admin td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin th { color: var(--text-secondary); font-weight: 600; }
.admin .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin .status-pending { font-weight: 650; }
.admin .status-rejected { color: var(--text-muted); }
.admin a { color: var(--accent); }
.admin .intro, .auth-page p { color: var(--text-secondary); }

/* Phone-only controls. */
.filters-toggle, .sheet-toggle, .current { display: none; }

.popup h3 { font-size: 13px; margin: 0 0 4px; }
.popup .sub { color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; }
.popup ul { margin: 0; padding: 0; list-style: none; max-height: 220px; overflow-y: auto; }
.popup li { padding: 3px 0; border-top: 1px solid var(--surface-2); }
.popup a { color: var(--accent); cursor: pointer; }
.leaflet-tooltip { font: 12px/1.4 system-ui, sans-serif; }

/* Phones: map first, filters in a panel, the list in a bottom sheet. */
@media (max-width: 767px) {
  body { height: 100dvh; }
  select, input, button { font-size: 16px; min-height: 40px; } /* 16px stops iOS zooming on focus */

  .bar { flex-wrap: nowrap; justify-content: space-between; gap: 12px; padding: 6px 12px; position: relative; z-index: 1001; }
  .filters-toggle { display: inline-flex; align-items: center; }
  .filters {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    padding: 12px; background: var(--surface-1); border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  }
  .bar.filters-open .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters label { flex-direction: column; align-items: stretch; gap: 4px; }

  main { flex-direction: column; }
  .map { order: 1; min-height: 0; }
  .side {
    order: 2; width: auto; border-right: 0; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08); padding-bottom: env(safe-area-inset-bottom);
  }
  .side.open { height: 62dvh; }
  .side:not(.open) .days, .side:not(.open) .help { display: none; }
  .side:not(.open) .plan > :not(.plan-head) { display: none; }
  .side.open .plan { overflow-y: auto; }
  .search { padding: 8px 12px; }
  .list-head { gap: 8px; }
  .list-head #summary { display: none; } /* shown in the sheet toggle */
  .side:not(.open) .list-head label, .side:not(.open) .tier-filter { display: none; }
  .tier-filter button.badge { min-height: 36px; font-size: 13px; }
  .sheet-toggle { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1; min-width: 0; }

  .current { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
  .current[hidden] { display: none; }
  .current button { min-width: 44px; font-size: 20px; line-height: 1; }
  #current-day { flex: 1; min-width: 0; font-size: 14px; }
  #current-day .meta { color: var(--text-secondary); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .legend { max-width: 70vw; }

  .account { margin-left: 0; }
  .account .signin .with { display: none; }
  .account a.button { min-height: 40px; font-size: 15px; }
  .account-menu > summary { max-width: 34vw; min-height: 40px; display: flex; align-items: center; }
  .admin table, .admin tbody, .admin tr, .admin td { display: block; }
  .admin thead { display: none; }
  .admin tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .admin td { border: 0; padding: 2px 0; }
  .admin td[data-label]::before { content: attr(data-label) ": "; color: var(--text-secondary); }
  .admin .actions { padding-top: 6px; }
}
