:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --panel-soft: #f2f7f6;
  --ink: #19212a;
  --muted: #637083;
  --line: #d9dfdf;
  --fire: #b8331d;
  --fire-dark: #842414;
  --amber: #d48424;
  --sky: #257d91;
  --green: #21745b;
  --blue: #243b53;
  --shadow: 0 18px 42px rgba(31, 42, 55, .12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button,
select {
  appearance: none;
}

a {
  color: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 44px);
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.admin-topbar {
  background: rgba(248, 250, 252, .94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--fire);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions a,
.link-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}

.top-actions a:hover,
.link-button:hover,
.secondary-button:hover,
.icon-text-button:hover,
.icon-button:hover,
.card-actions button:hover,
.card-actions a:hover {
  border-color: #b8c4c4;
  background: #f8fbfb;
}

.report-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 44px;
}

.intro-panel,
.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 20px;
}

.intro-panel h1,
.admin-head h1,
.sidebar-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
  letter-spacing: 0;
}

.intro-panel p:not(.eyebrow),
.privacy-note {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--fire);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.quiet-link {
  color: var(--sky);
  font-weight: 700;
  white-space: nowrap;
}

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

.form-panel,
.map-sidebar,
.admin-board,
.admin-editor > .form-panel,
.login-panel .form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-panel {
  padding: clamp(16px, 3vw, 24px);
}

.form-panel h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 18px;
  border: 2px dashed #c9d4d1;
  border-radius: var(--radius);
  background: var(--panel-soft);
  text-align: center;
  cursor: pointer;
}

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

.upload-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--fire);
}

.upload-box small,
.field span,
.privacy-note,
.media-preview small {
  color: var(--muted);
}

.media-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.media-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.media-tile img,
.media-tile video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.media-tile small {
  display: block;
  padding: 8px;
  overflow-wrap: anywhere;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.choice-grid label {
  position: relative;
}

.choice-grid input {
  position: absolute;
  opacity: 0;
}

.choice-grid span {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}

.choice-grid input:checked + span {
  border-color: var(--fire);
  box-shadow: inset 0 0 0 2px rgba(184, 51, 29, .16);
  color: var(--fire-dark);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd7d7;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.field select {
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, #52606d 50%),
    linear-gradient(135deg, #52606d 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.field select::-ms-expand {
  display: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.top-actions a:focus-visible,
.link-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.icon-text-button:focus-visible,
.icon-button:focus-visible,
.card-actions button:focus-visible,
.card-actions a:focus-visible {
  outline: 3px solid rgba(37, 125, 145, .22);
  border-color: var(--sky);
}

.field textarea {
  resize: vertical;
}

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

.panel-title-row,
.filter-row,
.toolbar,
.form-actions,
.submit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-text-button,
.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--fire);
  color: #fff;
}

.primary-button:hover {
  background: var(--fire-dark);
}

.login-button {
  margin-top: 16px;
}

.secondary-button,
.icon-text-button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button {
  width: 44px;
  padding: 0;
  flex: 0 0 auto;
}

.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(12px);
}

.submit-bar p,
#admin-form-status,
#login-status {
  margin: 0;
  color: var(--muted);
}

.map-box {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #dfe7e8;
}

.leaflet-control-zoom {
  border: 1px solid rgba(25, 33, 42, .16) !important;
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(25, 33, 42, .13) !important;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  color: var(--ink) !important;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.small-map {
  min-height: 260px;
}

.map-shell {
  display: grid;
  grid-template-columns: minmax(330px, 420px) 1fr;
  height: calc(100vh - 72px);
}

.map-sidebar {
  z-index: 5;
  overflow: auto;
  border-radius: 0;
  border-top: 0;
  border-left: 0;
  border-bottom: 0;
  padding: 20px;
  box-shadow: none;
}

.full-map {
  min-height: 480px;
}

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

.stat-card {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card strong {
  display: block;
  font-size: 1.5rem;
}

.stat-card span {
  color: var(--muted);
  font-size: .8rem;
}

.report-list,
.admin-report-list,
.mini-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.report-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf3f5;
  color: var(--blue);
  font-size: .78rem;
  font-weight: 750;
}

.pill.active,
.marker-dot.active {
  background: #ffe8df;
  color: var(--fire-dark);
}

.pill.checking,
.marker-dot.checking {
  background: #fff3d8;
  color: #6f4b09;
}

.pill.contained,
.marker-dot.contained {
  background: #e5f4ed;
  color: var(--green);
}

.pill.closed,
.pill.rejected {
  background: #edf0f2;
  color: #52606d;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.card-actions button,
.card-actions a {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 9px;
  text-decoration: none;
  cursor: pointer;
}

.marker-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--fire);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}

.marker-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.webcam-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid #fff;
  background: var(--sky);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}

.popup-media {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.popup-media img,
.popup-media video {
  width: 220px;
  max-width: 100%;
  border-radius: 8px;
}

.admin-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 22px auto 42px;
}

.admin-head {
  padding-top: 12px;
}

.admin-head h1 {
  font-size: clamp(2.1rem, 4vw, 3rem);
}

.admin-head .stats-grid {
  width: min(360px, 100%);
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 150px);
}

.compact-panel {
  width: min(420px, 100%);
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(360px, 470px);
  gap: 16px;
  align-items: start;
}

.admin-board {
  padding: 16px;
}

.toolbar {
  align-items: end;
}

.toolbar .field {
  margin-top: 0;
}

.search-field {
  flex: 1;
}

.admin-editor {
  display: grid;
  gap: 16px;
}

.mini-list .report-card {
  box-shadow: none;
}

.loading {
  opacity: .65;
  pointer-events: none;
}

.empty-state {
  padding: 24px;
  border: 1px dashed #cbd5d8;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

  .map-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .full-map {
    min-height: 62vh;
  }
}

@media (max-width: 680px) {
  .topbar,
  .intro-panel,
  .admin-head,
  .submit-bar,
  .panel-title-row,
  .filter-row,
  .toolbar,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions a,
  .top-actions button {
    flex: 1;
    text-align: center;
  }

  .two-cols,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .map-box {
    min-height: 310px;
  }
}
