/* Drone Operations console — drone-console.js. Its own file and token so a
   console change does not move style.css (pinned by test-console-door-change).
   Colours are the portal's --sc-* tokens; the map needs hex and keeps its own
   in drone-console.js because a canvas cannot read a CSS variable. */

#view-drone-console .dc-pad { padding: 0.9rem 1rem; }
#view-drone-console .dc-muted { color: var(--text-muted, #8A8F9C); font-size: 0.85em; }
#view-drone-console h4 { margin: 0 0 0.6rem; font-size: 0.95rem; }

.dc-card:focus-visible { outline: 2px solid var(--sc-accent, #6E5BE6); outline-offset: 2px; }

.dc-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dc-stat { background: var(--sc-card, #1C202A); border: 1px solid var(--sc-line, #262B36); border-radius: 10px;
  padding: 8px 12px; min-width: 96px; display: flex; flex-direction: column; }
.dc-stat b { font-size: 1.35rem; color: var(--sc-ink, #F2F4F8); }
.dc-stat span { font-size: 0.75rem; color: var(--text-muted, #8A8F9C); }
.dc-stat.warn { border-color: var(--sc-warn, #E0A44B); }
.dc-stat.danger { border-color: var(--sc-danger, #C2185B); background: rgba(194, 24, 91, 0.12); }

.dc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 12px; align-items: start; }
.dc-col-map, .dc-col-board { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.dc-map { position: relative; height: 460px; border-radius: 12px; overflow: hidden; border: 1px solid var(--sc-line, #262B36);
  background: #0F1117; touch-action: none; }
.dc-map.tall { height: 560px; }
.dc-osm { cursor: grab; user-select: none; }
.dc-osm:active { cursor: grabbing; }
.dc-tiles img { position: absolute; width: 256px; height: 256px; pointer-events: none; filter: saturate(0.85); }
.dc-svg { position: absolute; inset: 0; pointer-events: none; }
.dc-mk-label, .dc-gm-label { font: 600 11px var(--font-sans, system-ui); fill: #F2F4F8; paint-order: stroke; stroke: #0F1117; stroke-width: 3px; }
.dc-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.dc-zoom button { width: 32px; height: 32px; border-radius: 6px; border: 1px solid #262B36; background: #1C202A; color: #F2F4F8; font-size: 18px; cursor: pointer; }
.dc-attrib { position: absolute; left: 0; bottom: 0; right: 0; font-size: 10px; padding: 2px 6px; background: rgba(15, 17, 23, 0.75); color: #C9CDD6; }
.dc-attrib a { color: #C9CDD6; }

.dc-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.78rem; color: var(--text-muted, #8A8F9C); }
.dc-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* Columns wrap by the space the board actually has, not the window: the
   portal sidebar and the map take most of a laptop screen. */
.dc-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.dc-colset h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted, #8A8F9C); }
.dc-count { background: var(--sc-line, #262B36); border-radius: 10px; padding: 0 7px; margin-left: 4px; color: var(--sc-ink, #F2F4F8); }
.dc-card { display: block; width: 100%; text-align: left; font: inherit; color: var(--sc-ink, #F2F4F8);
  background: var(--sc-card, #1C202A); border: 1px solid var(--sc-line, #262B36); border-radius: 10px;
  padding: 9px 10px; margin-bottom: 8px; cursor: pointer; }
.dc-card:hover { border-color: #3A4050; }
.dc-card.sel { border-color: var(--sc-accent, #6E5BE6); }
.dc-card.gap { border-color: var(--sc-danger, #C2185B); box-shadow: 0 0 0 1px var(--sc-danger, #C2185B) inset; }
.dc-card-top { display: flex; align-items: center; gap: 6px; }
.dc-card-title { margin: 3px 0; font-weight: 600; font-size: 0.9rem; }
.dc-legs { margin-top: 6px; font-size: 0.82rem; line-height: 1.45; }
.dc-empty { color: var(--text-muted, #8A8F9C); font-size: 0.85rem; padding: 10px 2px; }

.dc-pill { display: inline-block; font-size: 0.72rem; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--c);
  color: var(--c); text-transform: capitalize; white-space: nowrap; }
.dc-prio { font-size: 0.7rem; padding: 0 6px; border-radius: 6px; margin-left: auto; background: var(--sc-line, #262B36); }
.dc-prio.p1 { background: var(--sc-danger, #C2185B); color: #fff; }
.dc-flag { display: inline-block; margin-top: 5px; font-size: 0.78rem; padding: 2px 8px; border-radius: 6px; }
.dc-flag.ok { background: rgba(63, 207, 142, 0.14); color: var(--sc-ok, #3FCF8E); }
.dc-flag.warn { background: rgba(224, 164, 75, 0.14); color: var(--sc-warn, #E0A44B); }
.dc-flag.danger { background: rgba(194, 24, 91, 0.18); color: #FF6FA8; font-weight: 600; }
.dc-cap { display: inline-block; font-size: 0.7rem; padding: 0 6px; border-radius: 6px; background: var(--sc-line, #262B36); margin: 1px 0; }

.dc-detail-head { display: flex; align-items: center; gap: 8px; }
.dc-detail-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.dc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.dc-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 8px 0; }
.dc-table th, .dc-table td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--sc-line, #262B36); vertical-align: top; }
.dc-table th { color: var(--text-muted, #8A8F9C); font-weight: 600; font-size: 0.75rem; }
.dc-list { margin: 4px 0 10px; padding-left: 18px; font-size: 0.82rem; line-height: 1.5; }
.dc-tl .k-gap, .dc-tl .k-bingo { color: #FF6FA8; }
.dc-tl .k-handover, .dc-tl .k-relief { color: var(--sc-warn, #E0A44B); }

.dc-form { display: flex; flex-direction: column; gap: 8px; }
.dc-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.dc-form label, .dc-maptools label { display: flex; flex-direction: column; gap: 3px; font-size: 0.75rem; color: var(--text-muted, #8A8F9C); }
.dc-form label.dc-check, .dc-maptools label.dc-check { flex-direction: row; align-items: center; gap: 6px; color: var(--sc-ink, #F2F4F8); font-size: 0.82rem; }
#view-drone-console input:not([type=checkbox]), #view-drone-console select, #view-drone-console textarea {
  background: var(--sc-canvas, #0F1117); border: 1px solid var(--sc-line, #262B36); color: var(--sc-ink, #F2F4F8);
  border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 0.85rem; min-width: 0; }
.dc-caps { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.dc-inline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; font-size: 0.82rem; }
.dc-maptools { align-items: center; }
.dc-plan { margin-top: 8px; font-size: 0.85rem; line-height: 1.5; }
.dc-plan ol { margin: 6px 0; padding-left: 20px; }
.dc-token { margin-top: 10px; padding: 10px; border-radius: 8px; border: 1px solid var(--sc-warn, #E0A44B); background: rgba(224, 164, 75, 0.08);
  font-size: 0.82rem; display: flex; flex-direction: column; gap: 6px; }
.dc-token code { word-break: break-all; font-family: var(--font-mono, monospace); background: #0F1117; padding: 6px; border-radius: 6px; user-select: all; }

/* v1.1 — one page per menu entry; collapsible forms; the mission book. */
#view-drone-console [hidden] { display: none !important; }
.dc-clickable tbody tr { cursor: pointer; }
.dc-clickable tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.dc-clickable tbody tr.sel { background: rgba(110, 91, 230, 0.14); }
.dc-clickable tbody tr:focus-visible { outline: 2px solid var(--sc-accent, #6E5BE6); outline-offset: -2px; }
.dc-filters { margin-bottom: 12px; }
.dc-filters label { display: flex; flex-direction: column; gap: 3px; font-size: 0.75rem; color: var(--text-muted, #8A8F9C); }
.dc-filters label.dc-check { flex-direction: row; align-items: center; gap: 6px; color: var(--sc-ink, #F2F4F8); }
.dc-pager { justify-content: flex-end; margin-top: 8px; }

/* v1.2 — the map's layers. */
.dc-canvas { position: absolute; inset: 0; pointer-events: none; }
.dc-gcanvas { pointer-events: none; }
.dc-osm.dc-base-dark { background: #0b0e14; }
.dc-ring-label { font: 600 10px var(--font-sans, system-ui); fill: #cfe3ff; paint-order: stroke; stroke: #0F1117; stroke-width: 3px; }
.dc-layers { position: absolute; left: 8px; top: 8px; z-index: 5; font-size: 0.8rem; color: #F2F4F8; max-width: 240px; }
.dc-layers-btn { background: #1C202A; border: 1px solid #3A4050; color: #F2F4F8; border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.dc-layers-btn[aria-expanded="true"] { border-color: var(--sc-accent, #6E5BE6); }
.dc-layers-body { margin-top: 6px; background: rgba(20, 23, 31, 0.96); border: 1px solid #3A4050; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow: auto; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.dc-layers-body label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.dc-layers-h { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; color: #8A8F9C; margin-top: 6px; }
.dc-bases { display: flex; flex-wrap: wrap; gap: 4px; }
.dc-bases button { background: #0F1117; border: 1px solid #3A4050; color: #F2F4F8; border-radius: 6px; padding: 3px 8px; font: inherit; cursor: pointer; }
.dc-bases button.on { background: var(--sc-accent, #6E5BE6); border-color: var(--sc-accent, #6E5BE6); }
.dc-legend-box { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; color: #C9CDD6; }
.dc-legend-box i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px; vertical-align: -1px; }
.dc-ramp { display: inline-block; width: 70px; height: 8px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; }
.dc-ramp.inc { background: linear-gradient(90deg, rgba(40,110,255,.6), rgb(60,220,120), rgb(255,220,60), rgb(235,40,60)); }
.dc-ramp.gap { background: linear-gradient(90deg, rgba(170,40,200,.6), rgb(235,60,120), rgb(255,40,40)); }

/* v1.3 — live video, targets and sightings, the black box. */
.dc-mini { padding: 2px 7px; font-size: 0.72rem; }
.dc-live, .dc-targets { margin: 10px 0; padding: 10px; border: 1px solid var(--sc-line, #262B36); border-radius: 10px; background: rgba(0,0,0,.15); }
.dc-videos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.dc-vcell { background: #000; border-radius: 8px; overflow: hidden; min-height: 120px; display: flex; flex-direction: column; }
.dc-vhead { font-size: 0.75rem; padding: 4px 8px; background: #11141c; display: flex; gap: 6px; align-items: center; }
.dc-rec { color: #ff4d6d; font-weight: 700; }
.dc-video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; display: block; }
.dc-novideo { padding: 18px 10px; color: #8A8F9C; font-size: 0.8rem; text-align: center; }
.dc-alarms .sev-critical { color: #FF6FA8; font-weight: 600; }
.dc-alarms .sev-warning { color: var(--sc-warn, #E0A44B); }
.dc-target-form input { max-width: 150px; }
.dc-bb { margin-top: 10px; padding: 10px; border-radius: 8px; border: 1px solid var(--sc-ok, #3FCF8E); font-size: 0.82rem; }
.dc-bb.bad { border-color: var(--sc-danger, #C2185B); background: rgba(194, 24, 91, 0.1); }

/* v1.4 — a control room screen does not grow: every section has its own
   height and its own scroll, sized to the window (the owner: "it keeps
   extending without scrolls"). The map stays in view while the board and the
   mission detail scroll beside it. */
#view-drone-console .dc-grid { align-items: stretch; }
#view-drone-console .dc-col-map { position: sticky; top: 8px; align-self: start; }
#view-drone-console .dc-map { height: clamp(360px, calc(100vh - 290px), 760px); }
#view-drone-console .dc-map.tall { height: clamp(380px, calc(100vh - 260px), 820px); }
#view-drone-console .dc-col-board { max-height: calc(100vh - 220px); min-height: 420px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#view-drone-console #dc-board { flex: 0 1 auto; max-height: 44%; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
#view-drone-console #dc-detail, #view-drone-console #dc-hub-detail { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#view-drone-console #dc-detail:empty { display: none; }
#view-drone-console #dc-new { max-height: 46vh; overflow-y: auto; }
#view-drone-console #dc-mission-table { max-height: calc(100vh - 300px); overflow: auto; }
#view-drone-console #dc-fleet-table, #view-drone-console #dc-hub-table { overflow-x: auto; }
#view-drone-console #dc-fleet-table { max-height: calc(100vh - 260px); overflow-y: auto; }
#view-drone-console .dc-table thead th { position: sticky; top: 0; background: var(--sc-card, #1C202A); z-index: 1; }
@media (max-width: 960px) {
  #view-drone-console .dc-col-map { position: static; }
  #view-drone-console .dc-col-board { max-height: none; }
}
.dc-nomap { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 24px; color: #C9CDD6; }
.dc-nomap p { max-width: 440px; font-size: 0.85rem; color: #8A8F9C; }
.dc-devmap .dc-attrib b { color: var(--sc-warn, #E0A44B); }
.dc-night .dc-tiles img { filter: invert(1) hue-rotate(185deg) brightness(0.82) contrast(0.92) saturate(0.6); }
/* v1.4 — the working day: duty board, incidents, flight log, reports. */
.dc-duties { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.dc-duty { border: 1px solid var(--sc-line, #262B36); border-radius: 10px; padding: 10px; font-size: 0.85rem; line-height: 1.5; }
.dc-duty.ok { border-color: var(--sc-ok, #3FCF8E); }
.dc-duty.none { border-color: var(--sc-danger, #C2185B); background: rgba(194, 24, 91, 0.08); }
.dc-handover { margin-top: 6px; font-size: 0.78rem; border-top: 1px dashed var(--sc-line, #262B36); padding-top: 6px; }
.dc-closure { margin: 10px 0; padding: 10px; border-radius: 8px; border: 1px solid var(--sc-line, #262B36); background: rgba(0,0,0,.15); font-size: 0.85rem; }
.dc-bar { display: inline-block; width: 70px; height: 7px; border-radius: 4px; background: var(--sc-line, #262B36); vertical-align: middle; overflow: hidden; }
.dc-bar i { display: block; height: 100%; background: var(--sc-accent, #6E5BE6); }
.dc-pf { margin: 10px 0; padding: 10px; border: 1px solid var(--sc-warn, #E0A44B); border-radius: 8px; }
.dc-pf label.dc-check { color: var(--sc-ink, #F2F4F8); }

/* v1.5 — the hub drawer, the situation card, clickable markers. */
.dc-osm.dc-over-marker { cursor: pointer; }
.dc-stats-sm .dc-stat { min-width: 84px; padding: 6px 9px; }
.dc-stats-sm .dc-stat b { font-size: 1.05rem; }
.dc-hubdrawer .dc-acts { white-space: normal; }
.dc-hubdrawer .dc-acts select { max-width: 130px; }
.dc-situation { flex: 0 0 auto; max-height: 34%; overflow-y: auto; border-color: rgba(110, 91, 230, 0.45); }
.dc-situation .dc-list li { margin-bottom: 3px; }
.dc-assess { margin: 8px 0; padding: 8px 10px; border-left: 3px solid var(--sc-accent, #6E5BE6); background: rgba(110, 91, 230, 0.08); font-size: 0.85rem; }
.dc-declog .k-gap, .dc-declog .k-safety { color: #FF6FA8; }
.dc-declog .k-rebalance, .dc-declog .k-rebalance_done { color: var(--sc-ok, #3FCF8E); }
#view-drone-console #dc-situation:empty, #view-drone-console #dc-hub-detail:empty { display: none; }
/* v1.5.1 — what is OPEN gets the room. The situation is a compact strip; the
   board shrinks to a strip while a hub or a mission is open, and grows back
   when it is closed. */
#view-drone-console #dc-situation { flex: 0 0 auto; max-height: 26%; overflow-y: auto; overscroll-behavior: contain; }
#view-drone-console .dc-situation { max-height: none; overflow: visible; }
#view-drone-console .dc-col-board.has-open #dc-board { max-height: 22%; }
#view-drone-console .dc-col-board.has-open #dc-situation { max-height: 16%; }

/* v1.7 — regions. */
.dc-chip { display: inline-block; font-size: 0.72rem; padding: 1px 7px; border-radius: 8px; border: 1px solid var(--sc-line, #262B36); color: var(--sc-ink, #F2F4F8); text-decoration: none; margin: 1px 2px; }
.dc-chip:hover { border-color: var(--sc-accent, #6E5BE6); }
.dc-row-gap td:first-child { border-left: 3px solid var(--sc-danger, #C2185B); }
#drone-console-controls select { background: var(--sc-canvas, #0F1117); border: 1px solid var(--sc-line, #262B36); color: var(--sc-ink, #F2F4F8); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 0.85rem; }

/* Mappls markers: the same grammar as the dev map — a dot (drone), a square (hub), hollow for out of service */
.dc-mp-mk { box-sizing: border-box; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); cursor: pointer; }
.dc-mp-mk.sq { border-radius: 3px; }
.dc-mp-mk.hollow { background: transparent; border-color: var(--c); }
.dc-mp-label { position: absolute; left: 100%; top: -2px; margin-left: 4px; white-space: nowrap; font: 600 11px/1.2 system-ui, sans-serif; color: #111; text-shadow: 0 0 2px #fff, 0 0 2px #fff; pointer-events: none; }
