/* SYSApp wallboard — dark for a TV across the room, light when printed. */
:root {
  --bg: #0b0f14; --panel: #121821; --panel-2: #18202b; --line: #243040;
  --text: #e8eef5; --muted: #8b98a8; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --info: #38bdf8; --quiet: #64748b;
  --ok-bg: rgba(34, 197, 94, .14); --warn-bg: rgba(245, 158, 11, .16); --bad-bg: rgba(239, 68, 68, .16); --info-bg: rgba(56, 189, 248, .14);
  --r: 12px; --gap: clamp(8px, 1vw, 16px);
  --fs: clamp(13px, 1.05vw, 20px);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 var(--fs)/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.row { display: flex; align-items: center; gap: .6em; min-width: 0; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .7em; }
.boot, .empty { color: var(--muted); margin: 1.5em 0; text-align: center; }
[hidden] { display: none !important; }

/* ---- controls ---- */
.btn { font: inherit; font-size: .9em; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .45em .9em; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.btn.primary { background: var(--ok); border-color: var(--ok); color: #04210f; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: .3em .7em; font-size: .8em; }
.btn.on { background: var(--info-bg); border-color: var(--info); }
.btn:disabled { opacity: .6; cursor: progress; }
.seg { display: inline-flex; gap: 4px; }
input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .6em .8em; width: 100%; }
.badge, .chip { display: inline-block; font-size: .75em; padding: .15em .55em; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.dot { width: .65em; height: .65em; border-radius: 50%; background: var(--quiet); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 .25em var(--ok-bg); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.quiet { background: var(--quiet); }

/* ---- sign-in ---- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.signin-card h1 { margin: 0; font-size: 1.6em; }
.signin-card p { margin: 0; }
.form-msg { min-height: 1.2em; color: var(--warn); }
details summary { cursor: pointer; color: var(--muted); }
details[open] > *:not(summary) { margin-top: 10px; }

/* ---- header ---- */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px clamp(12px, 1.5vw, 24px); border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.bar h1 { margin: 0; font-size: 1.25em; font-weight: 650; letter-spacing: .01em; }
.logo { width: 1.3em; height: 1.3em; border-radius: 6px; background: var(--ok); flex: none; }
.bar nav a { color: var(--muted); text-decoration: none; padding: .2em .5em; border-radius: 6px; }
.bar nav a.on { color: var(--text); background: var(--panel-2); }
.wall-clock { font-size: 1.15em; font-weight: 600; }
.status { font-size: .85em; }

/* ---- the board: one screen, no scrolling ---- */
body:has(.board) { overflow: hidden; }
#app:has(.board) { height: 100vh; display: flex; flex-direction: column; }
.board { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--gap); padding: var(--gap); transition: opacity .3s; }
.board.stale { opacity: .55; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5em, 1fr)); gap: calc(var(--gap) * .75); }
/* Seven tiles, two of them double: nine columns, one row, on anything wider than a laptop. */
/* Eight KPIs, four of them double: twelve columns, one row, on a laptop and up. */
@media (min-width: 1200px) { .tiles { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .5em .7em; min-width: 0; display: flex; flex-direction: column; gap: .1em; }
.tile[title] { cursor: help; }
.tile.wide { grid-column: span 2; }
.tile-label { color: var(--muted); font-size: .68em; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 1.65em; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-value small { font-size: .45em; font-weight: 500; color: var(--muted); }
.tile-foot { color: var(--muted); font-size: .68em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }
.tile.ok { border-color: rgba(34, 197, 94, .45); }
.tile.warn { border-color: var(--warn); background: linear-gradient(var(--warn-bg), var(--warn-bg)), var(--panel); }
.tile.bad { border-color: var(--bad); background: linear-gradient(var(--bad-bg), var(--bad-bg)), var(--panel); animation: breathe 2s ease-in-out infinite; }
.tile.bad-soft .tile-value { color: #fca5a5; }
@keyframes breathe { 50% { box-shadow: 0 0 0 4px var(--bad-bg); } }
.split { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .5em; }
.split > [title] { cursor: help; }
.split .n { font-size: 1em; font-weight: 700; font-variant-numeric: tabular-nums; }
.split .l { font-size: .4em; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .split .n { font-size: 1em; }

.mid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--gap); min-height: 0; }
.col { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: .55em .9em; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: .95em; font-weight: 650; }
.panel-head .muted { font-size: .8em; }
.panel-body { padding: .3em .9em .6em; overflow: hidden; min-height: 0; flex: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .45em 0; border-bottom: 1px solid var(--line); gap: .8em; }
.list li:last-child { border-bottom: 0; }
.more, .more td { color: var(--muted); font-size: .8em; padding-top: .4em; border-bottom: 0; }
.exts > .more { grid-column: 1 / -1; }
.pulse { width: .6em; height: .6em; border-radius: 50%; background: var(--warn); flex: none; animation: pulse 1.2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .6); } 100% { box-shadow: 0 0 0 .6em rgba(245, 158, 11, 0); } }
.timer.late { color: var(--bad); font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: .75em; text-transform: uppercase; letter-spacing: .05em; padding: .5em .4em; border-bottom: 1px solid var(--line); }
td { padding: .45em .4em; border-bottom: 1px solid var(--line); vertical-align: top; }
.r { text-align: right; }
.calls .sub { color: var(--muted); font-size: .78em; }
.calls tr.ringing td:first-child { box-shadow: inset 3px 0 var(--warn); }
.calls tr.connected td:first-child { box-shadow: inset 3px 0 var(--ok); }
.calls tr.on_hold td:first-child { box-shadow: inset 3px 0 var(--info); }
.state { font-size: .75em; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin-right: .4em; }
.state.ringing { color: var(--warn); } .state.connected { color: var(--ok); } .state.on_hold { color: var(--info); }

.exts { display: grid; grid-template-columns: repeat(auto-fill, minmax(11em, 1fr)); gap: calc(var(--gap) * .7); overflow: hidden; }
.ext { border: 1px solid var(--line); border-left: 4px solid var(--quiet); border-radius: 10px; padding: .45em .6em; background: var(--panel-2); min-width: 0; }
.ext.on_call { border-left-color: var(--ok); background: linear-gradient(var(--ok-bg), var(--ok-bg)), var(--panel-2); }
.ext.ready { border-left-color: var(--info); }
.ext.paused { border-left-color: var(--warn); }
.ext.offline, .ext.idle { opacity: .6; }
.ext-no { font-weight: 700; }
.ext-state { font-size: .72em; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ext.on_call .ext-state { color: var(--ok); } .ext.paused .ext-state { color: var(--warn); } .ext.ready .ext-state { color: var(--info); }
.ext-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ext-now { font-size: .8em; color: var(--muted); min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ext-today { display: flex; gap: .7em; font-size: .78em; color: var(--muted); }
.ext-today b { color: var(--text); }
.problem { max-width: 40em; margin: 10vh auto; text-align: center; }

/* A narrow screen (a phone) scrolls instead of fitting one screen. */
@media (max-width: 900px) {
  body:has(.board) { overflow: auto; }
  #app:has(.board) { height: auto; }
  .board { grid-template-rows: none; }
  .mid { grid-template-columns: 1fr; }
  .col { grid-template-rows: none; }
  .panel-body { overflow: visible; }
  .tile.wide { grid-column: span 1; }
  .tile-value { font-size: 1.8em; }
  .calls th:nth-child(4), .calls td:nth-child(4) { display: none; }
}

/* ---- the roster ---- */
.roster { padding: clamp(12px, 2vw, 32px); max-width: 1200px; margin: 0 auto; }
.roster-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.roster-head h2 { margin: 0 0 4px; font-size: 1.4em; }
.roster-head p { margin: 0; }
.roster-totals { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin-bottom: 12px; font-size: 1.3em; }
.roster-totals .split { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(5.2em, 1fr)); row-gap: .35em; }
.roster-totals .split .l { font-size: .5em; }
.roster-table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.roster-table tr.look td { background: var(--warn-bg); }
.roster-table td.tick { width: 2.2em; }
.roster-table td.tick::after { content: ''; display: inline-block; width: 1em; height: 1em; border: 1.5px solid var(--muted); border-radius: 3px; vertical-align: middle; }
@media (max-width: 700px) {
  .roster-table:not(.ext-table) th:nth-child(4), .roster-table:not(.ext-table) td:nth-child(4) { display: none; }
}

@media print {
  :root { --bg: #fff; --panel: #fff; --panel-2: #fff; --line: #bbb; --text: #000; --muted: #444; --warn-bg: #fff4d6; color-scheme: light; }
  body { font-size: 10.5pt; }
  .bar, .no-print { display: none !important; }
  .roster { padding: 0; max-width: none; }
  .roster-totals { font-size: 14pt; border: 1px solid #999; }
  .roster-table { border: 1px solid #999; }
  .roster-table tr { break-inside: avoid; }
  .roster-table thead { display: table-header-group; }
  .chip { border: 1px solid #999 !important; color: #000 !important; background: #fff !important; }
  .roster-table tr.look td { background: #fff4d6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .roster-table th:nth-child(4), .roster-table td:nth-child(4) { display: table-cell !important; }
}
@media (prefers-reduced-motion: reduce) { .pulse, .tile.bad { animation: none; } }

/* ---- extensions editor ---- */
.filters { margin: 0 0 12px; flex-wrap: wrap; }
.filters input[type=search] { max-width: 22em; }
.ext-table td { vertical-align: middle; }
.ext-table input:not([type=checkbox]) { padding: .35em .5em; font-size: .9em; min-width: 8em; }
.ext-table input:disabled { opacity: .7; }
.ext-table tr.off td { opacity: .55; }
.ext-table tr.off td:nth-child(5), .ext-table tr.off td:nth-child(6), .ext-table tr.off td:last-child { opacity: 1; }
.ext-table td.c { text-align: center; white-space: nowrap; }
.switch { display: inline-flex; align-items: center; gap: .4em; cursor: pointer; }
.switch input { width: 1.1em; height: 1.1em; accent-color: var(--ok); }
.save-state { font-size: .75em; color: var(--muted); white-space: nowrap; }
.save-state.ok { color: var(--ok); }
.save-state.bad { color: var(--bad); white-space: normal; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; margin-left: .4em; }
@media (max-width: 900px) {
  .ext-table th:nth-child(8), .ext-table td:nth-child(8), .ext-table th:nth-child(7), .ext-table td:nth-child(7) { display: none; }
  .ext-table { display: block; overflow-x: auto; }
}

/* A queue agent whose phone or app is not registered: cannot take a call. */
.ext.unavailable { border-left-color: var(--bad); background: linear-gradient(var(--bad-bg), var(--bad-bg)), var(--panel-2); }
.ext.unavailable .ext-state { color: var(--bad); font-weight: 700; }

/* ---- a panel, opened ---- */
button.panel-head.open { width: 100%; font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; }
button.panel-head.open:hover { background: var(--panel-2); }
.open-icon { color: var(--muted); font-size: .9em; }
.more.click { cursor: pointer; text-decoration: underline dotted; }
.more.click:hover, .more.click td:hover { color: var(--text); }
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: clamp(8px, 3vw, 40px); z-index: 50; }
.sheet { width: min(1400px, 100%); max-height: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: .7em 1em; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 1.05em; }
.sheet-body { overflow: auto; padding: .4em 1em 1em; }
.sheet-body .exts { overflow: visible; }

/* ---- history ---- */
.history .roster-totals { display: flex; gap: 2em; align-items: flex-end; flex-wrap: wrap; }
.history .roster-totals .split { flex: 1; }
.talk-total .n { font-size: 1em; font-weight: 700; }
.talk-total .l { font-size: .5em; color: var(--muted); }
.small-totals { font-size: 1.3em !important; }
.hist td.r, .hist th.r { text-align: right; white-space: nowrap; }
.hist tr.click { cursor: pointer; }
.hist tr.click:hover td { background: var(--panel-2); }
.hist tr.open td { background: var(--panel-2); }
.hist tr.drill > td { padding: 0 0 .6em 1.6em; background: var(--bg); }
.hist table.inner { margin-top: .3em; }
.hist table.inner td { font-size: .9em; }
.caret { color: var(--muted); }
.agent-head { margin: .4em 0 .6em; }
.agent-head h3 { margin: 0; }
.late-text { color: var(--warn); }

/* ---- team picker ---- */
.team-pick { font: inherit; font-size: .85em; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .3em .5em; max-width: 16em; }
.team-pick:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* ---- live listen ---- */
.btn.listen { padding: .2em .6em; font-size: .75em; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; gap: 12px; align-items: center; max-width: min(640px, calc(100% - 32px));
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 10px; padding: .7em 1em; font-size: .95em; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.small-sheet { width: min(460px, 100%); }

/* ---- calls and recordings ---- */
.calls-list td { vertical-align: middle; }
tr.player td { background: var(--panel-2); padding: .6em .8em; }
tr.player audio { width: min(520px, 100%); vertical-align: middle; margin-right: .6em; }
.bad-text { color: var(--bad); }

/* History: calls presented but not answered, and the day's missed-call audit. */
.warn-text { color: var(--warn); font-weight: 600; }
.missed-audit { margin-top: 14px; }
.missed-audit h4 { margin: 0 0 6px; font-size: .95em; }
.missed-audit h4 .muted { font-weight: 400; }

/* History carries the queue accounting and the agent figures side by side. */
.roster.history { max-width: 1760px; }
.roster.history .roster-table.hist { display: block; overflow-x: auto; }
