/* Control room (ported Eshaan "Operations Digital Twin" screens), in the control-tower look (docs/UI_CONTROL_TOWER.md).
   base.css already carries the demo's component styles; this file adds only what the SaaS port needs, scoped under the
   screen root .twin-root (not .twin: base.css already uses that for the demo yard diagram, `.twin svg { width: 100% }`).
   The copilot drawer lives on <body> as .twin-drawer. Tokens only; the live map keeps its dark canvas (the --map-*
   tokens) in both themes. */

.twin-root { min-width: 0; }
.twin-root .twin-kpis { margin-bottom: var(--gap); }

/* data provenance: "Sample data" (generated example) and "Your data" (tenant's records) */
.twin-root .pill.twin-sample, .twin-drawer .pill.twin-sample {
  background: var(--warn-soft); color: var(--warn-text); border: 1px dashed currentColor; padding: 0 6px; font-weight: 600; letter-spacing: .01em;
}
.twin-root .pill.twin-sample::before, .twin-drawer .pill.twin-sample::before { border-radius: 1px; transform: rotate(45deg); width: 5px; height: 5px; }
.twin-root .pill.twin-real { background: var(--good-soft); color: var(--good-text); }
.twin-root .card-h .actions .twin-sample { margin-right: 2px; }
.twin-root .kpi .d { flex-wrap: wrap; row-gap: 2px; } /* the pill takes the first line, the delta text the next */
.twin-root .kpi .d .twin-sample { font-size: var(--fs-xs); }
/* the demo's KPI deltas run to two lines: a KPI with a sparkline keeps a strip at its foot for it, so the line never
   runs under the drawing */
.twin-root .kpi:has(> .spark) { padding-bottom: 30px; }
.twin-root .pane-h .sub .twin-sample { font-size: var(--fs-xs); vertical-align: 1px; }
.twin-root .msg .twin-sample { margin-right: 4px; }

.twin-root .twin-banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 7px 10px; margin: 0 0 var(--gap); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2);
}
.twin-root .twin-banner > .pill { flex: none; margin-top: 1px; }
.twin-root .twin-banner b { color: var(--ink); font-weight: 600; }
.twin-root .twin-banner.sample { background: var(--warn-soft); border-color: var(--warn-line); }
.twin-root .twin-banner.real { border-left: 3px solid var(--good); }

/* real data has more and longer names than the demo (e.g. up to 11 customer groups in the map's segment): let the page
   header, its actions and segmented controls wrap instead of pushing the screen sideways */
.twin-root .page-h { flex-wrap: wrap; }
.twin-root .page-h .actions { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
.twin-root .seg { flex-wrap: wrap; max-width: 100%; }

/* base.css also styles a 3D scene's `.face` as position:absolute; in the control room `.face` is always the avatar badge,
   which must stay in its table cell / profile header */
.twin-root .face { position: relative; }

/* the chart kit's donut beside the screen's own legend (helpers.js donut): a fixed width so the flex row keeps it */
.twin-root .twin-donut { flex: none; }
.twin-root .twin-donut .ck-pie > svg { max-width: none; }
.twin-root .card-b > .ck-lollipop, .twin-root .card-b > svg.ck { max-width: 100%; }
/* the kit's sparkline (helpers.js sparkline) outside a .ck chart: its stroke and fill come from its --c here */
.twin-root .ck-spark .ck-line { fill: none; stroke: var(--c, var(--s1)); stroke-linejoin: round; stroke-linecap: round; }
.twin-root .ck-spark .ck-area { fill: var(--c, var(--s1)); }
.twin-root .ck-spark .ck-dot { fill: var(--c, var(--s1)); stroke: var(--surface); stroke-width: 1.5; }

/* the Command Center's jump tiles (jumpTiles(), cls twin-jump): a short title, the amount first in the sub, which may
   take two lines (as the tower's tiles do) so the figure after it is not cut off */
.twin-root .twin-jump .jump { align-items: flex-start; }
.twin-root .twin-jump .jump > svg { margin-top: 1px; }
.twin-root .twin-jump .jump i { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }

/* the Command Center's Hub board (cls twin-hub): the Remarks column takes what the other columns leave and ends in an
   ellipsis (the full remark is the cell's title), so the table fits its card instead of cutting the words off at a
   scroll edge that overlay scrollbars never show; 80 px is its floor, below that the table scrolls as any table does */
.twin-root .twin-hub td.twin-rem { width: 100%; min-width: 80px; max-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* line icons on the video wall's dark canvas (pane heads, the wall's top line, the notes under it): the text colour */
.twin-root .pane-h .ic { display: inline-flex; flex: none; }
.twin-root :is(.pane-h .ic, .wall-h, .wall-note b) svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.twin-root .pane-h .ic svg { width: 15px; height: 15px; }
.twin-root :is(.wall-h, .wall-note b) svg { width: 13px; height: 13px; margin-right: 4px; vertical-align: -2px; }
.twin-root .wall-note .dot { margin: 0 2px; }
/* the wall's panes: base.css goes two up at 1400 px of window, which leaves three 386 px panes beside the 212 px sidebar
   at 1440 and cuts their Countdown and Remarks columns off; here three up from 1800 px, two up below, one on a phone, and
   a table wider than its pane scrolls sideways inside .pane-b (helpers.js pane()) while the head and the foot stay */
@media (max-width: 1800px) { .twin-root .wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .twin-root .wall-grid { grid-template-columns: minmax(0, 1fr); } }
.twin-root .pane-b { min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--map-line) transparent; }
@media (max-width: 1100px) { .twin-root .wall-note { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* a status dot beside a column head's word (hub board: run / idle / off) */
.twin-root th .dot { margin-right: 4px; }

/* KPI with no source in the tenant's data yet */
.twin-root .kpi.twin-na .v { color: var(--muted); }
.twin-root .kpi.twin-na .d { color: var(--muted); font-style: italic; }

/* the WhatsApp digest preview (base.css .daily, demo chrome with its own tints) on the dense type scale */
.twin-root .daily { font-size: var(--fs-small); border-radius: var(--r-md); }
.twin-root .daily b.h { font-size: var(--fs-body); }

/* type the ported screens wrote inline (owner, programme, roles, CFO forecast) on the scale */
.twin-root .twin-n { font-size: var(--fs-xs); }
.twin-root .twin-ic { font-size: var(--fs-h3); line-height: 1; }
.twin-root .twin-ic.l { font-size: var(--fs-topbar); }
.twin-root .twin-h4 { margin: 0 0 6px; font-family: var(--font-ui); font-size: var(--fs-small); font-weight: 600; }
.twin-root .twin-h4.gap { margin-top: 12px; }

/* real vendor-ledger card shown on an otherwise sample screen */
.twin-root .card.twin-realcard { border-top: 2px solid var(--good); }

/* live map (MapLibre is loaded lazily on this screen only): a dark canvas in both themes, its chrome on the map tokens;
   text on the canvas is a light mix of the map tokens (the canvas is dark in either theme, so the text is light in both) */
.twin-root .route-map { position: relative; height: min(640px, calc(100vh - 220px)); min-height: 420px; border-radius: var(--r-md); overflow: hidden; background: var(--map-bg); border: 1px solid var(--line); }
.twin-root .route-map .map-panel, .twin-root .route-map .map-stats, .twin-root .route-map .map-legend { z-index: 3; }
.twin-root .route-map .rm-legend { bottom: 30px; }
.twin-root .route-map .maplibregl-popup-content { background: color-mix(in srgb, var(--map-bg) 96%, transparent); color: color-mix(in srgb, var(--map-line) 15%, white); font-size: var(--fs-meta); line-height: 1.45; border-radius: var(--r-sm); padding: 8px 10px; border: 1px solid var(--map-line); }
.twin-root .route-map .maplibregl-popup-tip { border-top-color: var(--map-bg); border-bottom-color: var(--map-bg); }
.twin-root .twin-map-status { position: absolute; inset: 0; display: grid; place-items: center; color: color-mix(in srgb, var(--map-line) 40%, white); font-size: var(--fs-small); pointer-events: none; z-index: 2; }
.twin-root .twin-map-status.failed { color: color-mix(in srgb, var(--crit) 40%, white); padding: 0 24px; text-align: center; line-height: 1.5; }

/* copilot: its button sits with the page head's buttons on every control-room screen (shell.js; a screen without a head
   has it at the foot), the drawer above the top bar area and below modals */
.twin-root > .twin-ask { display: flex; width: fit-content; margin: var(--sp-3) 0 0 auto; }
.twin-drawer { z-index: 45; }
.twin-drawer .twin-grow { flex: 1; }
.twin-drawer .msg .ev { margin-top: 6px; }

@media (max-width: 760px) {
  /* demo layouts sized for the control-room wall (stage rows, wave plans, wide tables) scroll inside their card */
  .twin-root .card-b { overflow-x: auto; }
  /* the charts ui.js draws (420–640 wide) keep their labels at 9 px or more and scroll in that card body */
  .twin-root .card-b svg.chart { min-width: 560px; }
  .twin-root .stage-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* the wall's top line wraps instead of squeezing each part into a column; its four notes stack */
  .twin-root .wall-h { flex-wrap: wrap; gap: 4px 12px; }
  .twin-root .wall-h .spacer { display: none; }
  .twin-root .wall-note { grid-template-columns: minmax(0, 1fr); }
  .twin-root .wave-row { grid-template-columns: minmax(0, 1fr); }
  .twin-root .twin-banner { flex-direction: column; gap: 6px; }
  .twin-root .route-map { min-height: 360px; }
  .twin-root .flex:has(> .twin-donut) { flex-wrap: wrap; }
  /* two jump tiles a row: a title may take a second line rather than lose its last word */
  .twin-root .twin-jump .jump b { white-space: normal; }
  .twin-drawer { width: 100%; }
}
