:root {
  --ink: #1c2b2e;
  --ink-soft: #4c5f61;
  --paper: #f6f8f7;
  --panel: #ffffff;
  --line: #dde5e3;
  --teal: #14606b;
  --teal-deep: #0c3d45;
  --aqua: #2f9e8f;
  --groundwater: #E8BEFF;
  --surfacewater: #E6E600;
  --rust: #b5493a;
  --brand-green: #007834;
  --brand-green-dark: #003300;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --workspace-height: 500px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.4;
}

/* ---- Top bar ------------------------------------------------------- */

.topbar {
  background: var(--brand-green);
  border-bottom: 1px solid var(--brand-green-dark);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.topbar-link:hover,
.topbar-link:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: #ffffff;
}

.topbar-email {
  width: 30px;
  padding: 0;
  font-size: 19px;
}

.topbar h1 {
  margin: 0;
  color: #ffffff;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar-logo {
  height: 30px;
  width: auto;
}

/* ---- Shell ----------------------------------------------------------- */

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

.search-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  padding-bottom: 0px;
}

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 280px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"] {
  font-family: var(--mono);
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

input[type="text"]:focus {
  outline: 2px solid var(--aqua);
  outline-offset: 1px;
  background: #fff;
}

.btn {
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand-green);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-green); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--teal);
}
.btn-ghost:hover { border-color: var(--brand-green); background: #eef5f4; }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.field-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}




.status-line {
  min-height: 18px;
  margin: 6px 2px 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.status-line.is-error { color: var(--rust); font-weight: 600; }

.disambig-panel { margin-top: 8px; }

.disambig-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.disambig-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.disambig-chip {
  font-family: var(--mono);
  font-size: 13px;
  background: #eef5f4;
  border: 1px solid var(--line);
  color: var(--teal-deep);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.disambig-chip:hover { border-color: var(--teal); background: #e2f0ee; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-green);
  margin: 0;
}

.count-badge {
  background: var(--brand-green);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}

/* ---- SPA summary strip ------------------------------------------------ */

.spa-summary {
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 20px;
}

.spa-summary .section-title { margin-bottom: 8px; }

.spa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.spa-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: 13px;
}

.spa-chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.spa-chip.gw .dot { background: var(--groundwater); }
.spa-chip.sw .dot { background: var(--surfacewater); }

.spa-chip .name { font-weight: 600; color: var(--ink); }
.spa-chip .meta { color: var(--ink-soft); }

/* ---- Workspace: map + results side by side ---------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.15fr);
  gap: 16px;
  align-items: stretch;
}

.map-panel,
.results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  height: var(--workspace-height);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  flex: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.legend-item .dot.gw { background: var(--groundwater); }
.legend-item .dot.sw { background: var(--surfacewater); }

#map {
  flex: 1;
  min-height: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #e9eeed; /* visible while tiles load */
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  flex: none;
}

.export-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-right: 2px;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: #eef5f4;
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--teal-deep);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody td:first-child, tbody td:nth-child(2) {
  font-family: var(--mono);
}

tbody tr:hover { background: #f8fbfa; }
tbody tr:last-child td { border-bottom: none; }

.results-empty {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-soft);
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 14px;
}

#mapFullscreenBtn {
  margin-left: auto; /* pushes it to the right edge of the legend row */
}

.btn-fullscreen {
  width: 30px;
  height: 30px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--teal-deep);
  cursor: pointer;
}
.btn-fullscreen:hover { border-color: var(--teal); background: #eef5f4; }
.btn-fullscreen:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }

.map-panel.is-fullscreen,
.results-panel.is-fullscreen {
  position: fixed;
  inset: 16px;
  height: auto;
  width: auto;
  z-index: 1000;
  box-shadow: 0 12px 40px rgba(12, 61, 69, 0.35);
}

body.has-fullscreen-panel {
  overflow: hidden;
}

body.has-fullscreen-panel::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(12, 30, 33, 0.45);
  z-index: 999;
}

.results-empty[hidden],
.table-wrap[hidden] {
  display: none;
}

.footer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---- Responsive: stack on narrow viewports ---------------------------- */

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .map-panel,
  .results-panel {
    height: 420px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

