/* =====================================================================
   The network map (map.js): the dashboard card, the map page and the
   subscriber form's picker. Colors come from the theme tokens in
   styles.css; status colors match the badges and the dashboard donut.
   ===================================================================== */
:root {
  --st-paid: var(--green);
  --st-due: var(--amber);
  --st-debt: var(--red);
  --st-advance: #a855f7;
  --st-off: var(--muted-2);
  --site-tower: var(--primary);
  --site-rooftop: var(--teal);
  --site-pop: #334155;
  --site-relay: var(--carrot);
  --pin-ring: #ffffff;
  --wire: var(--primary);
  --wire-down: var(--red);
  --role-tx: var(--primary);
  --role-rx: var(--teal);
  --role-txrx: #8b5cf6;
}
/* Over satellite imagery a light blue reads better than the theme's blue. */
.netmap.base-satellite { --wire: #5cc8ff; }
/* The three line colours -- the owner's from settings (--map-wire-*), else
   these. Worked out on the map itself so the satellite blue still applies. */
.netmap, .map-legend, .map-key, .map-colors, .map-filter {
  --wire-dc: var(--map-wire-dc, #7c3aed);
  --wire-cable: var(--map-wire-cable, #0d9488);
  --wire-backbone: var(--map-wire-backbone, var(--wire));
  --wire-client: var(--map-wire-client, var(--wire));
}
[data-theme="dark"] { --site-pop: #cbd5e1; }

/* Status dots (legends, filters, lists) */
.dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--st-off); }
.dot.st-paid { background: var(--st-paid); }
.dot.st-due { background: var(--st-due); }
.dot.st-debt { background: var(--st-debt); }
.dot.st-advance { background: var(--st-advance); }
.dot.is-site { border-radius: 3px; background: var(--site-tower); }

/* ---- Leaflet, in the app's clothes ---------------------------------- */
/* Leaflet's panes use z-index 200-1000; each map keeps them to itself, so the
   sticky header, windows and menus still lie on top of a map. */
.netmap, .map-stage, .map-card-body { isolation: isolate; }
.netmap.leaflet-container { font: inherit; font-size: 13px; background: var(--panel-muted); outline: none; }
.netmap .leaflet-control-attribution { padding: 1px 6px; border-radius: 6px 0 0 0; background: color-mix(in srgb, var(--panel) 82%, transparent); color: var(--muted); font-size: 10.5px; }
.netmap .leaflet-control-attribution a { color: var(--text-2); }
.netmap .leaflet-bar { border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-sm); overflow: hidden; }
.netmap .leaflet-bar a { width: 32px; height: 32px; line-height: 30px; border-bottom-color: var(--line); background: var(--panel-elevated); color: var(--text); font-weight: 500; }
.netmap .leaflet-bar a:hover { background: var(--primary-soft); color: var(--primary); }
.netmap .leaflet-bar a.leaflet-disabled { background: var(--panel-muted); color: var(--muted-2); }
.netmap .leaflet-control-scale-line { border-color: var(--text-2); background: color-mix(in srgb, var(--panel) 75%, transparent); color: var(--text-2); font-size: 10.5px; }
/* The street map in the dark theme: the same map, inverted to a night palette. */
[data-theme="dark"] .netmap:not(.base-satellite) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55); }
.netmap:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Subscriber pins: colored by status, sized by tariff; a shared pin shows a count. */
.nm-pin-wrap { background: none; border: 0; }
.nm-pin { --pin: var(--st-off); display: grid; place-items: center; width: var(--s, 14px); height: var(--s, 14px); border: 2.5px solid var(--pin-ring); border-radius: 50%; background: var(--pin); box-shadow: 0 1px 4px rgba(15, 23, 42, .4), 0 0 0 1px rgba(15, 23, 42, .12); color: #fff; font-size: 10.5px; font-weight: 750; line-height: 1; box-sizing: border-box; transition: transform .12s var(--ease); }
.leaflet-marker-icon:hover .nm-pin, .leaflet-marker-icon:focus-visible .nm-pin { transform: scale(calc(var(--nm-scale, 1) * 1.18)); }
/* Far away the signs shrink towards dots (--nm-scale, set by zoom in createNetMap). */
.nm-pin, .nm-site, .nm-boxsign { transform: scale(var(--nm-scale, 1)); transition: transform .18s var(--ease); }
/* A distribution box on its own spot */
.nm-boxsign { position: relative; display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--pin-ring); border-radius: 6px; background: var(--wire-cable, #0d9488); color: #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, .35); box-sizing: border-box; }
.nm-boxsign .icon { width: 14px; height: 14px; stroke-width: 2; }
.nm-boxsign.is-alert { background: var(--wire-down); }
.netmap.is-far .nm-boxsign .icon { opacity: 0; }
.netmap.is-far .nm-pin { font-size: 0; }
.netmap.is-far .nm-site .icon { opacity: 0; }
.netmap.is-far .nm-wire.is-backbone, .netmap.is-far .nm-flow.is-backbone { stroke-width: 3.5; }
.netmap.is-far .nm-flow { stroke-width: 2.5; }
.leaflet-marker-icon:focus-visible { outline: none; }
.leaflet-marker-icon:focus-visible .nm-pin, .leaflet-marker-icon:focus-visible .nm-site { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--primary); }
.nm-pin.st-paid { --pin: var(--st-paid); }
.nm-pin.st-due { --pin: var(--st-due); }
.nm-pin.st-debt { --pin: var(--st-debt); }
.nm-pin.st-advance { --pin: var(--st-advance); }
.nm-pin.is-group { border-width: 3px; }
/* the company's line now: a ring of its colour, blinking the faster the more it uses */
.nm-pin.has-live { box-shadow: 0 0 0 3px var(--live), 0 1px 4px rgba(15, 23, 42, .4); }
@media (prefers-reduced-motion: no-preference) {
  .nm-pin.has-live[data-level="1"] { animation: nm-live-ring 3.2s steps(1, end) infinite; }
  .nm-pin.has-live[data-level="2"] { animation: nm-live-ring 1.6s steps(1, end) infinite; }
  .nm-pin.has-live[data-level="3"] { animation: nm-live-ring .7s steps(1, end) infinite; }
}
/* as a port's light on a MikroTik: lit, with short dark flickers at uneven gaps -- more often the more traffic */
@keyframes nm-live-ring { 0%, 13%, 30%, 41%, 61%, 82%, 94%, 100% { box-shadow: 0 0 0 3px var(--live), 0 1px 4px rgba(15, 23, 42, .4); } 9%, 27%, 36%, 58%, 77%, 91% { box-shadow: 0 0 0 0 transparent, 0 1px 4px rgba(15, 23, 42, .4); } }
.nm-pin.st-debt { position: relative; }
.nm-pin.st-debt::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--st-debt); opacity: 0; animation: nm-pulse 2.4s ease-out infinite; }
@keyframes nm-pulse { 0% { transform: scale(.6); opacity: .7; } 80%, 100% { transform: scale(1.35); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .nm-pin.st-debt::after { animation: none; } }

/* Network sites: a rounded square with a mast, colored by kind. */
.nm-site-wrap { background: none; border: 0; }
.nm-site { --site: var(--site-tower); display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--pin-ring); border-radius: 9px; background: var(--site); color: #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .35); box-sizing: border-box; }
.nm-site .icon { width: 17px; height: 17px; stroke-width: 1.9; }
.nm-site.is-small { width: 24px; height: 24px; border-radius: 7px; border-width: 1.5px; }
.nm-site.kind-pop:not(.is-small) { width: 36px; height: 36px; border-radius: 11px; }
.nm-site.kind-pop:not(.is-small) .icon { width: 20px; height: 20px; }
/* An antenna here is off, or no signal reaches it: a red ring that pulses. */
.nm-site { position: relative; }
.nm-site.is-alert { border-color: var(--wire-down); }
.nm-site.is-alert::after { content: ""; position: absolute; inset: -6px; border-radius: 12px; border: 2px solid var(--wire-down); opacity: 0; animation: nm-pulse 2s ease-out infinite; }
.nm-site.is-small.is-alert::after { inset: -4px; border-radius: 9px; }
@media (prefers-reduced-motion: reduce) { .nm-site.is-alert::after { animation: none; opacity: .6; } }
.nm-site.is-small .icon { width: 14px; height: 14px; }
.nm-site.kind-rooftop, .nm-coverage.kind-rooftop, .nm-kind.kind-rooftop { --site: var(--site-rooftop); }
.nm-site.kind-pop, .nm-coverage.kind-pop, .nm-kind.kind-pop { --site: var(--site-pop); }
.nm-site.kind-relay, .nm-coverage.kind-relay, .nm-kind.kind-relay { --site: var(--site-relay); }
[data-theme="dark"] .nm-site.kind-pop { color: #0f172a; }
.nm-coverage { --site: var(--site-tower); stroke: var(--site); stroke-width: 1.5; stroke-opacity: .55; stroke-dasharray: 6 5; fill: var(--site); fill-opacity: .07; }
/* Lines: a faint wire with dots running along it the way the signal goes
   (site -> client, upstream -> downstream). The backbone between sites is the
   thick one. Red and still when broken; faint red below a break. */
.nm-wire { fill: none; stroke: var(--wire-client); stroke-width: 2; stroke-opacity: .32; stroke-linecap: round; }
.nm-wire.is-backbone { stroke: var(--wire-backbone); stroke-width: 6; stroke-opacity: .36; }
.nm-wire.is-dc { stroke: var(--wire-dc); stroke-opacity: .42; }
/* A wired client: a solid line, no dots -- the signal isn't in the air. */
.nm-wire.is-cable { stroke: var(--wire-cable); stroke-width: 3; stroke-opacity: .85; }
.nm-wire.is-off { stroke: var(--st-off); stroke-opacity: .6; stroke-dasharray: 2 5; }
.nm-wire.is-down { stroke: var(--wire-down); stroke-opacity: .85; stroke-dasharray: 8 6; }
.nm-wire.is-cut { stroke: var(--wire-down); stroke-opacity: .55; stroke-dasharray: 3 6; }
.nm-wire.is-backbone.is-down, .nm-wire.is-backbone.is-cut { stroke-width: 4; }
.nm-flow { fill: none; stroke: var(--wire-client); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: .1 16; animation: nm-flow 1.2s linear infinite; }
.nm-flow.is-backbone { stroke: var(--wire-backbone); stroke-width: 6; stroke-dasharray: .1 22; animation-name: nm-flow-backbone; animation-duration: 1s; }
.nm-flow.is-dc { stroke: var(--wire-dc); }
@keyframes nm-flow { to { stroke-dashoffset: -16; } }
@keyframes nm-flow-backbone { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) { .nm-flow { animation: none; } }
/* Legend swatches for the lines */
.lg-wire { display: inline-block; flex: none; width: 18px; height: 0; border-top: 2px dotted var(--wire-client); }
.lg-wire.is-backbone { border-top: 4px solid color-mix(in srgb, var(--wire-backbone) 55%, transparent); border-radius: 2px; }
.lg-wire.is-dc { border-top-color: color-mix(in srgb, var(--wire-dc) 75%, transparent); }
.lg-wire.is-cable { border-top: 3px solid var(--wire-cable); }
.map-filter .lg-wire { width: 14px; }
.nm-kind.is-cable { --site: var(--wire-cable); }
.nm-cable-tag { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: color-mix(in srgb, var(--wire-cable, #0d9488) 14%, transparent); color: var(--wire-cable, #0d9488); font-size: 10.5px; font-style: normal; font-weight: 650; }
.lg-wire.is-down { border-top: 2px dashed var(--wire-down); }
/* A fanned-out stack: thin legs from the spot to each sign */
.nm-fan-leg { fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 3 3; stroke-opacity: .85; }
.netmap.base-satellite .nm-fan-leg { stroke: #fff; }
.nm-measure { stroke: var(--primary); stroke-width: 3; stroke-dasharray: 8 6; fill: none; }
.nm-measure-dot { stroke: var(--primary); stroke-width: 2.5; fill: #fff; fill-opacity: 1; }
.nm-me { stroke: #fff; stroke-width: 2.5; fill: #2f66ea; fill-opacity: 1; }
.nm-me-accuracy { stroke: #2f66ea; stroke-opacity: .35; stroke-width: 1; fill: #2f66ea; fill-opacity: .1; }
.nm-place-pin { display: grid; place-items: center; width: 36px; height: 36px; color: var(--primary); filter: drop-shadow(0 3px 4px rgba(15, 23, 42, .4)); cursor: grab; }
.nm-place-pin .icon { width: 36px; height: 36px; fill: color-mix(in srgb, var(--primary) 22%, #fff); stroke-width: 1.8; }

/* Tooltips and popups */
.leaflet-tooltip.nm-tip { padding: 4px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-elevated); color: var(--text); box-shadow: var(--shadow-sm); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.leaflet-tooltip-top.nm-tip::before { border-top-color: var(--line-strong); }
.nm-popup .leaflet-popup-content-wrapper { padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel-elevated); color: var(--text); box-shadow: var(--shadow-md); }
.nm-popup .leaflet-popup-tip { background: var(--panel-elevated); box-shadow: none; }
.nm-popup .leaflet-popup-content { margin: 0; font-size: 13px; line-height: 1.45; }
.nm-popup a.leaflet-popup-close-button { top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 7px; color: var(--muted); font: 18px/22px system-ui, sans-serif; }
.nm-popup a.leaflet-popup-close-button:hover { background: var(--panel-muted); color: var(--text); }
.nm-pop { display: grid; gap: 10px; padding: 14px 16px 14px; }
.nm-pop-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-right: 22px; }
.nm-pop-head b { font-size: 14.5px; font-weight: 650; color: var(--text); line-height: 1.3; }
.nm-pop-head .status-badge { min-height: 22px; padding: 2px 9px; font-size: 11.5px; }
.nm-pop-rows { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 14px; margin: 0; font-variant-numeric: tabular-nums; }
.nm-pop-rows dt { color: var(--muted); font-size: 12px; }
.nm-pop-rows dd { margin: 0; color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }
.nm-pop-rows dd small { display: block; color: var(--muted); font-size: 11.5px; }
.nm-pop-rows a { color: var(--primary); text-decoration: none; }
.nm-pop .is-red { color: var(--red); font-weight: 650; }
.nm-pop .is-violet { color: var(--st-advance); font-weight: 650; }
.nm-pop .is-muted { color: var(--muted); }
/* The antennas in a popup */
.nm-devs { display: grid; gap: 2px; padding-top: 9px; border-top: 1px solid var(--line); }
.nm-devs-head { padding: 0 4px 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.nm-dev { display: grid; grid-template-columns: 8px minmax(0, 1fr); align-items: start; gap: 9px; width: 100%; padding: 6px 6px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; }
button.nm-dev { cursor: pointer; }
button.nm-dev:hover { background: var(--panel-muted); }
button.nm-dev:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.nm-dev-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--green); }
.nm-dev.is-down .nm-dev-dot { background: var(--wire-down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wire-down) 22%, transparent); }
.nm-dev-main { display: grid; gap: 2px; min-width: 0; }
.nm-dev-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
.nm-dev-title b { color: var(--text); font-size: 12.5px; font-weight: 650; }
.nm-dev small { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.nm-dev-addr { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.nm-role { --role: var(--role-tx); padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--role) 13%, transparent); color: var(--role); font-size: 11px; font-weight: 650; }
.nm-role.role-rx { --role: var(--role-rx); }
.nm-role.role-txrx { --role: var(--role-txrx); }
.nm-off { color: var(--wire-down); font-size: 11.5px; font-weight: 650; }
/* A site's equipment, as it is wired: box -> MikroTik -> antennas */
.nm-equip, .map-equip-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: start; gap: 8px; width: 100%; padding: 5px 6px 5px calc(6px + var(--lvl, 0) * 16px); border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; }
button.nm-equip, button.map-equip-row { cursor: pointer; }
button.nm-equip:hover, button.map-equip-row:hover { background: var(--panel-muted); }
button.nm-equip:focus-visible, button.map-equip-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.nm-equip-ico { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: color-mix(in srgb, var(--text-2) 10%, transparent); color: var(--text-2); }
.nm-equip-ico .icon { width: 14px; height: 14px; }
.nm-equip-ico.kind-router { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.nm-equip-ico.kind-antenna { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); }
.nm-equip.is-down .nm-equip-ico, .map-equip-row.is-down .nm-equip-ico { background: color-mix(in srgb, var(--wire-down) 16%, transparent); color: var(--wire-down); }
.nm-flowtext { color: var(--text-2) !important; }
.map-equip-row { margin-left: calc(var(--lvl, 0) * 4px); padding-left: calc(10px + var(--lvl, 0) * 14px); width: auto; }
.map-equip-row b { font-size: 12.5px; }
.nm-kind { --site: var(--site-tower); padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--site) 14%, transparent); color: var(--site); font-size: 11.5px; font-weight: 650; }
.nm-pop-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.nm-act { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; }
.leaflet-container a.nm-act { color: var(--text-2); }
.nm-act .icon { width: 14px; height: 14px; }
.nm-act:hover:not(:disabled) { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.nm-act:disabled { opacity: .45; cursor: not-allowed; }
.nm-act:focus-visible, .nm-name:focus-visible, .nm-mini:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.nm-pop-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nm-pop-list.is-scroll { max-height: 170px; overflow-y: auto; }
.nm-pop-list li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 7px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.nm-pop-list li:hover { background: var(--panel-muted); }
.nm-pop-list li > span { color: var(--muted); font-size: 12px; }
.nm-name { overflow: hidden; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.nm-name:hover { color: var(--primary); }
.nm-mini { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.nm-mini .icon { width: 14px; height: 14px; }
.nm-mini:hover { background: var(--primary-soft); color: var(--primary); }
.nm-ctx { gap: 4px; padding: 10px; }
.nm-ctx .nm-act { justify-content: flex-start; border-color: transparent; background: transparent; }
.nm-ctx-coords { padding: 0 6px 4px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* A small base switch on the compact maps */
.segmented.nm-base-toggle { box-shadow: var(--shadow-sm); background: var(--panel-elevated); }
.segmented.nm-base-toggle button { min-height: 26px; padding: 0 10px; font-size: 12px; }

/* ---- Dashboard card --------------------------------------------------- */
.map-card { margin-top: 0; margin-bottom: 20px; overflow: hidden; }
.map-card-side { display: flex; align-items: center; gap: 18px; min-width: 0; }
.map-key, .map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--muted); font-size: 12px; }
.map-key span, .map-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.map-card-body { position: relative; }
#dashMap { height: 400px; }
.map-card-empty { position: absolute; inset: 0; z-index: 500; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--panel) 62%, transparent); backdrop-filter: blur(1.5px); }
.map-card-empty > div { display: grid; justify-items: center; gap: 8px; max-width: 420px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-elevated); box-shadow: var(--shadow-md); text-align: center; }
.map-card-empty b { color: var(--text); font-size: 15px; }
.map-card-empty p { margin: 0 0 4px; color: var(--muted); font-size: 13px; line-height: 1.5; text-wrap: balance; }
@media (max-width: 1100px) { .map-key { display: none; } }

/* ---- The map page -------------------------------------------------------- */
.map-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.map-stat { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); box-shadow: var(--shadow-sm); }
.map-stat > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.map-stat strong { color: var(--text); font-size: 22px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.map-stat strong em { color: var(--muted); font-size: 15px; font-style: normal; font-weight: 600; }
.map-stat small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.map-stat small .text-link { min-height: 0; padding: 0; font-size: 12px; }
.map-stat.is-alert strong { color: var(--red); }
.map-progress { height: 5px; margin: 2px 0 2px; border-radius: 99px; background: var(--panel-muted); overflow: hidden; }
.map-progress i { display: block; height: 100%; border-radius: inherit; background: var(--green); }

.map-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; height: max(560px, calc(100vh - 318px)); }
.map-side { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); box-shadow: var(--shadow-sm); overflow: hidden; }
.map-side-head { display: grid; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.search-box.map-search { width: 100%; }
.map-search input { min-height: 40px; }
.map-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.map-filter button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .14s var(--ease), background .14s var(--ease); }
.map-filter button:hover { border-color: var(--line-strong); }
.map-filter button[aria-pressed="true"] { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.map-filter button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.segmented.map-tabs { display: flex; }
.segmented.map-tabs button { flex: 1 1 auto; padding: 0 8px; font-size: 12px; white-space: nowrap; }
.segmented.map-tabs b { margin-left: 3px; font-variant-numeric: tabular-nums; }
.map-list { overflow-y: auto; padding: 6px; }
.map-list-note { margin: 4px 8px 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.map-list-empty { display: grid; gap: 6px; padding: 34px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.map-list-empty small { font-size: 12px; line-height: 1.5; }
.map-row { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.map-row:hover { background: var(--panel-muted); }
.map-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.map-row.is-static { cursor: default; }
.map-row:has(.map-row-hit) { grid-template-columns: minmax(0, 1fr) auto; padding: 3px 6px 3px 3px; }
.map-row-hit { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 10px; padding: 6px 7px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.map-row-hit:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.map-row-main { display: grid; gap: 1px; min-width: 0; }
.map-row-main b { overflow: hidden; color: var(--text); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.map-row-main small, .map-row-side small { display: block; max-width: 100%; overflow: hidden; color: var(--muted); font-size: 11.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.map-row-side { display: grid; justify-items: end; gap: 1px; min-width: 0; max-width: 128px; color: var(--text-2); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.map-row-actions { display: flex; gap: 5px; }
/* The network tree: each site under the one it gets its signal from. */
.map-row.map-tree-row { position: relative; width: auto; margin-left: calc(var(--depth, 0) * 20px); grid-template-columns: minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: auto; }
.map-tree-row.is-child::before { content: ""; position: absolute; left: -10px; top: -5px; width: 10px; height: 26px; border-left: 1.5px solid var(--line-strong); border-bottom: 1.5px solid var(--line-strong); border-bottom-left-radius: 7px; pointer-events: none; }
.nm-alert-chip { padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--wire-down) 12%, transparent); color: var(--wire-down); font-size: 11px; font-weight: 650; white-space: nowrap; }
/* The antenna form */
.segmented.device-roles { display: flex; }
.segmented.device-roles button { flex: 1 1 0; }
.addr-input { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
/* "Add": what is added */
.add-choice-body { display: grid; gap: 12px; }
.add-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.add-choice { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color .14s var(--ease), background .14s var(--ease); }
.add-choice:hover:not(:disabled) { border-color: var(--primary-line); background: var(--primary-soft); }
.add-choice:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.add-choice:disabled { opacity: .45; cursor: not-allowed; }
.add-choice b { display: block; color: var(--text); font-size: 13.5px; font-weight: 650; }
.add-choice small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.add-choice.is-wide { padding: 12px 14px; }
.add-choice-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--text-2) 10%, transparent); color: var(--text-2); }
.add-choice-ico .icon { width: 18px; height: 18px; }
.add-choice-ico.is-tx { background: color-mix(in srgb, var(--role-tx) 14%, transparent); color: var(--role-tx); }
.add-choice-ico.is-rx { background: color-mix(in srgb, var(--role-rx) 14%, transparent); color: var(--role-rx); }
.add-choice-ico.is-txrx { background: color-mix(in srgb, var(--role-txrx) 14%, transparent); color: var(--role-txrx); }
.add-choice-ico.is-router { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.add-choice-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 600; }
.add-choice-sep::before, .add-choice-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.add-choice-body .field { margin: 0; }
/* Settings: the map's line colours */
.map-colors { display: grid; gap: 4px; }
.map-color-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 40px; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 10px; cursor: pointer; }
.map-color-row:hover { background: var(--panel-muted); }
.map-color-row input[type="color"] { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); cursor: pointer; }
.map-color-row span { display: grid; gap: 2px; min-width: 0; }
.map-color-row b { color: var(--text); font-size: 13.5px; font-weight: 650; }
.map-color-row small { color: var(--muted); font-size: 12px; }
.map-color-row .lg-wire { width: 40px; }
.line-editor { display:grid; grid-template-columns:1.1fr 1fr; gap:20px 24px; }
.line-preview { display:flex; flex-direction:column; justify-content:center; background:var(--panel-muted); border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.line-preview canvas { display:block; width:100%; height:224px; }
.line-preview>span { display:block; padding:0 14px 14px; font-size:11px; color:var(--muted); }
.line-controls { display:grid; grid-template-columns:minmax(0,1fr); gap:16px; }
.line-controls .field { margin:0; }
.line-controls label { display:flex; justify-content:space-between; gap:8px; }
.line-controls output { color:var(--primary); font-variant-numeric:tabular-nums; }
.line-controls input[type=range] { width:100%; min-height:36px; padding:0; accent-color:var(--primary); cursor:pointer; }
.line-editor>.map-colors { grid-column:1/-1; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 24px; }
.line-editor>.field-hint,.line-editor-actions { grid-column:1/-1; }
.line-editor-actions { display:flex; align-items:center; flex-wrap:wrap; gap:10px; border-top:1px solid var(--line); padding-top:16px; }
.line-editor-actions>span { margin-right:auto; color:var(--muted); font-size:12px; }
@media(max-width:900px){.line-editor{grid-template-columns:1fr}.line-controls{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.line-controls,.line-editor>.map-colors{grid-template-columns:1fr}.line-editor-actions>span{width:100%}}
.map-row-actions .btn.small { min-height: 30px; padding: 5px 10px; }

.map-stage { position: relative; min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel-muted); box-shadow: var(--shadow-sm); overflow: hidden; }
#netMap { position: absolute; inset: 0; }
.map-fallback { display: grid; place-items: center; height: 100%; padding: 24px; color: var(--muted); font-size: 14px; text-align: center; }
.map-toolbar { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 800; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; pointer-events: none; }
.map-toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; pointer-events: auto; }
.map-toolbar .segmented { background: var(--panel-elevated); box-shadow: var(--shadow-sm); }
.map-toolbar .segmented button[aria-pressed="true"], .nm-base-toggle button[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 13%, var(--panel-elevated)); }
.map-tool { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-elevated); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color .14s var(--ease), color .14s var(--ease), background .14s var(--ease); }
.map-tool .icon { width: 18px; height: 18px; }
.map-tool.icon-only { width: 38px; padding: 0; justify-content: center; }
.map-tool:hover { border-color: var(--primary-line); color: var(--primary); }
.map-tool[aria-pressed="true"] { border-color: var(--primary-line); background: color-mix(in srgb, var(--primary) 13%, var(--panel-elevated)); color: var(--primary); }
.map-tool[data-layer]::before { content: ""; width: 8px; height: 8px; border-radius: 2px; border: 1.5px solid currentColor; }
.map-tool[data-layer][aria-pressed="true"]::before { background: currentColor; }
.map-tool:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 800; max-width: calc(100% - 150px); padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel-elevated) 92%, transparent); box-shadow: var(--shadow-sm); }
.map-legend-note { color: var(--muted-2); }
.map-stage.is-picking .leaflet-container, .map-stage.is-picking .leaflet-grab, .map-stage.is-picking .leaflet-interactive { cursor: crosshair; }
.map-banner { position: absolute; top: 62px; left: 50%; z-index: 900; display: grid; gap: 8px; width: min(560px, calc(100% - 24px)); padding: 12px 14px; border: 1px solid var(--primary-line); border-radius: 14px; background: var(--panel-elevated); box-shadow: var(--shadow-md); transform: translateX(-50%); }
.map-banner .mb-text { display: grid; gap: 2px; }
.map-banner .mb-text b { color: var(--text); font-size: 13.5px; }
.map-banner .mb-text span { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.map-banner .mb-text span b { font-size: 12.5px; }
.map-banner .mb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.map-banner .mb-input, .map-banner .mb-select { flex: 1 1 180px; min-width: 0; min-height: 34px; padding: 5px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 12.5px; }
.map-banner .btn.danger-text { color: var(--red); }
.map-banner .mb-input:focus, .map-banner .mb-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.map-banner .btn.small { min-height: 34px; }
@media (max-width: 1500px) { .map-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; height: auto; }
  .map-stage { height: 64vh; min-height: 420px; order: -1; }
  .map-side { max-height: 520px; }
  .map-legend { display: none; }
}
@media (max-width: 640px) {
  .map-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .map-stat { padding: 10px 12px; }
  .map-stat strong { font-size: 18px; }
  .map-stat:last-child { grid-column: 1 / -1; }
  .map-toolbar .map-tool[data-layer] { display: none; }
  .map-banner { top: 58px; }
}

/* ---- The subscriber form's picker ------------------------------------------ */
.loc-field { display: grid; gap: 8px; }
.loc-field > label { margin-bottom: 0; }
.loc-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.loc-bar input { flex: 1 1 220px; min-width: 0; }
.loc-bar .btn.small { min-height: 42px; }
.loc-bar .btn.icon-only { width: 42px; padding: 0; justify-content: center; }
.loc-bar .btn.icon-only .icon { width: 17px; height: 17px; }
.loc-map { height: 250px; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.loc-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.loc-meta .is-good { color: var(--green); }
.loc-meta .is-bad { color: var(--red); }
.loc-meta .text-link { min-height: 0; padding: 0; color: var(--red); font-size: 12px; }
.loc-results { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.loc-results button { max-width: 100%; overflow: hidden; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.loc-results button:hover { border-color: var(--primary-line); color: var(--primary); }
.loc-suggest { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; padding: 8px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--text-2); font-size: 12.5px; }
.loc-suggest b { color: var(--text); }
.loc-suggest .text-link { min-height: 0; padding: 0; }

/* ---- Site window and the line check ------------------------------------------ */
.modal-actions-gap { flex: 1; }
.link-inputs { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); align-items: end; gap: 10px; }
.link-inputs .field { margin-bottom: 8px; }
.link-inputs label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-verdict { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); color: var(--text-2); font-size: 13px; }
.link-verdict > div { display: grid; gap: 3px; }
.link-verdict b { color: var(--text); font-size: 14px; }
.link-verdict.is-good { border-color: var(--green-line); background: var(--green-bg); }
.link-verdict.is-good b { color: var(--green); }
.link-verdict.is-warn { border-color: var(--amber-line); background: var(--amber-bg); }
.link-verdict.is-warn b { color: var(--amber); }
.link-verdict.is-bad { border-color: var(--red-line); background: var(--red-bg); }
.link-verdict.is-bad b, .link-verdict.is-bad:not(:has(b)) { color: var(--red); }
.link-verdict.is-busy { color: var(--muted); }
.link-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.link-facts > div { display: grid; gap: 2px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.link-facts span { color: var(--muted); font-size: 11.5px; }
.link-facts b { color: var(--text); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.link-chart svg { display: block; width: 100%; height: auto; }
.link-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.lp-grid { stroke: var(--line); stroke-width: 1; }
.lp-axis { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.lp-label { fill: var(--text-2); font-size: 11.5px; font-weight: 600; }
.lp-ground { fill: color-mix(in srgb, var(--carrot) 22%, var(--panel-muted)); stroke: color-mix(in srgb, var(--carrot) 70%, var(--text-2)); stroke-width: 1.5; stroke-linejoin: round; }
.lp-zone { fill: var(--primary); fill-opacity: .1; stroke: none; }
.lp-clear { fill: none; stroke: var(--primary); stroke-opacity: .55; stroke-width: 1.2; stroke-dasharray: 4 4; }
.lp-los { stroke: var(--primary); stroke-width: 2.2; }
.lp-mast { stroke: var(--text-2); stroke-width: 2.5; stroke-linecap: round; }
.lp-end { fill: var(--primary); stroke: var(--panel-elevated); stroke-width: 2; }
.lp-worst { stroke: var(--panel-elevated); stroke-width: 2; }
.lp-worst.is-clear { fill: var(--green); }
.lp-worst.is-partial { fill: var(--amber); }
.lp-worst.is-blocked { fill: var(--red); }
.lp-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 11.5px; }
.lp-key span { display: inline-flex; align-items: center; gap: 6px; }
.lp-key i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--primary); }
.lp-key i.k-zone { height: 8px; border: 0; border-radius: 2px; background: var(--primary); opacity: .18; }
.lp-key i.k-clear { border-top: 1.5px dashed var(--primary); opacity: .7; }
/* the signal over the line: a wave flowing from the mast to the client, its channel on a badge */
.link-chart { position: relative; }
.lp-los.is-faint { stroke-opacity: .35; stroke-width: 1.4; }
.lp-wave, .lp-wave-glow { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.lp-wave { stroke-width: 2.6; stroke-dasharray: 11 6; animation: lp-flow 1.1s linear infinite; }
.lp-wave-glow { stroke-width: 9; stroke-opacity: .16; }
.lp-wave.is-good, .lp-wave-glow.is-good { stroke: var(--green); }
.lp-wave.is-warn, .lp-wave-glow.is-warn { stroke: var(--amber); }
.lp-wave.is-bad, .lp-wave-glow.is-bad { stroke: var(--red); }
@keyframes lp-flow { to { stroke-dashoffset: -17; } }
@media (prefers-reduced-motion: reduce) { .lp-wave { animation: none; } }
.lp-badge { position: absolute; z-index: 1; transform: translate(-50%, calc(-100% - 16px)); display: grid; gap: 1px; justify-items: center; padding: 6px 12px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--panel-elevated); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); white-space: nowrap; pointer-events: auto; }
.lp-badge.is-below { transform: translate(-50%, 16px); }
.lp-badge b { color: var(--text); font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lp-badge span { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.lp-badge.is-good { border-color: var(--green); } .lp-badge.is-warn { border-color: var(--amber); } .lp-badge.is-bad { border-color: var(--red); }
.lp-badge.is-guess { border-style: dashed; }
.link-radio:not(:empty) { display: grid; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.lp-ch-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.lp-ch-head b { color: var(--text); font-size: 13.5px; }
.lp-ch-head span { color: var(--muted); font-size: 12px; }
.lp-ch-svg { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-muted); }
.lp-ch-gap { fill: var(--line); fill-opacity: .45; }
.lp-ch { stroke-width: 1.5; }
.lp-ch.is-good { fill: var(--green); stroke: var(--green); } .lp-ch.is-warn { fill: var(--amber); stroke: var(--amber); } .lp-ch.is-bad { fill: var(--red); stroke: var(--red); }
.lp-ch.is-mast { fill: var(--primary); fill-opacity: .75; stroke: none; }
.lp-ch.is-near { fill: var(--muted-2); fill-opacity: .6; stroke: none; }
.lp-ch.is-clash { stroke: var(--red); stroke-width: 2; }
.lp-ch-t { fill: var(--text-2); font-size: 10.5px; }
.lp-ch-t.is-me { fill: var(--text); font-weight: 700; }
.lp-ch-note { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.lp-ch-note.is-good { color: var(--green); } .lp-ch-note.is-warn { color: var(--amber); } .lp-ch-note.is-bad { color: var(--red); }
.lp-key i.k-wave { width: 18px; height: 6px; border: 0; --c: var(--green); background: radial-gradient(circle at 25% 50%, var(--c) 1.6px, transparent 2px) 0 0 / 6px 6px repeat-x; }
.lp-key i.k-wave.is-warn { --c: var(--amber); } .lp-key i.k-wave.is-bad { --c: var(--red); }
.lp-key i.k-ground { height: 8px; border: 1px solid color-mix(in srgb, var(--carrot) 70%, var(--text-2)); border-radius: 2px; background: color-mix(in srgb, var(--carrot) 22%, var(--panel-muted)); }
@media (max-width: 700px) {
  .link-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .link-inputs .field:first-child { grid-column: 1 / -1; }
  .link-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp-badge, .lp-badge.is-below { position: static; transform: none; width: fit-content; max-width: 100%; margin: 0 auto 8px; white-space: normal; text-align: center; padding: 5px 10px; }
  .lp-badge b { font-size: 12.5px; } .lp-badge span { font-size: 11px; }
}

@media (max-width: 767px) { .modal-actions-gap { display: none; } }

/* ---- the map page's scheme tab (static/network.html, in a frame) ---------------------------------- */
.map-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.network-frame { display: block; width: 100%; height: calc(100vh - 200px); height: calc(100dvh - 200px); min-height: 560px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
/* One Manager workspace: no nested brand, frame card or second page heading. */
body.network-page { overflow:hidden; }
body.network-page .content { max-width:none; padding:0; height:calc(100dvh - 76px); }
#view-map.active { display:flex; flex-direction:column; height:100%; min-height:0; animation:none; }
#mapNetPane,#mapSchemePane { flex:1; min-height:0; }
#view-map .network-frame { width:100%; height:100%; min-height:0; border:0; border-radius:0; background:var(--bg); }
#mapClassicPane { flex:1; min-height:0; overflow:auto; padding:20px 24px; }
/* one row on a wide screen -- the tabs, the network's figures, the actions; narrower, the figures go under them */
.network-toolbar { display:grid; grid-template-columns:auto minmax(0,1fr) auto; grid-template-areas:"tabs ctx acts"; align-items:center; gap:0 18px; padding:8px 24px 0; background:var(--panel); border-bottom:1px solid var(--line); flex-shrink:0; }
.network-tabs { grid-area:tabs; }
.network-context { grid-area:ctx; }
.network-actions { grid-area:acts; }
@media (max-width:1699px) { .network-toolbar { grid-template-columns:auto minmax(0,1fr); grid-template-areas:"tabs acts" "ctx ctx"; } .network-actions { justify-self:end; } .network-context { justify-content:space-between; padding:2px 0 8px; } }
.network-tabs { display:flex; flex-wrap:wrap; gap:6px; min-width:0; }
.network-tabs button { display:flex; align-items:center; justify-content:center; gap:7px; padding:13px 10px; border:0; border-bottom:3px solid transparent; background:none; color:var(--muted); font:inherit; font-size:12px; cursor:pointer; }
.network-tabs button .icon { width:17px; height:17px; }
.network-tabs button:hover { color:var(--text); background:var(--panel-muted); }
.network-tabs button[aria-current] { color:var(--primary); border-bottom-color:var(--primary); font-weight:700; }
.network-actions { display:flex; align-items:center; gap:8px; padding-bottom:7px; }
#networkSave { font-size:11px; color:var(--muted); margin-right:5px; }
#networkSave.bad { color:var(--red); }
/* the network's figures and what waits to be added: in the toolbar's own row, between the tabs and the actions */
.network-context { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:6px 18px; flex:1 1 auto; min-width:0; padding-bottom:7px; }
.network-queues { display:inline-flex; flex-wrap:wrap; gap:6px; }
#networkMetrics { display:flex; align-items:center; gap:18px; color:var(--muted); font-size:12px; }
#networkMetrics b { color:var(--text); margin-right:5px; font-variant-numeric:tabular-nums; }
.network-queue { border:0; background:var(--primary-soft); color:var(--primary); padding:5px 9px; border-radius:6px; font:inherit; font-size:11px; cursor:pointer; }
.network-queue b { margin-left:7px; }
.network-more { position:relative; }
.network-more summary { cursor:pointer; list-style:none; font-size:12px; padding:7px; color:var(--muted); }
.network-more summary::-webkit-details-marker { display:none; }
.network-more-menu { position:absolute; right:0; top:100%; width:240px; padding:7px; background:var(--panel); border:1px solid var(--line); border-radius:10px; box-shadow:var(--shadow-lg); z-index:30; }
.network-more-menu button,.network-more-menu a { display:block; width:100%; text-align:left; background:none; border:0; border-radius:6px; color:var(--text); padding:10px; font:inherit; font-size:12px; cursor:pointer; text-decoration:none; }
.network-more-menu button:hover,.network-more-menu a:hover { background:var(--primary-soft); }
.network-more-menu #mapSwitch { border-top:1px solid var(--line); margin-top:6px; padding-top:7px; }
.network-more-menu #mapSwitch>span { display:block; font-size:10px; color:var(--muted); padding:4px 10px; }
.network-toolbar button:focus-visible,.network-more summary:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
#view-map[data-network-view="scheme"] .network-context,#view-map[data-network-view="map"] .network-context { display:none; }
@media(max-width:767px) {
  body.network-page .content { height:calc(100dvh - 68px); }
  .network-toolbar { grid-template-columns:minmax(0,1fr); grid-template-areas:"tabs" "acts" "ctx"; padding:4px 10px 0; gap:0; }
  .network-tabs { width:100%; gap:0; }
  .network-tabs button { flex:1; padding:11px 4px; font-size:10px; gap:4px; }
  .network-tabs button .icon { display:none; }
  .network-actions { width:100%; padding:5px 0; }
  #networkSave { margin-right:auto; }
  .network-context { justify-content:space-between; padding:4px 0 6px; }
  #networkMetrics { gap:10px; font-size:10px; }
  .network-queue { font-size:10px; }
  #mapClassicPane { padding:12px; }
}
@media (max-width: 767px) {
  #view-map .map-switch-row { flex-wrap: wrap; gap: 6px; }
  #view-map .map-switch { width: 100%; min-width: 0; }
  #view-map .map-switch button { flex: 1; min-width: 0; font-size: 10px; padding: 8px 5px; }
  #view-map #mapSchemeOpen { margin-left: auto; font-size: 10px; padding: 5px 8px; }
}

/* clearing the map: what stays is ticked */
.map-clear-modal { width: min(640px, 100%); }
.map-clear-modal h4 { margin: 16px 0 6px; color: var(--text); font-size: 13px; font-weight: 650; }
.map-clear-lead { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.map-clear-site { padding: 4px 12px 8px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; }
.map-clear-modal .check-row { min-height: 34px; margin: 0; align-items: flex-start; padding-top: 7px; }
.map-clear-modal .check-row input { flex: none; margin-top: 1px; }
.map-clear-modal .check-row span { overflow-wrap: anywhere; }
.map-clear-modal .check-row.is-site { font-size: 13.5px; color: var(--text); }
.map-clear-devs { display: grid; padding-left: 25px; }
.map-clear-devs.is-off { opacity: .45; }
.map-clear-devs small { color: var(--muted); font-size: 12px; padding: 4px 0; }
.map-clear-rules { margin: 0; padding-left: 18px; display: grid; gap: 5px; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.map-clear-sum { margin: 16px 0 4px; padding: 10px 12px; border-radius: 10px; background: var(--panel-muted); color: var(--text); font-size: 13px; }
.map-clear-sure { color: var(--text) !important; font-weight: 600; }
.network-queues { display: inline-flex; flex-wrap: wrap; gap: 6px; }
