/* CedTech design tokens (aligned with site/index.html) */
:root {
  --logo-ced: #4B5459;
  --logo-tech: #C4293D;
  --logo-bracket: var(--logo-ced);
  --logo-primary: var(--logo-tech);
  --logo-secondary: #2E5C82;
  --logo-ink: #14181C;
  --paper: #EEF0EE;
  --paper-raised: #FFFFFF;
  --ink: var(--logo-ink);
  --ink-muted: #4B5459;
  --signal: var(--logo-tech);
  --signal-ink: #FFFFFF;
  --calib: var(--ink-muted);
  --ct-line: #C3CACA;
  --ct-line-strong: #9BA5A5;
  --radius: 2px;

  --navy: var(--paper);
  --navy-card: var(--paper-raised);
  --navy-card-hover: #E4E8E4;
  --navy-panel-strong: #F5F6F5;
  --line: var(--ct-line);
  --line-soft: color-mix(in srgb, var(--ct-line) 55%, transparent);
  --text: var(--ink);
  --text-dim: var(--ink-muted);
  --text-muted: var(--ink-muted);
  --pending: #7A858C;
  --blue: var(--logo-tech);
  --blue-strong: #A32032;
  --focus: var(--logo-tech);
  --green: #1F7A4D;
  --wip-hq: #C4293D;
  --wip-hq-border: rgba(196, 41, 61, 0.55);
  --wip-site: #4B5459;
  --wip-op: #1F7A4D;
  --chrome-ink: #14181C;
  --chrome-surface: rgba(20, 24, 28, 0.94);
  --chrome-border: rgba(196, 41, 61, 0.38);
  --chrome-accent: #C4293D;
  --chrome-text: #E8ECEF;
  --chrome-muted: #99A3A6;
  --sidebar-w: 300px;
  --stage-h: min(44vh, 460px);
  --map-chrome-pad: 12px;
  --font: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Archivo", "Arial Narrow", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

.hp-field {
  position: absolute;
  left: -9999px;
  height: 0;
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  :root {
    --logo-ced: #99A3A6;
    --logo-tech: #C4293D;
    --logo-ink: #E9ECEC;
    --paper: #12161A;
    --paper-raised: #191F24;
    --ink: var(--logo-ink);
    --ink-muted: #99A3A6;
    --signal: var(--logo-tech);
    --signal-ink: #FFFFFF;
    --calib: var(--ink-muted);
    --ct-line: #2C363A;
    --ct-line-strong: #445053;
    --navy-card-hover: #222A30;
    --navy-panel-strong: #151A1E;
    --blue-strong: #A32032;
    --focus: var(--logo-tech);
    --pending: #99A3A6;
    --wip-hq: #C4293D;
    --wip-hq-border: rgba(196, 41, 61, 0.55);
    --wip-site: #99A3A6;
    --chrome-surface: rgba(19, 25, 30, 0.96);
    --chrome-border: rgba(196, 41, 61, 0.38);
    --chrome-accent: #C4293D;
    --chrome-text: #E9ECEC;
    --chrome-muted: #99A3A6;
  }
}

body.is-operator {
  --sidebar-w: 340px;
  --stage-h: min(62vh, 680px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy);
  font-family: var(--font);
  color: var(--text);
  overflow: hidden;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  background: var(--navy-card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 0;
  z-index: 730;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  /* Pas de scroll ici: top / liste / tail sont des régions séparées (évite superposition). */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 41, 61, 0.22) transparent;
}
.sidebar-scroll-top {
  flex: 0 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sidebar-scroll-tail {
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
  isolation: isolate;
  background: var(--navy-card);
  border-top: 1px solid var(--line);
}
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(196, 41, 61, 0.22);
  border-radius: 999px;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 41, 61, 0.38);
}

.sidebar-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand-header { display: flex; justify-content: center; padding: 0 0 8px; }
.brand-link { display: flex; align-items: center; }
.brand-header-logo { display: block; height: 42px; width: auto; max-width: min(260px, 100%); }
.brand-header-fallback { display: none; align-items: center; justify-content: center; padding: 4px 0 8px; }
.brand-header-fallback.show { display: flex; }
.brand-word { font-family: var(--font-heading); font-weight: 800; font-size: 22px; color: var(--logo-ced); letter-spacing: 0.01em; }
.brand-word-ced { color: var(--logo-ced); font-weight: 400; font-family: var(--font-body); }
.brand-word-accent { color: var(--logo-tech); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--calib);
  margin: 0 0 4px;
}

.sidebar-head h1 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 20px;
  margin: 0 0 4px;
  line-height: 1.15;
}

#headerSummary, .tagline-inline {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.4;
}
.tagline-inline { margin-top: 4px; opacity: 0.9; }

.operator-badge {
  display: none;
  margin-top: 8px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #065f46;
  color: #ecfdf5;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}
body.is-operator .operator-badge { display: inline-block; }
.operator-badge.hidden { display: none !important; }

.CedBot-banner {
  margin: 8px 12px 0;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
  background: rgba(196, 41, 61, 0.1);
  border: 1px solid rgba(196, 41, 61, 0.28);
  color: var(--chrome-text);
}
.CedBot-banner.CedBot-verify {
  background: rgba(104, 211, 145, 0.1);
  border-color: rgba(104, 211, 145, 0.3);
  color: #bbf7d0;
}

.company-form {
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
.form-lead { margin: 0 0 4px; font-size: 12.5px; color: var(--text-dim); line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.field input, .field select, .operator-complete input, .operator-complete textarea {
  width: 100%;
  background: var(--navy-panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 9px;
  font: inherit;
  font-size: 13px;
}
.field input:focus-visible,
.field select:focus-visible,
.operator-complete input:focus-visible,
.operator-complete textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.form-hint { margin: 0; font-size: 11px; color: var(--text-muted); line-height: 1.35; }
.form-error {
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  font-size: 0.82rem;
}

.btn, .btn-primary, .btn-secondary, .btn-ghost {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover, .btn-secondary:hover, .btn-ghost:hover { opacity: 0.92; }
.btn:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-ghost:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.btn.primary, .btn-primary {
  width: 100%;
  border: 1px solid var(--logo-tech);
  background: var(--logo-tech);
  color: var(--signal-ink);
}
.btn.primary:hover, .btn-primary:hover { opacity: 0.9; color: var(--signal-ink); }
.btn.danger { border-color: rgba(248, 113, 113, 0.45); color: #fecaca; }
.btn.icon-btn { min-width: 40px; padding: 9px 10px; font-size: 16px; line-height: 1; }

.operator-complete {
  margin: 8px 12px;
  padding: 10px 11px;
  border: 1px solid rgba(104, 211, 145, 0.28);
  border-radius: 10px;
  background: rgba(4, 120, 87, 0.12);
}
.operator-kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--wip-op);
}
.operator-complete h2 { margin: 0.2rem 0 0.35rem; font-size: 0.98rem; }
.operator-complete .muted { margin: 0 0 0.5rem; font-size: 12px; color: var(--text-dim); }
.operator-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.operator-complete label { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 0.45rem; }
.operator-complete textarea { min-height: 3.6rem; resize: vertical; }
#operator-company-notes { min-height: 4.2rem; }
.operator-template { font-size: 0.82rem; }
.operator-template a { color: var(--wip-op); font-weight: 600; }
.operator-import-status { margin: 0.45rem 0 0; font-size: 0.82rem; color: var(--wip-op); }
.operator-import-status.is-error { color: #fdba74; }

.company-fiche {
  margin: 8px 12px 4px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
}
.fiche-kicker {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93c5fd;
}
.company-fiche h2 { margin: 0.15rem 0 0.3rem; font-size: 0.98rem; }
.company-fiche h3 {
  margin: 0.55rem 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.company-fiche .muted { margin: 0 0 0.45rem; font-size: 12px; }
.fiche-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 0.22rem 0.6rem;
  font-size: 12.5px;
}
.fiche-dl dt { color: var(--text-muted); font-weight: 500; }
.fiche-dl dd { margin: 0; color: var(--text); }
.fiche-directors ul {
  margin: 0;
  padding-left: 1.05rem;
  font-size: 12.5px;
}
.fiche-directors li { margin: 0.12rem 0; }
.fiche-directors .role { color: var(--text-muted); }
.fiche-directors .src-pub { font-size: 10.5px; color: #93c5fd; }
.fiche-sources { margin: 0.45rem 0 0; font-size: 11px; word-break: break-word; }

/* Accordion header row */
.fiche-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.fiche-header-summary { flex: 1; min-width: 0; }
.fiche-header-summary h2 { margin: 0.15rem 0 0.1rem; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fiche-siege { margin: 0; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fiche-toggle-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 6px;
  color: #93c5fd;
  font-size: 11px;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 0.2rem;
}
.fiche-toggle-btn:hover {
  background: rgba(147, 197, 253, 0.1);
  border-color: rgba(147, 197, 253, 0.5);
}

/* Collapsible body */
.fiche-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
  overflow: hidden;
}
.fiche-body > * { min-height: 0; }
.fiche-body--open {
  grid-template-rows: 1fr;
}
/* Inner wrapper needed for grid-template-rows trick */
.fiche-body > .fiche-body-inner {
  overflow: hidden;
}

.wan-schematic {
  margin-top: 0.65rem;
  padding: 8px 8px 6px;
  border: 1px dashed rgba(104, 211, 145, 0.35);
  border-radius: 8px;
  background: rgba(4, 120, 87, 0.08);
}
.wan-schematic svg { display: block; width: 100%; height: auto; }
.wan-schematic .wan-caption {
  margin: 4px 2px 0;
  font-size: 10.5px;
  color: var(--wip-op);
}
.legend-wan-line {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--wip-op);
  flex-shrink: 0;
}

.op-wan-form {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(104, 211, 145, 0.32);
  border-radius: 12px;
  background: rgba(4, 120, 87, 0.12);
}
.op-wan-form h3 {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wip-op);
  margin: 0 0 6px;
  font-weight: 600;
}
.op-wan-form .op-vs {
  letter-spacing: 0;
  text-transform: none;
  font-size: 11px;
  font-weight: 600;
  color: #a7f3d0;
  margin-left: 6px;
}
.op-wan-form .muted { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); }
.op-wan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
  margin-bottom: 10px;
}
.op-wan-form label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
}
.op-wan-form input,
.op-wan-form select,
.op-wan-form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
}
.op-wan-form textarea { min-height: 4.2rem; resize: vertical; }
.op-wan-form .btn { margin-top: 10px; width: auto; min-width: 180px; }

.leaflet-tooltip.wan-tooltip {
  background: #0f2a22;
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 6px;
  box-shadow: none;
}
.leaflet-tooltip.wan-tooltip:before { border-top-color: #0f2a22; }

.site-list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  isolation: isolate;
  position: relative;
  z-index: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 41, 61, 0.22) transparent;
}
.site-list-wrap::-webkit-scrollbar { width: 5px; }
.site-list-wrap::-webkit-scrollbar-thumb {
  background: rgba(196, 41, 61, 0.22);
  border-radius: 999px;
}
.site-list {
  padding: 8px 10px 12px;
  flex: 0 0 auto;
}
.site-empty {
  display: none;
  margin: 8px 12px 12px;
  padding: 11px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  line-height: 1.4;
}
.site-empty.show { display: block; }

.site-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 54px;
}
.site-item:hover { background: var(--navy-card-hover); }
.site-item.active { background: var(--navy-card-hover); border-color: var(--line); }
.site-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
  background: var(--blue-strong);
  box-shadow: 0 0 0 3px rgba(0, 83, 154, 0.28);
}
.site-item.is-hq .dot { background: var(--wip-hq); box-shadow: 0 0 0 3px rgba(232, 163, 23, 0.28); }
.site-item .meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.site-item .name { font-size: 14.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-item .sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-item .src { font-size: 11px; color: var(--text-muted); }
.src-yours { color: var(--wip-op); font-weight: 600; }
.src-public { color: var(--text-muted); font-weight: 600; }

.export-rapport-wrap {
  margin: 6px 12px 10px;
}
.export-rapport-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-color: var(--line);
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.export-rapport-btn:hover {
  background: var(--navy-card-hover);
  border-color: var(--logo-tech);
  color: var(--logo-tech);
}

.lite-sites-fallback { margin: 0 14px 10px; font-size: 12px; color: var(--text-muted); }
.data-status {
  margin: 8px 12px;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--logo-tech) 8%, var(--paper-raised));
  border: 1px solid color-mix(in srgb, var(--logo-tech) 28%, var(--line));
  color: var(--blue-strong);
  font-size: 0.8rem;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}
.disclaimer {
  margin: 0;
  padding: 10px 14px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  background: var(--navy-card);
}

.sidebar-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: var(--navy-panel-strong);
  flex: 0 0 auto;
}
.legal { margin: 4px 0 0; font-size: 11.5px; }
.legal a { color: var(--logo-tech); }
.legal a:hover { color: var(--blue-strong); }

.map-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; height: 100%; }
.map-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 380px at left center, color-mix(in srgb, var(--chrome-ink) 14%, transparent), transparent 54%),
    linear-gradient(180deg, color-mix(in srgb, var(--logo-tech) 4%, transparent), transparent);
  z-index: 0;
}

.grid-map,
#grid-map,
#grid-map.leaflet-container {
  width: 100%;
  height: 100%;
  min-height: 280px;
  background: var(--navy);
  z-index: 1;
  position: relative;
}
.leaflet-container { background: var(--navy); font-family: var(--font); }

.sidebar-toggle-fab {
  display: none;
  position: absolute;
  top: var(--map-chrome-pad);
  left: var(--map-chrome-pad);
  z-index: 760;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--chrome-border);
  background: var(--chrome-surface);
  color: var(--chrome-text);
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sidebar-toggle-fab:hover { border-color: var(--chrome-accent); }
.sidebar-toggle-fab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.sidebar-toggle-fab.is-open { border-color: var(--chrome-accent); }
.sidebar-toggle-fab .toggle-ico {
  font-size: 15px;
  line-height: 1;
  width: 1em;
  text-align: center;
}
.sidebar-scrim {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 720;
  background: rgba(5, 12, 22, 0.48);
  border: none;
  cursor: pointer;
}

.architecture-reseau-pin-wrap { background: transparent !important; border: none !important; }
.pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--wip-site);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
.pin-hq, .pin.hq {
  width: 32px;
  height: 32px;
  background: var(--wip-hq);
  border-color: var(--wip-hq-border);
}
.pin-site { background: var(--wip-site); }
.pin-op { background: var(--wip-op); border-color: var(--wip-op); }
.pin.entity-hq { width: 30px; height: 30px; border-color: var(--wip-hq-border); }
.pin.selected {
  border-color: var(--chrome-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chrome-accent) 45%, transparent), 0 4px 14px rgba(0, 0, 0, 0.5);
  transform: rotate(-45deg) scale(1.12);
}
.pin-inner {
  transform: rotate(45deg);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.pin-hq .pin-inner, .pin.hq .pin-inner { color: #fff; font-size: 11px; }

.map-badge {
  position: absolute;
  top: var(--map-chrome-pad);
  left: var(--map-chrome-pad);
  z-index: 500;
  background: var(--chrome-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--chrome-border);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--chrome-text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  max-width: min(72vw, 640px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.map-badge span { display: inline-flex; align-items: baseline; gap: 6px; }
.badge-k { color: var(--chrome-accent); font-weight: 650; }
.map-badge b { color: var(--chrome-text); font-weight: 700; }
.map-badge b.is-empty { color: var(--chrome-muted); font-weight: 650; }

.map-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 500;
  background: var(--chrome-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--chrome-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(240px, 46vw);
  color: var(--chrome-text);
}
.map-legend.hidden { display: none; }
.map-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin: 0;
  font-weight: 600;
}
.map-legend input { margin: 0; accent-color: var(--chrome-accent); }
.legend-pin {
  width: 12px;
  height: 12px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.85);
}
.legend-pin-hq { background: var(--wip-hq); }
.legend-pin-site { background: var(--blue); }
.legend-pin-op { background: var(--wip-op); }

.map-wrap.stage-open:not(.stage-maximized) .map-legend {
  bottom: calc(var(--stage-h) + 10px);
}

.fill-busy-overlay {
  position: absolute;
  inset: 0;
  z-index: 550;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--chrome-ink) 45%, transparent);
}
.fill-busy-overlay.hidden { display: none !important; }
.fill-busy-card {
  background: var(--chrome-surface);
  border: 1px solid var(--chrome-border);
  border-radius: 14px;
  padding: 18px 22px;
  min-width: min(420px, calc(100vw - 48px));
  max-width: 480px;
  text-align: left;
  color: var(--chrome-text);
}
.fill-busy-body { min-width: 0; }
.fill-busy-spinner {
  width: 28px;
  height: 28px;
  margin: 0 0 10px;
  border: 3px solid color-mix(in srgb, var(--chrome-accent) 25%, transparent);
  border-top-color: var(--chrome-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.fill-busy-title { font-weight: 700; color: var(--chrome-text); }
.fill-busy-step { margin-top: 4px; font-size: 12.5px; color: var(--chrome-muted); }
.fill-busy-meta {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--chrome-muted);
}
.fill-busy-track {
  margin-top: 10px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.fill-busy-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-strong), var(--chrome-accent));
  transition: width 0.45s ease;
}
.fill-busy-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.fill-busy-steps li {
  font-size: 11px;
  color: var(--chrome-muted);
  padding-left: 14px;
  position: relative;
}
.fill-busy-steps li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--chrome-accent) 30%, transparent);
}
.fill-busy-steps li.active {
  color: var(--chrome-text);
  font-weight: 600;
}
.fill-busy-steps li.active::before {
  background: var(--chrome-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chrome-accent) 25%, transparent);
}
.fill-busy-steps li.done {
  color: color-mix(in srgb, var(--wip-op) 70%, white);
}
.fill-busy-steps li.done::before {
  background: var(--wip-op);
}
@keyframes spin { to { transform: rotate(360deg); } }

.site-stage {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 530;
  height: var(--stage-h);
  max-height: 85%;
  display: none;
  flex-direction: column;
  background: color-mix(in srgb, var(--paper-raised) 96%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28);
  color: var(--text);
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.site-stage.open { display: flex; transform: translateY(0); }
.site-stage-handle { display: flex; justify-content: center; padding: 8px 0 2px; }
.site-stage-handle span {
  width: 42px; height: 4px; border-radius: 999px; background: color-mix(in srgb, var(--logo-ced) 45%, transparent);
}
.site-stage-head {
  padding: 6px 18px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px 18px;
  align-items: flex-start;
  justify-content: space-between;
}
.site-stage-head h2 {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
}
.site-stage-head .addr { margin: 0; font-size: 13px; color: var(--text-dim); }
.stage-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 22px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 41, 61, 0.22) transparent;
}
.stage-body::-webkit-scrollbar { width: 5px; }
.stage-body::-webkit-scrollbar-track { background: transparent; }
.stage-body::-webkit-scrollbar-thumb {
  background: rgba(196, 41, 61, 0.22);
  border-radius: 999px;
}
.stage-body::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 41, 61, 0.38);
}

.recap-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.recap-card {
  background: var(--navy-panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.recap-card .k {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.recap-card .v { font-size: 18px; font-weight: 700; margin: 0; color: var(--logo-tech); line-height: 1.25; }
.recap-card .s { margin: 6px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.recap-card.warn .v { color: var(--blue-strong); }
.recap-card.ok .v { color: var(--wip-op); }

.infra-block {
  background: var(--navy-panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.infra-block h3 {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--logo-tech);
  margin: 0 0 12px;
  font-weight: 600;
}
.infra-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
}
.infra-metrics .metric span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.infra-metrics .metric b { font-size: 14px; font-weight: 600; color: var(--text); }

.recap-ops {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  list-style: none;
  margin: 14px 0 0;
  padding: 10px 8px;
  background: #fff;
  border-radius: 10px;
}
.recap-ops li { flex: 1 1 0; min-width: 0; }
.recap-ops img { display: block; width: 100%; height: 22px; object-fit: contain; }
.recap-disc { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.leaflet-popup-content-wrapper {
  background: var(--chrome-ink);
  color: var(--chrome-text);
  border-radius: 10px;
}
.leaflet-popup-tip { background: var(--chrome-ink); }
.leaflet-popup-content .popup-type { font-weight: 700; color: var(--chrome-accent); }
.leaflet-popup-content .popup-type.is-hq { color: var(--chrome-accent); }
.popup-yours { color: color-mix(in srgb, var(--wip-op) 75%, white); font-weight: 600; }
.popup-public { color: var(--chrome-muted); }
.leaflet-popup-content .popup-ops {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.2rem;
  align-items: center;
}
.leaflet-popup-content .popup-ops img { height: 16px; width: auto; }

body:not(.is-operator) .operator-only { display: none !important; }
body:not(.is-operator) .src-public,
body:not(.is-operator) .site-item .src { display: none !important; }
.hidden { display: none !important; }
.map-hint-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

/* Sidebar must paint above the CedBot widget (which uses position:fixed z-index:99999).
   The chat panel/message preview can extend left and overlap the sidebar; raising
   the sidebar above it keeps site-list cards always readable. */
.sidebar { z-index: 100000 !important; }

@media (max-width: 1100px) {
  .recap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .op-wan-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .infra-metrics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1480px), (max-height: 860px) {
  :root { --stage-h: min(44vh, 420px); }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: min(268px, 84vw);
    max-width: 280px;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.45);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle-fab { display: inline-flex; }
  .app.sidebar-open .sidebar-toggle-fab { left: calc(min(268px, 84vw) + 10px); }
  .map-badge { left: calc(var(--map-chrome-pad) + 92px); max-width: min(58vw, 420px); }
  .app.sidebar-open .map-badge { left: calc(min(268px, 84vw) + 58px); max-width: min(48vw, 380px); }
  .app.sidebar-open .sidebar-scrim { display: block; }
  .fill-busy-overlay { left: calc(var(--map-chrome-pad) + 92px); }
  .app.sidebar-open .fill-busy-overlay { left: calc(min(268px, 84vw) + 58px); }
  .recap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-stage-head h2 { font-size: 18px; }
  .stage-body { padding: 12px 14px 20px; }
}
@media (max-width: 760px) {
  .sidebar { width: min(300px, 86vw); }
  .app.sidebar-open .sidebar-toggle-fab { left: calc(min(300px, 86vw) + 8px); }
  .map-badge { left: calc(var(--map-chrome-pad) + 86px); }
  .app.sidebar-open .map-badge { left: calc(min(300px, 86vw) + 52px); }
  .fill-busy-overlay { left: calc(var(--map-chrome-pad) + 86px); }
  .app.sidebar-open .fill-busy-overlay { left: calc(min(300px, 86vw) + 52px); }
  .recap-grid { grid-template-columns: 1fr; }
}
