/* ─────────────────────────────────────────────────────────────────────────
   DDL Map — main stylesheet
   Tab-driven sidebar, body-portal autocomplete, card popups.
   Mobile-first.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --brand: #0b3954;
  --brand-2: #087e8b;
  --accent: #ff6b35;
  --good: #16a34a;
  --warn: #f59e0b;
  --bad:  #dc2626;
  --info: #2563eb;
  --shadow: 0 8px 24px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.16), 0 2px 4px rgba(15,23,42,.08);
  --radius: 12px;
  --sidebar-w: 360px;
  --sidebar-w-collapsed: 56px;
  --tab-h: 52px;
  --header-h: 56px;
  --transition: cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

.muted { color: var(--ink-2); font-size: 13px; }

/* ─── App layout ───────────────────────────────────────────────────────── */
body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas: "side map";
  overflow: hidden;
  transition: grid-template-columns .25s var(--transition);
}
.sidebar {
  grid-area: side;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: width .25s var(--transition);
  min-width: 0;
}
.map { grid-area: map; height: 100vh; width: 100%; }

/* ─── Sidebar header ──────────────────────────────────────────────────── */
.sidebar__head {
  flex: 0 0 auto;
  position: relative;
  height: var(--header-h);
  padding: 0 12px 0 16px;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  white-space: nowrap;
}
.sidebar__brand {
  flex: 1 1 auto; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; line-height: 1.1;
}
.sidebar__title {
  margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__sub {
  font-size: 11px; opacity: .85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__foot {
  flex: 0 0 auto;
  padding: 8px 16px; border-top: 1px solid var(--line); color: var(--ink-2);
  background: var(--panel);
  white-space: nowrap; overflow: hidden;
}
.sidebar__foot small { font-size: 11px; }

/* ─── Tab bar ─────────────────────────────────────────────────────────── */
.tabs {
  flex: 0 0 auto;
  display: flex; align-items: stretch;
  height: var(--tab-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
  gap: 2px;
}
.tab {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: transparent; border: 0;
  color: var(--ink-2);
  font-size: 11px; font-weight: 500;
  border-radius: 8px;
  transition: background-color .15s, color .15s;
  position: relative;
  padding: 6px 4px;
  white-space: nowrap;
}
.tab:hover { background: var(--line-2); color: var(--ink); }
.tab.is-active { color: var(--brand-2); }
.tab.is-active::after {
  content: ''; position: absolute; left: 12%; right: 12%; bottom: -1px;
  height: 2px; background: var(--brand-2); border-radius: 2px;
}
.tab__icon { display: inline-flex; }
.tab__icon svg { display: block; }
.tab__label { letter-spacing: .2px; }

/* ─── Scrollable tab content ──────────────────────────────────────────── */
.tab-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
}
.tab-content::-webkit-scrollbar { width: 8px; }
.tab-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.tab-content::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

.tabpane { display: none; padding: 14px 16px 18px; }
.tabpane.is-active { display: block; animation: paneIn .2s var(--transition); }
@keyframes paneIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.pane__h {
  margin: 14px 0 8px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--ink-2);
}
.pane__h:first-child { margin-top: 2px; }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.iconbtn {
  width: 34px; height: 34px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 9px; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background-color .15s, border-color .15s;
}
.iconbtn:hover { background: var(--bg); border-color: var(--ink-3); }
.iconbtn--ghost { background: rgba(255,255,255,.16); border: 0; color: #fff; }
.iconbtn--ghost:hover { background: rgba(255,255,255,.28); }
.iconbtn--mini { width: 24px; height: 24px; border: 0; background: transparent; }
.iconbtn--mini:hover { background: var(--line-2); }

.btn {
  padding: 9px 12px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); border-radius: 10px;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn--primary:hover { background: #0a324a; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ─── Route panel ─────────────────────────────────────────────────────── */
.route-input {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.route-input__field {
  position: relative; flex: 1 1 auto; min-width: 0;
}
.route-input__field input {
  width: 100%; padding: 10px 32px 10px 11px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); outline: none;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.route-input__field input:focus {
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8,126,139,.15);
}
.route-input__clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; color: var(--ink-3);
  font-size: 18px; line-height: 1;
}
.route-input__clear:hover { color: var(--ink); }

.dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}
.dot--a { background: var(--good); }
.dot--b { background: var(--bad); }

.route-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ─── Route summary ───────────────────────────────────────────────────── */
.route-summary {
  margin-top: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px; line-height: 1.5;
}
.route-summary .summary__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.route-summary .summary__title { font-weight: 600; font-size: 14px; }
.route-summary .summary__bookmark {
  background: transparent; border: 0; color: var(--brand-2);
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.route-summary .summary__bookmark:hover { background: var(--line-2); }
.route-summary .summary__bookmark.is-saved { color: var(--accent); }
.route-summary .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0;
}
.route-summary .row .k { color: var(--ink-2); }
.route-summary .ok   { color: var(--good); font-weight: 600; }
.route-summary .bad  { color: var(--bad);  font-weight: 600; }
.route-summary .warn { color: var(--warn); font-weight: 600; }
.route-summary .avoided-list {
  margin: 6px 0 0; padding-left: 18px; font-size: 12px;
  color: var(--ink-2);
}
.route-summary .avoided-list li { margin: 2px 0; }
.route-summary .avoided-list em { color: var(--bad); font-style: normal; font-weight: 500; }

/* ─── Recent / Saved lists ────────────────────────────────────────────── */
.hist-list, .saved-list {
  list-style: none; margin: 0 0 6px; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.hist-item, .saved-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.hist-item:hover, .saved-item:hover {
  background: #fff; border-color: var(--line);
}
.hist-item__icon, .saved-item__icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3);
}
.hist-item__body, .saved-item__body {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; line-height: 1.25;
}
.hist-item__label, .saved-item__label {
  font-size: 13px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-item__sub, .saved-item__sub {
  font-size: 11px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-item__del, .saved-item__del {
  background: transparent; border: 0; color: var(--ink-3);
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  opacity: .7; transition: opacity .15s, background-color .15s, color .15s;
}
.hist-item__del:hover, .saved-item__del:hover {
  background: rgba(220,38,38,.1); color: var(--bad); opacity: 1;
}

/* ─── Filters ─────────────────────────────────────────────────────────── */
.check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 14px; cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--brand-2); cursor: pointer; }

.status {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px 12px; font-size: 13px; margin: 4px 0 10px;
}
.status .k { color: var(--ink-2); display: block; font-size: 11px; }

/* ─── FAB & toasts ────────────────────────────────────────────────────── */
.fab {
  display: none; position: fixed; left: 12px; top: 12px; z-index: 1000;
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: var(--shadow);
  color: var(--ink);
}

.toasts {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 2000; pointer-events: none;
}
.toast {
  background: #0f172a; color: #fff;
  padding: 10px 14px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 13px;
  pointer-events: auto; max-width: 80vw;
  animation: toastIn .2s ease-out;
}
.toast--bad  { background: var(--bad); }
.toast--warn { background: var(--warn); color: #1f2937; }
.toast--ok   { background: var(--good); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Autocomplete dropdown (body portal) ─────────────────────────────── */
.ac-dropdown {
  position: fixed;
  z-index: 4000;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
}
.ac-dropdown[hidden] { display: none; }
.ac-dropdown__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  cursor: pointer; user-select: none;
  font-size: 14px; color: var(--ink);
  transition: background-color .1s;
}
.ac-dropdown__item:hover,
.ac-dropdown__item[aria-selected="true"] {
  background: var(--line-2);
}
.ac-dropdown__icon {
  width: 28px; height: 28px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; background: var(--bg); color: var(--ink-2);
}
.ac-dropdown__body {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; line-height: 1.3;
}
.ac-dropdown__primary {
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-dropdown__secondary {
  font-size: 11px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-dropdown__empty {
  padding: 16px; text-align: center; color: var(--ink-2); font-size: 13px;
}
.ac-dropdown__loading {
  padding: 14px; text-align: center; color: var(--ink-2); font-size: 12px;
}

/* ─── Leaflet popup card ──────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0;
}
.leaflet-popup-content {
  margin: 0;
  font-size: 13px; line-height: 1.45;
  width: 320px !important;
}
.leaflet-popup-tip { box-shadow: var(--shadow); }

.popup-card {
  display: flex; flex-direction: column;
  max-height: 70vh; overflow: hidden;
  border-radius: 14px;
}
.popup-card__head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.popup-card__badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #fff;
  white-space: nowrap;
}
.b-closure     { background: var(--bad); }
.b-flooding    { background: var(--info); }
.b-construction{ background: var(--warn); color: #1f2937; }
.b-disruption  { background: var(--accent); }
.b-restriction { background: #6b7280; }
.popup-card__src {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: .6px;
}
.popup-card__title {
  margin: 0; padding: 12px 14px 4px;
  font-size: 15px; font-weight: 600; color: var(--ink);
  line-height: 1.3;
}
.popup-card__body {
  padding: 6px 14px 12px;
  overflow-y: auto;
}
.popup-card__row {
  display: flex; gap: 8px; padding: 6px 0;
  border-top: 1px solid var(--line-2);
}
.popup-card__row:first-child { border-top: 0; }
.popup-card__row--alert {
  background: rgba(220,38,38,.06);
  border-radius: 8px; padding: 8px 10px; margin: 4px 0;
  border: 1px solid rgba(220,38,38,.18);
}
.popup-card__icon {
  flex-shrink: 0; width: 18px; height: 18px;
  color: var(--ink-3);
  margin-top: 1px;
}
.popup-card__field { flex: 1 1 auto; min-width: 0; }
.popup-card__label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-2);
  margin-bottom: 1px;
}
.popup-card__value {
  font-size: 13px; color: var(--ink);
  white-space: pre-wrap; word-wrap: break-word;
}
.popup-card__row--alert .popup-card__icon { color: var(--bad); }
.popup-card__row--alert .popup-card__label { color: var(--bad); }

.popup-card__footer {
  padding: 10px 14px; background: var(--panel-2);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.popup-card__images {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.popup-card__images img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 8px; cursor: zoom-in;
}
.popup-card__actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.popup-card__actions .btn {
  padding: 6px 10px; font-size: 12px; flex: 1 1 auto;
}

/* ─── Marker icons ────────────────────────────────────────────────────── */
.ddl-marker {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  font-size: 14px; line-height: 1; user-select: none;
  color: #fff; font-weight: 700;
}
.ddl-marker--closure     { background: var(--bad); }
.ddl-marker--flooding    { background: var(--info); }
.ddl-marker--construction{ background: var(--warn); color: #1f2937; }
.ddl-marker--disruption  { background: var(--accent); }
.ddl-marker--restriction { background: #6b7280; }

.ddl-user-pulse {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1d4ed8; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(29,78,216,.25);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(29,78,216,.45); }
  70%  { box-shadow: 0 0 0 14px rgba(29,78,216,0); }
  100% { box-shadow: 0 0 0 0 rgba(29,78,216,0); }
}

/* ─── Modal ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal__panel {
  background: #fff; border-radius: 14px;
  width: min(440px, 100%); padding: 16px;
  box-shadow: var(--shadow-lg);
}
.modal__panel header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.modal__panel h3 { margin: 0; font-size: 16px; }
#ugc-form label {
  display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 8px;
}
#ugc-form input[type="text"], #ugc-form textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.ugc-preview img { max-width: 100%; border-radius: 8px; margin-top: 6px; }
.modal__actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px;
}

/* ─── Leaflet control tweaks ──────────────────────────────────────────── */
.leaflet-control-zoom a { border-radius: 8px !important; }

/* ─── Collapsed sidebar (icon rail) ───────────────────────────────────── */
.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.is-collapsed .sidebar__brand { display: none; }
.is-collapsed .sidebar__head {
  justify-content: center; padding: 0;
}
.is-collapsed .sidebar__foot { display: none; }
.is-collapsed .tabs {
  flex-direction: column;
  height: auto;
  padding: 6px;
  gap: 4px;
  border-bottom: 0;
}
.is-collapsed .tab {
  flex: 0 0 auto;
  height: 44px;
  padding: 0;
  border-radius: 9px;
}
.is-collapsed .tab__label { display: none; }
.is-collapsed .tab.is-active { background: var(--line-2); }
.is-collapsed .tab.is-active::after { display: none; }
.is-collapsed .tab-content { display: none; }
.is-collapsed #btn-collapse { transform: rotate(180deg); }

#btn-collapse { transition: transform .25s var(--transition); }

/* ─── Community marker badge ──────────────────────────────────────────── */
.ddl-marker--community {
  border-style: dashed;
  border-color: #fff;
  position: relative;
}
.ddl-marker__badge {
  position: absolute;
  bottom: -4px; right: -6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}

/* ─── User menu (sidebar header) ──────────────────────────────────────── */
.user-menu-slot { display: flex; align-items: center; }
.is-collapsed .user-menu-slot { display: none; }

.auth-pill {
  background: rgba(255,255,255,.18);
  border: 0; color: #fff;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  transition: background-color .15s;
}
.auth-pill:hover { background: rgba(255,255,255,.28); }

.user-menu { position: relative; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  border: 0; color: #fff;
  font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background-color .15s;
}
.user-avatar:hover { background: rgba(255,255,255,.34); }

.user-menu__pop {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; color: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  min-width: 220px; z-index: 1800;
  overflow: hidden;
  animation: paneIn .15s var(--transition);
}
.user-menu__head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.user-menu__name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.user-menu__email { font-size: 12px; color: var(--ink-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.user-menu__item {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; background: transparent;
  border: 0; color: var(--ink); font-size: 13px;
  cursor: pointer;
}
.user-menu__item:hover { background: var(--line-2); }

/* ─── Auth modal ──────────────────────────────────────────────────────── */
.auth-panel {
  width: min(440px, 100%);
  padding: 22px;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.6);
  box-shadow: 0 20px 60px rgba(15,23,42,.18), 0 1px 4px rgba(15,23,42,.06);
}
.auth-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.auth-header h3 {
  margin: 0; font-size: 20px; letter-spacing: -.2px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-reason {
  background: rgba(8,126,139,.08);
  border: 1px solid rgba(8,126,139,.22);
  color: var(--brand);
  padding: 10px 12px; border-radius: 10px;
  font-size: 13px; margin-bottom: 14px; line-height: 1.4;
}

.auth-tabs {
  position: relative;
  display: flex; gap: 4px;
  background: var(--panel-2);
  padding: 4px; border-radius: 12px;
  margin-bottom: 16px;
  transition: opacity .25s, max-height .25s, margin .25s;
  max-height: 60px;
  overflow: hidden;
}
.auth-tabs.is-hidden { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; pointer-events: none; }
.auth-tab {
  flex: 1; padding: 10px; border: 0; background: transparent;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  position: relative; z-index: 2;
  transition: color .2s;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.is-active {
  background: #fff; color: var(--brand);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.auth-stack {
  position: relative;
  display: grid; /* keeps height stable while forms cross-fade */
}
.auth-stack > .auth-form { grid-area: 1 / 1 / 2 / 2; }

.auth-form {
  display: none;
  flex-direction: column; gap: 12px;
}
.auth-form.is-active {
  display: flex;
  animation: authIn .22s var(--transition);
}
@keyframes authIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.auth-form label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  letter-spacing: .2px;
}
.auth-form input {
  padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 14px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.auth-form input:focus {
  outline: none; border-color: var(--brand-2); background: #fff;
  box-shadow: 0 0 0 3px rgba(8,126,139,.15);
}
.auth-form input:invalid:not(:placeholder-shown) { border-color: var(--bad); }
.auth-form input::placeholder { color: var(--ink-3); }

.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: -2px;
}
.auth-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2); cursor: pointer; user-select: none;
}
.auth-check input { accent-color: var(--brand-2); cursor: pointer; }

.auth-help {
  margin: 0 0 4px; font-size: 13px; color: var(--ink-2); line-height: 1.5;
}

.auth-submit { margin-top: 6px; padding: 11px; font-weight: 600; font-size: 14px; }
.auth-form__error {
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.3);
  color: var(--bad);
  padding: 9px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.4;
  animation: authIn .2s var(--transition);
}
.auth-form__ok {
  background: rgba(22,163,74,.1);
  border: 1px solid rgba(22,163,74,.3);
  color: var(--good);
  padding: 9px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.4;
  animation: authIn .2s var(--transition);
}
.auth-link {
  background: transparent; border: 0; padding: 2px 4px;
  color: var(--brand-2); font-size: 13px;
  cursor: pointer; text-align: left;
  font-weight: 500;
}
.auth-link:hover { text-decoration: underline; }
.auth-link--center { text-align: center; margin-top: 4px; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
.btn--primary.is-loading { display: inline-flex; align-items: center; justify-content: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Profile modal ───────────────────────────────────────────────────── */
.profile-panel { width: min(440px, 100%); padding: 20px; }
.profile-panel header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.profile-panel header h3 { margin: 0; font-size: 18px; }

.pm-avatar-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.pm-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px; font-weight: 600;
  overflow: hidden; flex-shrink: 0;
  border: 2px solid #fff; box-shadow: var(--shadow);
}
.pm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pm-avatar__initial { line-height: 1; }
.pm-avatar-actions { display: flex; flex-direction: column; gap: 4px; }
.pm-avatar-actions .btn { font-size: 13px; }
.pm-avatar-actions small { font-size: 11px; }

#pm-form { display: flex; flex-direction: column; gap: 12px; }
#pm-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); }
#pm-form input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 14px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
#pm-form input:focus {
  outline: none; border-color: var(--brand-2); background: #fff;
  box-shadow: 0 0 0 3px rgba(8,126,139,.15);
}
#pm-form input[readonly] { background: var(--line-2); color: var(--ink-2); }

/* ─── User menu (header) — avatar refinements ─────────────────────────── */
.user-avatar-btn {
  background: transparent; border: 0; padding: 0;
  cursor: pointer; border-radius: 50%;
  transition: transform .12s;
}
.user-avatar-btn:hover { transform: scale(1.04); }
.user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  color: #fff; font-weight: 600; font-size: 13px;
  overflow: hidden; border: 2px solid rgba(255,255,255,.45);
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-menu__head {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.user-menu__head-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.user-menu__head-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-menu__head-info { min-width: 0; flex: 1; }
.user-menu__name { font-weight: 600; font-size: 14px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.user-menu__email { font-size: 12px; color: var(--ink-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.user-menu__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-right: 8px;
}
.user-menu__item--danger { color: var(--bad); }
.user-menu__item--danger:hover { background: rgba(220,38,38,.08); }

/* ─── Event detail panel (in routes tab) ──────────────────────────────── */
.event-detail {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel-2), #fff);
  border: 1px solid var(--line);
  animation: paneIn .2s var(--transition);
}
.event-detail[hidden] { display: none; }

.ev-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.ev-head__left { display: flex; align-items: center; gap: 8px; }
.ev-glyph { font-size: 22px; line-height: 1; }
.ev-badge {
  background: var(--accent); color: #fff;
  padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase;
}
.ev-title {
  margin: 0 0 6px; font-size: 16px; font-weight: 600; line-height: 1.3;
  color: var(--ink);
}
.ev-source-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.ev-type {
  font-size: 11px; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
}
.ev-source {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 8px; border-radius: 999px;
}
.ev-source--official {
  background: rgba(11,57,84,.1); color: var(--brand); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
}
.ev-source--community {
  background: rgba(255,107,53,.12); color: var(--accent); font-weight: 500;
}
.ev-avatar {
  width: 18px; height: 18px; border-radius: 50%; overflow: hidden;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}
.ev-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ev-reporter { font-weight: 600; }

.ev-loc { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; line-height: 1.4; }

.ev-row {
  display: flex; align-items: center; gap: 10px; margin: 6px 0;
  font-size: 13px;
}
.ev-row__k { color: var(--ink-2); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; min-width: 70px; }
.ev-pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.ev-pill--sev-low      { background: rgba(22,163,74,.15);  color: var(--good); }
.ev-pill--sev-medium   { background: rgba(245,158,11,.18); color: #92400e; }
.ev-pill--sev-high     { background: rgba(255,107,53,.15); color: var(--accent); }
.ev-pill--sev-critical { background: rgba(220,38,38,.12);  color: var(--bad); }
.ev-pill--status-pending  { background: rgba(148,163,184,.2); color: #475569; }
.ev-pill--status-approved { background: rgba(22,163,74,.15); color: var(--good); }
.ev-pill--status-rejected { background: rgba(220,38,38,.12); color: var(--bad); }
.ev-pill--status-resolved { background: rgba(99,102,241,.12); color: #4338ca; }

.ev-section { margin-top: 12px; }
.ev-section__h {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-2); margin-bottom: 4px;
}
.ev-section--alert {
  background: rgba(220,38,38,.04);
  border: 1px solid rgba(220,38,38,.18);
  border-radius: 9px; padding: 8px 10px;
}
.ev-section--alert .ev-section__h { color: var(--bad); }
.ev-text {
  margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; word-wrap: break-word;
}

.ev-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.ev-actions .btn { flex: 1 1 auto; font-size: 12px; padding: 8px 10px; }

.ev-gallery { min-height: 8px; }

/* ─── Photo gallery (used in event detail + photos tab) ──────────────── */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}
.gallery__item {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  border-radius: 10px; overflow: hidden;
  background: var(--bg);
  cursor: zoom-in;
  border: 1px solid var(--line);
  transition: transform .12s, box-shadow .15s;
}
.gallery__item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.gallery__item:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.gallery__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery__cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #fff; padding: 14px 8px 6px;
  font-size: 10px; line-height: 1.2;
  display: flex; flex-direction: column; gap: 2px;
}
.gallery__by { font-weight: 600; }
.gallery__at { opacity: .8; }
.gallery__del, .gallery__view {
  position: absolute; width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff;
  border: 0; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0;
  transition: opacity .15s, background-color .15s;
}
.gallery__del { top: 4px; right: 4px; }
.gallery__view { top: 4px; left: 4px; font-size: 13px; }
.gallery__item:hover .gallery__del,
.gallery__item:hover .gallery__view,
.gallery__item:focus-within .gallery__del,
.gallery__item:focus-within .gallery__view { opacity: 1; }
.gallery__del:hover { background: var(--bad); }
.gallery__view:hover { background: var(--brand-2); }
.gallery__empty { padding: 12px 0; }

/* ─── Lightbox ────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  animation: lightboxIn .15s var(--transition);
}
.lightbox[hidden] { display: none; }
@keyframes lightboxIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox__figure {
  margin: 0; padding: 0;
  max-width: min(1100px, 96vw);
  max-height: 92vh;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
}
.lightbox__img {
  max-width: 100%; max-height: 84vh;
  object-fit: contain;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  border-radius: 6px;
}
.lightbox__caption {
  color: rgba(255,255,255,.85);
  font-size: 13px; text-align: center;
  max-width: 90%;
}
.lightbox__counter {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7); font-size: 12px; letter-spacing: .4px;
}
.lightbox__close, .lightbox__nav {
  position: absolute; background: rgba(255,255,255,.12);
  border: 0; color: #fff; font-size: 24px;
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background-color .15s;
}
.lightbox__close { top: 18px; right: 18px; }
.lightbox__nav--prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: 18px; top: 50%; transform: translateY(-50%); }
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255,255,255,.22); }

/* ─── Photos tab ──────────────────────────────────────────────────────── */
#photos-list { padding-top: 4px; }

/* ─── Owner controls (popup + event detail) ──────────────────────────── */
.btn--ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
}
.btn--ghost:hover { background: var(--line-2); border-color: var(--ink-3); }
.btn--danger {
  background: rgba(220,38,38,.08); color: var(--bad);
  border: 1px solid rgba(220,38,38,.25);
}
.btn--danger:hover { background: rgba(220,38,38,.16); border-color: var(--bad); }
.btn--danger:disabled { background: rgba(220,38,38,.05); cursor: progress; }

.popup-card__owner-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 0;
  margin: 4px 0;
  border-top: 1px dashed var(--line);
}
.popup-card__owner-actions .btn {
  padding: 6px 10px; font-size: 12px; flex: 1 1 auto; min-width: 80px;
}

.popup-card__img-wrap {
  position: relative; display: inline-block;
}
.popup-card__img-del {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background-color .15s;
}
.popup-card__img-wrap:hover .popup-card__img-del,
.popup-card__img-wrap:focus-within .popup-card__img-del { opacity: 1; }
.popup-card__img-del:hover { background: var(--bad); }

.ev-owner-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.ev-owner-actions .btn { font-size: 12px; padding: 8px 12px; flex: 1 1 auto; }

/* ─── Community popup tweaks ──────────────────────────────────────────── */
.popup-card--community .popup-card__head {
  background: linear-gradient(90deg, rgba(255,107,53,.06), transparent);
}
.popup-reporter {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink);
}
.popup-reporter__name { font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popup-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
  font-size: 11px; font-weight: 700;
}
.popup-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─── Report modal ────────────────────────────────────────────────────── */
.report-panel { width: min(520px, 100%); padding: 18px; max-height: 90vh; overflow-y: auto; }
.report-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.report-panel header h3 { margin: 0; font-size: 17px; }

#rm-form { display: flex; flex-direction: column; gap: 10px; }
#rm-form > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
#rm-form input[type="text"], #rm-form select, #rm-form textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-size: 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
#rm-form input[type="text"]:focus,
#rm-form select:focus,
#rm-form textarea:focus {
  outline: none; border-color: var(--brand-2); background: #fff;
  box-shadow: 0 0 0 3px rgba(8,126,139,.15);
}
#rm-form textarea { resize: vertical; min-height: 60px; font-family: inherit; }

.rm-sev-row {
  border: 0; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--ink-2);
}
.rm-sev-row legend { font-size: 12px; color: var(--ink-2); padding: 0; margin: 0 0 4px; }
.rm-sev-row > div, .rm-sev-row { /* dummy to allow flex on parent */ }
.rm-sev-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.rm-sev {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 4px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); cursor: pointer;
  font-size: 12px; text-transform: capitalize;
  transition: all .15s;
}
.rm-sev input { position: absolute; opacity: 0; pointer-events: none; }
.rm-sev:hover { border-color: var(--ink-3); }
.rm-sev:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.rm-sev--low:has(input:checked)      { background: #16a34a; border-color: #16a34a; }
.rm-sev--medium:has(input:checked)   { background: var(--warn); color: #1f2937; border-color: var(--warn); }
.rm-sev--high:has(input:checked)     { background: var(--accent); border-color: var(--accent); }
.rm-sev--critical:has(input:checked) { background: var(--bad); border-color: var(--bad); }

.rm-drop {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 22px;
  border: 2px dashed var(--line); border-radius: 12px;
  background: var(--panel-2); color: var(--ink-2);
  cursor: pointer; user-select: none;
  transition: border-color .15s, background-color .15s;
  text-align: center;
}
.rm-drop:hover, .rm-drop:focus { border-color: var(--brand-2); background: #fff; }
.rm-drop.is-drag { border-color: var(--brand-2); background: rgba(8,126,139,.06); }
.rm-drop strong { color: var(--ink); font-size: 14px; }
.rm-drop small { font-size: 11px; color: var(--ink-3); }

.rm-staged {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px;
}
.rm-staged:empty { display: none; }
.rm-thumb {
  position: relative;
  border-radius: 9px; overflow: hidden;
  aspect-ratio: 1; background: var(--bg);
  border: 1px solid var(--line);
}
.rm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rm-thumb__del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.rm-thumb__bar {
  position: absolute; left: 4px; right: 4px; bottom: 4px;
  height: 4px; border-radius: 4px;
  background: rgba(255,255,255,.4); overflow: hidden;
}
.rm-thumb__bar > div { height: 100%; background: var(--brand-2); transition: width .15s; }
.rm-thumb__ok {
  position: absolute; left: 50%; bottom: 6px;
  transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--good); color: #fff;
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.rm-thumb.is-error { border-color: var(--bad); }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas: "map";
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform .22s var(--transition);
    z-index: 1500;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
  .fab { display: inline-flex; align-items: center; justify-content: center; }
  .is-collapsed .sidebar { width: min(86vw, var(--sidebar-w)); }
  .is-collapsed .sidebar__brand { display: flex; }
  .is-collapsed .sidebar__foot { display: block; }
  .is-collapsed .tabs { flex-direction: row; height: var(--tab-h); padding: 0 6px; gap: 2px; }
  .is-collapsed .tab__label { display: inline; }
  .is-collapsed .tab-content { display: block; }
  .is-collapsed { grid-template-columns: 1fr; }
}
