:root {
  --red: #c1121f;
  --red-dark: #8f0d17;
  --ink: #111827;
  --muted: #64748b;
  --line: #d8dee9;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --blue: #0f4c81;
  --teal: #0f766e;
  --gold: #b7791f;
  --shadow: 0 18px 42px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.sprite { display: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: #101820;
  color: #fff;
  padding: 24px 18px;
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--red);
  border-radius: 8px;
  font-weight: 900;
}
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: #b8c3cf; font-size: 13px; margin-top: 2px; }
.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  padding: 3px 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #f8fafc;
  background: rgba(193,18,31,.35);
  font-size: 12px;
  font-weight: 800;
}
.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: #dbe5ef;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
}
.nav-button svg, .icon-button svg, .action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-button.active, .nav-button:hover { background: rgba(255,255,255,.10); color: #fff; }

.shell { margin-left: 280px; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 20px 28px;
  background: rgba(246, 248, 251, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 2px; color: var(--red); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top-version {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.searchbar { display: grid; grid-template-columns: minmax(190px, 1fr) 170px 84px 44px auto; gap: 10px; width: min(820px, 60vw); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
}
textarea { min-height: 112px; resize: vertical; }
.icon-button, .action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  padding: 10px 14px;
  font-weight: 800;
}
.action.secondary { background: #e8edf3; color: var(--ink); }
.action.danger { background: #fee2e2; color: #991b1b; }
.auth-action { white-space: nowrap; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 10px 0;
  font-weight: 900;
  text-align: left;
}
.hidden { display: none !important; }
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(8,13,20,.88), rgba(8,13,20,.48)),
    url("https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?auto=format&fit=crop&w=1800&q=80") center/cover;
}
.login-panel {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.login-brand {
  color: var(--ink);
  margin-bottom: 18px;
}
.login-brand span { color: var(--muted); }
.login-brand .version-badge { color: var(--red); background: #fff5f5; border-color: #fecdd3; }
.auth-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--red);
  font-weight: 800;
}
.readonly-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 800;
}
.user-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

#view { padding: 28px; }
.hero {
  min-height: 300px;
  display: grid;
  align-items: end;
  padding: 34px;
  color: #fff;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(8,13,20,.86), rgba(8,13,20,.38)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1800&q=80") center/cover;
}
.hero h2 { margin: 0; max-width: 780px; font-size: clamp(34px, 5vw, 64px); line-height: 1; letter-spacing: 0; }
.hero p { max-width: 720px; font-size: 18px; color: #e2e8f0; }

.stats { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 14px; margin: 18px 0; }
.stat, .panel, .card, .form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}
.stat { padding: 16px; }
.stat strong { display: block; font-size: 28px; }
.stat span { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel, .form-panel { padding: 18px; }
.panel h2, .form-panel h2 { margin: 0 0 14px; font-size: 20px; }
.card { overflow: hidden; }
.card-media {
  height: 150px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  display: flex;
  align-items: end;
  padding: 16px;
  color: #fff;
}
.card-body { padding: 16px; }
.muted { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.section-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: #334155; font-size: 13px; font-weight: 800; }
.list { display: grid; gap: 10px; }
.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.dropzone {
  border: 2px dashed #b9c5d5;
  background: #fff;
  border-radius: 8px;
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
}
.dropzone.dragover { border-color: var(--red); background: #fff5f5; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.photo-card img { width: 100%; height: 170px; object-fit: cover; display: block; background: #e2e8f0; }
.photo-card button { width: 100%; border: 0; padding: 0; background: transparent; }
.video-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; background: #0f172a; }
#map { height: 540px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mini-map {
  min-height: 180px;
  background: #dbeafe;
  border-radius: 8px;
  padding: 14px;
  color: #0f172a;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(3, 7, 18, .88);
  display: grid;
  place-items: center;
  padding: 28px;
}
.modal.hidden { display: none; }
.modal img { max-width: 94vw; max-height: 88vh; object-fit: contain; }
.modal-close {
  position: fixed;
  top: 18px;
  right: 22px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  font-size: 30px;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .grid, .grid.two, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: stretch; flex-direction: column; }
  .searchbar { width: 100%; grid-template-columns: 1fr 1fr 90px 44px auto; }
}

@media (max-width: 780px) {
  .sidebar { position: static; width: auto; padding: 16px; }
  .brand { margin-bottom: 12px; }
  #nav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .shell { margin-left: 0; }
  .topbar { position: static; padding: 18px; }
  #view { padding: 18px; }
  .searchbar, .form-grid, .grid, .grid.two, .grid.four, .stats { grid-template-columns: 1fr; }
  .hero { min-height: 260px; padding: 22px; }
  .list-item { grid-template-columns: 1fr; }
  #map { height: 420px; }
}
