:root {
  --bg: #0b0e14;
  --bg-soft: #11151d;
  --bg-card: #161b25;
  --bg-elev: #1c2230;
  --border: #242b3a;
  --border-soft: #1b2230;
  --text: #e8ecf3;
  --text-dim: #9aa3b2;
  --text-mute: #6b7384;
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-soft: rgba(220, 38, 38, 0.12);
  --warn: #f59e0b;
  --ok: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.55);
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(180deg, #0e1320 0%, #0b0e14 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 30%, #ef4444 0%, #dc2626 50%, #991b1b 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 4px 12px rgba(220,38,38,0.35);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 9px;
  background: white;
  clip-path: path('M9 0 C 4 0 0 4 0 9 c 0 7.5 9 16 9 16 s 9 -8.5 9 -16 c 0 -5 -4 -9 -9 -9 z M 9 13 a 4 4 0 1 1 0 -8 a 4 4 0 0 1 0 8 z');
}
.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand-sub {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Emergency banner ---------- */
.emergency-banner {
  background: linear-gradient(90deg, #4a1414 0%, #2a0e0e 100%);
  border-bottom: 1px solid #5b1818;
  color: #fde2e2;
  padding: 10px 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  position: relative;
}
.emergency-banner strong { color: #fff; }
.emergency-banner a { color: #fecaca; text-decoration: underline; }
.emergency-banner .dismiss {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #fde2e2;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  opacity: 0.7;
}
.emergency-banner .dismiss:hover { opacity: 1; }

/* ---------- Buttons ---------- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: 0;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { background: #4a1f1f; cursor: not-allowed; opacity: 0.7; }

.ghost-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
.ghost-btn:hover { color: var(--text); border-color: #3a4356; }

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: var(--bg-elev); }

/* ---------- Main layout ---------- */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 18px 8px;
}
.sidebar-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}
.count-badge {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.search-row {
  position: relative;
  padding: 4px 18px 8px;
  display: flex;
  align-items: center;
}
.search-row .search-icon {
  position: absolute;
  left: 28px;
  color: var(--text-mute);
  pointer-events: none;
}
.search-row input {
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 30px 7px 32px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-row input::placeholder { color: var(--text-mute); }
.search-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-row input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  right: 24px;
  background: transparent;
  border: 0;
  color: var(--text-mute);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.search-clear:hover { color: var(--text); background: var(--bg-elev); }

.filter-row {
  padding: 4px 18px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.filter-row label {
  font-size: 12px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.filter-row select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
}
.report-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.report-list:empty::after {
  content: attr(data-empty);
  display: block;
  padding: 24px 18px;
  font-size: 13px;
  color: var(--text-mute);
  font-style: italic;
}
.report-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s;
}
.report-item:hover { background: var(--bg-card); }
.report-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); padding-left: 15px; }
.report-item .venue {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
  word-wrap: break-word;
}
.report-item .meta {
  font-size: 12px;
  color: var(--text-mute);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.report-item .meta .tag {
  background: var(--bg-elev);
  color: var(--text-dim);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
}
.report-item .desc {
  font-size: 13px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
}
.sidebar-foot {
  padding: 12px 18px;
  font-size: 11px;
  color: var(--text-mute);
  border-top: 1px solid var(--border-soft);
  background: var(--bg);
  margin: 0;
  line-height: 1.5;
}

/* ---------- Map ---------- */
.map-wrap { position: relative; min-height: 0; }
#map { width: 100%; height: 100%; background: #0a0d12; }

.map-instructions {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 14, 20, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px);
  animation: fade-down 0.4s ease;
}
.map-instructions svg { color: var(--accent); }
@keyframes fade-down {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.map-wrap.picking { cursor: crosshair; }
.map-wrap.picking #map { cursor: crosshair; }

/* Leaflet overrides for dark theme */
.leaflet-container {
  background: #0a0d12 !important;
  font-family: var(--font);
}
.leaflet-control-attribution {
  background: rgba(11, 14, 20, 0.85) !important;
  color: var(--text-mute) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-elev) !important; }

.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  border-radius: var(--radius-sm) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-content {
  margin: 12px 14px !important;
  font-size: 13px;
  line-height: 1.45;
}
.leaflet-popup-content .popup-venue {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  word-wrap: break-word;
}
.leaflet-popup-content .popup-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.leaflet-popup-content .popup-desc {
  color: var(--text-dim);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 180px;
  overflow-y: auto;
}

/* Pin marker (custom div icon) */
.pin-marker {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  background: var(--accent);
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), 0 0 0 6px rgba(220,38,38,0.15);
}
.pin-marker.fresh { animation: pin-pulse 1.6s ease-in-out infinite; }
@keyframes pin-pulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.5), 0 0 0 4px rgba(220,38,38,0.25); }
  50% { box-shadow: 0 2px 6px rgba(0,0,0,0.5), 0 0 0 14px rgba(220,38,38,0); }
}
.pin-marker.preview {
  background: var(--warn);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), 0 0 0 6px rgba(245,158,11,0.25);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2);
  animation: modal-in 0.18s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 18px 20px 8px; }

.anon-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.anon-notice svg { color: var(--ok); flex-shrink: 0; margin-top: 1px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field > span em {
  font-style: normal;
  color: var(--accent-hover);
  text-transform: none;
  font-size: 11px;
  margin-left: 6px;
  letter-spacing: 0;
}
.field input[type='text'],
.field input[type='date'],
.field input[type='time'],
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color-scheme: dark;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-mute);
}

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

.venue-field { position: relative; }
.venue-input-wrap { position: relative; }
.venue-status {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-mute);
  pointer-events: none;
  background: var(--bg-soft);
  padding: 0 4px;
}
.venue-status.error { color: #fecaca; }
.venue-suggestions {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-1);
}
.venue-suggestions li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.venue-suggestions li:hover,
.venue-suggestions li.active {
  background: var(--bg-card);
}
.venue-suggestions li.active { box-shadow: inset 0 0 0 1px var(--accent); }
.venue-suggestions .sug-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.venue-suggestions .sug-text { min-width: 0; flex: 1; }
.venue-suggestions .sug-name {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.venue-suggestions .sug-addr {
  color: var(--text-mute);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
}
.location-pick .picked {
  flex: 1;
  font-size: 13px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.location-pick .picked.set { color: var(--text); }
.location-pick .ghost-btn { padding: 5px 10px; font-size: 12px; }

.acks { margin: 4px 0 6px; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
  cursor: pointer;
}
.check input { margin-top: 2px; accent-color: var(--accent); }

.turnstile-slot {
  margin: 4px 0 12px;
  min-height: 65px;
  display: flex;
  justify-content: center;
}
.turnstile-slot[hidden] { display: none; }

.form-error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fecaca;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 14px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  z-index: 1200;
  font-size: 14px;
  animation: toast-in 0.25s ease;
}
.toast.error { border-left-color: var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Footer ---------- */
.app-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 11px;
  color: var(--text-mute);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
  .app-header { padding: 10px 14px; gap: 10px; }
  .brand-sub { display: none; }
  .brand h1 { font-size: 14px; }
  .primary-btn { padding: 8px 12px; font-size: 13px; }
  .primary-btn svg { display: none; }
  .emergency-banner { padding: 9px 14px; font-size: 12px; }
  .app-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--border);
    max-height: 42vh;
  }
  .map-wrap { grid-row: 1; }
  .map-instructions { font-size: 12px; padding: 7px 12px; top: 10px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .field:last-child { grid-column: span 2; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .app-foot { font-size: 10px; padding: 6px 14px; }
}
