/* css/shell.css
   Owns: the frame around the pages (js/shell/shell.js): the top bar (its name, slot, user menu and return chip), the
   section rail, the page bar, the page frames the old panels move into; the "Needs attention" pill and panel
   (js/shell/attention.js); the tooltip (#tip, shell/tooltips.js); the signed-out page (index.php's .gate); the update
   bar (#updateBar) and the boot notices (#bootFail, main.js's .fatal). Phones: css/mobile.css. */

/* ---------- the frame: top bar over [rail | workspace] ---------- */

.app { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.workspace > .layout { flex: 1; min-height: 0; }

.topbar { flex: none; display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.topbar-menu { display: none; }
.topbar-slot { display: flex; align-items: center; gap: var(--s2); min-width: 0; margin-left: var(--s4); }
body[data-section]:not([data-section="watch"]) .topbar-slot { display: none; }
.topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
/* The date and time (shell/clock.js): plain text, steady width (tabular figures), never wrapping. */
.topbar-clock { padding: 0 var(--s2); font-size: var(--fs-md); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

.rail { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) 0; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; }
.rail a, .rail button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px;
  color: var(--muted); text-decoration: none; font: inherit; font-size: var(--fs-xs); background: none; border: 0; cursor: pointer; }
.rail a:hover, .rail button:hover { color: var(--text); background: var(--panel-2); }
.rail a[aria-current="page"] { color: var(--text); }
.rail a[aria-current="page"]::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); }
.rail .rail-foot { margin-top: auto; }
.rail .rail-badge { position: absolute; top: 4px; right: 12px; min-width: 16px; padding: 0 4px; border-radius: 9px;
  background: var(--warn); color: var(--on-err); font-size: 10px; font-weight: 700; line-height: 15px; text-align: center; }
svg.i { width: 22px; height: 22px; flex: none; }

/* The tabs scroll sideways on their own; the page's actions stay at the right (on a phone, a row of their own). */
.pagebar { flex: none; display: flex; align-items: center; gap: var(--s3); min-height: var(--pagebar-h); padding: 0 var(--s4);
  background: var(--panel); border-bottom: 1px solid var(--line); }
.pagebar-tabs { flex: 1 1 auto; min-width: 0; align-self: stretch; display: flex; align-items: stretch; gap: 2px; overflow-x: auto; }
.pagebar a { display: flex; align-items: center; padding: 0 var(--s3); color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.pagebar a:hover { color: var(--text); }
.pagebar a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.pagebar .pagebar-title { display: flex; align-items: center; font-weight: 600; }

/* A page: one scroll container. An old panel sits in a framed column, not a stretched stripe. */
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-frame { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 1100px; }
.page-frame > .tabpanel { flex: 1; min-height: 0; }
.page-note { padding: var(--s5); color: var(--muted); }

.usermenu { position: relative; }
/* Who is signed in, beside the menu: plain text that opens it. */
.whoami { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 4px; font-size: 12.5px; }
.whoami:hover { color: var(--text); }
.usermenu .whoami { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-menu); min-width: 200px; padding: 4px;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px var(--scrim); }
.menu > a, .menu > button { display: block; text-align: left; padding: 9px 12px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); text-decoration: none; font: inherit; cursor: pointer; }
.menu > a:hover, .menu > button:hover, .menu > a:focus-visible, .menu > button:focus-visible { background: var(--panel-2); outline: none; }
.menu > .danger { color: var(--err-fg); }

.return-chip { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* One section only (a security responder: Watch; js/shell/shell.js): no rail and no ☰, the stage takes the width. */
body.one-section .app { grid-template-columns: minmax(0, 1fr); }
body.one-section .rail, body.one-section .rail-backdrop, body.one-section .topbar-menu { display: none; }

/* Below 1100 px of deck every transport button keeps its icon and tooltip and drops its words. */
.transport.narrow .lbl { display: none; }

/* Staff on site (shell/onsite.js): quiet while off, green while the security company is held back. Never wraps or
   squeezes; its end time goes first when the bar is short of room. On a phone it shows only while on, and the user
   menu turns it on and off (#menuOnSite, desktop has the button). */
.pill.onsite { white-space: nowrap; flex: none; }
/* The online demo's pill (shell.js): what this copy is, start over, leave. */
.pill.demo-pill { flex: none; background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); font-weight: 600; }
.pill.onsite:not(.on) { color: var(--muted); }
.pill.onsite.on { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-fg); }
/* this person's shift is over: overtime until it checks itself out */
.pill.onsite.over { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.pill.onsite[aria-disabled="true"] { cursor: default; }
.menu > .menu-onsite { display: none; }
.pill.attn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none; }
.pill.attn.on { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.pill.attn:not(.on) { color: var(--muted); }
.pill.attn .attn-count { font-weight: 700; }
/* The server's problems (shell/health.js): red while one is critical, amber for a warning only. */
.pill.health { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: 0 1 auto; min-width: 0;
  background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.pill.health.crit { background: var(--err-bg); border-color: var(--err-line); color: var(--err-fg); }
.pill.health .health-count { font-weight: 700; }
.pill.health .health-label { overflow: hidden; text-overflow: ellipsis; max-width: 26ch; }
.health-item { border: 1px solid var(--warn-line); border-radius: var(--radius); background: var(--panel-2); padding: 10px 12px; margin-bottom: 10px; }
.health-item.crit { border-color: var(--err-line); }
.health-title { font-weight: 600; color: var(--warn-fg); }
.health-item.crit .health-title { color: var(--err-fg); }
.health-detail { margin: 6px 0 0; color: var(--text-2); }

.attn-panel {
  position: fixed; top: var(--attn-top, var(--topbar-h)); right: 0; bottom: 0; width: min(480px, 100vw);
  z-index: calc(var(--z-dialog) - 3); display: flex; flex-direction: column;   /* over the pages; under the phone rail, frame viewer, dialogs */
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px var(--scrim);
}
.attn-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.attn-bar strong { flex: 1; }
.attn-list { flex: 1; overflow-y: auto; padding: 10px 14px 16px; }
.attn-item { border: 1px solid var(--warn-line); border-radius: var(--radius); background: var(--panel-2); padding: 10px 12px; margin-bottom: 10px; }
.attn-head { display: flex; align-items: baseline; gap: 8px; }
.attn-head .badge { margin-left: auto; }
.attn-title { margin-top: 4px; font-weight: 600; color: var(--warn-fg); }
.attn-action { margin: 6px 0 8px; color: var(--text-2); }
.attn-steps { display: flex; flex-direction: column; gap: 6px; }
.attn-step { display: grid; grid-template-columns: 18px 1fr; column-gap: 10px; align-items: start; cursor: pointer; }
.attn-step input[type=checkbox] { width: 18px; height: 18px; margin: 1px 0 0; }
.attn-step-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.attn-step.done .attn-label { color: var(--text-2); }
.attn-who { color: var(--ok-fg); font-size: var(--fs-sm); }
.attn-amt { width: 7.5em; }
.attn-tools { display: flex; gap: 8px; margin-top: 8px; }
.attn-close { display: flex; gap: 8px; margin-top: 8px; }
.attn-close input { flex: 1; }
.attn-done summary { cursor: pointer; margin-top: 6px; }
.attn-done .attn-item { border-color: var(--line); }
.attn-item.finished .attn-title { color: var(--text-2); }
.attn-note { margin: 6px 0 0; color: var(--text-2); font-size: var(--fs-sm); }

/* Hover tooltip: fixed, above the pointer, never under it. */
.tip {
  position: fixed; z-index: var(--z-tip); pointer-events: none;
  background: var(--tip-bg); border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 9px; font-size: 12px; line-height: 1.4; color: var(--text);
  max-width: 300px; box-shadow: 0 6px 20px rgba(0,0,0,.55); white-space: pre-line;   /* a "?" tip may run to two lines */
}

/* ---------- signed out: the sign-in page (index.php, tv.php) ---------- */

.gate { display: grid; place-items: center; align-content: center; gap: 16px; flex: 1; padding: 16px 0; }
.gate form, .gate .demo-start {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px 30px; width: min(340px, 90vw); display: grid; gap: 10px;
}
.gate h1 { margin: 0; font-size: 20px; }
.gate p { margin: 0 0 6px; }
.gate input, .gate button {
  padding: 9px 11px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2);
}
.gate button { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 600; cursor: pointer; }
/* The online demo's start (index.php #demoStart): a little wider than the sign-in, for its two sentences; one button
   per account to look through. */
.gate .demo-start { width: min(420px, 90vw); }
.gate .demo-roles { display: grid; gap: 8px; }
.gate .demo-roles button { display: grid; gap: 2px; text-align: left; font-size: 16px; padding: 10px 12px; }
.gate .demo-roles button span { font-weight: 400; font-size: 13px; opacity: .85; }
.gate button.linkish { background: none; color: var(--accent); border: 0; padding: 0; font-weight: 400; text-decoration: underline; }
.gate .fine { font-size: 13px; }
/* The desk PC (index.php #deskPick): names as big buttons, then the PIN with a touch pad. */
.gate .desk-pick { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; width: min(460px, 92vw);
  display: grid; gap: 12px; }
.gate .desk-pick form { background: none; border: 0; padding: 0; width: auto; }
.gate .desk-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.gate .desk-names button { display: grid; gap: 2px; padding: 14px 10px; font-size: 17px; }
.gate .desk-names button span { font-weight: 400; font-size: 12px; opacity: .85; }
.gate .desk-names button.mgr { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); }
.gate .desk-who { font-size: 18px; font-weight: 600; }
.gate .pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gate .pinpad button { font-size: 20px; padding: 12px 0; background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); }
.gate .row-buttons { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.gate button.ghost { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); }

/* "Newer version available" bar for installed PWAs (no refresh button of their own). Sits above the toast, clears the
   safe-area, never steals the focus. */
.updatebar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  z-index: 48; display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 9px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); font-size: 13px; color: var(--text);
}
.updatebar .updatebar-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.updatebar .pill { flex: none; }

/* The app could not start (main.js boot() threw): its words in place of the page. */
.fatal { padding: 24px; color: var(--err); white-space: pre-wrap; }
/* The app's modules did not load (index.php): one plain line and a Reload button, never a reload by itself. */
.bootfail { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 200; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--err); border-radius: var(--radius); color: var(--text); }
.bootfail button { margin-left: 10px; }

/* ---------- the assistant (shell/assistant.js) ---------- */

/* The prompt bar in the top bar: a title pill that opens, animated, into a box of up to five lines over the page
   (the top bar keeps its height), and closes back to the pill. A phone has the round button instead (mobile.css). */
.ask-bar { position: relative; display: flex; align-items: center; }
.ask-bar[hidden] { display: none; }
.ask-pill { white-space: nowrap; transition: opacity .15s; }
.ask-drop { position: absolute; top: -4px; right: 0; z-index: calc(var(--z-dialog) - 1); display: flex; align-items: flex-end; gap: 6px;
  width: 100%; padding: 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
  box-shadow: 0 10px 30px var(--scrim); opacity: 0; pointer-events: none; transform-origin: top right;
  transition: width .22s ease, opacity .15s ease; }
.ask-drop textarea { flex: 1; min-width: 0; resize: none; overflow-y: auto; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: var(--fs-md); line-height: 1.4; }
.ask-drop textarea:focus { outline: none; border-color: var(--accent); }
.ask-bar.open .ask-drop { width: min(32rem, 60vw); opacity: 1; pointer-events: auto; }
.ask-bar.open .ask-pill { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .ask-drop, .ask-pill { transition: none; } }
.ask-fab { display: none; }

/* The answers: a side panel like Needs attention's, over the page. */
.ask-panel { --ask-fs: 14px; position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: min(460px, 100vw); z-index: calc(var(--z-dialog) - 2);
  display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px var(--scrim); }
.ask-panel[hidden] { display: none; }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ask-head .spacer { flex: 1; }
.ask-head .tbtn { white-space: nowrap; }
.ask-head .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-thread { flex: 1; overflow-y: auto; padding: 10px 14px 16px; font-size: var(--ask-fs); }
.ask-size { min-width: 2.4em; }
.ask-divider { display: flex; align-items: center; gap: 8px; margin: var(--s3) 0; color: var(--muted); font-size: var(--fs-xs); }
.ask-divider::before, .ask-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.ask-empty { margin: var(--s4) 0; }
.ask-turn { margin-bottom: var(--s4); }
.ask-q { margin: 0 0 6px auto; width: fit-content; max-width: 90%; padding: 8px 10px; border-radius: var(--radius);
  background: var(--panel-2); color: var(--text); white-space: pre-wrap; }
.ask-answer p { margin: 0 0 8px; line-height: 1.45; }
.ask-answer ul { margin: 0 0 8px; padding-left: 1.2em; }
.ask-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.ask-steps { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-sm); }
.ask-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: ask-pulse 1s ease-in-out infinite; }
@keyframes ask-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .ask-dot { animation: none; } }
.ask-refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; margin: 6px 0; }
.ask-ref img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.ask-how { color: var(--muted); font-size: var(--fs-sm); }
.ask-how summary { cursor: pointer; }
.ask-how ol { margin: 4px 0 0; padding-left: 1.4em; }
.ask-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); }
.ask-compose textarea { flex: 1; resize: none; overflow-y: auto; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: var(--ask-fs); line-height: 1.4; }
.ask-act { margin: 2px 0; }
.still-tile.ask-flash { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- the time clock's ask, the floating sign-outs, the desk PC's "not checked in" (shell/onsite.js, deskbar.js) */

/* "Work shift ended. Add more time?": above everything but dialogs, at the bottom, never covering the top bar. */
.shift-ask {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px); z-index: 47;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-fg);
  box-shadow: 0 6px 24px var(--scrim);
}
.shift-ask-left { font-variant-numeric: tabular-nums; }
/* ⎋: the label shows on hover (and to screen readers always). */
.float-out {
  position: fixed; left: 14px; bottom: calc(env(safe-area-inset-bottom) + 14px); z-index: 46;
  display: flex; align-items: center; gap: 8px; height: 44px; min-width: 44px; padding: 0 13px; border-radius: 22px;
  font-size: 20px; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg);
  box-shadow: 0 4px 16px var(--scrim);
}
.float-out .float-out-label { display: none; font-size: 14px; font-weight: 600; }
.float-out:hover .float-out-label, .float-out:focus-visible .float-out-label { display: inline; }
.float-out.pulse { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); animation: float-pulse 1.6s ease-in-out infinite; }
.float-out.pulse .float-out-label { display: inline; }
@keyframes float-pulse { 50% { box-shadow: 0 0 0 8px var(--warn-line), 0 4px 16px var(--scrim); } }
@media (prefers-reduced-motion: reduce) { .float-out.pulse { animation: none; } }
#demoBack + #deskBack, #deskBack ~ #demoBack { left: 70px; }
.desk-out { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--scrim); padding: 16px; }
.desk-out-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(380px, 100%); display: grid; gap: 10px; }
.desk-out-card h2 { margin: 0; font-size: 20px; }
.desk-out-actions { display: grid; gap: 8px; }
.desk-out-actions .tbtn { padding: 12px; font-size: 16px; }
.desk-switch-names { display: grid; gap: 6px; margin-bottom: 10px; }
.desk-switch-name { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.desk-switch-name .fine { margin-left: auto; }
