:root {
  --blue: #061f86;
  --blue-dark: #041255;
  --ink: #102a43;
  --muted: #5b677a;
  --line: #d9e2ec;
  --soft-line: #edf2f7;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --green: #207a55;
  --green-soft: #e7f6ee;
  --gold: #9a6a00;
  --gold-soft: #fff4d7;
  --coral: #c2412d;
  --coral-soft: #ffe9e3;
  --purple: #6b3fb3;
  --purple-soft: #f0e9ff;
  --gray-soft: #eef1f5;
  --shadow: 0 18px 46px rgba(15, 36, 66, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(6, 31, 134, 0.22);
  outline-offset: 2px;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(210px, 0.72fr) minmax(260px, 1.2fr) minmax(320px, 0.86fr);
  align-items: center;
  gap: 22px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--blue);
  font-weight: 800;
}

.brand-lockup span {
  border: 1px solid rgba(6, 31, 134, 0.14);
  background: #f7f9ff;
  border-radius: 6px;
  padding: 6px 9px;
  line-height: 1;
}

.brand-lockup strong {
  color: var(--blue-dark);
  font-size: 1.02rem;
  line-height: 1;
}

.campaign-heading {
  min-width: 0;
}

.campaign-heading p,
.section-heading p,
.address-heading p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

.campaign-heading h1 {
  margin: 0;
  color: var(--blue-dark);
  font-size: 1.34rem;
  line-height: 1.12;
}

.topbar-stats {
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
  width: min(100%, 390px);
}

.topbar-stats div,
.metric-grid div,
.signal-grid div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfdff;
}

.topbar-stats strong,
.metric-grid strong,
.signal-grid strong {
  display: block;
  color: var(--blue-dark);
  font-size: 1.05rem;
  line-height: 1.1;
  white-space: nowrap;
}

.topbar-stats span,
.metric-grid span,
.signal-grid span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 326px minmax(420px, 1fr) 374px;
  gap: 14px;
  padding: 14px;
}

.left-panel,
.right-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.left-panel {
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding-right: 2px;
}

.right-panel {
  max-height: calc(100vh - 104px);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.right-panel > * {
  flex: 0 0 auto;
}

.sheet-handle {
  display: none;
}

.panel-section,
.address-card,
.address-results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(15, 36, 66, 0.06);
}

.panel-section,
.address-results {
  padding: 14px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  color: var(--blue-dark);
  font-size: 1rem;
  line-height: 1.18;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.role-switch button,
.button-row button,
.action-strip button,
.location-button,
.theme-button,
.full-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 0.88rem;
  font-weight: 800;
}

.role-switch button.active,
.button-row button.primary,
.followup-form button.primary {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.role-switch svg,
.button-row svg,
.action-strip svg,
.search-box svg,
.theme-button svg,
.full-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.candidate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.candidate-card strong,
.candidate-card span {
  display: block;
}

.candidate-card strong {
  color: var(--blue-dark);
}

.candidate-card span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 700;
}

.candidate-card a {
  flex: 0 0 auto;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--blue);
  background: #eef3ff;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.issue-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.issue-chips span {
  border-radius: 6px;
  padding: 6px 8px;
  color: #234;
  background: var(--gray-soft);
  font-size: 0.76rem;
  font-weight: 850;
}

.issue-chips span:nth-child(1) {
  background: #e8f0ff;
}

.issue-chips span:nth-child(2) {
  background: var(--green-soft);
}

.issue-chips span:nth-child(3) {
  background: var(--gold-soft);
}

.compact-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.compact-field span,
.followup-form label span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.compact-field select,
.compact-field input,
.followup-form input,
.followup-form textarea,
.search-box input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.compact-field select,
.compact-field input,
.followup-form input {
  min-height: 38px;
  padding: 8px 10px;
}

.followup-form textarea {
  resize: vertical;
  padding: 10px;
}

.progress-stack {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.progress-stack div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.progress-stack strong {
  color: var(--blue-dark);
}

meter {
  width: 100%;
  height: 10px;
}

.draw-controls {
  display: grid;
  gap: 8px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.turf-list,
.door-plan ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.turf-list {
  display: grid;
  gap: 8px;
}

.turf-list li {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfdff;
}

.turf-list strong {
  color: var(--blue-dark);
  font-size: 0.88rem;
}

.turf-list span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.metric-grid,
.signal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.full-button {
  width: 100%;
  margin-top: 12px;
}

.map-stage {
  min-width: 0;
  min-height: calc(100vh - 104px);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf5;
  box-shadow: var(--shadow);
}

.ward-map {
  position: absolute;
  inset: 0;
}

.map-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  pointer-events: none;
}

.search-box,
.map-actions,
.location-button,
.theme-button {
  pointer-events: auto;
}

.search-box {
  width: min(520px, 100%);
  flex: 1 1 420px;
  max-width: 520px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(15, 36, 66, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(15, 36, 66, 0.12);
}

.search-box input {
  border: 0;
  outline: 0;
  min-height: 38px;
  padding: 0;
  background: transparent;
}

.map-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.location-button,
.theme-button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(15, 36, 66, 0.12);
}

.location-button.is-locating,
.theme-button[aria-pressed="true"] {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.location-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.location-button svg,
.theme-button svg {
  width: 16px;
  height: 16px;
}

.location-button span,
.theme-button span {
  white-space: nowrap;
}

.map-footer {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.map-footer span {
  max-width: 50%;
  border: 1px solid rgba(15, 36, 66, 0.12);
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(15, 36, 66, 0.1);
  font-size: 0.75rem;
  font-weight: 800;
}

.map-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--muted);
  background: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
  z-index: 2;
}

.maplibregl-ctrl-attrib {
  display: none;
}

.maplibregl-ctrl-top-right {
  top: 72px;
  right: 14px;
}

.maplibregl-ctrl-group {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(15, 36, 66, 0.14);
}

.address-card {
  min-height: 330px;
}

.address-empty {
  min-height: 330px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
}

.address-empty svg {
  width: 42px;
  height: 42px;
  color: var(--blue);
}

.address-empty h2,
.address-empty p {
  margin: 0;
}

.address-empty h2 {
  color: var(--blue-dark);
}

.address-empty p {
  color: var(--muted);
  font-weight: 700;
}

.address-detail {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.address-heading {
  position: relative;
  padding-right: 42px;
}

.address-heading h2 {
  margin: 0;
  color: var(--blue-dark);
  font-size: 1.24rem;
  line-height: 1.14;
}

.address-heading button {
  position: absolute;
  top: 0;
  right: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.address-heading svg {
  width: 17px;
  height: 17px;
}

.insight-band {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--soft-line);
  background: #f7f9ff;
}

.insight-band strong,
.insight-band span {
  display: block;
}

.insight-band strong {
  color: var(--blue-dark);
  font-size: 0.96rem;
}

.insight-band span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 750;
  line-height: 1.35;
}

.signal-grid {
  margin-top: 0;
}

.door-plan {
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
}

.door-plan p {
  margin: 0;
  color: var(--ink);
  font-size: 0.91rem;
  font-weight: 650;
  line-height: 1.45;
}

.door-plan li {
  position: relative;
  margin-top: 8px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.35;
}

.door-plan li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
}

.action-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 0;
}

.action-strip button {
  justify-content: flex-start;
  min-height: 42px;
  padding: 0 10px;
}

.action-strip button[data-action="supporter"] {
  background: var(--green-soft);
  border-color: #bbdfcd;
  color: var(--green);
}

.action-strip button[data-action="sign"] {
  background: var(--gold-soft);
  border-color: #f2d58d;
  color: var(--gold);
}

.action-strip button[data-action="followup"] {
  background: var(--coral-soft);
  border-color: #ffc4b5;
  color: var(--coral);
}

.action-strip button[data-action="postcard"] {
  background: var(--purple-soft);
  border-color: #d6c2ff;
  color: var(--purple);
}

.followup-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: var(--coral-soft);
}

.followup-form label {
  display: grid;
  gap: 6px;
}

.followup-form button {
  min-height: 40px;
  border-radius: 7px;
  font-weight: 850;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.history-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfdff;
}

.history-item strong {
  color: var(--blue-dark);
  font-size: 0.84rem;
}

.history-item span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.address-results [data-address-list] {
  display: grid;
  gap: 8px;
}

.result-button {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.result-button.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(6, 31, 134, 0.1);
}

.result-button strong {
  color: var(--blue-dark);
  font-size: 0.88rem;
}

.result-button span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.hidden,
[hidden] {
  display: none !important;
}

body[data-theme="dark"] {
  --ink: #f8fafc;
  --muted: #aeb7c7;
  --line: rgba(255, 255, 255, 0.12);
  --soft-line: rgba(255, 255, 255, 0.09);
  --bg: #101217;
  --panel: #151922;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  color: #f8fafc;
  background: #101217;
}

body[data-theme="dark"] .topbar {
  border-bottom-color: rgba(255, 255, 255, 0.1);
  background: rgba(17, 19, 24, 0.96);
}

body[data-theme="dark"] .brand-lockup,
body[data-theme="dark"] .brand-lockup strong,
body[data-theme="dark"] .campaign-heading h1,
body[data-theme="dark"] .section-heading h2,
body[data-theme="dark"] .section-heading h3,
body[data-theme="dark"] .topbar-stats strong,
body[data-theme="dark"] .metric-grid strong,
body[data-theme="dark"] .signal-grid strong,
body[data-theme="dark"] .candidate-card strong,
body[data-theme="dark"] .turf-list strong,
body[data-theme="dark"] .address-empty h2,
body[data-theme="dark"] .address-heading h2,
body[data-theme="dark"] .insight-band strong,
body[data-theme="dark"] .history-item strong,
body[data-theme="dark"] .result-button strong,
body[data-theme="dark"] .progress-stack strong {
  color: #f8fafc;
}

body[data-theme="dark"] .brand-lockup span,
body[data-theme="dark"] .topbar-stats div,
body[data-theme="dark"] .metric-grid div,
body[data-theme="dark"] .signal-grid div,
body[data-theme="dark"] .panel-section,
body[data-theme="dark"] .address-card,
body[data-theme="dark"] .address-results,
body[data-theme="dark"] .candidate-card,
body[data-theme="dark"] .turf-list li,
body[data-theme="dark"] .door-plan,
body[data-theme="dark"] .history-item,
body[data-theme="dark"] .result-button {
  border-color: rgba(255, 255, 255, 0.1);
  background: #171a21;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] .candidate-card {
  background: linear-gradient(180deg, #1c2028, #171a21);
}

body[data-theme="dark"] .map-stage,
body[data-theme="dark"] .ward-map {
  border-color: rgba(255, 255, 255, 0.1);
  background: #0e0e0e;
}

body[data-theme="dark"] .search-box,
body[data-theme="dark"] .location-button,
body[data-theme="dark"] .theme-button,
body[data-theme="dark"] .role-switch button,
body[data-theme="dark"] .button-row button,
body[data-theme="dark"] .full-button,
body[data-theme="dark"] .action-strip button[data-action="not_home"],
body[data-theme="dark"] .map-footer span,
body[data-theme="dark"] .map-status,
body[data-theme="dark"] .maplibregl-ctrl-group,
body[data-theme="dark"] .address-heading button,
body[data-theme="dark"] .compact-field select,
body[data-theme="dark"] .compact-field input,
body[data-theme="dark"] .followup-form input,
body[data-theme="dark"] .followup-form textarea {
  border-color: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  background: rgba(18, 21, 28, 0.94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
}

body[data-theme="dark"] .location-button.is-locating,
body[data-theme="dark"] .theme-button[aria-pressed="true"],
body[data-theme="dark"] .role-switch button.active,
body[data-theme="dark"] .button-row button.primary,
body[data-theme="dark"] .followup-form button.primary {
  color: #ffffff;
  border-color: #365ce8;
  background: #365ce8;
}

body[data-theme="dark"] .search-box input,
body[data-theme="dark"] .compact-field select,
body[data-theme="dark"] .compact-field input,
body[data-theme="dark"] .followup-form input,
body[data-theme="dark"] .followup-form textarea {
  color: #f8fafc;
}

body[data-theme="dark"] .search-box input::placeholder,
body[data-theme="dark"] .search-box svg,
body[data-theme="dark"] .map-footer span,
body[data-theme="dark"] .map-status,
body[data-theme="dark"] .role-switch button,
body[data-theme="dark"] .button-row button,
body[data-theme="dark"] .full-button,
body[data-theme="dark"] .address-heading button,
body[data-theme="dark"] .topbar-stats span,
body[data-theme="dark"] .metric-grid span,
body[data-theme="dark"] .signal-grid span,
body[data-theme="dark"] .candidate-card span,
body[data-theme="dark"] .turf-list span,
body[data-theme="dark"] .address-empty p,
body[data-theme="dark"] .insight-band span,
body[data-theme="dark"] .door-plan p,
body[data-theme="dark"] .door-plan li,
body[data-theme="dark"] .history-item span,
body[data-theme="dark"] .result-button span,
body[data-theme="dark"] .progress-stack div,
body[data-theme="dark"] .campaign-heading p,
body[data-theme="dark"] .section-heading p,
body[data-theme="dark"] .address-heading p,
body[data-theme="dark"] .compact-field span {
  color: #aeb7c7;
}

body[data-theme="dark"] .action-strip button[data-action="not_home"] {
  color: #f8fafc;
}

body[data-theme="dark"] button:disabled {
  opacity: 0.56;
}

body[data-theme="dark"] .issue-chips span,
body[data-theme="dark"] .candidate-card a {
  color: #dbe5ff;
  background: #202638;
}

body[data-theme="dark"] .insight-band,
body[data-theme="dark"] .address-heading {
  border-color: rgba(255, 255, 255, 0.1);
  background: #1a1d24;
}

body[data-theme="dark"] .followup-form {
  background: #2b1917;
}

body[data-theme="dark"] .followup-form label span {
  color: #f2c4b9;
}

body[data-theme="dark"] .result-button.active {
  border-color: #8fa2ff;
  box-shadow: 0 0 0 3px rgba(143, 162, 255, 0.16);
}

body[data-theme="dark"] .maplibregl-ctrl-group button {
  background-color: transparent;
}

body[data-theme="dark"] .maplibregl-ctrl-group button + button {
  border-top-color: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .maplibregl-ctrl-icon {
  filter: invert(1);
}

@media (max-width: 1220px) {
  .topbar {
    grid-template-columns: 180px 1fr;
  }

  .topbar-stats {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
  }

  .workspace {
    grid-template-columns: 300px minmax(380px, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 880px) {
  html,
  body {
    background: var(--bg);
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100svh;
  }

  .topbar {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 0;
    padding: 12px;
    border: 0;
    background: linear-gradient(180deg, rgba(12, 14, 19, 0.68), rgba(12, 14, 19, 0));
    pointer-events: none;
  }

  .brand-lockup {
    width: max-content;
    min-height: 36px;
    pointer-events: auto;
    border: 1px solid rgba(15, 36, 66, 0.12);
    border-radius: 999px;
    padding: 6px 9px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  }

  .brand-lockup span,
  .brand-lockup strong,
  .campaign-heading,
  .topbar-stats {
    display: none;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    padding: 0;
  }

  .map-stage {
    height: 100svh;
    min-height: 100svh;
    border: 0;
    border-radius: 0;
    background: #e8edf5;
    box-shadow: none;
    order: 0;
  }

  .ward-map {
    background: #e8edf5;
  }

  .left-panel {
    display: none;
  }

  .right-panel {
    order: 1;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: var(--sheet-height, min(48svh, 420px));
    max-height: calc(100svh - 12px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
    padding: 0 12px 12px;
    color: var(--ink);
    background: #ffffff;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.42);
    overscroll-behavior: contain;
    scrollbar-width: none;
    transition: height 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms ease, background-color 180ms ease;
    will-change: height;
  }

  .right-panel::-webkit-scrollbar {
    display: none;
  }

  .right-panel.is-dragging {
    transition: none;
    user-select: none;
  }

  .sheet-handle {
    width: 100%;
    min-height: 42px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    align-self: center;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: ns-resize;
    touch-action: none;
  }

  .sheet-handle span {
    width: 48px;
    height: 4px;
    border-radius: 999px;
    background: rgba(15, 36, 66, 0.2);
  }

  .right-panel .address-card,
  .right-panel .address-results {
    border-color: rgba(15, 36, 66, 0.1);
    background: transparent;
    box-shadow: none;
  }

  .address-card {
    min-height: 0;
  }

  .right-panel .address-results {
    padding: 12px 0 0;
    border-width: 1px 0 0;
    border-radius: 0;
  }

  .right-panel .section-heading p,
  .right-panel .address-heading p,
  .right-panel .signal-grid span,
  .right-panel .history-item span,
  .right-panel .result-button span {
    color: var(--muted);
  }

  .right-panel .section-heading h2,
  .right-panel .section-heading h3,
  .right-panel .address-heading h2,
  .right-panel .history-item strong,
  .right-panel .result-button strong,
  .right-panel .signal-grid strong {
    color: var(--blue-dark);
  }

  .address-empty {
    min-height: 118px;
    padding: 8px 10px 14px;
    color: var(--ink);
  }

  .address-empty h2 {
    color: var(--blue-dark);
  }

  .address-empty p {
    color: var(--muted);
  }

  body[data-has-selected="false"] .right-panel {
    gap: 8px;
  }

  body[data-has-selected="false"] .right-panel .address-card {
    border-color: transparent;
  }

  body[data-has-selected="false"] .address-empty {
    min-height: 70px;
    display: block;
    padding: 0 4px 8px;
    text-align: left;
  }

  body[data-has-selected="false"] .address-empty svg {
    display: none;
  }

  body[data-has-selected="false"] .address-empty h2 {
    font-size: 1.06rem;
    line-height: 1.15;
  }

  body[data-has-selected="false"] .address-empty p {
    max-width: 30ch;
    margin-top: 4px;
    font-size: 0.82rem;
    line-height: 1.3;
  }

  .address-detail {
    padding: 0;
    gap: 10px;
  }

  .address-heading {
    padding: 14px 56px 14px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
  }

  .address-heading button {
    top: 12px;
    right: 12px;
    border-color: var(--line);
    color: var(--muted);
    background: #ffffff;
  }

  .insight-band,
  .door-plan,
  .history-item,
  .result-button,
  .signal-grid div {
    border-color: var(--soft-line);
    background: #fbfdff;
  }

  .insight-band strong {
    color: var(--blue-dark);
  }

  .insight-band span,
  .door-plan p,
  .door-plan li {
    color: var(--muted);
  }

  .followup-form {
    background: var(--coral-soft);
  }

  .followup-form label span {
    color: var(--coral);
  }

  .map-toolbar {
    top: 14px;
    left: 12px;
    right: 12px;
    flex-direction: row;
    align-items: center;
    gap: 7px;
  }

  .search-box {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 42px;
    border-color: rgba(15, 36, 66, 0.12);
    border-radius: 999px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 14px 34px rgba(15, 36, 66, 0.14);
  }

  .search-box input {
    color: var(--ink);
  }

  .search-box input::placeholder {
    color: var(--muted);
  }

  .search-box svg {
    color: var(--muted);
  }

  .map-actions {
    flex: 0 0 auto;
    justify-content: flex-start;
    width: auto;
    gap: 7px;
  }

  .location-button,
  .theme-button {
    min-width: 42px;
    min-height: 42px;
    padding: 0 11px;
    border-color: rgba(15, 36, 66, 0.12);
    border-radius: 999px;
    color: var(--blue);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 14px 34px rgba(15, 36, 66, 0.14);
  }

  .map-footer {
    display: none;
  }

  .maplibregl-ctrl-top-right {
    top: 76px;
    right: 12px;
  }

  body[data-has-selected="true"][data-sheet-state="mid"] .right-panel .address-results,
  body[data-has-selected="true"][data-sheet-state="mid"] .right-panel .signal-grid,
  body[data-has-selected="true"][data-sheet-state="mid"] .right-panel .door-plan,
  body[data-has-selected="true"][data-sheet-state="mid"] .right-panel .history-list,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .address-results,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .signal-grid,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .door-plan,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .history-list,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .insight-band,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .action-strip,
  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel .followup-form {
    display: none;
  }

  body[data-has-selected="true"][data-sheet-state="peek"] .right-panel {
    gap: 0;
  }

  body[data-has-selected="true"][data-sheet-state="peek"] .address-heading {
    min-height: 80px;
  }

  .map-stage {
    order: 0;
  }

  .maplibregl-ctrl-group {
    background: rgba(255, 255, 255, 0.94);
  }

  .maplibregl-ctrl-group button {
    background-color: transparent;
  }

  .maplibregl-ctrl-group button + button {
    border-top-color: rgba(15, 36, 66, 0.12);
  }

  .maplibregl-ctrl-icon {
    filter: none;
  }

  body[data-theme="dark"] {
    background: #101217;
  }

  body[data-theme="dark"] .map-stage,
  body[data-theme="dark"] .ward-map {
    background: #0e0e0e;
  }

  body[data-theme="dark"] .right-panel {
    color: #f8fafc;
    background: #111318;
    box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.42);
  }

  body[data-theme="dark"] .sheet-handle span {
    background: rgba(255, 255, 255, 0.25);
  }

  body[data-theme="dark"] .right-panel .address-card,
  body[data-theme="dark"] .right-panel .address-results {
    border-color: rgba(255, 255, 255, 0.1);
  }

  body[data-theme="dark"][data-has-selected="false"] .right-panel .address-card {
    border-color: transparent;
  }

  body[data-theme="dark"] .right-panel .section-heading p,
  body[data-theme="dark"] .right-panel .address-heading p,
  body[data-theme="dark"] .right-panel .signal-grid span,
  body[data-theme="dark"] .right-panel .history-item span,
  body[data-theme="dark"] .right-panel .result-button span,
  body[data-theme="dark"] .address-empty p {
    color: #aeb7c7;
  }

  body[data-theme="dark"] .right-panel .section-heading h2,
  body[data-theme="dark"] .right-panel .section-heading h3,
  body[data-theme="dark"] .right-panel .address-heading h2,
  body[data-theme="dark"] .history-item strong,
  body[data-theme="dark"] .result-button strong,
  body[data-theme="dark"] .signal-grid strong,
  body[data-theme="dark"] .address-empty h2 {
    color: #f8fafc;
  }

  body[data-theme="dark"] .address-empty {
    color: #f8fafc;
  }

  body[data-theme="dark"] .address-heading {
    border-color: rgba(255, 255, 255, 0.1);
    background: #1a1d24;
  }

  body[data-theme="dark"] .address-heading button {
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    background: #252832;
  }

  body[data-theme="dark"] .insight-band,
  body[data-theme="dark"] .door-plan,
  body[data-theme="dark"] .history-item,
  body[data-theme="dark"] .result-button,
  body[data-theme="dark"] .signal-grid div {
    border-color: rgba(255, 255, 255, 0.1);
    background: #171a21;
  }

  body[data-theme="dark"] .insight-band strong {
    color: #f8fafc;
  }

  body[data-theme="dark"] .insight-band span,
  body[data-theme="dark"] .door-plan p,
  body[data-theme="dark"] .door-plan li {
    color: #c5ccda;
  }

  body[data-theme="dark"] .followup-form {
    background: #2b1917;
  }

  body[data-theme="dark"] .followup-form label span {
    color: #f2c4b9;
  }

  body[data-theme="dark"] .search-box,
  body[data-theme="dark"] .location-button,
  body[data-theme="dark"] .theme-button {
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    background: rgba(15, 18, 24, 0.9);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
  }

  body[data-theme="dark"] .search-box input {
    color: #f8fafc;
  }

  body[data-theme="dark"] .search-box input::placeholder,
  body[data-theme="dark"] .search-box svg {
    color: #d5dbe7;
  }

  body[data-theme="dark"] .maplibregl-ctrl-group {
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(15, 18, 24, 0.9);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  }

  body[data-theme="dark"] .maplibregl-ctrl-group button + button {
    border-top-color: rgba(255, 255, 255, 0.12);
  }

  body[data-theme="dark"] .maplibregl-ctrl-icon {
    filter: invert(1);
  }

  .action-strip button {
    min-height: 46px;
  }

  .panel-section {
    box-shadow: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
  }

  .metric-grid,
  .signal-grid {
    grid-template-columns: 1fr;
  }

  .topbar-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .topbar-stats div {
    padding: 8px 7px;
  }

  .topbar-stats strong {
    font-size: 0.95rem;
  }

  .topbar-stats span {
    font-size: 0.67rem;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .action-strip {
    grid-template-columns: 1fr 1fr;
  }

  .action-strip button[data-action="not_home"] {
    grid-column: 1 / -1;
  }

  .address-empty {
    min-height: 104px;
    padding: 6px 10px 12px;
  }

  .address-empty svg {
    width: 34px;
    height: 34px;
  }

  .map-stage {
    height: 100svh;
    min-height: 100svh;
  }

  .location-button span,
  .theme-button span {
    display: none;
  }
}
