:root {
  --bg: #edf4fa;
  --ink: #16222f;
  --muted: #415466;
  --panel: rgba(255, 255, 255, 0.85);
  --card: rgba(255, 255, 255, 0.9);
  --line: rgba(21, 34, 47, 0.12);
  --accent-a: #1572a1;
  --accent-b: #f39c34;
  --accent-c: #2b8c6a;
  --warn: #c04f15;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f4f8fc 0%, #eaf2f9 100%);
  min-height: 100vh;
}

.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(48rem 28rem at 8% -8%, rgba(21, 114, 161, 0.22), transparent 65%),
    radial-gradient(42rem 30rem at 94% 6%, rgba(243, 156, 52, 0.18), transparent 70%),
    radial-gradient(38rem 24rem at 40% 110%, rgba(43, 140, 106, 0.16), transparent 70%);
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.2rem;
  background: linear-gradient(120deg, rgba(21, 114, 161, 0.9), rgba(38, 81, 111, 0.94));
  color: #fff;
  border-radius: 0;
  box-shadow: 0 12px 28px rgba(22, 34, 47, 0.2);
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 600;
  font-size: 0.72rem;
  opacity: 0.88;
}

.hero h1 {
  margin: 0.3rem 0;
  font-size: clamp(1.35rem, 2.8vw, 2rem);
}

.range-text {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.95;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.95rem;
}

.card,
.panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 0;
  box-shadow: 0 10px 22px rgba(31, 54, 75, 0.09);
}

.card {
  padding: 0.9rem;
}

.card-label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.01em;
}

.card-value {
  margin: 0.25rem 0 0.18rem;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 700;
}

.card-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.panel {
  padding: 0.95rem;
}

.layout > .panel {
  margin-top: 0.95rem;
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 208px;
  gap: 0.75rem;
  align-items: start;
}

#clearanceMap {
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  background: #e8eef4;
}

.map-legend {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: 0.7rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.map-legend h3 {
  margin: 0 0 0.4rem;
  font-size: 0.83rem;
  text-transform: none;
  letter-spacing: 0.01em;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.26rem 0;
}

.legend-chip {
  width: 0.94rem;
  height: 0.94rem;
  border-radius: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex: 0 0 auto;
}

.legend-note {
  margin-top: 0.55rem;
  font-size: 0.76rem;
}

.leaflet-tooltip.map-tooltip {
  background: rgba(16, 31, 46, 0.95);
  border: 0;
  color: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  padding: 0.42rem 0.5rem;
}

.leaflet-tooltip.map-tooltip .name {
  font-weight: 700;
  margin-bottom: 0.14rem;
}

.daily-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.chart-wrap {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 0;
  padding: 0.75rem 0.75rem calc(0.96rem + 3px);
  overflow-x: auto;
}

.daily-chart h3 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.01em;
}

.daily-subtitle {
  margin-bottom: 0.4rem;
}

.bar-grid {
  height: 210px;
  display: grid;
  grid-template-columns: repeat(var(--bar-count, 7), minmax(52px, 1fr));
  gap: 0.4rem;
  align-items: end;
  min-width: 420px;
  position: relative;
  isolation: isolate;
  --daily-grid-bottom-inset: 2.55rem;
  --daily-grid-baseline: calc(100% - var(--daily-grid-bottom-inset));
}

.bar-grid::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: calc(100% - var(--daily-grid-baseline));
  left: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, var(--line), var(--line)),
    linear-gradient(to right, var(--line), var(--line)),
    linear-gradient(to right, var(--line), var(--line));
  background-repeat: no-repeat;
  background-size:
    100% 1px,
    100% 1px,
    100% 1px;
  background-position:
    0 25%,
    0 50%,
    0 75%;
}

.bar-grid::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: var(--daily-grid-baseline);
  border-top: 1px solid var(--line);
  pointer-events: none;
  z-index: 0;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.bar-stack {
  height: 170px;
  width: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 0.2rem;
}

.bar-stack.single .bar {
  width: 68%;
}

.bar {
  width: 40%;
  border-radius: 0;
  min-height: 2px;
  transition: height 280ms ease;
}

.bar.primary {
  background: linear-gradient(180deg, #1c86bc, #156a95);
}

.bar.secondary {
  background: linear-gradient(180deg, #f3ad48, #cd7f1d);
}

.bar-label,
.bar-value {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.73rem;
  color: var(--muted);
  text-align: center;
}

.bar-value {
  font-size: 0.82rem;
}

.bar-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.03rem;
  line-height: 1.08;
  white-space: normal;
}

.bar-day,
.bar-date {
  display: block;
}

.bar-value {
  font-weight: 600;
  white-space: nowrap;
}

#dailyRequestsEmpty,
#dailyClosedEmpty {
  margin-top: 0.5rem;
}

.list-wrap {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: 0.35rem 0.75rem;
}

.list-wrap ol {
  margin: 0;
  padding: 0.2rem 0 0.2rem 1.2rem;
}

.list-wrap li {
  margin: 0.36rem 0;
}

.list-wrap strong {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
}

.table-shell {
  position: relative;
}

table {
  border-collapse: collapse;
  width: 100%;
}

#neighborhoodSummaryTable {
  table-layout: fixed;
}

#neighborhoodSummaryTable th,
#neighborhoodSummaryTable td {
  width: 12.5%;
}

th,
td {
  text-align: left;
  padding: 0.58rem 0.62rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

th {
  text-transform: none;
  letter-spacing: 0.01em;
  color: var(--muted);
  font-size: 0.75rem;
}

.sort-button {
  border: 0;
  background: transparent;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
  display: inline;
  line-height: 1.15;
}

.sort-button::after {
  content: attr(data-sort-indicator);
  display: inline-block;
  width: 0.75em;
  margin-left: 0.16em;
  text-align: center;
  vertical-align: baseline;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 120ms ease-in-out;
}

.sort-button[data-sort-direction="asc"]::after {
  transform: rotate(180deg);
}

.sort-button:hover {
  color: #244257;
}

.sort-button.active {
  color: #173952;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.52rem;
  border-radius: 0;
  font-size: 0.74rem;
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.status-pill.open {
  background: rgba(21, 114, 161, 0.14);
  color: #0e5f89;
}

.status-pill.closed {
  background: rgba(43, 140, 106, 0.16);
  color: #20664e;
}

.footnote {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.footnote a {
  color: #125f88;
}

@media (min-width: 961px) {
  .map-layout {
    display: block;
    position: relative;
  }

  #clearanceMap {
    width: 100%;
  }

  .map-legend {
    position: absolute;
    right: calc(0.72rem + 10px);
    bottom: calc(0.72rem + 20px);
    width: min(14.2rem, calc(100% - 1.44rem));
    max-height: calc(100% - 1.44rem);
    overflow-y: auto;
    z-index: 450;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 20px rgba(20, 40, 60, 0.15);
  }
}

@media (max-width: 960px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .daily-grid {
    grid-template-columns: 1fr;
    row-gap: 1.1rem;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  #clearanceMap {
    min-height: 420px;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .layout {
    padding: 1rem 0.75rem 1.8rem;
  }

  .daily-chart {
    padding: 0.68rem 0.68rem calc(0.9rem + 3px);
    overflow-x: hidden;
  }

  .daily-chart .bar-grid {
    min-width: 0;
    grid-template-columns: repeat(var(--bar-count, 7), minmax(0, 1fr));
    gap: 0.26rem;
    height: 198px;
    --daily-grid-bottom-inset: 2.35rem;
  }

  .daily-chart .bar-stack {
    height: 152px;
  }

  .daily-chart .bar-label,
  .daily-chart .bar-value {
    font-size: 0.62rem;
  }

  .daily-chart .bar-value {
    font-size: 0.7rem;
  }

  .table-shell::after {
    content: "";
    position: absolute;
    top: 1px;
    right: 1px;
    width: 1.6rem;
    height: calc(100% - 2px);
    pointer-events: none;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0));
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    z-index: 4;
  }

  #neighborhoodSummaryTable th,
  #neighborhoodSummaryTable td {
    font-size: 0.74rem;
    padding: 0.4rem 0.34rem;
    width: auto;
  }

  #neighborhoodSummaryTable {
    min-width: 45.4rem;
    table-layout: fixed;
  }

  #neighborhoodSummaryTable th {
    font-size: 0.62rem;
    line-height: 1.24;
  }

  #neighborhoodSummaryTable th:first-child,
  #neighborhoodSummaryTable td:first-child {
    position: sticky;
    left: 0;
    width: 7.2rem;
    min-width: 7.2rem;
    background: #f7fbff;
    white-space: nowrap;
    padding-right: 0.56rem;
    box-shadow: 2px 0 0 rgba(21, 34, 47, 0.14);
  }

  #neighborhoodSummaryTable th:nth-child(2),
  #neighborhoodSummaryTable td:nth-child(2) {
    padding-left: 0.5rem;
  }

  #neighborhoodSummaryTable th:not(:first-child),
  #neighborhoodSummaryTable td:not(:first-child) {
    width: 5.45rem;
    min-width: 5.45rem;
  }

  #neighborhoodSummaryTable .sort-button {
    line-height: inherit;
  }

  #neighborhoodSummaryTable th:first-child {
    z-index: 3;
  }

  #neighborhoodSummaryTable td:first-child {
    z-index: 2;
  }
}
