/* Kontrollhistorie scrollbar ab 3 Einträgen */
.kontroll-history-scroll {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  padding-right: 4px;
}
/* =============================================
  UrbanFlowGuard – Hydrantenverwaltung
   ============================================= */

:root {
  --color-primary: #cc2200;
  --color-primary-dark: #991900;
  --color-sidebar: #1e293b;
  --color-sidebar-light: #273549;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
  --color-green: #22c55e;
  --color-yellow: #eab308;
  --color-red: #ef4444;
  --color-gray: #94a3b8;
  --color-blue: #3b82f6;
  --sidebar-width: 300px;
  --detail-width: 360px;
  --navbar-height: 56px;
  --navbar-height-mobile: 88px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: var(--color-text);
  overflow: hidden;
}

/* ── Navbar ── */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

#navbar .brand {
  order: 1;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

#navbar .brand svg {
  width: 28px;
  height: 28px;
}

#search-wrapper {
  order: 2;
  flex: 1;
  max-width: 340px;
  position: relative;
}

#nav-actions {
  order: 3;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

#search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.35);
  overflow: hidden;
  display: none;
  z-index: 1200;
  backdrop-filter: blur(10px);
}

#search-suggestions.visible {
  display: block;
}

.search-suggestion {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 0.88rem;
}

.search-suggestion:hover,
.search-suggestion.active {
  background: rgba(255,255,255,0.1);
}

.search-suggestion-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-suggestion-count {
  flex-shrink: 0;
  color: rgba(255,255,255,0.72);
  font-size: 0.75rem;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 2px 8px;
}

#search-input {
  width: 100%;
  padding: 7px 36px 7px 12px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: background 0.2s;
}

#search-input::placeholder {
  color: rgba(255,255,255,0.6);
}

#search-input:focus {
  background: rgba(255,255,255,0.25);
}

#search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 1rem;
  display: none;
  line-height: 1;
  padding: 2px;
}

#search-clear.visible {
  display: block;
}

.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.nav-btn-icon {
  line-height: 1;
}

.nav-btn-icon-only {
  min-width: 40px;
  padding-inline: 10px;
}

#btn-nav-menu {
  display: none;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.25);
}

.nav-btn.active {
  background: rgba(255,255,255,0.3);
}

#user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-left: auto;
}

#user-name {
  display: none;
}

/* ── Layout ── */
#app-layout {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
}

/* ── Filter Sidebar ── */
#filter-panel {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.3s ease, width 0.3s ease;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

#filter-panel.collapsed {
  width: 0;
  overflow: hidden;
}

.filter-header {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-reset-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.filter-reset-btn:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.filter-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.filter-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
}

.filter-option input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.filter-option .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  background: var(--color-sidebar-light);
  padding: 1px 6px;
  border-radius: 10px;
}

.radius-filter-label {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.radius-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#street-radius-input {
  width: 110px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-sidebar-light);
  color: var(--color-text);
  font-size: 0.85rem;
}

#street-radius-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.radius-filter-value {
  font-size: 0.82rem;
  color: var(--color-text);
  min-width: 44px;
}

.radius-filter-hint {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--color-text-muted);
  line-height: 1.35;
}

/* Stats in filter panel */
#stats-box {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.stats-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat-item {
  background: var(--color-sidebar-light);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 3px;
}

.stat-item.green .stat-value { color: var(--color-green); }
.stat-item.yellow .stat-value { color: var(--color-yellow); }
.stat-item.red .stat-value { color: var(--color-red); }
.stat-item.gray .stat-value { color: var(--color-gray); }

/* ── Map ── */
/* ── Map ── */
#map {
  flex: 1;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 300px;
}

/* Leaflet overrides */
.leaflet-control-attribution {
  font-size: 10px !important;
}

/* ── Detail Panel ── */
#detail-panel {
  width: 0;
  background: var(--color-sidebar);
  overflow: hidden;
  flex-shrink: 0;
  border-left: 0 solid transparent;
  transform: translateX(100%);
  transition: transform 0.3s ease, width 0.3s ease, border-left-width 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

#detail-panel.open {
  width: var(--detail-width);
  overflow-y: auto;
  border-left-width: 1px;
  border-left-color: var(--color-border);
  transform: translateX(0);
}

#detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  z-index: 10;
}

#detail-close:hover {
  color: var(--color-text);
}

#detail-content {
  padding: 16px;
  flex: 1;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.detail-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.detail-nummer {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0;
  padding-right: 0;
}

.detail-control-btn {
  flex-shrink: 0;
}

.detail-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.detail-status-badge.einsatzbereit {
  background: rgba(34,197,94,0.15);
  color: var(--color-green);
}

.detail-status-badge.eingeschraenkt {
  background: rgba(234,179,8,0.15);
  color: var(--color-yellow);
}

.detail-status-badge.ausser-betrieb {
  background: rgba(239,68,68,0.15);
  color: var(--color-red);
}

.detail-status-badge.unbekannt {
  background: rgba(148,163,184,0.15);
  color: var(--color-gray);
}

.detail-field {
  margin-bottom: 12px;
}

.detail-field-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.detail-field-value {
  font-size: 0.92rem;
  word-break: break-word;
}

.detail-field-value.empty {
  color: var(--color-text-muted);
  font-style: italic;
}

.detail-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 14px 0;
}

.detail-coords {
  display: flex;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-family: monospace;
}

/* Edit form */
.edit-form {
  display: none;
}

.edit-form.visible {
  display: block;
}

.view-mode {
  display: block;
}

.view-mode.hidden {
  display: none;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 7px 10px;
  background: var(--color-sidebar-light);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--color-primary);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-sidebar-light);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--color-red);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.3);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.kontroll-summary,
.kontroll-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kontroll-history-item {
  background: var(--color-sidebar-light);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.84rem;
}

.kontroll-history-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

#modal-einstellungen .modal-box.modal-box-wide {
  width: min(960px, calc(100vw - 48px));
  height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-tabs {
  flex: 0 0 auto;
  z-index: 4;
  display: flex;
  gap: 2px;
  margin: -2px 0 14px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
  overflow-x: auto;
}

.settings-tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-tab {
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.1px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.settings-tab:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
}

.settings-tab.is-active {
  border-color: rgba(204,34,0,0.25);
  background: linear-gradient(180deg, rgba(204,34,0,0.2), rgba(204,34,0,0.1));
  color: #fff;
  box-shadow: 0 4px 14px rgba(204,34,0,0.18);
}

.settings-tab-radio:checked + .settings-tab {
  border-color: rgba(204,34,0,0.25);
  background: linear-gradient(180deg, rgba(204,34,0,0.2), rgba(204,34,0,0.1));
  color: #fff;
  box-shadow: 0 4px 14px rgba(204,34,0,0.18);
}

.settings-tab:focus-visible {
  outline: 2px solid rgba(248,113,113,0.85);
  outline-offset: 2px;
}

.settings-tab-panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.settings-tab-panel {
  display: none;
  animation: settingsPanelEnter 0.2s ease;
}

.settings-tab-panel.is-active {
  display: block;
}

#settings-tab-system-radio:checked ~ .settings-tab-panels #settings-panel-system,
#settings-tab-admin-radio:checked ~ .settings-tab-panels #settings-panel-admin,
#settings-tab-users-radio:checked ~ .settings-tab-panels #settings-panel-users,
#settings-tab-export-radio:checked ~ .settings-tab-panels #settings-panel-export {
  display: block;
}

#settings-tab-system-radio:checked ~ .settings-tab-panels #settings-panel-system,
#settings-tab-admin-radio:checked ~ .settings-tab-panels #settings-panel-admin,
#settings-tab-users-radio:checked ~ .settings-tab-panels #settings-panel-users,
#settings-tab-export-radio:checked ~ .settings-tab-panels #settings-panel-export {
  display: block;
}

#settings-tab-system-radio:checked ~ .settings-tab-panels #settings-panel-system,
#settings-tab-admin-radio:checked ~ .settings-tab-panels #settings-panel-admin,
#settings-tab-users-radio:checked ~ .settings-tab-panels #settings-panel-users,
#settings-tab-export-radio:checked ~ .settings-tab-panels #settings-panel-export {
  display: block;
}

.settings-tab-panel[hidden] {
  display: none !important;
}

@keyframes settingsPanelEnter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-section {
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 18px;
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}

.settings-section-head {
  margin-bottom: 12px;
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
}

.settings-section-copy {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.settings-admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.system-settings-form {
  margin-top: 10px;
}

.form-hint {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.settings-user-management {
  margin-top: 0;
  padding-top: 18px;
  border-top: none;
}

.user-create-form {
  margin-bottom: 16px;
}

.user-management-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-management-item {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
}

.user-management-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.user-management-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.user-management-meta {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.user-management-grid {
  margin-bottom: 12px;
}

.user-management-wide-field {
  grid-column: 1 / -1;
}

.user-management-actions,
.user-management-create-actions {
  justify-content: flex-end;
}

.user-management-empty {
  border: 1px dashed var(--color-border);
  border-radius: 10px;
  padding: 14px;
  color: var(--color-text-muted);
  text-align: center;
}

.user-fire-units-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.user-fire-units-list .choice-pill {
  border-radius: 10px;
  width: 100%;
  justify-content: flex-start;
  min-height: 40px;
}

.user-fire-units-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  padding: 10px;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.export-section-head {
  margin-bottom: 0;
}

.export-intro-card {
  margin-bottom: 16px;
}

.export-section-copy {
  margin-bottom: 14px;
}

.export-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

.export-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.025));
}

.export-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.export-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.export-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  min-width: 0;
}

.export-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(255,255,255,0.02);
  min-width: 0;
  overflow-wrap: anywhere;
}

.export-option input {
  margin-top: 2px;
}

.export-option:has(input:checked) {
  border-color: rgba(204,34,0,0.45);
  background: rgba(204,34,0,0.08);
}

#modal-einstellungen .modal-box {
  max-height: min(88vh, 900px);
}

#modal-neuer-hydrant .modal-box {
  max-height: 88vh;
  overflow-y: auto;
}

#modal-neuer-hydrant .modal-box.new-hydrant-modal-box {
  width: min(960px, calc(100vw - 48px));
}

.new-hydrant-section {
  margin-bottom: 14px;
}

.new-hydrant-actions {
  justify-content: flex-end;
  padding-top: 4px;
}

.new-hydrant-actions .btn-primary {
  min-width: 210px;
}

.export-hint {
  margin-top: 12px;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.export-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.export-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-xs {
  padding: 5px 9px;
  font-size: 0.76rem;
}

.control-modal-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: -8px;
  margin-bottom: 18px;
}

.control-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-row,
.control-defect-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-sidebar-light);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.86rem;
}

.choice-pill input {
  accent-color: var(--color-primary);
}

.choice-pill-checkbox {
  border-radius: 10px;
}

.control-hint {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.25);
  color: #bfdbfe;
  font-size: 0.84rem;
}

.control-status-modal-box {
  width: min(420px, calc(100vw - 24px));
}

.status-choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.status-choice-btn {
  width: 100%;
  justify-content: center;
  min-height: 44px;
  font-size: 0.92rem;
}

body.auth-required {
  overflow: hidden;
}

body.auth-required #navbar,
body.auth-required #app-layout,
body.auth-required #modal-einstellungen,
body.auth-required #modal-neuer-hydrant,
body.auth-required #control-modal,
body.auth-required #foto-viewer,
body.auth-required #toast-container {
  display: none !important;
}

body.auth-required #login-modal {
  display: flex !important;
  padding: 24px;
  background: linear-gradient(180deg, rgba(15,23,42,0.22), rgba(2,6,23,0.34));
  overflow: hidden;
}

body.auth-required #login-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/UrbanFlowGuard_BG_3.png") center center / contain no-repeat;
  opacity: 0.9;
  transform: scale(1);
}

body.auth-required #login-modal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15,23,42,0.26), rgba(2,6,23,0.46));
}

body.auth-required #login-modal .modal-box {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(10px);
}

body.auth-required #login-modal .modal-close,
body.auth-required #login-cancel-btn {
  display: none;
}

/* ── Login Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 28px 24px;
  width: 340px;
  max-width: 95vw;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.login-copy {
  margin: -8px 0 16px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.login-legal {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
  color: rgba(241, 245, 249, 0.72);
  font-size: 0.72rem;
  line-height: 1.45;
}

.login-legal-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.login-legal-icon {
  width: 1.1em;
  flex: 0 0 1.1em;
  color: rgba(255,255,255,0.92);
}

.alert {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  #modal-einstellungen .modal-box.modal-box-wide {
    width: min(760px, calc(100vw - 32px));
    height: min(90vh, 820px);
  }

  .settings-tabs {
    margin-bottom: 12px;
  }

  .export-layout {
    grid-template-columns: 1fr;
  }

  #modal-neuer-hydrant .modal-box.new-hydrant-modal-box {
    width: min(760px, calc(100vw - 32px));
  }

  .export-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .modal-box {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding: 20px 16px;
  }

  #modal-einstellungen .modal-box.modal-box-wide {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    height: min(92vh, 760px);
  }

  .settings-tabs {
    gap: 6px;
    padding: 4px;
    margin: -2px 0 12px;
  }

  .settings-tab {
    padding: 7px 12px;
    font-size: 0.79rem;
  }

  .settings-section {
    padding: 14px;
  }

  #modal-neuer-hydrant .modal-box.new-hydrant-modal-box {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .settings-admin-actions {
    flex-direction: column;
    padding-left: 0;
  }

  .settings-admin-actions .btn {
    width: 100%;
  }

  .user-management-head {
    flex-direction: column;
  }

  .user-management-actions,
  .user-management-create-actions {
    flex-direction: column;
  }

  .user-management-actions .btn,
  .user-management-create-actions .btn {
    width: 100%;
  }

  .user-fire-units-list {
    grid-template-columns: 1fr;
  }

  .new-hydrant-actions {
    flex-direction: column;
  }

  .new-hydrant-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .export-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .export-actions {
    justify-content: stretch;
  }

  .export-actions .btn {
    width: 100%;
  }

  .export-actions .btn {
    flex: 1;
  }

  body.auth-required #login-modal {
    padding: 16px;
  }

  body.auth-required #login-modal .modal-box {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding: 24px 18px;
  }

  body.auth-required #login-modal::before {
    background-size: cover;
    background-position: center center;
  }
}

.alert-danger {
  background: rgba(239,68,68,0.15);
  color: var(--color-red);
  border: 1px solid rgba(239,68,68,0.3);
}

/* ── Map controls overlay ── */
#map-controls {
  position: absolute;
  bottom: 30px;
  right: 10px;
  z-index: 500;
}

.map-controls-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-ctrl-toggle {
  display: none;
}

.map-ctrl-toggle::-webkit-details-marker {
  display: none;
}

.map-ctrl-toggle::marker {
  content: '';
}

.map-ctrl-btn {
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: background 0.2s;
}

.map-ctrl-btn:hover {
  background: var(--color-sidebar-light);
}

/* ── Leaflet custom markers ── */
.hydrant-marker {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.15s;
}

.hydrant-marker:hover {
  transform: scale(1.3);
  z-index: 1000 !important;
}

.hydrant-marker.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.5), 0 2px 8px rgba(0,0,0,0.6);
  transform: scale(1.4);
  z-index: 999 !important;
}

.hydrant-marker.street-selected {
  border-color: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245,158,11,0.35), 0 2px 8px rgba(0,0,0,0.55);
  transform: scale(1.35);
  z-index: 998 !important;
}

.hydrant-marker.street-selected.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.6), 0 0 0 7px rgba(245,158,11,0.35), 0 2px 8px rgba(0,0,0,0.6);
}

.hydrant-marker.address-target {
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.55), 0 0 0 9px rgba(96,165,250,0.28), 0 2px 10px rgba(0,0,0,0.65);
  transform: scale(1.55);
  z-index: 1001 !important;
}

.hydrant-marker.address-near {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.35), 0 2px 8px rgba(0,0,0,0.6);
  transform: scale(1.42);
  z-index: 999 !important;
}

.hausnummer-spot-ring {
  animation: hausnummerPulse 1.8s ease-out infinite;
}

.hausnummer-spot-marker {
  filter: drop-shadow(0 0 8px rgba(56,189,248,0.75));
}

.hausnummer-spot-label {
  background: rgba(2, 6, 23, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(2, 6, 23, 0.45);
}

@keyframes hausnummerPulse {
  0% {
    stroke-opacity: 0.9;
    fill-opacity: 0.2;
  }
  100% {
    stroke-opacity: 0.2;
    fill-opacity: 0.02;
  }
}

/* Marker cluster */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: none !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(30,41,59,0.9) !important;
  border: 2px solid #475569 !important;
  color: #f1f5f9 !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease;
}

.toast.success {
  border-color: var(--color-green);
  color: var(--color-green);
}

.toast.error {
  border-color: var(--color-red);
  color: var(--color-red);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Foto-Galerie ── */
.foto-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.foto-thumb {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
}

.foto-add-btn {
  aspect-ratio: 1;
  background: var(--color-sidebar-light);
  border: 2px dashed var(--color-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  transition: border-color 0.2s;
}

.foto-add-btn:hover {
  border-color: var(--color-text-muted);
}

/* ── Responsive (mobile) ── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
    --detail-width: 100%;
    --navbar-height: var(--navbar-height-mobile);
  }

  #navbar {
    height: auto;
    min-height: var(--navbar-height);
    padding: 8px 12px 10px;
    gap: 8px;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: center;
  }

  #navbar .brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  #btn-nav-menu {
    display: flex;
    flex-shrink: 0;
  }

  #nav-actions {
    position: absolute;
    top: calc(100% - 2px);
    right: 12px;
    z-index: 1250;
    display: none;
    min-width: 220px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.96);
    box-shadow: 0 14px 30px rgba(0,0,0,0.35);
    backdrop-filter: blur(10px);
  }

  #navbar.nav-menu-open #nav-actions {
    display: flex;
  }

  #nav-actions .nav-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
  }

  #user-info {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #user-name {
    display: block !important;
    padding: 2px 4px 6px;
    color: rgba(255,255,255,0.72);
    font-size: 0.8rem;
  }

  #user-name:empty {
    display: none !important;
  }

  #filter-panel {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    z-index: 900;
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    border-right: none;
    box-shadow: 4px 0 16px rgba(0,0,0,0.5);
  }

  #filter-panel.open-mobile {
    transform: translateX(0);
  }

  #detail-panel {
    position: fixed;
    top: var(--navbar-height);
    right: 0;
    bottom: 0;
    width: 100% !important;
    z-index: 900;
  }

  #search-wrapper {
    order: 10;
    flex: 1 0 100%;
    width: 100%;
    max-width: none;
  }

  #search-input {
    padding: 8px 36px 8px 12px;
    border-radius: 9px;
    font-size: 0.95rem;
  }

  #search-suggestions {
    top: calc(100% + 8px);
    max-height: min(40vh, 280px);
    overflow-y: auto;
    border-radius: 12px;
  }

  .search-suggestion {
    align-items: flex-start;
    padding: 12px 14px;
    font-size: 0.96rem;
  }

  .search-suggestion-name {
    white-space: normal;
    line-height: 1.3;
  }

  .search-suggestion-count {
    margin-top: 1px;
  }

  .brand span.brand-text {
    display: inline;
    font-size: 1.05rem;
  }

  #legend.legend-menu {
    left: 8px;
    bottom: 8px;
  }

  #legend > .legend-toggle {
    display: flex;
  }

  #legend > .legend-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    display: none;
    min-width: 124px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.68rem;
    box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  }

  #legend[open] > .legend-panel {
    display: block;
  }

  .legend-title {
    margin-bottom: 4px;
    font-size: 0.62rem;
    letter-spacing: 0.3px;
  }

  .legend-item {
    gap: 6px;
    padding: 1px 0;
  }

  .legend-dot {
    width: 8px;
    height: 8px;
    border-width: 1px;
  }

  #map-controls {
    bottom: 8px;
    right: 8px;
    width: var(--map-controls-mobile-width, auto);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }

  .map-ctrl-toggle {
    display: flex;
    width: 100%;
  }

  .map-controls-list {
    display: none;
    width: 100%;
    gap: 4px;
  }

  .map-controls-list .map-ctrl-btn {
    width: 100%;
  }

  #map-controls[open] .map-controls-list {
    display: flex;
    margin-top: 0;
  }

  .map-ctrl-btn {
    padding: 6px 8px;
    border-radius: 5px;
    font-size: 0.74rem;
    gap: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  }

  .control-dialog-grid {
    grid-template-columns: 1fr;
  }

  #modal-einstellungen .modal-box.modal-box-wide {
    width: 95vw;
  }
}

@media (min-width: 769px) {
  #map-controls > .map-ctrl-toggle {
    display: none !important;
  }

  .map-controls-list {
    display: flex;
    gap: 6px;
    margin-top: 0;
  }

  #map-controls {
    display: block;
    bottom: 30px;
    right: 10px;
  }

  .map-ctrl-btn {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  }

  #filter-panel {
    transform: none !important;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

/* ── Leaflet popup override ── */
.leaflet-popup-content-wrapper {
  background: var(--color-sidebar) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip {
  background: var(--color-sidebar) !important;
}

.leaflet-popup-content {
  margin: 10px 14px !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
}

.popup-nummer {
  font-weight: 700;
  font-size: 1rem;
}

.popup-info {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* ── Legend ── */
#legend {
  position: absolute;
  bottom: 30px;
  left: 10px;
  z-index: 500;
}

.legend-toggle {
  display: none;
}

.legend-toggle::-webkit-details-marker {
  display: none;
}

.legend-toggle::marker {
  content: '';
}

.legend-panel {
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-size: 0.78rem;
}

.legend-title {
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.7rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
}

/* ── Loading overlay ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: #0f172a;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.5s ease;
}

#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Foto viewer modal */
#foto-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
}

#foto-viewer.open {
  display: flex;
}

#foto-viewer img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
  object-fit: contain;
}

#foto-viewer-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

/* No-results hint */
#no-results {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
  z-index: 400;
  display: none;
  pointer-events: none;
}

#no-results.visible {
  display: block;
}

#no-results p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
