:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #17212b;
  --muted: #667687;
  --line: #dce4eb;
  --accent: #165d73;
  --accent-strong: #0d4050;
  --accent-soft: #dcecf1;
  --success: #24734a;
  --warning: #9a6b0f;
  --danger: #9a3b32;
  --shadow: 0 12px 35px rgba(27, 45, 62, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, select { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 22px;
  background: #102d38;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px;
  color: #102d38; background: #dcecf1;
}
.brand-title { font-weight: 800; font-size: 20px; letter-spacing: .08em; }
.brand-subtitle { color: #c5d7de; font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 640px; }
.phase-badge { font-size: 12px; font-weight: 700; letter-spacing: .04em; padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.10); color: #e6f0f3; white-space: nowrap; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 16px;
  padding: 16px;
}
.map-card, .side-panel { min-height: 0; }
.map-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(540px, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.map-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 23px; margin-bottom: 0; }
h2 { font-size: 25px; margin-bottom: 8px; }
h3 { font-size: 18px; margin-bottom: 0; }
.toolbar-actions { display: flex; align-items: end; gap: 9px; }
.select-wrap { display: grid; gap: 4px; font-size: 11px; color: var(--muted); }
select, button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}
select { min-width: 205px; }
button { cursor: pointer; font-weight: 700; }
button:hover { border-color: #b8c7d1; background: var(--surface-2); }

#map { width: 100%; height: 100%; min-height: 540px; background: #dfe7eb; }
.leaflet-container { font: inherit; }
.parish-tooltip {
  background: rgba(16,45,56,.92) !important;
  color: #fff !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 6px !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  padding: 3px 6px !important;
}
.parish-tooltip:before { display: none !important; }
.map-status {
  position: absolute;
  z-index: 800;
  left: 18px; bottom: 18px;
  display: flex; align-items: center; gap: 8px;
  max-width: min(520px, calc(100% - 36px));
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(18,44,57,.14);
  font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex: 0 0 auto; }
.status-dot.ok { background: var(--success); }
.status-dot.error { background: var(--danger); }
.status-dot.loading { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}
.panel-section {
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(27,45,62,.06);
}
.hero-panel { background: linear-gradient(180deg, #ffffff, #f8fbfc); }
.hero-panel > .eyebrow { margin-bottom: 6px; }
.hero-panel > p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.stat-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; }
.stat-card span { display: block; color: var(--muted); font-size: 10px; line-height: 1.2; }
.stat-card strong { display: block; margin-top: 4px; font-size: 21px; color: var(--accent-strong); }
.details { margin: 0; display: grid; }
.details > div { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-top: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: 11px; }
.details dd { margin: 0; text-align: right; font-size: 12px; font-weight: 700; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.integrity-pill { font-size: 10px; font-weight: 800; border-radius: 999px; padding: 5px 8px; background: #f6ecd5; color: var(--warning); }
.integrity-pill.ok { background: #ddf1e6; color: var(--success); }
.integrity-pill.error { background: #f5e0de; color: var(--danger); }
.checklist { display: grid; gap: 5px; max-height: 292px; overflow: auto; padding-right: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 5px 7px; border-radius: 8px; font-size: 11px; cursor: default; }
.check-row[data-loaded="true"] { background: #f5faf7; }
.check-icon { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: #eef1f3; color: #8996a1; font-size: 10px; font-weight: 900; }
.check-row[data-loaded="true"] .check-icon { background: #d9eddf; color: var(--success); }
.check-code { margin-left: auto; color: #93a0aa; font-variant-numeric: tabular-nums; }
.source-panel p { font-size: 12px; line-height: 1.45; margin-bottom: 8px; }
.muted { color: var(--muted); }
.source-warning { margin-top: 10px; border-left: 3px solid #c79527; background: #fff8e7; color: #73520d; padding: 9px 10px; font-size: 11px; line-height: 1.4; border-radius: 0 8px 8px 0; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side-panel { overflow: visible; }
  .map-card { grid-template-rows: auto 62vh; }
  .brand-subtitle { max-width: 55vw; }
}
@media (max-width: 650px) {
  .topbar { padding: 12px 14px; }
  .brand-subtitle { display: none; }
  .phase-badge { font-size: 10px; }
  .workspace { padding: 10px; gap: 10px; }
  .map-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { align-items: stretch; }
  .select-wrap { flex: 1; }
  select { width: 100%; min-width: 0; }
  #map { min-height: 500px; }
}
