:root {
  color-scheme: light;
  --bg: #f5f2f3;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #666666;
  --line: #e4dadd;
  --brand: #6f1028;
  --brand-strong: #410916;
  --brand-soft: #f6e9ed;
  --brand-mid: #9b1c3c;
  --accent: #111111;
  --accent-soft: #f4e7eb;
  --danger: #9b132f;
  --ok: #195c35;
  --shadow: 0 18px 44px rgba(17, 17, 17, 0.12);
  --shadow-soft: 0 8px 22px rgba(17, 17, 17, 0.08);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(111, 16, 40, 0.16), rgba(245, 242, 243, 0) 320px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 34px 34px, 34px 34px, auto;
  color: var(--ink);
  display: grid;
  grid-template-rows: auto 1fr auto;
  font-family: Arial, Helvetica, sans-serif;
}

.auth-page {
  grid-template-rows: 1fr auto;
}

.auth-main {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 44px 16px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid rgba(111, 16, 40, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff, #fbf8f9);
  box-shadow: var(--shadow);
  border-top: 6px solid var(--brand);
}

.auth-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  display: block;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid rgba(111, 16, 40, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.auth-card h1 {
  margin-bottom: 20px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 48px);
  background:
    linear-gradient(135deg, #111111 0%, #2a0a13 44%, #6f1028 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 32px rgba(17, 17, 17, 0.18);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 74px;
  height: 74px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.72);
  padding: 5px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.topbar h1 {
  color: #ffffff;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 24px;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

nav a,
.button,
button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

nav a {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  backdrop-filter: blur(8px);
}

nav a.active,
nav a:hover,
button:hover,
.button:hover,
.secondary-button:hover {
  background: var(--brand-strong);
  color: #ffffff;
}

nav a.active {
  border-color: #ffffff;
  background: #ffffff;
  color: var(--brand);
}

.button.secondary,
.secondary-button {
  background: #ffffff;
  color: var(--brand);
}

.button.accent {
  border-color: #111111;
  background: #111111;
  box-shadow: 0 8px 18px rgba(17, 17, 17, 0.18);
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.danger-button:hover {
  background: #6f0d22;
  color: #ffffff;
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 52px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-top: 4px solid var(--brand);
  background: linear-gradient(135deg, #111111, #261016);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.footer-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
  background: #ffffff;
  padding: 2px;
}

.hero-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(111, 16, 40, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 233, 237, 0.96)),
    linear-gradient(90deg, rgba(111, 16, 40, 0.08) 1px, transparent 1px);
  background-size: auto, 22px 22px;
  box-shadow: var(--shadow);
  border-left: 8px solid var(--brand);
}

.hero-band h2 {
  max-width: 720px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.12;
  color: #111111;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metrics div,
.toolbar,
.form-panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid rgba(111, 16, 40, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics div {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-left: 6px solid var(--brand);
  background: linear-gradient(180deg, #ffffff, #fbf8f9);
}

.metrics div::after {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  width: 72px;
  height: 72px;
  background: rgba(111, 16, 40, 0.07);
  transform: translate(26px, -26px) rotate(45deg);
}

.metrics .metric-alert {
  border-left-color: var(--danger);
}

.metrics span {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--brand);
}

.metrics p {
  margin: 4px 0 0;
  color: var(--muted);
}

.toolbar {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(6, minmax(130px, 1fr)) auto auto auto;
  gap: 10px;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid #d8c9ce;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(111, 16, 40, 0.18);
  border-color: var(--brand);
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow: auto;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

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

th {
  background: linear-gradient(180deg, #f8edf1, #f1dde4);
  color: #111111;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:hover {
  background: #fcf7f9;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.number {
  text-align: right;
}

.status {
  display: inline-flex;
  min-width: 92px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eee9eb;
  color: #111111;
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  background: #e4f4e9;
  color: var(--ok);
}

.status.danger {
  background: #fde8e5;
  color: var(--danger);
}

.link {
  color: var(--brand);
  font-weight: 800;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.site-map-panel {
  margin-bottom: 20px;
  border: 1px solid rgba(111, 16, 40, 0.14);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.site-map-panel .section-heading {
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8edf1);
}

.site-map-panel .section-heading p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.site-map {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(111, 16, 40, 0.08), rgba(17, 17, 17, 0.02)),
    radial-gradient(circle at 20% 25%, rgba(111, 16, 40, 0.15), transparent 22%),
    radial-gradient(circle at 80% 70%, rgba(17, 17, 17, 0.08), transparent 24%),
    #fbf8f9;
}

.leaflet-map {
  display: block;
  min-height: 420px;
  background: #f6e9ed;
}

.leaflet-map.ready {
  display: block;
}

.fallback-map.hidden {
  display: none;
}

.picker-map {
  min-height: 360px;
  border: 1px solid rgba(111, 16, 40, 0.18);
  border-radius: 8px;
  overflow: hidden;
}

.picker-fallback {
  min-height: 220px;
  border: 1px solid rgba(111, 16, 40, 0.18);
  border-radius: 8px;
}

.picker-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.picker-actions span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.location-status {
  color: var(--brand);
}

.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(111, 16, 40, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 16, 40, 0.12) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.55));
}

.map-point {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(17, 17, 17, 0.22);
}

.map-point span {
  max-width: 38px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-point::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(111, 16, 40, 0.25);
  border-radius: 50%;
}

.map-point:hover {
  background: #111111;
}

.map-point.inactive {
  background: #777777;
}

.empty-map {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.form-panel {
  padding: clamp(18px, 3vw, 26px);
  border-top: 6px solid var(--brand);
}

.danger-panel {
  border-top-color: var(--danger);
}

.delete-summary {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(155, 19, 47, 0.2);
  border-radius: 8px;
  background: #fff7f8;
}

.delete-summary p {
  margin: 0;
}

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

.record-form {
  display: grid;
  gap: 18px;
}

fieldset {
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(111, 16, 40, 0.16);
  border-radius: 8px;
  background: #fffdfd;
}

legend {
  padding: 0 8px;
  color: var(--brand);
  font-weight: 800;
}

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

label {
  display: grid;
  gap: 6px;
  color: #21191c;
  font-size: 13px;
  font-weight: 800;
}

label.wide {
  grid-column: 1 / -1;
}

.check-label {
  align-content: end;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 70px;
}

.check-label input {
  width: 20px;
  min-height: 20px;
}

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

.alert,
.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.alert {
  background: #fde8e5;
  color: var(--danger);
}

.alert p {
  margin: 0 0 6px;
}

.alert p:last-child {
  margin-bottom: 0;
}

.notice {
  background: #e4f4e9;
  color: var(--ok);
}

.field-shell {
  display: grid;
  gap: 18px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(22px, 4vw, 32px);
  border-radius: 8px;
  background:
    linear-gradient(135deg, #111111, #6f1028);
  border: 1px solid rgba(111, 16, 40, 0.24);
  box-shadow: var(--shadow);
}

.field-header .eyebrow,
.field-header h2 {
  color: #ffffff;
}

.field-header h2 {
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.05;
}

.field-form {
  display: grid;
  gap: 16px;
}

.field-card {
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid rgba(111, 16, 40, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fcf9fa);
  box-shadow: var(--shadow);
}

.field-card h3 {
  margin: 0 0 16px;
  font-size: 21px;
}

.primary-card {
  border-top: 7px solid var(--brand);
}

.result-card {
  border-top: 7px solid #111111;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.reading-grid {
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr));
}

.field-form label {
  font-size: 14px;
}

.site-picker-label {
  margin-bottom: 14px;
}

.selected-site-summary {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(111, 16, 40, 0.14);
  border-radius: 8px;
  background: #f8edf1;
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
}

.field-form input,
.field-form select,
.field-form textarea {
  min-height: 52px;
  font-size: 18px;
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.chip {
  min-height: 40px;
  border-color: #c9a6b0;
  background: var(--accent-soft);
  color: var(--brand);
  box-shadow: var(--shadow-soft);
}

.chip:hover {
  background: var(--brand);
  color: #ffffff;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 52px;
  place-items: center;
  border: 1px solid #d8c9ce;
  border-radius: 6px;
  background: #ffffff;
  color: #21191c;
  font-size: 16px;
  font-weight: 900;
}

.segmented input:checked + span {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px;
  border: 1px solid rgba(111, 16, 40, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 28px rgba(17, 17, 17, 0.08);
}

.report-cover {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: clamp(24px, 4vw, 34px);
  border-radius: 8px;
  background:
    linear-gradient(135deg, #111111 0%, #46101d 42%, #6f1028 100%);
  color: #ffffff;
  box-shadow: var(--shadow);
  border-left: 8px solid #ffffff;
}

.report-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.report-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.65);
  padding: 5px;
}

.report-cover .eyebrow,
.report-cover p {
  color: #ffffff;
}

.report-cover h2 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

.report-cover p {
  margin: 8px 0 0;
  font-weight: 700;
}

.report-cover button {
  border-color: #ffffff;
  background: #ffffff;
  color: var(--brand);
}

.report-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 0.6fr)) auto auto;
  gap: 10px;
  align-items: center;
}

.report-section {
  margin-top: 20px;
}

.report-section .section-heading {
  padding: 16px 18px;
  margin-bottom: 0;
  border: 1px solid rgba(111, 16, 40, 0.14);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #ffffff, #f8edf1);
}

.report-section .table-wrap {
  border-radius: 0 0 8px 8px;
}

.report-table {
  min-width: 720px;
}

.report-metrics {
  break-inside: avoid;
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .site-footer,
  .no-print,
  .report-cover button {
    display: none;
  }

  .report-logo {
    border-color: #111111;
  }

  main {
    width: 100%;
    padding: 0;
  }

  .report-cover,
  .metrics div,
  .table-wrap {
    box-shadow: none;
  }

  .report-cover {
    margin-bottom: 14px;
    color: #111111;
    background: #ffffff;
    border: 2px solid #111111;
  }

  .report-cover .eyebrow,
  .report-cover p {
    color: #111111;
  }

  .metrics {
    grid-template-columns: repeat(4, 1fr);
  }

  .report-section,
  .metrics div,
  tr {
    break-inside: avoid;
  }
}

@media (max-width: 1100px) {
  .filters,
  .grid,
  .field-grid,
  .reading-grid,
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .hero-band,
  .report-cover,
  .report-brand,
  .field-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  nav,
  .actions,
  .site-footer,
  .sticky-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filters,
  .report-filters,
  .grid,
  .field-grid,
  .reading-grid,
  .segmented,
  .metrics {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }

  .report-brand {
    align-items: flex-start;
  }

  .report-logo {
    width: 72px;
    height: 72px;
  }
}
