:root {
  --background: #f5f7fa;
  --foreground: #13243a;
  --panel: #ffffff;
  --panel-soft: #eef3f7;
  --panel-raised: #fbfcfe;
  --border: rgba(33, 54, 82, 0.14);
  --border-strong: rgba(33, 54, 82, 0.24);
  --muted: #627085;
  --muted-strong: #41536b;
  --ink: #102a56;
  --primary: #1647a8;
  --primary-foreground: #ffffff;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(16, 42, 86, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(16, 42, 86, 0.035) 1px, transparent 1px),
    var(--background);
  background-size: 36px 36px;
  color: var(--foreground);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
path:focus-visible {
  outline: 3px solid rgba(45, 108, 223, 0.3);
  outline-offset: 2px;
}

.app-shell {
  width: min(1800px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow,
.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 34px;
  font-weight: 800;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted-strong);
  font-size: 13px;
}

.summary-strip strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) minmax(390px, 460px);
  gap: 18px;
  align-items: start;
}

.map-panel,
.control-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.55) inset,
    0 18px 42px rgba(25, 42, 70, 0.08);
}

.map-panel {
  min-width: 0;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
}

.map-toolbar h2,
.section-heading h2 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.legend-chip span {
  width: 18px;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-soft);
}

.map-stage {
  position: relative;
  padding: 0 18px 12px;
}

.nigeria-map {
  display: block;
  width: 100%;
  height: auto;
}

.map-field {
  fill: var(--panel-soft);
}

.lga-layer path {
  transition:
    fill 160ms cubic-bezier(0.23, 1, 0.32, 1),
    stroke 120ms ease-out,
    stroke-width 120ms ease-out;
}

.lga-layer path:hover {
  stroke: #111827;
  stroke-width: 1.4;
}

.state-border-layer path {
  fill: none;
  stroke: rgba(17, 36, 58, 0.56);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.label-layer rect {
  fill: rgba(255, 255, 255, 0.94);
  stroke: rgba(15, 23, 42, 0.08);
  stroke-width: 1;
}

.label-layer text {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
  user-select: none;
}

.map-tooltip {
  position: absolute;
  z-index: 3;
  display: grid;
  gap: 2px;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 32px rgba(16, 42, 86, 0.16);
  color: var(--foreground);
  pointer-events: none;
}

.map-tooltip strong,
.map-tooltip span {
  display: block;
}

.map-tooltip strong {
  font-size: 13px;
}

.map-tooltip span {
  color: var(--muted);
  font-size: 12px;
}

.map-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.control-panel {
  display: grid;
  gap: 0;
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.control-section {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.control-section:last-child {
  border-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.field-label {
  display: block;
  margin: 11px 0 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
}

.select-input,
.text-input,
.config-box {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fc;
  color: var(--foreground);
}

.select-input,
.text-input {
  min-height: 40px;
  padding: 9px 10px;
}

.color-editor {
  display: grid;
  grid-template-columns: 48px minmax(110px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

input[type="color"] {
  width: 46px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fc;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 800;
  transition:
    transform 100ms ease-out,
    background 160ms ease-out,
    border-color 160ms ease-out;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.state-row:active,
.lga-name-button:active {
  transform: scale(0.98);
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.secondary-button {
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--ink);
}

.ghost-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-strong);
}

.ghost-button.danger {
  color: var(--danger);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.state-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-height: 250px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 3px;
}

.state-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font-size: 12px;
  text-align: left;
}

.state-row:hover,
.state-row.is-selected,
.lga-row:hover,
.lga-row.is-selected {
  border-color: var(--border);
  background: #f4f7fb;
}

.state-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-row small {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.state-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 5px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.lga-list {
  display: grid;
  gap: 6px;
  max-height: 330px;
  margin-top: 10px;
  overflow: auto;
  padding-right: 3px;
}

.lga-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 10px;
}

.lga-name-button {
  display: grid;
  gap: 2px;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-weight: 800;
  text-align: left;
}

.lga-name-button small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.config-box {
  min-height: 170px;
  resize: vertical;
  padding: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .map-toolbar,
  .map-footer,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .summary-strip,
  .legend-row {
    justify-content: flex-start;
  }

  .map-stage {
    padding: 0 10px 10px;
  }

  .color-editor,
  .lga-row,
  .state-list {
    grid-template-columns: 1fr;
  }

  .color-editor input[type="color"],
  .lga-row input[type="color"] {
    width: 100%;
  }
}
