:root {
  --ink: #17211f;
  --muted: #61716e;
  --line: #d7dfdc;
  --surface: #ffffff;
  --wash: #f3f7f4;
  --deep: #112b2a;
  --accent: #116b62;
  --accent-2: #dfb139;
  --danger: #c94737;
  --nodata: #111817;
  --none: #a9b4b1;
  --low: #e4c75f;
  --moderate: #db8740;
  --high: #bf3d35;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

/* Author display rules (e.g. display: grid on the login form) must not beat the hidden attribute. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #eef4f0;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 82px;
  padding: 14px clamp(16px, 3vw, 36px);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.32rem, 2.2vw, 2.1rem);
  line-height: 1.05;
  margin: 0;
}

h2 {
  font-size: clamp(1.45rem, 2.4vw, 2.35rem);
  line-height: 1.1;
  margin-bottom: 8px;
}

h3 {
  font-size: 1rem;
}

.tabs {
  align-items: center;
  background: #e3ebe7;
  border: 1px solid #cbd7d2;
  border-radius: 8px;
  display: flex;
  padding: 4px;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #41504d;
  min-height: 36px;
  padding: 0 14px;
}

.tab.is-active {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(26, 46, 42, 0.13);
  color: var(--ink);
  font-weight: 750;
}

.master-link {
  background: transparent;
  border: 1px solid #cbd7d2;
  border-radius: 8px;
  color: #41504d;
  font-weight: 750;
  min-height: 36px;
  padding: 0 12px;
}

.master-link:hover {
  background: #f7faf8;
}

main {
  padding: clamp(16px, 3vw, 36px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.map-layout,
.form-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
}

.map-shell,
.form-shell,
.detail-panel,
.side-note,
.admin-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 50px rgba(30, 47, 43, 0.07);
}

.map-shell,
.form-shell,
.admin-shell {
  padding: clamp(16px, 2.2vw, 26px);
}

.map-head,
.admin-head,
.section-head {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.map-head p,
.side-note p,
.empty-state p {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
}

.primary-button,
.secondary-button,
.text-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 750;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  border: 1px solid #0b5b53;
  color: white;
  padding: 0 16px;
}

.primary-button:hover {
  background: #0b5b53;
}

.secondary-button {
  background: #f8faf8;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 14px;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--accent);
  min-height: 36px;
  padding: 0 6px;
}

.filters,
.admin-toolbar {
  align-items: end;
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin: 18px 0 14px;
  padding: 14px 0;
}

label,
fieldset {
  color: #3c4c49;
  font-size: 0.88rem;
  font-weight: 720;
}

select,
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  background: #fbfdfb;
  border: 1px solid #c9d4cf;
  border-radius: 8px;
  color: var(--ink);
  display: block;
  margin-top: 6px;
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  color: #3c4c49;
  font-size: 0.88rem;
  font-weight: 720;
  margin-bottom: 8px;
}

.filters fieldset {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters fieldset label,
.check-row {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.map-stage {
  background:
    linear-gradient(180deg, rgba(210, 229, 222, 0.55), rgba(244, 248, 246, 0.9)),
    radial-gradient(circle at 20% 22%, rgba(255, 255, 255, 0.9), transparent 35%);
  border: 1px solid #cfdbd6;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

#reportMap {
  display: block;
  height: min(68vh, 640px);
  min-height: 430px;
  width: 100%;
}

#reportMap.leaflet-container {
  background: #dfece8;
  color: var(--ink);
  font-family: inherit;
}

.leaflet-control-zoom a {
  color: var(--ink);
}

.leaflet-tooltip {
  border: 1px solid #cbd7d2;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(20, 40, 36, 0.14);
  color: var(--ink);
  font-weight: 750;
}

.zoom-note {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d9e2de;
  border-radius: 8px;
  color: #455653;
  font-size: 0.82rem;
  font-weight: 720;
  left: 58px;
  max-width: min(390px, calc(100% - 24px));
  padding: 8px 10px;
  position: absolute;
  top: 12px;
  z-index: 500;
}

.legend {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid #d9e2de;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 12px 14px;
}

.legend span {
  align-items: center;
  color: #3e4e4b;
  display: inline-flex;
  font-size: 0.84rem;
  font-weight: 720;
  gap: 7px;
}

.swatch {
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 4px;
  display: inline-block;
  height: 14px;
  width: 22px;
}

.nodata {
  background: var(--nodata);
}

.none {
  background: var(--none);
}

.low {
  background: var(--low);
}

.moderate {
  background: var(--moderate);
}

.high {
  background: var(--high);
}

.detail-panel,
.side-note {
  align-self: start;
  padding: 18px;
}

.metric-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.metric-row div {
  background: var(--wash);
  border: 1px solid #dce6e1;
  border-radius: 8px;
  padding: 12px;
}

.metric-row strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1;
}

.metric-row span,
.detail-meta,
.admin-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  border: 1px dashed #bfccc7;
  border-radius: 8px;
  padding: 18px;
}

.county-title {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.pressure-badge,
.status-badge {
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 850;
  padding: 5px 9px;
  text-transform: uppercase;
}

.status-badge {
  background: #65736f;
}

.status-badge.flagged {
  background: #995a14;
}

.status-badge.rejected {
  background: #8f342b;
}

.breakdown {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.breakdown-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 88px 1fr 28px;
}

.bar-track {
  background: #e7eeeb;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  border-radius: inherit;
  height: 100%;
}

.load-status {
  background: var(--wash);
  border: 1px solid #dce6e1;
  border-radius: 8px;
  color: #3c4c49;
  font-size: 0.86rem;
  font-weight: 700;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.load-status.is-error {
  background: #fbeceb;
  border-color: #efc4c0;
  color: #9a3128;
}

.turnstile-box {
  min-height: 65px;
}

.tool-message {
  color: var(--accent);
  font-weight: 750;
  margin: 12px 0 0;
  min-height: 1em;
}

.recent-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.report-snippet,
.admin-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.report-snippet p,
.admin-item p {
  color: #40504d;
  line-height: 1.42;
  margin-bottom: 8px;
}

.form-layout {
  align-items: start;
}

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

form {
  display: grid;
  gap: 18px;
}

.pressure-options {
  display: grid;
  gap: 10px;
}

.pressure-options label,
.upload-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 12px;
}

.pressure-options label {
  align-items: center;
}

.upload-box {
  background: var(--wash);
  cursor: pointer;
  flex-direction: column;
}

.upload-box input {
  max-width: 100%;
}

.upload-box small {
  color: var(--muted);
  font-weight: 550;
}

.robot-field {
  display: none;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

#formMessage {
  color: var(--accent);
  font-weight: 750;
  margin: 0;
}

.side-note {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.86)),
    linear-gradient(135deg, rgba(17, 107, 98, 0.16), rgba(223, 177, 57, 0.16));
}

.admin-shell {
  max-width: 1120px;
}

.master-unlock {
  align-items: end;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(200px, 300px) minmax(200px, 300px) auto;
  margin-top: 18px;
  padding-top: 18px;
}

.master-unlock p,
.master-unlock small,
.tool-panel p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.master-unlock p,
.master-unlock small {
  grid-column: 1 / -1;
}

#masterMessage {
  color: var(--danger);
  font-weight: 700;
  min-height: 1em;
}

.master-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  margin-top: 18px;
}

.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.admin-item {
  background: #fbfdfb;
}

.admin-edit {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 0.6fr) minmax(260px, 1fr);
  margin-top: 12px;
}

.admin-item-head,
.admin-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.admin-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.admin-actions button {
  border: 1px solid #cbd7d2;
  border-radius: 8px;
  min-height: 34px;
  padding: 0 10px;
}

.admin-actions .approve {
  background: #eaf5ef;
  color: #126244;
}

.admin-actions .flag {
  background: #fff6e2;
  color: #87570b;
}

.admin-actions .reject {
  background: #fbeceb;
  color: #9a3128;
}

@media (max-width: 920px) {
  .map-layout,
  .form-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .side-note {
    align-self: stretch;
  }
}

@media (max-width: 680px) {
  .topbar,
  .map-head,
  .admin-head,
  .section-head,
  .form-actions,
  .master-unlock {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .form-grid,
  .metric-row,
  .admin-edit,
  .master-grid,
  .master-unlock {
    grid-template-columns: 1fr;
  }

  #reportMap {
    min-height: 330px;
  }

  .zoom-note {
    bottom: 12px;
    left: 12px;
    top: auto;
  }
}
