/* ============================================================
   DRKTrack v2 — Dark dispatcher theme
   Inspired by professional German emergency dispatch systems
   ============================================================ */

:root {
  --color-bg:            #13131f;
  --color-sidebar:       #1c1c2e;
  --color-sidebar-hover: #252538;
  --color-header:        #252538;
  --color-border:        #2e2e48;
  --color-text:          #e0e0f0;
  --color-text-muted:    #7878a0;
  --color-accent:        #4ecdc4;   /* teal — map highlights, active items */
  --color-alert:         #c0392b;   /* red — notifications, DRK brand */
  --color-alert-bg:      #3b0f0a;
  --color-online:        #2ecc71;
  --color-offline:       #555570;
  --color-popup-bg:      #1e1e32;
  --color-bg-panel:      #1e1e32;
  --sidebar-width:       300px;    /* right sidebar */
  --nav-left-width:      220px;    /* left navigation menu — updated by nav.js on collapse */
  --topbar-height:       0px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ---- Map ---- */

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ---- Search bar (top-left, floats over map) ---- */

.search-bar {
  position: absolute;
  top: 12px;
  left: calc(var(--nav-left-width) + 12px);
  z-index: 100;
  /* Smoothly follows the nav when it expands/collapses */
  transition: left 0.2s ease;
  display: flex;
  align-items: center;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 6px 10px;
  gap: 8px;
  width: 260px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 13px;
  flex: 1;
}

.search-bar input::placeholder {
  color: var(--color-text-muted);
}

.search-bar .search-icon {
  color: var(--color-text-muted);
  font-size: 15px;
}

.geocode-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  overflow: hidden;
  z-index: 200;
}

.geocode-item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--color-text);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.geocode-item:last-child { border-bottom: none; }

.geocode-item:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-accent);
}


/* ---- Clock (bottom-right, floats over map) ---- */

.clock {
  position: absolute;
  bottom: 24px;
  right: calc(var(--sidebar-width) + 12px);
  z-index: 100;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  transition: right 0.2s ease;
}


/* ---- Bottom bar ---- */

.bottom-bar {
  position: absolute;
  bottom: 0;
  left: var(--nav-left-width);
  right: var(--sidebar-width);
  z-index: 100;
  /* Smoothly follows both nav collapse (left) and sidebar collapse (right) */
  transition: left 0.2s ease, right 0.2s ease;
  height: 36px;
  background: var(--color-sidebar);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
}

.bottom-bar-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.1s;
}

.bottom-bar-btn:hover {
  background: var(--color-sidebar-hover);
}

.bottom-bar-btn.active {
  background: var(--color-alert);
  border-color: var(--color-alert);
}

/* ---- Inline create forms ---- */

.inline-form-trigger {
  background: none;
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
}

.inline-form-trigger:hover,
.inline-form-trigger.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.inline-form-trigger.small {
  padding: 3px 8px;
  font-size: 11px;
  width: auto;
}

.inline-form {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inline-input {
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  color: var(--color-text);
  padding: 6px 9px;
  font-size: 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.inline-input:focus {
  border-color: var(--color-accent);
}

.inline-input::placeholder {
  color: var(--color-text-muted);
}

.inline-submit {
  background: var(--color-alert);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  align-self: flex-end;
}

.inline-submit:hover    { opacity: 0.85; }
.inline-submit:disabled { opacity: 0.4; cursor: not-allowed; }


/* ---- Event filter block (between header and nav sections) ---- */

.nav-event-filter {
  border-bottom: 1px solid var(--color-border);
  padding: 6px 0 8px;
  flex-shrink: 0;
}

.nav-event-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 14px 5px;
}

.nav-event-filter-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.nav-event-new-btn {
  background: var(--color-online);
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.nav-event-new-btn:hover { opacity: 0.8; }

/* Dropdown trigger button — shows summary of active filter */
.nav-event-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 28px);
  margin: 0 14px;
  padding: 5px 9px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.nav-event-dropdown-btn:hover { background: var(--color-sidebar-hover); }

.nav-event-summary {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-event-chevron {
  font-size: 9px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Checklist panel that opens below the trigger */
.nav-event-dropdown {
  margin-top: 4px;
  border-top: 1px solid var(--color-border);
  padding: 4px 0 2px;
}

.nav-event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 12px;
  color: var(--color-text);
  user-select: none;
}
.nav-event-item:hover { background: var(--color-sidebar-hover); }

.nav-event-check {
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.nav-event-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-event-status {
  font-size: 10px;
  color: var(--color-online);
  flex-shrink: 0;
}

.nav-event-item-ended { opacity: 0.55; }

.nav-event-edit-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s;
}
.nav-event-item:hover .nav-event-edit-btn { opacity: 1; }
.nav-event-edit-btn:hover { color: var(--color-accent); }

.nav-event-empty {
  padding: 4px 14px;
  font-size: 11px;
  color: var(--color-text-muted);
}

/* Hidden in icon-only (collapsed) mode */
.nav-left.collapsed .nav-event-filter { display: none; }


/* ---- Utility ---- */

[x-cloak] { display: none !important; }


/* ════════════════════════════════════════════════════════
   LEFT NAVIGATION SIDEBAR
   Loaded dynamically by nav.js from menu-left.html.
   ════════════════════════════════════════════════════════ */

/*
 * The nav panel sits on the left edge, full height, above the map (z-index 200).
 * display: flex + flex-direction: column lets header/user/sections/footer
 * stack vertically, with the sections area growing to fill the space.
 *
 * width uses var(--nav-left-width) which nav.js updates on collapse/expand.
 * The CSS transition on width makes the resize animate smoothly.
 */
.nav-left {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--nav-left-width);
  z-index: 200;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

/* ─ Logo / app branding ─ */

.nav-left-header {
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

/*
 * .nav-header-top holds the logo and the collapse toggle button.
 * justify-content: space-between keeps the button pinned to the right.
 */
.nav-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-left-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* The red DRK cross — uses --color-alert so changing the theme variable updates it everywhere */
.nav-left-logo-icon {
  color: var(--color-alert);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  flex-shrink: 0;
}

.nav-left-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-text);
}

.nav-left-version {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 4px;
  padding-left: 32px;  /* aligns under the logo text, past the icon */
}

/* ─ Collapse toggle button ─ */

.nav-collapse-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 3px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.15s;
}

.nav-collapse-btn:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

/* ─ Logged-in user strip ─ */

.nav-left-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* Circle avatar showing the first letter of the username */
.nav-left-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-alert);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

/* min-width: 0 is necessary for text-overflow: ellipsis to work inside flex */
.nav-left-user-info {
  min-width: 0;
}

.nav-left-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-left-role {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* ─ Scrollable nav sections area ─ */

.nav-left-sections {
  flex: 1;                /* grows to fill space between user strip and footer */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.nav-left-sections::-webkit-scrollbar       { width: 4px; }
.nav-left-sections::-webkit-scrollbar-track { background: transparent; }
.nav-left-sections::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* Section group label (e.g. "LAGE", "VERWALTUNG") */
.nav-section-label {
  padding: 10px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  user-select: none;
}

/* ─ Individual navigation item ─ */

/*
 * border-left: 3px creates the active highlight stripe.
 * When inactive it's transparent, so all items have the same total width
 * and nothing shifts when an item becomes active.
 */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.12s;
  border-left: 3px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--color-sidebar-hover);
}

.nav-item.active {
  background: rgba(78, 205, 196, 0.08);  /* faint teal wash */
  border-left-color: var(--color-accent);
  color: var(--color-accent);
}

/* Fixed-width icon column keeps labels aligned regardless of icon size */
.nav-item-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}

/* Right-side chevron — dims when inactive, brightens on hover/active */
.nav-item-arrow {
  font-size: 16px;
  color: var(--color-text-muted);
  transition: color 0.12s;
}

.nav-item:hover .nav-item-arrow,
.nav-item.active .nav-item-arrow {
  color: var(--color-text);
}

/* Count badge (e.g. number of active Einsätze) */
.nav-item-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--color-alert);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─ Footer: connection status + logout ─ */

.nav-left-footer {
  border-top: 1px solid var(--color-border);
  padding: 10px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Tiny WebSocket indicator above the logout button */
.nav-left-connection {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.nav-conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-conn-dot.connected    { background: var(--color-online); }
.nav-conn-dot.disconnected { background: var(--color-offline); }

.nav-conn-label {
  font-size: 11px;
  color: var(--color-text-muted);
}

.nav-footer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 3px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-footer-btn:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}


/* ════════════════════════════════════════════════════════
   LEFT NAV — COLLAPSED STATE
   Applied via .nav-left.collapsed (set by Alpine in menu-left.html).
   All rules here narrow the nav to icon-only mode.
   ════════════════════════════════════════════════════════ */

/*
 * In collapsed mode the elements below are hidden entirely.
 * CSS display:none is used (not x-show / opacity) because we want no
 * reserve space left behind — all 52 px of width is just icons.
 */
.nav-left.collapsed .nav-left-logo-text,
.nav-left.collapsed .nav-left-version,
.nav-left.collapsed .nav-left-user-info,
.nav-left.collapsed .nav-item-label,
.nav-left.collapsed .nav-item-arrow,
.nav-left.collapsed .nav-item-badge,
.nav-left.collapsed .nav-section-label,
.nav-left.collapsed .nav-conn-label,
.nav-left.collapsed .nav-footer-label {
  display: none;
}

/* Header: stack logo icon and toggle button vertically when 52 px wide */
.nav-left.collapsed .nav-header-top {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* User strip: show only the avatar, centred */
.nav-left.collapsed .nav-left-user {
  justify-content: center;
  padding: 10px 0;
}

/* Nav items: centre the icon, remove side padding */
.nav-left.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  /* Keep the left border for the active indicator */
}

/* Slightly larger icon in collapsed mode so it's easier to click */
.nav-left.collapsed .nav-item-icon {
  width: auto;
  font-size: 17px;
}

/* Connection row: centre the dot */
.nav-left.collapsed .nav-left-connection {
  justify-content: center;
}

/* Logout button: icon only, centred */
.nav-left.collapsed .nav-footer-btn {
  justify-content: center;
  padding: 7px 0;
}

/* Footer: centre children when in icon-only mode */
.nav-left.collapsed .nav-left-footer {
  padding: 8px 0;
  align-items: center;
}


/* ════════════════════════════════════════════════════════
   EBENEN PANEL — floating map-source + style picker
   Positioned bottom-left, above the MapLibre scale control.
   Follows the nav sidebar width via --nav-left-width.
   ════════════════════════════════════════════════════════ */

.layers-picker {
  position: fixed;
  bottom: 36px;                                     /* above the scale bar */
  left: calc(var(--nav-left-width) + 12px);
  z-index: 150;
  transition: left 0.2s ease;                       /* follows nav collapse */
}

/* The collapsed toggle button — always visible */
.layers-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: background 0.15s;
  white-space: nowrap;
}

.layers-toggle-btn:hover {
  background: var(--color-sidebar-hover);
}

.layers-toggle-icon {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* The expanded picker panel — opens above the toggle button */
.layers-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 230px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

/* Section label inside the panel (e.g. "KARTENQUELLE", "KARTENSTIL") */
.layers-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* ── Source cards ── */

/* Outer grid — stacks groups vertically */
.layers-source-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* One group (e.g. "Vektor" or "OpenStreetMap") */
.layers-source-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Small uppercase label above a group of cards */
.layers-group-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  opacity: 0.7;
}

/* Row of source cards within a group — wraps if many files */
.layers-source-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/*
 * Each source card is a small square with an icon on top and a short
 * label below. Active card gets the accent border.
 */
.layers-source-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 64px;
  min-height: 64px;
  padding: 6px 4px;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  text-align: center;
  color: var(--color-text-muted);
  line-height: 1.2;
  transition: border-color 0.15s, color 0.15s;
  word-break: break-word;
}

.layers-source-card:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.layers-source-card.active {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.layers-source-card.disabled {
  opacity: 0.4;
  cursor: default;
}

.layers-source-icon {
  font-size: 18px;
  line-height: 1;
}

/* ── Theme pills ── */

/* Horizontal row of theme pills */
.layers-theme-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.layers-theme-pill {
  padding: 5px 12px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.layers-theme-pill:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.layers-theme-pill.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #000;
  font-weight: 600;
}


/* ── Layers visibility toggles ──────────────────────────────────────────────── */

.layers-visibility-row {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         5px 0;
  font-size:       12px;
  color:           var(--color-text);
  border-top:      1px solid var(--color-border);
  margin-top:      10px;
}

/* Pill-style toggle switch */
.layers-vis-switch {
  position:   relative;
  width:      34px;
  height:     18px;
  flex-shrink: 0;
}
.layers-vis-switch input { display: none; }
.layers-vis-slider {
  position:          absolute;
  inset:             0;
  background:        var(--color-border);
  border-radius:     9px;
  cursor:            pointer;
  transition:        background 0.2s;
}
.layers-vis-slider::before {
  content:           '';
  position:          absolute;
  width:             12px;
  height:            12px;
  left:              3px;
  top:               3px;
  background:        #fff;
  border-radius:     50%;
  transition:        transform 0.2s;
}
.layers-vis-switch input:checked + .layers-vis-slider {
  background: var(--color-accent);
}
.layers-vis-switch input:checked + .layers-vis-slider::before {
  transform: translateX(16px);
}


/* ── Import buttons (below "Bereiche anzeigen" in Ebenen panel) ──────────────── */
.layers-import-btns {
  display:        flex;
  flex-direction: column;
  gap:            5px;
  margin-top:     8px;
}
.layers-import-btn {
  width:          100%;
  padding:        5px 10px;
  background:     rgba(255,255,255,0.05);
  border:         1px solid var(--color-border);
  border-radius:  5px;
  color:          var(--color-text-muted);
  font-size:      11px;
  text-align:     left;
  cursor:         pointer;
  transition:     background 0.15s, color 0.15s, border-color 0.15s;
}
.layers-import-btn:hover {
  background:   rgba(255,255,255,0.1);
  border-color: var(--color-accent);
  color:        var(--color-text);
}


/* ── POI popup ──────────────────────────────────────────────────────────────── */

/* Override MapLibre's default popup chrome to match the dark theme */
.poi-popup .maplibregl-popup-content {
  background:    var(--color-popup-bg);
  color:         var(--color-text);
  border:        1px solid var(--color-border);
  border-radius: 8px;
  padding:       12px 14px;
  box-shadow:    0 4px 16px rgba(0,0,0,0.6);
  font-family:   inherit;
  font-size:     13px;
  min-width:     180px;
}

.poi-popup .maplibregl-popup-tip {
  border-top-color:    var(--color-popup-bg);
  border-bottom-color: var(--color-popup-bg);
}

.poi-popup .maplibregl-popup-close-button {
  color: var(--color-text-muted);
  font-size: 16px;
  padding: 4px 8px;
}

.poi-popup .maplibregl-popup-close-button:hover {
  color: var(--color-text);
  background: none;
}

.poi-popup-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 2px;
}

.poi-popup-type {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: capitalize;
  margin-bottom: 8px;
}

.poi-popup-details {
  margin-top: 6px;
  border-top: 1px solid var(--color-border);
  padding-top: 6px;
}

.poi-detail-row {
  font-size: 12px;
  color: var(--color-text);
  margin-bottom: 4px;
  line-height: 1.4;
  word-break: break-word;
}

.poi-detail-row a {
  color: var(--color-accent);
  text-decoration: none;
}

.poi-detail-row a:hover {
  text-decoration: underline;
}

.poi-detail-loading,
.poi-detail-none {
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
}



.modal-error {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(220, 50, 50, 0.12);
  border: 1px solid rgba(220, 50, 50, 0.35);
  border-radius: 4px;
  color: #e55;
  font-size: 12px;
}


/* ── Map crosshair ───────────────────────────────────────────────────────────── */

.map-crosshair {
  width: 22px;
  height: 22px;
  position: relative;
  pointer-events: none;
}
.map-crosshair::before {          /* horizontal arm */
  content: '';
  position: absolute;
  width: 22px; height: 2px;
  top: 10px; left: 0;
  background: #e74c3c;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.55);
}
.map-crosshair::after {           /* vertical arm */
  content: '';
  position: absolute;
  width: 2px; height: 22px;
  top: 0; left: 10px;
  background: #e74c3c;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.55);
}


/* ── Map context panel ───────────────────────────────────────────────────────── */

.map-context-panel {
  position: fixed;
  z-index: 2000;
  background: var(--color-bg-panel, #1e1e32);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55);
  width: 252px;
  overflow: hidden;
  font-size: 12px;
  color: var(--color-text);
  transition: width 0.15s ease;
}
.map-context-panel--wide { width: 430px; }

.ctx-drag-handle {
  height: 14px;
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid var(--color-border);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--color-text-muted);
  user-select: none;
  letter-spacing: 2px;
}
.ctx-drag-handle:active { cursor: grabbing; }

.ctx-coords {
  padding: 7px 12px;
  font-size: 10px;
  font-family: monospace;
  color: var(--color-text-muted);
  background: rgba(0,0,0,0.12);
  border-bottom: 1px solid var(--color-border);
  letter-spacing: 0.03em;
}

.ctx-action-btn {
  display: block;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.ctx-action-btn:hover { background: rgba(255,255,255,0.06); }
.ctx-action-disabled { color: var(--color-text-muted); cursor: default; }
.ctx-action-disabled:hover { background: none; }

.ctx-close-btn {
  display: block;
  width: 100%;
  padding: 7px 14px;
  text-align: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.ctx-close-btn:hover { color: var(--color-text); }

/* Mission form inside context panel */
.ctx-form-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 11px;
}
.ctx-form-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctx-header-label {
  font-size: 9px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 4px;
}
/* Small kat dot for use in the header and collapsed patient summary */
.ctx-kat-sm {
  width: 14px !important;
  height: 14px !important;
  border-radius: 2px !important;
  flex-shrink: 0;
}
/* Collapsed patient preview row */
.patient-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  flex: 1;
  min-width: 0;
}
.patient-triage-square {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  flex-shrink: 0;
}
.patient-triage-square[data-kat="white"]  { background: #ccc; }
.patient-triage-square[data-kat="green"]  { background: #27ae60; }
.patient-triage-square[data-kat="yellow"] { background: #f39c12; }
.patient-triage-square[data-kat="red"]    { background: #e74c3c; }
.patient-triage-square[data-kat="black"]  { background: #2c2c2c; }
/* Generic small icon buttons in the header */
.ctx-hdr-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
  border-radius: 3px;
  transition: background 0.1s, color 0.1s;
}
.ctx-hdr-btn:hover          { background: rgba(255,255,255,0.08); }
.ctx-close-btn-sm           { color: var(--color-text-muted); }
.ctx-close-btn-sm:hover     { color: var(--color-text); }
.ctx-save-btn               { color: var(--color-accent); }
.ctx-save-btn:hover         { background: rgba(91,192,222,0.15); }
.ctx-delete-btn             { color: #e74c3c; }
.ctx-delete-btn:hover       { background: rgba(231,76,60,0.15); }

/* Event chip in the form header — replaces the old <select> */
.ctx-event-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-size: 11px;
  overflow: hidden;
}
.ctx-event-chip-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctx-pen-btn {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 10px;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.1s;
}
.ctx-pen-btn:hover { color: var(--color-accent); }

/* Pick-event interstitial — shown when user right-clicks with no single event active */
.ctx-pick-title {
  padding: 8px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.ctx-pick-event-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.ctx-pick-event-btn:hover { background: rgba(255,255,255,0.06); }
.ctx-pick-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

.ctx-back-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.ctx-back-btn:hover { color: var(--color-text); }

/* Collapsible section header (Einsatzkräfte) */
.ctx-collapsible-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}
.ctx-collapsible-header:hover { background: rgba(255,255,255,0.04); }
.ctx-collapsible-summary {
  flex: 1;
  color: var(--color-text);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctx-collapsible-chevron { font-size: 8px; flex-shrink: 0; }

.ctx-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.ctx-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 7px 12px;
  background: rgba(255,255,255,0.05);
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
}
.ctx-input:focus { border-bottom-color: var(--color-accent); }

.ctx-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  background: #1e1e32;
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 12px;
  appearance: none;
  cursor: pointer;
  outline: none;
}
.ctx-select option {
  background: #1e1e32;
  color: var(--color-text);
}

/* Einsatzkräfte checklist */
.ctx-device-list {
  max-height: 120px;
  overflow-y: auto;
  border-bottom: 1px solid var(--color-border);
}
.ctx-device-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ctx-device-item:hover { background: rgba(255,255,255,0.05); }
.ctx-device-item-sel   { background: rgba(91,192,222,0.1); }
.ctx-device-check { font-size: 13px; flex-shrink: 0; color: var(--color-accent); }
.ctx-device-name  { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-device-meta  { display: flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--color-text-muted); font-size: 10px; }
.ctx-device-status {
  padding: 1px 4px;
  border-radius: 3px;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

/* Kategorie triage colour picker (standalone row — kept for possible reuse) */
.ctx-kategorie-row {
  display: flex;
  gap: 8px;
  padding: 6px 12px 6px;
  border-bottom: 1px solid var(--color-border);
}
.ctx-kat-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.ctx-kat-btn[data-kat="white"]  { background: #f0f0f0; }
.ctx-kat-btn[data-kat="green"]  { background: #27ae60; }
.ctx-kat-btn[data-kat="yellow"] { background: #f39c12; }
.ctx-kat-btn[data-kat="red"]    { background: #e74c3c; }
.ctx-kat-btn.kat-active {
  border-color: var(--color-accent);
  transform: scale(1.18);
}

.ctx-error { margin: 6px 12px 0; padding: 5px 8px; }

.ctx-form-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px 10px;
}
.ctx-btn-cancel {
  flex: 1;
  padding: 6px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.ctx-btn-submit {
  flex: 2;
  padding: 6px;
  background: var(--color-accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.ctx-btn-submit:disabled { opacity: 0.4; cursor: default; }


/* ── Mission map markers ─────────────────────────────────────────────────────── */

.mission-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.mission-marker-flag {
  padding: 3px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(0,0,0,0.22);
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
}
.mission-marker-stem {
  width: 2px;
  height: 7px;
  background: rgba(0,0,0,0.45);
}
.mission-badge-row {
  display:         flex;
  gap:             3px;
  justify-content: center;
  padding-top:     4px;
}
.mission-badge {
  min-width:     16px;
  height:        16px;
  padding:       0 4px;
  border-radius: 3px;
  font-size:     10px;
  font-weight:   700;
  line-height:   16px;
  text-align:    center;
  box-shadow:    0 1px 2px rgba(0,0,0,0.3);
}

.mission-resource-row {
  padding-top:   3px;
  font-size:     9px;
  font-weight:   500;
  opacity:       0.82;
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}




/* ── Patients section ────────────────────────────────────────────────────────── */

.mission-patients-section {
  padding: 8px 12px 10px;
}
.mission-patients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.patient-symptoms-preview {
  font-size: 10px;
  opacity: .6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.patient-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  margin-bottom: 6px;
  overflow: hidden;
}
.patient-header-clickable { cursor: pointer; }
.patient-header-clickable:hover { background: rgba(255,255,255,0.03); }
.patient-collapse-chevron {
  font-size: 8px;
  color: var(--color-text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

.patient-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-bottom: 1px solid var(--color-border);
}
.patient-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.patient-triage-buttons {
  display: flex;
  gap: 5px;
}
.patient-kat-btn {
  width: 20px !important;
  height: 20px !important;
}

.patient-symptoms-input {
  border-bottom: 1px solid var(--color-border) !important;
  border-radius: 0 !important;
  font-size: 11px;
}

/* ── Patient location status ── */
.patient-status-row {
  display: flex;
  border-top: 1px solid var(--color-border);
}
.patient-status-btn {
  flex: 1;
  padding: 4px 2px;
  background: none;
  border: none;
  border-right: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.patient-status-btn:last-child { border-right: none; }
.patient-status-btn:hover { background: rgba(255,255,255,0.05); color: var(--color-text); }
.patient-status-active { background: rgba(91,192,222,0.15) !important; color: var(--color-accent) !important; font-weight: 600; }

.patient-destination-row {
  display: flex;
  border-top: 1px solid var(--color-border);
  background: rgba(0,0,0,0.1);
}
.patient-dest-btn {
  flex: 1;
  padding: 3px 4px;
  background: none;
  border: none;
  border-right: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.patient-dest-btn:last-child { border-right: none; }
.patient-dest-btn:hover { background: rgba(255,255,255,0.05); }
.patient-dest-active { color: #27ae60 !important; font-weight: 600; }

.patient-care-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-top: 1px solid var(--color-border);
  background: rgba(0,0,0,0.08);
}
.patient-care-label {
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.patient-care-select {
  flex: 1;
  background: var(--color-bg-secondary, #1e2229);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 4px;
  cursor: pointer;
}
.patient-care-select:focus { outline: 1px solid var(--color-accent); }

.ctx-device-item-disabled { opacity: 0.45; cursor: default; }
.ctx-device-item-disabled:hover { background: none; }

.mx-res-release-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 2px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
}
.mx-res-release-btn:hover { color: var(--color-alert); background: rgba(231,76,60,0.12); }

/* ── Treatment tags ── */
.patient-treatments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px 8px;
  border-top: 1px solid var(--color-border);
}
.treatment-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.treatment-tag-code {
  background: rgba(91,192,222,0.18);
  color: var(--color-accent);
  border: 1px solid rgba(91,192,222,0.35);
}
.treatment-tag-free {
  background: rgba(255,255,255,0.08);
  color: var(--color-text-muted);
  border: 1px solid rgba(255,255,255,0.12);
}

/* ── Add-treatment area ── */
.patient-treatment-add {
  border-top: 1px solid var(--color-border);
  padding: 5px 8px;
}
.treatment-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 5px;
}
.treatment-preset-btn {
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px dashed rgba(91,192,222,0.4);
  background: none;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.treatment-preset-btn:hover {
  background: rgba(91,192,222,0.12);
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.treatment-free-row {
  display: flex;
  gap: 4px;
}
.treatment-free-input {
  flex: 1;
  font-size: 10px !important;
  padding: 3px 6px !important;
}

.btn-add-patient {
  display: block;
  width: 100%;
  padding: 6px;
  margin-top: 2px;
  background: rgba(78,205,196,0.1);
  border: 1px dashed var(--color-accent);
  border-radius: 4px;
  color: var(--color-accent);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-add-patient:hover { background: rgba(78,205,196,0.18); }
.btn-add-patient:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-add-patient:disabled:hover { background: rgba(78,205,196,0.1); }

.mx-action-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}
.mx-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.mx-save-btn {
  background: none;
  border: 1.5px solid var(--color-accent);
  color: var(--color-accent);
}
.mx-save-btn:hover { background: var(--color-accent); color: #fff; }
.mx-finish-btn {
  background: #27ae60;
  border: 1.5px solid #27ae60;
  color: #fff;
}
.mx-finish-btn:hover { background: #2ecc71; border-color: #2ecc71; }

.patient-ctx-delete-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.1s;
}
.patient-ctx-delete-btn:hover { color: #ff2222; }





/* ── Force flag markers ──────────────────────────────────────────────────────
   Each device gets a rectangular flag label on the map.
   When multiple devices are within 50 px of each other they are stacked
   inside one .force-cluster wrapper and share a single MapLibre Marker.
   ──────────────────────────────────────────────────────────────────────────── */

/*
 * Force flag markers
 * ──────────────────
 * .force-cluster is the MapLibre marker element (anchor: bottom-left).
 * Its bottom-left corner is cemented to the geographic coordinate every frame.
 *
 * Layout (top → bottom inside .force-cluster):
 *   .force-flags   — the flag label rows
 *   .force-pin     — short stem + dot; REAL DOM element so getBoundingClientRect
 *                    includes it in the height MapLibre uses for translate(0,-100%)
 *
 * Using real child elements (not ::before/::after pseudo-elements) is critical:
 * pseudo-elements that overflow outside the box are NOT counted by
 * getBoundingClientRect, which breaks MapLibre's anchor calculation and causes
 * the marker to drift during zoom.
 */

.force-cluster {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  cursor: default;
}

.force-flags {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

/* Stem + dot — last child, bottom edge = the map coordinate */
.force-pin {
  position: relative;
  width: 2px;
  height: 10px;
  background: #1a1a1a;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.7);
  pointer-events: none;
}

/* Dot centred on the coordinate (= bottom edge of .force-pin) */
.force-pin::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  /* bottom: -4px  →  dot bottom is 4px below .force-pin bottom
     dot centre y  =  -4px + 4px  =  0  =  .force-pin bottom  =  coordinate y ✓
     left:  -3px  →  dot left is 3px left of .force-pin left
     dot centre x  =  -3px + 4px  =  +1px  ≈  coordinate x  ✓              */
  bottom: -4px;
  left: -3px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1a1a1a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.55);
}

.force-flag {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 5px rgba(0,0,0,0.55);
  white-space: nowrap;
  cursor: pointer;
  transition: filter 0.15s;
}

.force-flag:hover { filter: brightness(1.15); }

/* Top row: status badge + device name */
.force-flag-row {
  display: inline-flex;
  align-items: stretch;
  height: 20px;
}

.force-flag-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 4px;
  background: #333;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.force-flag-name {
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  line-height: 20px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Bottom strip: linked resource name */
.force-flag-resource {
  padding: 1px 7px 2px;
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  background: rgba(0,0,0,0.28);
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
  letter-spacing: 0.02em;
}





/* ── Draw area UI ──────────────────────────────────────────────────── */

/* Shape picker grid — 3 equal buttons side by side */
.ctx-draw-shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0 4px;
}

.ctx-draw-shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ctx-draw-shape-btn:hover {
  background: var(--color-bg-hover, #2a2a40);
  border-color: #4488ff;
  color: #4488ff;
}

.ctx-draw-shape-icon {
  font-size: 20px;
  line-height: 1;
}

/* Color swatches row */
.ctx-color-swatches {
  display: flex;
  gap: 6px;
  margin: 8px 0 4px;
}

.ctx-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: outline 0.1s, transform 0.1s;
  outline: 2px solid transparent;
  outline-offset: 2px;
  flex-shrink: 0;
}

.ctx-color-swatch-active {
  outline-width: 2px;
  outline-style: solid;
  transform: scale(1.15);
}

/* Hint bar shown at the bottom of the map during drawing */
.draw-hint-bar {
  position: fixed;
  bottom: 38px;          /* sits just above the bottom bar */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 20, 0.82);
  color: #ccd;
  font-size: 12px;
  padding: 6px 18px;
  border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1200;
  backdrop-filter: blur(4px);
}


/* ── Tactical symbol markers ─────────────────────────────────────────────────── */

/* anchor:'center' — the SVG fills the sym.size × sym.size box and its centre
   is the geographic coordinate.  MapLibre adds position:absolute (via the
   .maplibregl-marker class); we must NOT override it with position:relative
   or markers will stack in normal flow and appear at wrong y positions. */
.sym-marker {
  display:    block;
  cursor:     pointer;
  user-select: none;
}
.sym-marker:hover svg {
  filter: brightness(1.25) drop-shadow(0 0 4px currentColor);
}
/* Label sits below the symbol via absolute positioning.
   The explicit height on the element means the label does NOT inflate
   the box dimensions that MapLibre uses for translate(-50%,-50%). */
.sym-label {
  position:       absolute;
  top:            100%;
  left:           50%;
  transform:      translateX(-50%);
  margin-top:     3px;
  font-size:      11px;
  font-weight:    600;
  color:          #fff;
  text-shadow:    0 1px 3px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.7);
  white-space:    nowrap;
  pointer-events: none;
}

/* Symbol picker — search bar */
.sym-search-wrap {
  padding:       6px 10px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sym-search-input {
  display:       block;
  width:         100%;
  box-sizing:    border-box;
  background:    rgba(255,255,255,0.06);
  border:        1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color:         var(--color-text);
  font-size:     12px;
  padding:       5px 8px;
  outline:       none;
}
.sym-search-input::placeholder { color: var(--color-text-muted); }
.sym-search-input:focus { border-color: var(--color-accent); }
.sym-no-results {
  text-align:  center;
  color:       var(--color-text-muted);
  font-size:   12px;
  padding:     20px 0;
}

/* Symbol picker — scrollable grouped container */
.sym-picker-scroll {
  max-height:       380px;
  overflow-y:       scroll;   /* always reserve scrollbar gutter so grid width is stable */
  scrollbar-width:  thin;
  scrollbar-color:  #444 #1a1a1a;
  padding: 0 8px;
}
.sym-picker-group-hdr {
  font-size:        10px;
  font-weight:      700;
  text-transform:   uppercase;
  letter-spacing:   0.07em;
  color:            #888;
  padding:          8px 2px 4px;
  border-bottom:    1px solid #333;
  margin-bottom:    4px;
}
.sym-picker-grid {
  display:          grid;
  grid-template-columns: repeat(6, 1fr);
  gap:              5px;
  padding:          0 0 6px;
}
/* Wrapper makes the star button position relative to each card */
.sym-picker-wrap {
  position: relative;
}
.sym-picker-btn {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  width:          100%;
  padding:        6px 3px 4px;
  background:     rgba(255,255,255,0.05);
  border:         1px solid var(--color-border);
  border-radius:  6px;
  cursor:         pointer;
  color:          var(--color-text);
  line-height:    1;
  transition:     background 0.15s, border-color 0.15s;
}
.sym-picker-btn:hover {
  background:    rgba(255,255,255,0.12);
  border-color:  var(--color-accent);
}
.sym-picker-label {
  font-size:       9px;
  color:           var(--color-text-muted);
  margin-top:      4px;
  text-align:      center;
  line-height:     1.2;
  max-width:       54px;
  overflow:        hidden;
  text-overflow:   ellipsis;
  white-space:     nowrap;
}
/* Star favorite button — visible on hover or when active */
.sym-fav-btn {
  position:   absolute;
  top:        2px;
  right:      2px;
  width:      15px;
  height:     15px;
  font-size:  10px;
  line-height: 15px;
  text-align: center;
  background: none;
  border:     none;
  cursor:     pointer;
  color:      #555;
  padding:    0;
  opacity:    0;
  transition: opacity 0.15s, color 0.15s;
}
.sym-picker-wrap:hover .sym-fav-btn,
.sym-fav-btn.sym-fav-active {
  opacity: 1;
}
.sym-fav-btn.sym-fav-active {
  color: #ffcc00;
}

/* Drag hint text in edit panel */
.sym-drag-hint {
  font-size:  11px;
  color:      var(--color-text-muted);
  text-align: center;
  margin:     6px 0 2px;
}

/* Corner resize handles — shown on marker hover */
.sym-resize-handle {
  position:       absolute;
  width:          14px;
  height:         14px;
  opacity:        0;
  transition:     opacity 0.15s;
  z-index:        10;
}
.sym-marker:hover .sym-resize-handle {
  opacity: 1;
}
.sym-resize-handle::after {
  content:        '';
  position:       absolute;
  width:          7px;
  height:         7px;
  border:         1.5px solid rgba(255,255,255,0.9);
  background:     rgba(0,0,0,0.55);
  border-radius:  1px;
}
.sym-resize-nw { top: -3px;    left: -3px;    cursor: nwse-resize; }
.sym-resize-ne { top: -3px;    right: -3px;   cursor: nesw-resize; }
.sym-resize-sw { bottom: -3px; left: -3px;    cursor: nesw-resize; }
.sym-resize-se { bottom: -3px; right: -3px;   cursor: nwse-resize; }
.sym-resize-nw::after { top: 0;    left: 0; }
.sym-resize-ne::after { top: 0;    right: 0; }
.sym-resize-sw::after { bottom: 0; left: 0; }
.sym-resize-se::after { bottom: 0; right: 0; }


/* ── Custom confirm dialog ───────────────────────────────────────── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirm-in 0.12s ease;
}
.confirm-overlay.confirm-fade-out {
  animation: confirm-out 0.1s ease forwards;
}
@keyframes confirm-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes confirm-out { from { opacity: 1; } to { opacity: 0; } }

.confirm-box {
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px 22px 16px;
  min-width: 260px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(-6px);
  animation: confirm-box-in 0.14s ease forwards;
}
@keyframes confirm-box-in { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.confirm-msg {
  font-size: 13px;
  color: var(--color-text);
  margin: 0 0 16px;
  line-height: 1.5;
}

.confirm-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.confirm-btn {
  padding: 7px 16px;
  border-radius: 4px;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
}
.confirm-btn-cancel {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.confirm-btn-cancel:hover { background: var(--color-border); }
.confirm-btn-ok {
  background: #e74c3c;
  color: #fff;
}
.confirm-btn-ok:hover { background: #c0392b; }
