/* =========================================================
   C2 GIS — design tokens
   ========================================================= */
:root {
  --bg: #070b10;
  --bg-elev: #0c1219;
  --bg-panel: rgba(10, 16, 24, 0.88);
  --bg-panel-solid: #0b121b;
  --bg-input: #0e1620;
  --line: rgba(120, 150, 180, 0.16);
  --line-strong: rgba(140, 175, 205, 0.28);
  --text: #e8eef5;
  --text-2: #93a5b7;
  --text-3: #6b7d90;
  --accent: #3d9fd6;
  --accent-2: #5eead4;
  --ok: #3ecf8e;
  --warn: #e2b44c;
  --bad: #e26d6d;
  --info: #6aa8e0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.28);
  --font: "Segoe UI", Inter, Tahoma, Arial, sans-serif;
  --focus-ring: 0 0 0 3px rgba(61, 159, 214, 0.28);
  --ease: cubic-bezier(.2, .7, .3, 1);
  --topbar-h: 56px;
  --status-h: 30px;
  --sidebar-w: 360px;
  --drawer-w: 380px;
  --z-map: 0;
  --z-chrome: 8;
  --z-side: 12;
  --z-drawer: 20;
  --z-pop: 25;
  --z-modal: 40;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); }
body { font-size: 13px; line-height: 1.45; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted, .hint { color: var(--text-3); font-size: 12px; }

/* =========================================================
   Login
   ========================================================= */
.login-view {
  height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(900px 500px at 70% 0%, rgba(30, 70, 110, 0.35), transparent 60%),
    radial-gradient(700px 400px at 10% 90%, rgba(20, 60, 80, 0.25), transparent 55%),
    var(--bg);
}
.login-card {
  width: 380px; padding: 28px; display: grid; gap: 12px;
  background: var(--bg-panel-solid); border: 1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 4px 0 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { color: var(--text-3); font-size: 12px; margin-bottom: 6px; }
.login-card label { display: grid; gap: 6px; color: var(--text-2); font-size: 12px; }
.login-card input {
  padding: 11px 12px; border: 1px solid var(--line-strong); background: var(--bg-input);
  color: var(--text); border-radius: 10px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61, 159, 214, 0.18); }
.login-error { color: var(--bad); font-size: 12px; min-height: 16px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); background: linear-gradient(160deg, #142433, #0d1722);
  border-radius: 10px; font-weight: 800; font-size: 13px; letter-spacing: 0.04em; color: var(--accent-2);
}
.brand-mark.big { width: 48px; height: 48px; font-size: 16px; margin-bottom: 4px; }
.demo-box { border-top: 1px solid var(--line); padding-top: 10px; color: var(--text-2); font-size: 12px; }
.demo-box summary { cursor: pointer; }
.demo-account { display: flex; justify-content: space-between; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--line); align-items: center; }
.demo-account small { color: var(--text-3); }
.demo-account button {
  border: 1px solid var(--line-strong); background: var(--bg-input); color: var(--text-2);
  border-radius: 8px; padding: 4px 10px; font-size: 11px;
}

/* =========================================================
   Shell
   ========================================================= */
.app-shell { display: grid; grid-template-rows: var(--topbar-h) 1fr var(--status-h); height: 100vh; }

.topbar {
  display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  align-items: center; gap: 12px; padding: 0 14px;
  background: rgba(8, 12, 18, 0.96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); z-index: 15;
}
.topbar * { min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 320px; }
.brand-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-subtitle { margin-top: 2px; color: var(--text-3); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.view-tabs {
  display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line);
  background: var(--bg-elev); border-radius: 10px; justify-self: center;
}
.view-tab {
  border: 0; border-radius: 8px; padding: 7px 16px; background: transparent;
  color: var(--text-2); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
.view-tab:hover { color: var(--text); background: rgba(61, 159, 214, 0.1); }
.view-tab.active { color: #fff; background: #1a3a52; box-shadow: inset 0 0 0 1px rgba(94, 190, 234, 0.35); }
.view-tab:disabled { opacity: 0.35; cursor: not-allowed; }

.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; overflow: hidden; }

.icon-btn {
  height: 32px; min-width: 32px; padding: 0 8px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); background: #121c28; }
.panel-btn {
  height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text-2); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: 0 0 auto;
}
.panel-btn:hover { border-color: var(--line-strong); color: var(--text); }
.panel-btn.primaryish { border-color: rgba(61, 159, 214, 0.45); color: #cfe9fa; background: rgba(26, 58, 82, 0.55); }
.user-chip {
  display: grid; gap: 0; padding: 5px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg-elev); font-size: 10.5px; line-height: 1.4; max-width: 220px; flex: 0 0 auto;
}
.user-chip b { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip span { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell-count {
  position: absolute; top: -5px; left: -5px; background: #c44d4d; color: #fff;
  border-radius: 999px; font-size: 9px; padding: 0 5px; min-width: 14px; text-align: center;
}

/* =========================================================
   Workspace / map
   ========================================================= */
.workspace { position: relative; min-height: 0; overflow: hidden; }
.map-column { position: absolute; inset: 0; overflow: hidden; }
.map { position: absolute; inset: 0; z-index: var(--z-map); width: 100%; height: 100%; background: #060a0f; }


/* HUD stack: one flow container — tools row → chips → KPI, no absolute row collisions */
.map-hud-stack {
  position: absolute; z-index: var(--z-chrome); top: 12px; left: 12px;
  right: calc(var(--sidebar-w) + 24px);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; transition: left .2s ease;
}
.map-hud-stack > * { pointer-events: auto; }


/* KPI overlay — third flow row under chips */
.kpi-overlay {
  position: relative; top: auto; left: auto; right: auto;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; pointer-events: auto;
}
.metric {
  min-height: 72px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-panel); backdrop-filter: blur(14px); box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column; justify-content: center; gap: 2px; text-align: start;
}
.metric b { display: block; font-size: 20px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; }
.metric b.ok { color: var(--ok); } .metric b.warn { color: var(--warn); } .metric b.bad { color: var(--bad); }
.metric > span:not(.metric-ico) { color: var(--text-2); font-size: 11px; }
.metric-ico { color: var(--text-3); margin-bottom: 2px; display: block; }
.metric-note { display: block; margin-top: 2px; color: var(--text-3); font-size: 10px; font-style: normal; }
.delta { display: inline-block; margin-inline-start: 4px; font-size: 10px; font-style: normal; font-weight: 700; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }


/* layer chips — second flow row under top HUD, never under tools/draw */
.map-chips {
  position: relative; top: auto; left: auto; right: auto;
  display: flex; flex-wrap: wrap; gap: 6px; pointer-events: auto;
}
.map-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--bg-panel);
  color: var(--text-2); font-size: 11px; font-weight: 600; backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}
.map-chip:hover { border-color: var(--line-strong); color: var(--text); }
.map-chip.on { border-color: rgba(61, 159, 214, 0.5); background: rgba(26, 58, 82, 0.75); color: #e8f4fc; }
.map-chip .chip-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.map-chip .chip-count { opacity: 0.7; font-weight: 700; font-size: 10px; }



.layer-count {
  margin-inline-start: auto; color: var(--text-2); font-size: 10px; font-weight: 700; min-width: 20px;
  text-align: center; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
.opacity-row { display: grid; gap: 6px; color: var(--text-2); font-size: 11px; }
.opacity-row input[type="range"] { width: 100%; accent-color: var(--accent); }


/* annotate CTA — same slot as draw tools (mutually exclusive by view) */
.annotate-cta {
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid rgba(61, 159, 214, 0.45); background: rgba(20, 42, 60, 0.92); color: #dcecf8;
  font-size: 12px; font-weight: 600; box-shadow: var(--shadow-soft); display: inline-flex; align-items: center; gap: 7px;
}
.annotate-cta:hover { background: rgba(30, 62, 88, 0.95); }


/* =========================================================
   Sidebar (floating glass)
   ========================================================= */
.sidebar {
  position: absolute; z-index: var(--z-side); top: 12px; right: 12px; bottom: 12px; width: var(--sidebar-w);
  overflow-y: auto; overflow-x: hidden; padding: 14px 14px 22px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--bg-panel); backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: var(--shadow); opacity: 0.78;
  transition: opacity .18s ease, background .18s ease, box-shadow .18s ease, transform .22s ease;
  scrollbar-width: thin; scrollbar-color: #2a3d50 transparent;
}
.sidebar:hover, .sidebar:focus-within {
  opacity: 1; background: rgba(9, 14, 21, 0.97); box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.sidebar.collapsed { transform: translateX(calc(100% + 28px)); opacity: 0; pointer-events: none; }
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.side-title { min-width: 0; }
.sidebar h3 { margin: 4px 0 0; font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.eyebrow { color: var(--text-3); font-size: 9.5px; letter-spacing: 0.16em; font-weight: 800; direction: ltr; text-align: start; }
.ghost { background: transparent; border-color: transparent; color: var(--text-3); }
.ghost:hover { background: var(--bg-elev); border-color: var(--line); color: var(--text); }
.side-open {
  position: absolute; z-index: var(--z-side); top: 14px; right: 14px; height: 36px; width: 36px;
  display: grid; place-items: center; border: 1px solid var(--line-strong);
  background: var(--bg-panel); color: var(--text-2); border-radius: 10px; backdrop-filter: blur(12px);
}
.side-open:hover { background: #142030; color: var(--text); }

/* segmented tabs */
.seg-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; margin: 10px 0 4px;
  border: 1px solid var(--line); background: rgba(12, 18, 26, 0.7); border-radius: 10px;
}
.seg-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 0; border-radius: 7px; padding: 8px 6px; background: transparent; color: var(--text-2);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; position: relative;
}
.seg-tab:hover { color: var(--text); }
.seg-tab.active { background: #1a3a52; color: #fff; box-shadow: inset 0 0 0 1px rgba(94, 190, 234, 0.3); }
.seg-tab .seg-count {
  position: absolute; top: -5px; left: -4px; min-width: 16px; padding: 0 4px; border-radius: 999px;
  background: #c44d4d; color: #fff; font-size: 9px; line-height: 14px; text-align: center;
}
.seg-body { padding-top: 4px; }

.section-title {
  margin: 16px 0 8px; color: var(--text-3); font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em;
}
.section-title:first-child { margin-top: 4px; }

.layer-row {
  display: flex; justify-content: space-between; align-items: center; margin: 4px 0;
  color: var(--text); font-size: 12.5px; padding: 6px 8px; border-radius: 8px;
}
.layer-row:hover { background: rgba(255,255,255,0.03); }
.layer-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.layer-row input { accent-color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

.filter-grid { display: grid; gap: 8px; }
.filter-grid label { display: grid; gap: 5px; color: var(--text-2); font-size: 11px; }
.filter-grid select {
  padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--bg-input); color: var(--text); outline: none;
}
.filter-grid select:focus { border-color: var(--accent); }
.switch-row {
  display: flex !important; grid-auto-flow: column; align-items: center; justify-start;
  gap: 7px; color: var(--warn); font-size: 11.5px; margin-top: 4px;
}
.switch-row input { accent-color: var(--warn); }

.queue-block { margin-top: 10px; padding-top: 2px; border-top: 1px solid var(--line); }
.queue { display: grid; gap: 6px; margin-top: 8px; }
.queue-item {
  padding: 10px; border: 1px solid var(--line); background: rgba(12, 18, 28, 0.8);
  border-radius: 10px; font-size: 12px;
}
.queue-item-head { display: flex; justify-content: space-between; gap: 8px; }
.queue-item small { color: var(--text-3); }
.queue-item-actions { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.queue-item-actions button { padding: 5px 9px; font-size: 10.5px; }
.queue-note {
  margin-top: 6px; padding: 7px 9px; border-inline-start: 2px solid var(--warn);
  background: rgba(226, 180, 76, 0.08); color: #e0c98a; border-radius: 6px; font-size: 11px; line-height: 1.5;
}

/* =========================================================
   Dashboard sections
   ========================================================= */
.dash-section {
  margin-top: 8px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(11, 17, 26, 0.72); overflow: hidden;
}
.dash-section > summary {
  cursor: pointer; padding: 12px 13px; font-size: 12.5px; font-weight: 700; color: var(--text);
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.dash-section > summary::-webkit-details-marker { display: none; }
.dash-section > summary:hover { background: rgba(255,255,255,0.03); }
.dash-section > summary .count {
  color: var(--text-2); font-weight: 700; min-width: 22px; text-align: center;
  padding: 1px 7px; border-radius: 999px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line); font-size: 10.5px; margin-inline-start: auto;
}
.dash-body { padding: 2px 12px 12px; }
.sec-ico { display: inline-flex; align-items: center; margin-inline-end: 8px; color: var(--accent); opacity: 0.9; vertical-align: middle; }

.summary-text { margin: 0 0 8px; font-size: 12.5px; line-height: 1.75; color: var(--text); }
.notes-list { margin: 0; padding-inline-start: 16px; color: var(--text-2); font-size: 12px; line-height: 1.8; }
.section-caption { margin: 10px 0 4px; color: var(--text-3); font-size: 11px; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  color: var(--text-3); font-weight: 700; text-align: start; padding: 8px 6px;
  border-bottom: 1px solid var(--line); font-size: 10.5px; letter-spacing: 0.03em;
}
.data-table td { padding: 9px 6px; border-bottom: 1px solid rgba(120,150,180,0.08); color: var(--text); line-height: 1.55; vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .num { direction: ltr; text-align: start; }
.data-table tbody tr:nth-child(odd) td { background: rgba(255,255,255,0.015); }

.bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,0.06); overflow: hidden; min-width: 48px; }
.bar > i { display: block; height: 100%; border-radius: 99px; }

.kv {
  display: flex; justify-content: space-between; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid rgba(120,150,180,0.08); font-size: 12px; line-height: 1.5;
}
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-3); }

.alert-row {
  padding: 10px 12px; margin: 6px 0; border: 1px solid rgba(226, 109, 109, 0.3);
  border-inline-start: 3px solid var(--bad); background: rgba(80, 28, 28, 0.35);
  border-radius: 10px; font-size: 12px; line-height: 1.6;
}
.alert-row b { display: block; margin-bottom: 3px; font-weight: 700; }
.alert-row small { color: #c4a09a; }
.alert-row.warn { border-color: rgba(226, 180, 76, 0.3); border-inline-start-color: var(--warn); background: rgba(70, 55, 18, 0.3); }
.alert-row.warn small { color: #cbb88a; }
.alert-row.info { border-color: rgba(106, 168, 224, 0.28); border-inline-start-color: var(--info); background: rgba(24, 48, 72, 0.35); }
.alert-row.info small { color: #9ab4cc; }

.timeline-row { padding: 7px 0; border-bottom: 1px solid rgba(120,150,180,0.08); font-size: 11.5px; }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row small { color: var(--text-3); }
.drill-btn { margin-top: 6px; padding: 5px 10px; font-size: 11px; }
.wide { width: 100%; }
.small { padding: 4px 9px; font-size: 11px; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04); color: var(--text-2); font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.chip.ok { border-color: rgba(62, 207, 142, 0.4); background: rgba(62, 207, 142, 0.12); color: #7ee0b4; }
.chip.warn { border-color: rgba(226, 180, 76, 0.4); background: rgba(226, 180, 76, 0.12); color: #f0d48a; }
.chip.bad { border-color: rgba(226, 109, 109, 0.4); background: rgba(226, 109, 109, 0.12); color: #f0a8a8; }

.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.tile {
  padding: 12px 8px; text-align: center; border: 1px solid var(--line);
  background: rgba(12, 18, 28, 0.7); border-radius: 10px;
}
.tile b { display: block; font-size: 18px; font-weight: 750; letter-spacing: -0.03em; }
.tile b.ok { color: var(--ok); } .tile b.warn { color: var(--warn); } .tile b.bad { color: var(--bad); }
.tile span { color: var(--text-2); font-size: 10.5px; }
.tile small { display: block; margin-top: 3px; color: var(--text-3); font-size: 10px; }
.tile .bar { margin-top: 7px; }

.bar-row { margin: 9px 0; }
.bar-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-2); margin-bottom: 4px; }
.bar-head b { color: var(--text); font-weight: 700; }

.mission-card { display: flex; gap: 14px; align-items: flex-start; }
.mission-ring { flex: 0 0 auto; }
.mission-body { flex: 1; min-width: 0; }
.mission-body h4 { margin: 0 0 6px; font-size: 13.5px; font-weight: 700; }

.directive-row {
  display: flex; gap: 9px; align-items: flex-start; padding: 8px 0;
  border-bottom: 1px solid rgba(120,150,180,0.08); font-size: 12px;
}
.directive-row:last-child { border-bottom: 0; }
.directive-row em {
  flex: 0 0 20px; height: 20px; border-radius: 50%; background: #1a3a52; color: #cfe8fa;
  font-size: 11px; font-style: normal; display: grid; place-items: center; font-weight: 700;
}
.directive-row div { flex: 1; color: var(--text); line-height: 1.6; }

.crew-row {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(120,150,180,0.08); font-size: 12px;
}
.crew-row:last-child { border-bottom: 0; }
.crew-ready { text-align: end; }
.crew-ready b { display: block; font-size: 13px; font-weight: 750; }
.crew-ready b.ok { color: var(--ok); } .crew-ready b.warn { color: var(--warn); } .crew-ready b.bad { color: var(--bad); }

.donut-wrap { display: flex; align-items: center; gap: 14px; }
.donut-box { position: relative; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { display: block; font-size: 20px; font-weight: 750; }
.donut-center span { color: var(--text-3); font-size: 10px; }
.legend { display: grid; gap: 6px; flex: 1; }
.legend-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-2); }
.legend-row b { margin-inline-start: auto; color: var(--text); }

.spark { width: 100%; height: 44px; display: block; }
.spark-labels { display: flex; justify-content: space-between; color: var(--text-3); font-size: 9.5px; margin-top: 2px; }
.donut { display: block; }

/* =========================================================
   Drawer (feature inspector)
   ========================================================= */
.drawer {
  position: absolute; z-index: var(--z-drawer); left: 14px; top: 14px; bottom: 14px; width: var(--drawer-w);
  padding: 0; overflow: auto; border: 1px solid var(--line-strong);
  background: rgba(9, 14, 21, 0.96); border-radius: 16px; box-shadow: var(--shadow);
  backdrop-filter: blur(18px); transform: translateX(calc(-100% - 30px)); transition: transform .2s ease;
  scrollbar-width: thin; scrollbar-color: #2a3d50 transparent;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; padding: 16px 16px 12px; background: linear-gradient(180deg, rgba(12,18,28,0.98), rgba(12,18,28,0.92));
  border-bottom: 1px solid var(--line); border-radius: 16px 16px 0 0;
}
.drawer h2 { margin: 2px 0 0; font-size: 17px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.3; }
.kicker {
  display: inline-flex; align-items: center; gap: 6px; color: var(--accent-2); font-size: 10.5px;
  font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; direction: rtl;
}
.close-btn { border: 0; background: transparent; color: var(--text-3); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 8px; }
.close-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.drawer-hero {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.drawer-hero-ring { position: relative; width: 72px; height: 72px; }
.drawer-hero-meta { min-width: 0; }
.drawer-hero-meta .hero-value { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.drawer-hero-meta .hero-label { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.drawer-hero-meta .hero-sub { color: var(--text-3); font-size: 11px; margin-top: 4px; }

.drawer-body { padding: 8px 16px 18px; }
.drawer-section { margin-top: 14px; }
.drawer-section-title {
  color: var(--text-3); font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.drawer-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.detail-list { border-top: 0; }
.detail-row {
  display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid rgba(120,150,180,0.08); font-size: 12.5px; line-height: 1.5;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row span:first-child { color: var(--text-3); font-size: 11.5px; }
.detail-row span:last-child { color: var(--text); font-weight: 600; text-align: start; word-break: break-word; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04); font-size: 10.5px; font-weight: 700;
}
.badge.draft { border-color: rgba(226, 180, 76, 0.45); background: rgba(226, 180, 76, 0.12); color: #f0d48a; }
.badge.review { border-color: rgba(106, 168, 224, 0.45); background: rgba(106, 168, 224, 0.12); color: #a8cef0; }
.badge.rejected { border-color: rgba(226, 109, 109, 0.45); background: rgba(226, 109, 109, 0.12); color: #f0a8a8; }
.badge.approved { border-color: rgba(62, 207, 142, 0.45); background: rgba(62, 207, 142, 0.12); color: #7ee0b4; }
.badge.archived { border-color: var(--line-strong); background: rgba(255,255,255,0.04); color: var(--text-2); }
.badge.high { border-color: rgba(226, 109, 109, 0.45); background: rgba(226, 109, 109, 0.12); color: #f0a8a8; }
.badge.medium { border-color: rgba(226, 180, 76, 0.45); background: rgba(226, 180, 76, 0.12); color: #f0d48a; }
.badge.low { border-color: rgba(106, 168, 224, 0.4); background: rgba(106, 168, 224, 0.1); color: #a8cef0; }
.badge.active, .badge.open, .badge.monitoring { border-color: rgba(62, 207, 142, 0.4); background: rgba(62, 207, 142, 0.1); color: #7ee0b4; }

.drawer-actions { display: grid; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

/* =========================================================
   Panels / modal / notif / toast / status
   ========================================================= */
.panel-overlay {
  position: absolute; z-index: var(--z-modal); inset: 0; background: rgba(3, 6, 10, 0.62);
  display: flex; justify-content: center; padding: 16px; backdrop-filter: blur(4px);
}
.panel {
  width: min(1100px, 100%); max-height: calc(100% - 6px); display: flex; flex-direction: column;
  border: 1px solid var(--line-strong); background: var(--bg-panel-solid); border-radius: 16px; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 750; }
.panel-body { padding: 16px 20px; overflow: auto; }
.panel-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-tab {
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text-2);
  border-radius: 9px; padding: 7px 13px; font-size: 12px; font-weight: 600;
}
.panel-tab.active { background: #1a3a52; color: #fff; border-color: rgba(94, 190, 234, 0.35); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card {
  border: 1px solid var(--line); background: rgba(12, 18, 28, 0.85); border-radius: 12px;
  padding: 13px; font-size: 12px;
}
.card h4 { margin: 0 0 8px; font-size: 13.5px; font-weight: 700; }
.card .row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.card .row span:first-child { color: var(--text-3); }
.card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  position: sticky; top: 0; background: #101a26; color: var(--text-2); padding: 10px;
  text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 11px;
}
.tbl td { padding: 11px 10px; border-bottom: 1px solid rgba(120,150,180,0.08); color: var(--text); vertical-align: top; line-height: 1.55; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: rgba(255,255,255,0.02); }
.tbl .nowrap { white-space: nowrap; }
.tbl button { padding: 4px 9px; font-size: 11px; margin-inline-end: 4px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.modal-backdrop {
  display: none; position: absolute; z-index: var(--z-modal); inset: 0; align-items: center;
  justify-content: center; background: rgba(3, 6, 10, 0.7); backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 540px; max-width: calc(100% - 30px); max-height: calc(100% - 40px); overflow: auto;
  padding: 20px; border: 1px solid var(--line-strong); background: var(--bg-panel-solid);
  border-radius: 16px; box-shadow: var(--shadow);
}
.modal h3 { margin: 4px 0 14px; font-size: 16px; }
.modal label { display: grid; gap: 6px; margin: 10px 0; color: var(--text-2); font-size: 12px; }
.modal input, .modal textarea, .modal select {
  padding: 10px; border: 1px solid var(--line-strong); background: var(--bg-input);
  color: var(--text); border-radius: 9px; outline: none;
}
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); }
.modal textarea { min-height: 72px; resize: vertical; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1.3fr 0.7fr 0.9fr auto auto; gap: 6px; align-items: center; margin: 6px 0; }
.field-row input, .field-row select { padding: 7px; font-size: 12px; }

.notif-pop {
  position: absolute; z-index: var(--z-pop); right: calc(var(--sidebar-w) + 28px); top: 14px;
  width: 340px; max-height: 420px; overflow: auto; border: 1px solid var(--line-strong);
  background: var(--bg-panel-solid); border-radius: 14px; box-shadow: var(--shadow); padding: 12px;
}
.notif-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.notif-list { display: grid; gap: 7px; }
.notif-item {
  border: 1px solid var(--line); background: rgba(12, 18, 28, 0.85); border-radius: 10px;
  padding: 9px 10px; font-size: 12px; cursor: pointer;
}
.notif-item:hover { border-color: var(--line-strong); }
.notif-item.unread { border-inline-start: 3px solid var(--accent); }
.notif-item b { display: block; margin-bottom: 3px; font-size: 12.5px; }
.notif-item small { color: var(--text-3); }

.toast {
  position: absolute; z-index: 60; left: 50%; bottom: 48px; transform: translate(-50%, 16px);
  opacity: 0; pointer-events: none; padding: 10px 16px; border: 1px solid var(--line-strong);
  background: rgba(14, 24, 36, 0.96); color: var(--text); border-radius: 10px; font-size: 12.5px;
  transition: .18s; max-width: 70%; box-shadow: var(--shadow-soft);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.statusbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px; border-top: 1px solid var(--line);
  background: #080d13; color: var(--text-3); font-size: 10.5px; overflow: hidden; flex-wrap: nowrap; height: var(--status-h);
}
.statusbar > span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.statusbar strong { color: var(--text-2); font-weight: 600; }
.status-ok { color: var(--ok) !important; }
.status-error { color: var(--bad) !important; }
.push { margin-inline-start: auto; }

.primary, .secondary { padding: 9px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 600; }
.primary { border: 1px solid rgba(61, 159, 214, 0.55); background: #1c4a68; color: #fff; }
.primary:hover { background: #235a7c; }
.secondary { border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--text-2); }
.secondary:hover { color: var(--text); border-color: rgba(140,175,205,0.4); }
.danger {
  border: 1px solid rgba(226, 109, 109, 0.45); background: rgba(90, 30, 24, 0.55); color: #f0b0a8;
  padding: 5px 9px; border-radius: 8px; font-size: 11.5px; font-weight: 600;
}

/* =========================================================
   Leaflet theme
   ========================================================= */
.leaflet-container { background: #060a0f; font-family: inherit; font-size: 11px; }
.leaflet-control-attribution {
  background: rgba(8, 12, 18, 0.82) !important; color: var(--text-3) !important; font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-bar a {
  background: rgba(12, 18, 28, 0.92) !important; color: var(--text) !important;
  border-bottom-color: var(--line) !important; width: 32px !important; height: 32px !important; line-height: 32px !important;
}
.leaflet-bar a:hover { background: #162232 !important; }
.leaflet-bar { border: 1px solid var(--line-strong) !important; border-radius: 10px !important; overflow: hidden; box-shadow: var(--shadow-soft); }
.leaflet-control-scale-line {
  background: rgba(8, 12, 18, 0.8); border-color: var(--line-strong); color: var(--text-2);
  border-radius: 4px; font-size: 10px; padding: 2px 6px !important;
}
.leaflet-tooltip.c2-tooltip {
  background: rgba(10, 16, 24, 0.94); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 8px; box-shadow: var(--shadow-soft); direction: rtl; text-align: start;
  padding: 6px 10px; font-size: 12px;
}
.leaflet-tooltip.c2-tooltip::before { display: none; }
.leaflet-tooltip.c2-tooltip .tt-sub { color: var(--text-3); font-size: 10.5px; }
.leaflet-tooltip.c2-tooltip b { font-size: 12px; font-weight: 700; }

/* zone polygons — smooth state changes + glow on hover/select */
.leaflet-overlay-pane path.feat {
  transition:
    stroke-width 0.16s ease,
    stroke 0.16s ease,
    stroke-opacity 0.16s ease,
    fill-opacity 0.18s ease;
}
.leaflet-overlay-pane path.feat-region,
.leaflet-overlay-pane path.feat-sector {
  stroke-linejoin: round;
  stroke-linecap: round;
}
.leaflet-overlay-pane path.feat-region.feat-hover,
.leaflet-overlay-pane path.feat-sector.feat-hover {
  filter: drop-shadow(0 0 4px var(--glow, rgba(127, 184, 232, 0.55)))
          drop-shadow(0 0 10px color-mix(in srgb, var(--glow, #7fb8e8) 40%, transparent));
}
.leaflet-overlay-pane path.feat-selected {
  animation: feat-selected-pulse 1.7s ease-in-out infinite;
}
@keyframes feat-selected-pulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 5px rgba(255, 255, 255, 0.45))
      drop-shadow(0 0 12px var(--glow, rgba(127, 184, 232, 0.4)));
  }
  50% {
    filter:
      drop-shadow(0 0 9px rgba(255, 255, 255, 0.7))
      drop-shadow(0 0 20px var(--glow, rgba(127, 184, 232, 0.65)));
  }
}

/* permanent region names — quiet cartographic labels */
.leaflet-tooltip.region-label {
  background: transparent; border: 0; box-shadow: none;
  color: rgba(232, 242, 250, 0.4);
  font-weight: 700; font-size: 10.5px; letter-spacing: 0.16em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 14px rgba(0, 0, 0, 0.65);
  pointer-events: none; white-space: nowrap;
  padding: 0;
}
.leaflet-tooltip.region-label::before { display: none; }

/* sector permanent labels */
.leaflet-tooltip.sector-label {
  background: transparent; border: 0; box-shadow: none; color: #e8f2fa;
  font-weight: 800; font-size: 12.5px; text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.7);
  pointer-events: none; white-space: nowrap;
}
.leaflet-tooltip.sector-label::before { display: none; }
.leaflet-tooltip.event-label {
  background: rgba(12, 18, 28, 0.92); border: 1px solid rgba(226, 109, 109, 0.55);
  color: #ffd0cc; border-radius: 999px; font-size: 11px; font-weight: 700;
  padding: 4px 10px; box-shadow: var(--shadow-soft); white-space: nowrap;
}
.leaflet-tooltip.event-label::before { display: none; }
.leaflet-tooltip.event-label.sev-medium { border-color: rgba(226, 180, 76, 0.55); color: #ffe6a8; }
.leaflet-tooltip.event-label.sev-low { border-color: rgba(106, 168, 224, 0.5); color: #c8e0ff; }

.dot-regions { background: linear-gradient(135deg, #4ea3e0, #8b7cf6); } .dot-sectors { background: #4a7a63; } .dot-units { background: #6da8d1; }
.dot-operations { background: #c09b54; } .dot-events { background: #e0726c; } .dot-annotations { background: #b68ade; }

/* military assets */
.asset-marker { background: none; border: none; }
.asset-badge {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-elev); vertical-align: middle;
  margin-inline-end: 6px; flex: 0 0 auto;
}
.layer-ico { display: inline-flex; align-items: center; color: var(--accent); }
.ui-icon { vertical-align: middle; flex: 0 0 auto; }
.draw-ico { display: block; height: 16px; }
.secondary .ui-icon, .side-open .ui-icon, .icon-btn .ui-icon, .panel-btn .ui-icon, .annotate-cta .ui-icon { display: block; }

/* =========================================================
   Drawer open: shift left map HUD so drawer never covers tools/chips/KPI
   ========================================================= */
body.drawer-open .map-hud-stack {
  left: calc(var(--drawer-w) + 24px);
}
/* when sidebar also open, keep right edge clear */
body.drawer-open .map-hud-stack {
  right: calc(var(--sidebar-w) + 24px);
}
/* drawer squeezes HUD — icon-only tools + tighter title so columns never collide */
/* if no room (narrow), allow HUD to use full width under drawer */
@media (max-width: 1200px) {
  body.drawer-open .map-hud-stack { right: 12px; }
}

/* =========================================================
   Board mode (dashboard grid)
   ========================================================= */
body.dash-grid .workspace {
  display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow: auto;
  background: radial-gradient(800px 300px at 50% 0%, rgba(20, 40, 60, 0.35), transparent 60%), var(--bg);
}
body.dash-grid .map-column {
  position: relative; inset: auto; flex: 0 0 auto; height: 44vh; min-height: 320px;
  border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
  order: 0;
}
body.dash-grid .map-hud-stack { right: 10px; left: 10px; top: 10px; }
body.dash-grid .map-chips { position: relative; }
body.dash-grid .sidebar {
  position: relative; top: auto; right: auto; bottom: auto; width: 100%; max-width: none;
  opacity: 1 !important; background: transparent; border: 0; backdrop-filter: none; box-shadow: none;
  padding: 0 0 20px; overflow: visible; transform: none; order: 1;
}
body.dash-grid .sidebar:hover, body.dash-grid .sidebar:focus-within { opacity: 1 !important; background: transparent; box-shadow: none; }
body.dash-grid .sidebar.collapsed { transform: none; opacity: 1; pointer-events: auto; }
body.dash-grid .side-open, body.dash-grid .side-head, body.dash-grid #segTabs { display: none !important; }
body.dash-grid .seg-body[data-seg-body="indicators"] { display: block !important; padding-top: 0; }
body.dash-grid .seg-body[data-seg-body="layers"],
body.dash-grid .seg-body[data-seg-body="review"] { display: none !important; }
body.dash-grid #dashPanels {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; align-content: start;
  align-items: start; grid-auto-flow: row dense;
}
body.dash-grid .dash-section { margin-top: 0; background: rgba(11, 17, 26, 0.9); }
body.dash-grid .asset-legend { display: none !important; }
body.dash-grid .leaflet-bottom.leaflet-right { margin-right: 0 !important; }
/* drawer hidden in board mode to avoid covering cards */
body.dash-grid .drawer { display: none !important; }
body.dash-grid.drawer-open .map-hud-stack { left: 10px; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1460px) { .brand-subtitle { display: none; } }
@media (max-width: 1360px) {
  .panel-btn .btn-label { display: none; }
  .panel-btn { padding: 0 10px; }
  .view-tab { padding: 7px 12px; }
}
@media (max-width: 1200px) {
  .user-chip span { display: none; }
  .user-chip { max-width: 150px; }
  .hide-md { display: none; }
  .statusbar { gap: 10px; }
}
@media (max-width: 1080px) {
  :root { --sidebar-w: 320px; }
  .brand-title { max-width: 160px; }
  .view-tab { padding: 6px 10px; font-size: 12px; }
  .hide-sm { display: none; }
  .kpi-overlay { grid-template-columns: repeat(2, 1fr); }
  .map-hud-stack { right: calc(var(--sidebar-w) + 20px); }
}
@media (max-width: 900px) {
  .brand-subtitle { display: none; }
  .view-tabs { justify-self: start; }
  .map-hud-stack { right: 12px; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  body.dash-grid #dashPanels { grid-template-columns: 1fr; }
  .notif-pop { right: 12px; left: 12px; width: auto; }
}

/* panel-open bottom control shift (attribution only; zoom stays left) */
body.panel-open .leaflet-bottom.leaflet-right { margin-right: calc(var(--sidebar-w) + 8px); transition: margin-right .22s ease; }
@media (max-width: 1080px) { body.panel-open .leaflet-bottom.leaflet-right { margin-right: 0; } }

/* leaflet zoom/scale clear of legend */
.leaflet-bottom.leaflet-left { bottom: 8px; left: 8px; }
.leaflet-control-zoom { margin-bottom: 8px !important; }
.leaflet-control-scale { margin-bottom: 4px !important; }

/* =========================================================
   GIS polish
   ========================================================= */
/* keyless dark basemap: OSM tiles darkened client-side (CARTO dark now needs a key) */
.leaflet-tile-pane .tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(0.72) contrast(0.9) saturate(0.4); }

/* compact KPI row over the map: one line per metric so the map keeps its height;
   the full card (with note) is kept for board mode */
.kpi-overlay { min-height: 46px; }
.kpi-overlay .metric {
  min-height: 46px; padding: 6px 10px; display: grid; align-items: center; column-gap: 8px;
  grid-template-columns: auto auto minmax(0, 1fr); grid-template-rows: auto;
}
.kpi-overlay .metric-ico { margin: 0; }
.kpi-overlay .metric b { font-size: 18px; white-space: nowrap; }
.kpi-overlay .metric > span:not(.metric-ico) {
  font-size: 11px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.kpi-overlay .metric-note { display: none; }

/* sector label: name + readiness pill in its tone */
.leaflet-tooltip.sector-label { display: inline-flex; align-items: center; gap: 6px; padding: 0; }
.leaflet-tooltip.sector-label .sl-ready {
  font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 999px; direction: ltr;
  color: var(--tone); background: rgba(8, 12, 18, 0.78);
  border: 1px solid color-mix(in srgb, var(--tone) 60%, transparent); text-shadow: none;
}

/* label declutter (see declutterLabels in map.js) */
.leaflet-tooltip.label-culled { visibility: hidden; }
.leaflet-tooltip-pane.labels-zooming .leaflet-tooltip.region-label,
.leaflet-tooltip-pane.labels-zooming .leaflet-tooltip.sector-label,
.leaflet-tooltip-pane.labels-zooming .leaflet-tooltip.event-label { opacity: 0 !important; }
.leaflet-tooltip.region-label, .leaflet-tooltip.sector-label, .leaflet-tooltip.event-label { transition: opacity .15s ease; }

/* numbers & units read left-to-right inside the RTL shell */
.leaflet-control-scale-line { direction: ltr; }
#cursorCoords { unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

/* export buttons: icon + format tag so CSV and Excel are distinguishable */
.icon-btn.labeled { padding: 0 8px 0 7px; gap: 4px; }
.icon-btn .icon-tag { font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; color: var(--text-3); direction: ltr; }
.icon-btn.labeled:hover .icon-tag { color: var(--text-2); }

/* visible keyboard focus on map chrome */
.map-rail button:focus-visible, .map-chip:focus-visible, .draw-btn:focus-visible, .legend-head:focus-visible,
.icon-btn:focus-visible, .panel-btn:focus-visible, .seg-tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* =========================================================
   Map redesign: calmer chrome, one tool rail, map key
   ========================================================= */
/* notification badge pinned to the bell (button is the positioning context) */
.icon-btn.bell { position: relative; }
.bell-count {
  top: -6px; left: -6px; min-width: 18px; height: 18px; padding: 0 5px; line-height: 14px;
  font-size: 10px; font-weight: 800; border: 2px solid var(--bg); pointer-events: none;
  font-variant-numeric: tabular-nums; direction: ltr;
}
.icon-btn.bell.has-unread { color: var(--text); border-color: rgba(196, 77, 77, 0.45); }

/* HUD row under the KPI strip: layer chips (start) · view actions (end) */
.map-hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
.map-hud-row > * { pointer-events: auto; }
.map-hud-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.map-chip { height: 26px; padding: 0 10px; font-size: 10.5px; }
.map-chip:not(.on) { opacity: 0.62; }
.map-chip:not(.on) .chip-dot { background: transparent !important; box-shadow: inset 0 0 0 1.5px currentColor; }

/* draw toolbar: compact horizontal buttons */
.draw-toolbar {
  display: none; gap: 2px; align-items: center; padding: 3px;
  border: 1px solid rgba(61, 159, 214, 0.35); background: rgba(16, 34, 50, 0.94);
  border-radius: 10px; backdrop-filter: blur(12px); box-shadow: var(--shadow-soft);
}
.draw-toolbar.visible { display: flex; }
.draw-btn {
  height: 28px; padding: 0 9px; border: 1px solid transparent; background: transparent;
  color: #b7d4ea; border-radius: 7px; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
}
.draw-btn .draw-ico { height: auto; display: inline-flex; }
.draw-btn:hover { background: rgba(61, 159, 214, 0.16); color: #fff; }
.draw-btn.active { background: rgba(61, 159, 214, 0.3); border-color: rgba(61, 159, 214, 0.55); color: #fff; }
.draw-btn[data-draw="finish"] { color: var(--ok); }
.draw-btn[data-draw="finish"]:not(.hidden) { background: rgba(62, 207, 142, 0.14); border-color: rgba(62, 207, 142, 0.4); }
.draw-btn[data-draw="cancel"] { color: #f0b0a8; }
.annotate-cta { padding: 6px 12px; font-size: 11.5px; }

/* tool rail: stacked with zoom in the bottom-left Leaflet corner */
.map-rail { display: flex; flex-direction: column; }
.map-rail button {
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  background: rgba(12, 18, 28, 0.92); color: var(--text-2); border: 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.map-rail button:last-child { border-bottom: 0; }
.map-rail button:hover { background: #162232; color: var(--text); }
.map-rail button.active { background: rgba(61, 159, 214, 0.28); color: #fff; }
.leaflet-bottom.leaflet-left { transition: left .2s ease; }
body.drawer-open:not(.dash-grid) .leaflet-bottom.leaflet-left { left: calc(var(--drawer-w) + 22px); }

/* bottom-right corner: map key + optional minimap, clear of sidebar and attribution */
.map-corner-br {
  position: absolute; z-index: var(--z-chrome); right: calc(var(--sidebar-w) + 24px); bottom: 34px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none;
  transition: right .2s ease;
}
.map-corner-br > * { pointer-events: auto; }
body:not(.panel-open) .map-corner-br { right: 12px; }
.map-minimap {
  width: 170px; height: 120px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line-strong); box-shadow: var(--shadow); background: #0a1018;
}
.map-minimap .leaflet-control-attribution, .map-minimap .leaflet-control-container { display: none !important; }

.asset-legend {
  width: 250px; padding: 0; border: 1px solid var(--line); background: var(--bg-panel);
  border-radius: 12px; backdrop-filter: blur(12px); box-shadow: var(--shadow-soft); overflow: hidden;
}
.asset-legend.collapsed { width: auto; }
.legend-head {
  display: flex; align-items: center; gap: 7px; width: 100%; padding: 8px 11px;
  font-size: 11.5px; color: var(--text-2); font-weight: 700; background: none; border: 0; cursor: pointer;
}
.legend-head:hover { color: var(--text); }
.legend-head b { color: var(--text-3); font-weight: 600; font-size: 10.5px; }
.legend-caret { margin-inline-start: auto; display: inline-flex; transition: transform .15s ease; transform: rotate(180deg); }
.asset-legend.collapsed .legend-caret { transform: none; }
.asset-legend.collapsed .legend-body { display: none; }
.legend-body { padding: 2px 12px 10px; max-height: 46vh; overflow: auto; border-top: 1px solid var(--line); }
.key-sec { padding-top: 8px; }
.key-title { font-size: 10.5px; color: var(--text-3); font-weight: 700; margin-bottom: 5px; }
.key-title small { font-weight: 500; }
.key-row { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.key-item { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-2); }
.key-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); display: inline-block; }
.key-line { width: 22px; height: 0; border-top: 2.6px solid #c09b54; display: inline-block; }
.key-line.dashed { border-top-style: dashed; }
.key-line.faint { opacity: 0.4; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-2); min-width: 0; }
.legend-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-item b { margin-inline-start: auto; color: var(--text-3); }

/* unit symbols (APP-6 style frame; stroke = readiness tone) */
.asset-marker { background: none; border: none; }
.asset-symbol { display: block; width: 32px; height: 32px; filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.7)); transition: transform .12s ease; }
.asset-symbol svg { display: block; }
.asset-marker:hover .asset-symbol { transform: scale(1.12); }
.asset-marker.is-selected .asset-symbol { transform: scale(1.18); filter: drop-shadow(0 0 6px var(--tone)) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.7)); }

/* unit clusters */
.unit-cluster { background: none; border: none; }
.unit-cluster span {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: rgba(9, 16, 24, 0.92); border: 2px solid var(--tone); color: #eef5fa; line-height: 1;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 22%, transparent), 0 3px 10px rgba(0, 0, 0, 0.6);
  transition: transform .12s ease;
}
.unit-cluster span b { font-size: 13px; font-weight: 800; }
.unit-cluster span small { font-size: 7.5px; color: var(--text-2); margin-top: 1px; }
.unit-cluster:hover span { transform: scale(1.08); }

/* incident markers: diamond in priority colour, open high-priority pulses */
.event-marker { background: none; border: none; }
.event-diamond {
  display: block; width: 12px; height: 12px; margin: 5px; transform: rotate(45deg);
  background: var(--tone); border: 1.5px solid #f4f8fb; border-radius: 2px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
}
.event-diamond.mini { width: 9px; height: 9px; margin: 0 2px; border-width: 1px; }
.event-diamond.pulse { animation: event-pulse 2s ease-out infinite; }
@keyframes event-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 70%, transparent), 0 1px 5px rgba(0, 0, 0, 0.7); }
  70%, 100% { box-shadow: 0 0 0 12px transparent, 0 1px 5px rgba(0, 0, 0, 0.7); }
}
.event-marker.is-selected .event-diamond { outline: 2px solid #fff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .event-diamond.pulse { animation: none; } }

.goto-marker { background: none; border: none; color: #7fd0ff; filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.9)); }

.leaflet-tooltip.c2-tooltip > div { font-size: 11px; color: var(--text-2); }

@media (max-width: 1080px) {
  .map-corner-br { right: calc(var(--sidebar-w) + 20px); }
  .map-minimap { display: none; }
}
@media (max-width: 900px) {
  .map-hud-row { flex-direction: column; }
  .map-corner-br { right: 12px; }
}
body.dash-grid .map-corner-br { display: none; }
.key-frames { margin-bottom: 6px; }
/* bright imagery under glass panels hurts legibility: go opaque on satellite */
body[data-basemap="satellite"] { --bg-panel: rgba(9, 14, 21, 0.95); }
body[data-basemap="satellite"] .sidebar { opacity: 1; background: rgba(9, 14, 21, 0.96); }
body[data-basemap="satellite"] .leaflet-tooltip.sector-label,
body[data-basemap="satellite"] .leaflet-tooltip.region-label { text-shadow: 0 1px 3px #000, 0 0 10px #000, 0 0 16px #000; }

/* =========================================================
   UX polish: shared controls, feedback states, motion
   ========================================================= */
/* one scrollbar style everywhere (Firefox + WebKit) */
* { scrollbar-width: thin; scrollbar-color: #2a3d50 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3d50; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #3a5670; }
::-webkit-scrollbar-track { background: transparent; }
::selection { background: rgba(61, 159, 214, 0.35); color: #fff; }

/* numbers line up in tables, KPIs and counters */
.metric b, .tile b, .donut-center b, .hero-value, .num, .layer-count, .chip-count, .count,
.seg-count, .card .row span:last-child, .tbl td { font-variant-numeric: tabular-nums; }

/* keyboard focus is always visible, mouse focus stays quiet */
button:focus-visible, a:focus-visible, summary:focus-visible, .view-tab:focus-visible,
.panel-tab:focus-visible, .notif-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* buttons: consistent press / disabled / busy feedback */
button { transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .08s ease, opacity .15s ease; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled, button[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; }
.primary:disabled:hover { background: #1c4a68; }
.danger:hover { background: rgba(120, 36, 28, 0.7); color: #ffd0cc; }
button[aria-busy="true"] { position: relative; color: transparent !important; }
button[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* form controls inside panels (admin, entry) share the modal look */
.panel-body label { display: grid; gap: 6px; margin: 10px 0; color: var(--text-2); font-size: 12px; }
.panel-body label.switch-row { display: flex !important; }
.panel-body input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
.panel-body select, .panel-body textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line-strong); background: var(--bg-input);
  color: var(--text); border-radius: 9px; outline: none;
}
.panel-body textarea { min-height: 80px; resize: vertical; }
.panel-body .field-row input, .panel-body .field-row select { padding: 7px; font-size: 12px; }
.setting-input { width: 230px !important; max-width: 100%; padding: 6px 9px !important; }
.modal input, .modal select { width: 100%; }
.modal input[type="checkbox"], .modal input[type="color"] { width: auto; }
.modal input[type="color"], .panel-body input[type="color"] {
  height: 36px; padding: 3px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--bg-input); cursor: pointer;
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
.panel-body input:focus, .panel-body select:focus, .panel-body textarea:focus,
.login-card input:focus, .modal input:focus, .modal textarea:focus, .modal select:focus, .filter-grid select:focus {
  border-color: var(--accent) !important; box-shadow: var(--focus-ring); outline: none;
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
select { cursor: pointer; }

/* login: roomier card, submit feedback */
.login-card { width: min(400px, calc(100vw - 32px)); padding: 32px 30px 26px; animation: rise .35s var(--ease) both; }
.login-card .primary { padding: 11px 14px; font-size: 13.5px; margin-top: 2px; }
.login-error:not(:empty) {
  padding: 8px 10px; border-radius: 8px; background: rgba(226, 109, 109, 0.1);
  border: 1px solid rgba(226, 109, 109, 0.3); animation: shake .32s ease;
}
.demo-account button:hover { color: var(--text); border-color: var(--accent); }
.demo-box summary { padding: 2px 0; }
.demo-box summary:hover { color: var(--text); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* surfaces: gentle entrance so state changes are noticeable */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel-overlay:not(.hidden) { animation: fade .16s ease both; }
.panel-overlay:not(.hidden) .panel { animation: rise .22s var(--ease) both; }
.modal-backdrop.open { animation: fade .14s ease both; }
.modal-backdrop.open .modal { animation: rise .2s var(--ease) both; }
.notif-pop:not(.hidden) { animation: rise .16s var(--ease) both; }

/* panel chrome */
.panel-head { gap: 12px; }
.panel-tabs { position: sticky; top: -16px; z-index: 3; padding: 10px 0; margin: -10px 0 8px; background: var(--bg-panel-solid); }
.panel-tab:hover { color: var(--text); border-color: var(--line-strong); }
.card { transition: border-color .15s ease, background-color .15s ease; }
.card:hover { border-color: var(--line-strong); }
.card h4 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; line-height: 1.45; }
.card-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(120, 150, 180, 0.08); }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tbl tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.012); }
.tbl td small, .data-table td small { color: var(--text-3); }
.tbl td:last-child { white-space: nowrap; }
.close-btn { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; }
.modal { padding: 22px 22px 18px; }
.modal-actions { position: sticky; bottom: -18px; margin: 18px -22px -18px; padding: 12px 22px; background: var(--bg-panel-solid); border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; }
.modal .hint { padding: 8px 10px; border-radius: 8px; background: rgba(106, 168, 224, 0.07); border: 1px solid rgba(106, 168, 224, 0.15); line-height: 1.6; }
.panel-body > .hint:first-child, #adminTabBody > .hint:first-child {
  margin-bottom: 12px; padding: 9px 12px; border-radius: 9px; line-height: 1.6;
  background: rgba(106, 168, 224, 0.07); border: 1px solid rgba(106, 168, 224, 0.15); color: var(--text-2);
}

/* empty + loading states */
.card-grid > .hint:only-child, .notif-list > .hint, .queue-item.empty {
  grid-column: 1 / -1; padding: 26px 14px; text-align: center; border: 1px dashed var(--line-strong);
  border-radius: 12px; color: var(--text-3); background: rgba(255, 255, 255, 0.015);
}
.loading-state {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 12px;
  color: var(--text-3); font-size: 12.5px;
}
.loading-state::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite;
}

/* notifications */
.notif-pop { padding: 0; display: flex; flex-direction: column; max-height: min(460px, calc(100% - 28px)); overflow: hidden; }
.notif-head { position: sticky; top: 0; padding: 12px 12px 10px; margin: 0; border-bottom: 1px solid var(--line); gap: 8px; }
.notif-list { padding: 10px 12px 12px; overflow: auto; }
.notif-item { transition: border-color .15s ease, background-color .15s ease; }
.notif-item:hover { background: rgba(20, 32, 46, 0.9); }
.notif-item b { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.notif-item b .badge { white-space: nowrap; flex: 0 0 auto; }
.notif-item > div { color: var(--text-2); line-height: 1.55; }
.notif-item small { display: block; margin-top: 4px; }

/* toast: tone by outcome */
.toast { display: flex; align-items: center; gap: 8px; border-inline-start: 3px solid var(--accent); font-weight: 600; }
.toast.ok { border-inline-start-color: var(--ok); }
.toast.error { border-inline-start-color: var(--bad); background: rgba(46, 18, 18, 0.97); color: #ffd6d2; }

/* sidebar: tabs & accordion read as interactive */
.dash-section > summary { transition: background-color .15s ease; justify-content: flex-start; }
.dash-section > summary:not(:has(.count))::after { margin-inline-start: auto; }
.dash-section[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.dash-section > summary::after {
  content: ""; width: 7px; height: 7px; flex: 0 0 auto; margin-inline-start: 4px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg); transition: transform .18s ease; margin-top: -3px;
}
.dash-section[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
body.dash-grid .dash-section > summary::after { display: none; }
.layer-row label { flex: 1; }
.switch-row { cursor: pointer; }

/* statusbar live dot */
#apiStatus.status-ok::before, #apiStatus.status-error::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; margin-inline-end: 5px; vertical-align: middle; box-shadow: 0 0 6px currentColor;
}

/* smaller screens: panels use the whole viewport */
@media (max-width: 760px) {
  .panel-overlay { padding: 0; }
  .panel { border-radius: 0; max-height: 100%; height: 100%; }
  .card-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; max-height: 100%; border-radius: 14px 14px 0 0; align-self: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
