/* Signal Desk layout on top of the shared library theme (../../style.css) */
body.sd { --sd-blue: #5fd0ff; --sd-amber: #f3c74f; }
#sd-main { flex: 1; padding: 12px 16px; }
#sd-row { display: flex; gap: 14px; align-items: flex-start; justify-content: center; }
#sd-left { display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 0; }
#office { image-rendering: pixelated; image-rendering: crisp-edges; display: block; cursor: pointer; }
#sd-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; background: #0c0e14; border: 2px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.sd-clock { font-size: 18px; font-weight: 800; color: var(--gold); min-width: 170px; }
.sd-clock .sub { font-size: 13px; font-weight: 400; }
#b-progress { width: 160px; }
#b-progress > span { background: var(--gold); }
#reason { margin: 0; font-weight: 700; color: var(--gold); text-align: center; min-height: 2.6em; }
/* The side panel keeps one fixed, screen-bounded size; its views update in place (see renderSide in ui.js). */
#sd-side { width: 330px; flex: 0 0 330px; background: var(--panel); border: 3px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; height: min(680px, calc(100vh - 110px)); min-height: 380px; }
#side-tabs { display: flex; gap: 4px; padding: 6px; border-bottom: 2px solid var(--line); }
#side-tabs button { flex: 1; padding: 4px 6px; font-size: 13px; }
#side-tabs button[aria-selected="true"] { border-color: var(--gold); background: #3a3320; }
#side-tabs { flex: none; }
#side-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; font-size: 14px; line-height: 1.45; }
.side-scroll { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.insp { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.insp-head { flex: none; padding: 10px 12px 6px; border-bottom: 1px solid var(--line); }
.insp-status { min-height: 1.6em; }
.insp-detail { min-height: 2.9em; margin: 4px 0 0; }       /* room for a two-line call description */
.insp-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 12px 10px; }
.insp-flag { margin: 4px 0 0; }
.insp-flag:empty { display: none; }                          /* inside the scrolling area: no effect on the buttons */
.insp-actions { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 12px 10px; border-top: 2px solid var(--line); background: var(--panel); }
.insp-actions button { width: 100%; height: 36px; padding: 0 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-note { grid-column: 1 / -1; height: 2.6em; margin: 0; font-size: 12px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* Incident buttons: one fixed two-line height, so a changing label ("Post…" → "Status update is live") never resizes them. */
.inc-actions { display: grid; gap: 6px; margin: 8px 0 4px; }
.note [data-f="text"] { display: block; min-height: 5.8em; }   /* live and cleared texts take the same room */
.inc-actions button { width: 100%; height: 3.4em; padding: 0 8px; font-size: 13px; line-height: 1.25; white-space: normal; overflow: hidden; }
@media (pointer: coarse) { .insp-actions button { height: 44px; } .inc-actions button { height: max(44px, 3.4em); } }
/* Short landscape phones: compact header, tabs and footer so the details area keeps usable room. */
@media (max-height: 500px) {
  #side-tabs { padding: 4px; } #side-tabs button { min-height: 36px; padding: 2px 6px; }
  .insp-head { padding: 6px 12px 4px; }
  .insp-head .big { display: inline; font-size: 15px; } .insp-status { display: inline; margin-left: 8px; }
  .insp-detail { min-height: 1.35em; height: 1.35em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .insp-actions { grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px 12px; }
  .insp-actions button { height: 40px; }
  .insp-note { height: 1.3em; -webkit-line-clamp: 1; }
}
.st-pill.empty { visibility: hidden; }
.insp-actions button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; border-color: var(--line); }
#side-body h3 { margin: 10px 0 4px; font-size: 13px; color: var(--accent); text-transform: uppercase; }
#side-body .big { font-size: 18px; font-weight: 800; color: var(--gold); }
.meter { display: grid; grid-template-columns: 74px 1fr 34px; gap: 6px; align-items: center; margin: 3px 0; font-size: 13px; }
.meter .bar { height: 10px; }
.meter .bar > span.good { background: var(--good); }
.meter .bar > span.mid { background: var(--gold); }
.meter .bar > span.bad { background: var(--bad); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chips button { font-size: 13px; padding: 4px 8px; }
.reasons { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.st-pill { display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--line); margin-left: 6px; }
.st-call { color: #ff8a80; border-color: #ff8a80; } .st-idle { color: var(--good); border-color: var(--good); }
.st-wrap { color: var(--gold); border-color: var(--gold); } .st-off, .st-absent { color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.feed li { padding: 4px 0; border-bottom: 1px solid var(--line); }
table.roster { width: 100%; border-collapse: collapse; font-size: 14px; }
table.roster th, table.roster td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.roster select { font: inherit; background: #0f1220; color: var(--ink); border: 2px solid var(--line); border-radius: 4px; padding: 3px 4px; }
table.roster td.absent { color: var(--muted); font-style: italic; }
.cov-ok { color: var(--good); } .cov-low { color: var(--bad); font-weight: 700; }
.applicant { background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; padding: 10px; margin: 8px 0; }
@media (max-width: 1100px) { #sd-row { flex-direction: column; align-items: center; } #sd-side { width: 100%; max-width: 760px; flex: none; height: min(600px, calc(100vh - 24px)); height: min(600px, calc(100dvh - 24px)); } }
/* Phones: portrait (narrow) or landscape (short). */
@media (max-width: 700px), (max-height: 500px) {
  #sd-main { padding: 8px 12px; }
  #sd-bar { gap: 8px; padding: 6px 8px; }
  .sd-clock { min-width: 9.5em; font-size: 16px; }
  #b-progress { width: 100%; flex: 1 1 120px; }
  #reason { font-size: 13px; }
  #side-body { font-size: 13px; }
  #panel table.roster, #panel table.sheet { display: block; overflow-x: auto; max-width: 100%; }
  table.roster th, table.roster td { padding: 4px; }
  .meter { grid-template-columns: 64px 1fr 30px; }
}

/* ---- Phone shell (html.phone, see js/camera.js and the shared style.css) ---------------------------------
   Top strip: clock, reserve, waiting, service level. The live inspector becomes a non-pausing bottom sheet. */
html.phone body.sd .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
html.phone body.sd .stats > div { display: none; }
html.phone body.sd .stats > div:nth-child(n+2):nth-child(-n+5) { display: flex; }
html.phone #sd-main { padding: 6px 8px; }
html.phone #sd-row { flex-direction: column; align-items: stretch; gap: 6px; }
html.phone #sd-left { width: 100%; align-items: stretch; gap: 6px; }
html.phone #sd-bar { width: 100%; justify-content: space-between; }
html.phone #reason { min-height: 0; font-size: 13px; }
html.phone #sd-side { position: fixed; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom)); width: auto; max-width: none; min-height: 0;
  height: 56vh; height: 56dvh; z-index: 15; border-radius: 12px 12px 0 0; border-bottom: 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
  transform: translateY(calc(100% + 90px)); transition: transform 0.2s ease; visibility: hidden; }
html.phone.side-open #sd-side { transform: none; visibility: visible; }
html.phone #side-close { display: block; flex: 0 0 auto; }
@media (max-height: 500px) { html.phone #sd-side { height: calc(100dvh - 80px); } }
.staff-cards { display: grid; gap: 8px; margin-top: 8px; }
.staff-card { display: flex; flex-direction: column; align-items: stretch; gap: 4px; text-align: left; width: 100%; padding: 10px 12px; min-height: 60px; }
.staff-card .sc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.staff-card .st-pill { margin-left: 0; white-space: nowrap; }
.staff-card .sub { font-size: 13px; margin: 0; }
html.phone.side-open #reason { display: none; }
/* Phone shift bar: two fixed rows (clock + progress / speed + End shift), so Pause and End stay together. */
html.phone #sd-bar { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "clock prog" "speed main"; gap: 6px 8px; align-items: center; }
html.phone .sd-clock { grid-area: clock; min-width: 0; }
html.phone #b-progress { grid-area: prog; width: auto; }
html.phone #sd-bar .speed { grid-area: speed; }
html.phone #b-main { grid-area: main; justify-self: end; white-space: nowrap; }
/* Phone details sheet: compact three-column actions (short labels) leave a ~150px+ reading area in quick view. */
html.phone .insp-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 8px 10px; }
html.phone .insp-actions button { padding: 0 4px; }
html.phone .insp-note { height: 1.3em; -webkit-line-clamp: 1; }
html.phone .insp-head { padding: 8px 12px 4px; }
html.phone #side-tabs .sheet-close { flex: 0 0 44px; padding: 0; font-size: 16px; }
html.phone #side-expand { display: block; }
/* Expanded: scene hidden, shift bar (Pause) stays on top, the sheet fills the rest (height set in fit()). */
html.phone.side-expanded .cam-shell, html.phone.side-expanded #reason { display: none; }
html.phone.side-expanded .insp-note { height: 2.6em; -webkit-line-clamp: 2; }
html.phone #b-main { min-width: 7.5em; }               /* one fixed slot for Briefing / End shift / Results */
/* Short landscape phones: details sheet on the right (scene stays visible on the left), one-row shift bar. */
@media (max-height: 500px) {
  html.phone #sd-side { left: auto; right: 0; top: 46px; bottom: 0; width: min(400px, 46vw); height: auto;
    border-radius: 12px 0 0 0; transform: translateX(calc(100% + 20px)); }
  html.phone.side-open:not(.side-expanded) #sd-left { padding-right: calc(min(400px, 46vw) + 4px); }
  html.phone.side-expanded #sd-side { left: 0; width: auto; border-radius: 0; }
  html.phone.side-expanded .cam-shell { display: block; }
  html.phone:not(.side-open) #sd-bar { grid-template-columns: auto minmax(60px, 1fr) auto auto; grid-template-areas: "clock prog speed main"; }
  html.phone #reason { display: none; }
}
/* With live details open (portrait), the shift bar is one row: Pause / speeds / End shift. The clock is in the top strip. */
html.phone.side-open #sd-bar .sd-clock, html.phone.side-open #b-progress { display: none; }
html.phone.side-open #sd-bar { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "speed main"; }
@media (max-height: 500px) { html.phone.side-open #sd-bar .sd-clock, html.phone.side-open #b-progress { display: none; } }


/* ---- 2026 live-ops visual system (scoped to Signal Desk) -------------------------------------------------- */
body.sd {
  --panel: #0d1d2a; --panel-2: #142c39; --ink: #e8f1ed; --muted: #92aab3; --line: #31515e;
  --gold: #ffd166; --good: #8ee6a8; --bad: #ff7168; --accent: #57d9ee;
  background: radial-gradient(circle at 48% -10%, #173e4a 0, #091925 42%, #060e18 100%);
}
body.sd #hud { background: rgba(6, 17, 27, .96); border-bottom-color: #31515e; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
body.sd .brand { font-size: 18px; letter-spacing: 2px; white-space: nowrap; }
.brand-signal { color: var(--accent); }
.brand-live { display: inline-block; margin-left: 8px; padding: 2px 5px; border: 1px solid #41616a; border-radius: 3px; color: var(--good); font-size: 8px; letter-spacing: 1px; vertical-align: middle; }
body.sd .stats { gap: 8px 15px; }
body.sd .stats dd { font-size: 15px; }
body.sd .stats .score-stat dd { color: var(--gold); }
body.sd .stats .streak-stat dd { color: var(--accent); }
body.sd .hud-buttons { flex-wrap: wrap; }
body.sd .hud-buttons button { padding: 5px 9px; font-size: 12px; }
#sd-main { padding-top: 14px; }
body.sd #canvas-wrap { border: 2px solid #365b67; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 3px #06111a, 0 18px 45px rgba(0,0,0,.46), 0 0 35px rgba(60,194,205,.07); }
#sd-bar { background: linear-gradient(180deg, #112633, #0a1722); border: 1px solid #365563; box-shadow: 0 6px 18px rgba(0,0,0,.24); }
#b-progress { background: #06121b; }
#b-progress > span { background: linear-gradient(90deg, var(--accent), var(--good)); }
#reason { color: #b8d4d6; font-weight: 600; max-width: 960px; }

#manager-bar { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#manager-bar button { position: relative; min-height: 54px; padding: 7px 12px 7px 42px; text-align: left; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; background: linear-gradient(180deg, #173442, #0e2532); border: 1px solid #3a6470; border-bottom: 3px solid #274550; border-radius: 6px; overflow: hidden; }
#manager-bar button:hover:not(:disabled) { background: #1b4350; border-color: var(--accent); transform: translateY(-1px); }
#manager-bar button:active:not(:disabled) { transform: translateY(1px); border-bottom-width: 1px; }
#manager-bar button:disabled { opacity: .52; }
#manager-bar b { color: var(--ink); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
#manager-bar small { color: #9fbac2; font-size: 10px; margin-top: 3px; white-space: nowrap; }
#manager-bar .mgr-key { position: absolute; left: 10px; top: 12px; display: grid; place-items: center; width: 23px; height: 23px; color: #07131c; background: var(--gold); border-radius: 3px; font-weight: 900; box-shadow: 0 2px 0 #8e6a27; }
#manager-bar [data-mgr="focus"] .mgr-key { background: var(--accent); box-shadow: 0 2px 0 #27768a; }
#manager-bar [data-mgr="callbacks"] .mgr-key { background: var(--good); box-shadow: 0 2px 0 #3a855a; }
body.sd #toast { background: #102c38; border-color: var(--accent); box-shadow: 0 8px 30px rgba(0,0,0,.55); text-align: center; }

/* Title and field guide: a polished operations console rather than a plain form. */
body.sd #overlay { background: radial-gradient(circle at 50% 15%, rgba(32,85,96,.55), rgba(3,10,17,.9)); backdrop-filter: blur(4px); }
body.sd #panel { background: linear-gradient(145deg, #102735, #091824 70%); border: 1px solid #426673; border-radius: 10px; box-shadow: 0 0 0 3px #06111a, 0 24px 70px rgba(0,0,0,.65); }
body.sd #panel h2 { font-size: clamp(28px, 5vw, 50px); letter-spacing: 3px; color: var(--ink); text-shadow: 3px 3px 0 #153d4a; }
body.sd #panel h2::after { content: ''; display: block; width: 68px; height: 3px; margin-top: 8px; background: linear-gradient(90deg, var(--accent), transparent); }
.title-kicker { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 1.5px; margin: 16px 0 10px; }
#panel .title-lead { font-size: 18px; line-height: 1.55; color: #f3f6e9; max-width: 680px; }
.feature-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.feature-chips span { padding: 5px 8px; border: 1px solid #365c69; border-radius: 3px; color: #a7dfe1; background: #112d39; font-size: 10px; font-weight: 800; letter-spacing: .7px; }
.title-actions { justify-content: flex-start; }
body.sd #panel .note { background: #132e3a; }
body.sd #panel table.sheet { border-color: #31515e; }

.result-hero { display: grid; grid-template-columns: 150px 1fr 1fr; gap: 10px; margin: 18px 0 12px; }
.result-hero > div { min-height: 112px; padding: 14px 18px; display: flex; flex-direction: column; justify-content: center; background: linear-gradient(145deg, #173947, #0c202c); border: 1px solid #3a606c; border-radius: 7px; }
.result-hero span { color: #8fabb4; font-size: 10px; font-weight: 800; letter-spacing: 1.3px; }
.result-hero b { font-size: 38px; line-height: 1.1; color: var(--gold); }
.result-hero small { color: #a5bec3; margin-top: 7px; }
.result-hero .grade-badge { align-items: center; text-align: center; border-color: var(--gold); }
.result-hero .grade-badge b { font-size: 64px; }
.result-hero .grade-S, .result-hero .grade-A { box-shadow: inset 0 0 28px rgba(255,209,102,.1); }
#panel .result-tip { color: #b4cdd0; padding: 4px 2px 10px; }

#sd-side { background: linear-gradient(180deg, #102633, #0b1b27); border: 1px solid #365765; box-shadow: 0 12px 28px rgba(0,0,0,.24); }
#side-tabs { background: #091923; border-bottom-color: #34535f; }
#side-tabs button[aria-selected="true"] { color: var(--accent); background: #163642; border-color: var(--accent); }
.insp-actions { background: #0b1b27; border-top-color: #34535f; }

@media (max-width: 1100px) {
  #manager-bar { max-width: 960px; }
  body.sd .hud-buttons { flex-wrap: nowrap; overflow-x: auto; }
}
@media (max-width: 700px), (max-height: 500px) {
  #manager-bar { gap: 5px; }
  #manager-bar button { min-height: 52px; padding: 5px 5px 5px 30px; }
  #manager-bar b { font-size: 10px; letter-spacing: 0; }
  #manager-bar small { font-size: 8px; white-space: normal; line-height: 1.2; }
  #manager-bar .mgr-key { left: 5px; top: 8px; width: 19px; height: 19px; font-size: 11px; }
  .result-hero { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .result-hero > div { min-height: 90px; padding: 9px 7px; }
  .result-hero b { font-size: 26px; }
  .result-hero .grade-badge b { font-size: 44px; }
  .result-hero small { font-size: 9px; }
  #panel .title-lead { font-size: 15px; }
  body.sd #panel h2 { font-size: 30px; }
  body.sd #toast { bottom: calc(76px + env(safe-area-inset-bottom)); font-size: 12px; width: max-content; }
}
html.phone #manager-bar { flex: none; }
html.phone.side-open #manager-bar { visibility: hidden; }
@media (max-height: 500px) {
  #manager-bar button { min-height: 44px; }
  #manager-bar small { display: none; }
  #manager-bar .mgr-key { top: 11px; }
  #sd-main { padding-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #manager-bar button { transition: none; }
  #manager-bar button:hover:not(:disabled) { transform: none; }
}

/* Medium-width browser review: never let the nine live statistics collapse into a vertical strip. */
@media (min-width: 701px) and (max-width: 1100px) and (min-height: 501px) {
  body.sd #hud { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 7px 12px; }
  body.sd #hud .brand { display: none; }
  body.sd .stats { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); width: 100%; gap: 3px 8px; }
  body.sd .stats dt { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.sd .stats dd { font-size: 13px; }
  body.sd .hud-buttons { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}
