:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5c6975;
  --panel: #ffffff;
  --line: #d9e0e7;
  --wash: #f4f7f8;
  --green: #267a45;
  --green-dark: #145533;
  --blue: #245f93;
  --amber: #b6670e;
  --red: #a84032;
  --selected: rgba(36, 95, 147, 0.18);
  --shadow: 0 8px 24px rgba(25, 35, 45, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.45;
}

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

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 650;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 95, 147, 0.14);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 74px;
  padding: 0 22px;
  background: #143f37;
  color: #fff;
  border-bottom: 4px solid #d58d28;
}

.app-header h1,
.review-top h2,
.panel-section h2,
.manual-questions h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 1.45rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-panel .eyebrow {
  color: var(--muted);
}

.header-actions,
.export-actions,
.button-grid,
.input-row,
.mini-row,
.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-btn {
  background: #e19c2a;
  color: #17212b;
  border-color: #e19c2a;
  padding: 0 14px;
}

.primary-btn:hover {
  background: #f1b346;
}

.secondary-btn,
.ghost-btn,
.text-btn,
.danger-btn,
.icon-btn {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  padding: 0 12px;
}

.ghost-btn {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.42);
}

.secondary-btn:hover,
.text-btn:hover,
.icon-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.danger-btn {
  color: var(--red);
  border-color: rgba(168, 64, 50, 0.32);
}

.text-btn {
  min-height: 30px;
  color: var(--blue);
  font-size: 0.82rem;
}

.icon-btn {
  width: 82px;
  flex: 0 0 82px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(420px, 1fr) minmax(380px, 510px);
  height: calc(100vh - 74px);
  min-height: 650px;
}

.control-panel,
.review-panel {
  overflow: auto;
  background: var(--panel);
}

.control-panel {
  border-right: 1px solid var(--line);
}

.review-panel {
  border-left: 1px solid var(--line);
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-section h2 {
  font-size: 0.96rem;
}

.section-heading {
  justify-content: space-between;
}

.input-row {
  align-items: stretch;
}

.address-combobox {
  position: relative;
}

.mini-row {
  justify-content: space-between;
}

.mini-row select {
  max-width: 128px;
}

.helper,
.empty-state,
.source-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.candidate-list {
  display: grid;
  gap: 8px;
  min-height: 56px;
}

.candidate-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.candidate-row label {
  display: block;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.candidate-row small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.candidate-row input {
  width: 16px;
  height: 16px;
}

.candidate-actions {
  display: flex;
  justify-content: flex-end;
}

.suggestion-list {
  position: absolute;
  z-index: 15;
  top: calc(100% + 4px);
  left: 0;
  right: 90px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.suggestion-list[hidden] {
  display: none;
}

.suggestion-option {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 650;
}

.suggestion-option:last-child {
  border-bottom: 0;
}

.suggestion-option:hover,
.suggestion-option.active {
  background: #edf3f3;
  color: var(--green-dark);
}

.map-panel {
  position: relative;
  min-width: 0;
}

#mapView {
  width: 100%;
  height: 100%;
}

.map-status {
  position: absolute;
  left: 16px;
  bottom: 18px;
  max-width: min(480px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 43, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.86rem;
}

.review-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.review-top h2 {
  font-size: 1.2rem;
}

.export-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--green-dark);
  border-bottom-color: var(--green);
}

.tab-pane {
  display: none;
  padding: 18px;
}

.tab-pane.active {
  display: block;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.summary-band > div {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.summary-band > div:last-child {
  border-right: 0;
}

.metric,
.metric-label {
  display: block;
}

.metric {
  color: var(--green-dark);
  font-size: 1.4rem;
  font-weight: 800;
}

.metric-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.answer-list,
.manual-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.question-bucket {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.bucket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #edf3f3;
}

.bucket-header h3,
.official-group-title {
  margin: 0;
  color: var(--green-dark);
  font-size: 0.94rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.bucket-header span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bucket-body {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.answer-row h3 {
  margin: 0 0 5px;
  font-size: 0.94rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.answer-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.answer-pill {
  align-self: start;
  justify-self: end;
  width: 72px;
  padding: 5px 8px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.answer-yes {
  color: #0f5d38;
  background: #dcefe5;
}

.answer-no {
  color: #27516f;
  background: #ddeaf3;
}

.answer-manual,
.answer-tbd {
  color: #8a4f11;
  background: #f6e6ce;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full-span {
  grid-column: 1 / -1;
}

.manual-questions {
  margin-top: 22px;
}

.manual-questions h3 {
  font-size: 1rem;
}

.manual-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 142px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.manual-row p {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.manual-textarea {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.82rem;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #edf3f3;
  color: var(--ink);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  color: var(--muted);
}

.details-block {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.details-block summary {
  cursor: pointer;
  font-weight: 800;
}

.details-block textarea {
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17212b;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 330px minmax(380px, 1fr);
    grid-template-rows: minmax(520px, 58vh) auto;
    height: auto;
  }

  .review-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 780px) {
  .app-header {
    height: auto;
    min-height: 88px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .workspace {
    display: block;
    min-height: 0;
  }

  .control-panel,
  .review-panel {
    max-height: none;
    border: 0;
  }

  .map-panel {
    height: 520px;
  }

  .review-top,
  .form-grid,
  .manual-row,
  .answer-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .answer-pill {
    justify-self: start;
  }
}

@media print {
  .app-header,
  .control-panel,
  .map-panel,
  .tabs,
  .export-actions,
  .toast {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .workspace {
    display: block;
    height: auto;
    min-height: 0;
  }

  .review-panel {
    border: 0;
  }

  .tab-pane {
    display: block !important;
    padding: 12px 0;
  }

  .review-top {
    padding: 0 0 12px;
  }

  .answer-row,
  .summary-band,
  .table-wrap {
    break-inside: avoid;
  }
}
