/* Contact center dashboards — design tokens (light + dark), validated categorical palette */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f2ee; --border: rgba(11,11,11,.10);
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --good-ink: #006300; --bad-ink: #b02a2a;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --st-available: #1baf7a; --st-on_call: #2a78d6; --st-ringing: #eda100; --st-wrap_up: #6250d6; --st-paused: #eb6834; --st-logged_out: #c3c2b7;
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --border: rgba(255,255,255,.10);
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-ink: #0ca30c; --bad-ink: #e66767;
    --seq-1: #1d2a3a; --seq-2: #104281; --seq-3: #184f95; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
    --st-available: #199e70; --st-on_call: #3987e5; --st-ringing: #c98500; --st-wrap_up: #9085e9; --st-paused: #d95926; --st-logged_out: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --border: rgba(255,255,255,.10);
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-ink: #0ca30c; --bad-ink: #e66767;
  --seq-1: #1d2a3a; --seq-2: #104281; --seq-3: #184f95; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
  --st-available: #199e70; --st-on_call: #3987e5; --st-ringing: #c98500; --st-wrap_up: #9085e9; --st-paused: #d95926; --st-logged_out: #383835;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--s1); }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 20px; height: 20px; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.nav a.active { background: var(--surface-2); color: var(--ink); }
.spacer { flex: 1; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); padding: 3px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.live .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: pulse 2s infinite; }
.live.off .dot { background: var(--critical); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }
.clock { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); border-radius: 8px; padding: 5px 9px; cursor: pointer; font: inherit; }

main { padding: 16px 20px 40px; max-width: 1680px; margin: 0 auto; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 22px 0 10px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
h2.section small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .sub { color: var(--muted); font-weight: 400; font-size: 12px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-height: 86px; position: relative; }
.tile .label { color: var(--ink-2); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.tile .value .u { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.tile .foot { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.tile.status-good .foot .flag, .flag.good { color: var(--good-ink); }
.tile.status-bad .foot .flag, .flag.bad { color: var(--bad-ink); }
.flag { font-weight: 600; }
.tile .bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 8px; overflow: hidden; position: relative; }
.tile .bar i { display: block; height: 100%; background: var(--s1); border-radius: 2px; }
.tile .bar b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink-2); }

/* grids */
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g2, .g3, .g-2-1 { grid-template-columns: 1fr; } }

/* queue cards */
.queues { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.qcard .head { display: flex; align-items: baseline; justify-content: space-between; }
.qcard .name { font-weight: 650; font-size: 16px; }
.qcard .waiting { display: flex; gap: 18px; margin: 10px 0 12px; }
.qcard .big { font-size: 30px; font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums; }
.qcard .big.alert { color: var(--bad-ink); }
.qcard .cap { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.seg { display: flex; height: 10px; gap: 2px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.seg i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--grid); }
.kv div { font-size: 11px; color: var(--muted); }
.kv b { display: block; font-size: 15px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--axis); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.t td { padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.t tr:hover td { background: var(--surface-2); }
.t th.sortable { cursor: pointer; } .t th.sortable:hover { color: var(--ink); }
.scroll { max-height: 420px; overflow: auto; }
.empty { color: var(--muted); padding: 18px 8px; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 99px; font-size: 12px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.inline-bar { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--s1); vertical-align: middle; margin-right: 6px; }

/* agent board */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.agent { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: grid; grid-template-columns: 36px 1fr auto; gap: 2px 10px; align-items: center; border-left: 4px solid var(--st, var(--axis)); }
.agent .av { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; font-size: 13px; grid-row: span 2; color: var(--ink-2); }
.agent .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent .tm { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); text-align: right; }
.agent .st { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agent .stats { grid-column: 1 / -1; display: flex; gap: 12px; font-size: 11px; color: var(--muted); margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--grid); }
.agent .stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.agent.logged_out { opacity: .55; }

/* filters / forms */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; color: var(--ink-2); }
select, input, button, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 6px 9px; }
select[multiple] { min-height: 34px; }
button.primary { background: var(--s1); border-color: var(--s1); color: #fff; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
.seg-ctl { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.seg-ctl button { border: 0; border-radius: 0; padding: 6px 11px; cursor: pointer; background: transparent; color: var(--ink-2); }
.seg-ctl button + button { border-left: 1px solid var(--axis); }
.seg-ctl button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--axis); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; user-select: none; background: var(--surface); color: var(--ink-2); }
.chip.on { background: var(--s1); border-color: var(--s1); color: #fff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 14px 0 4px; overflow-x: auto; }
.tabs button { border: 0; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 14px; color: var(--ink-2); cursor: pointer; font-weight: 500; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--s1); }
.tab { display: none; } .tab.on { display: block; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.chart-tip { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* heatmap */
.heat { display: grid; grid-template-columns: 40px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 11px; }
.heat .c { aspect-ratio: 1.6; border-radius: 3px; position: relative; }
.heat .c:hover { outline: 2px solid var(--ink); }
.heat .lab { color: var(--muted); display: flex; align-items: center; }
.heat .hl { color: var(--muted); text-align: center; }
.scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.scale i { width: 22px; height: 8px; border-radius: 2px; display: inline-block; }

.tooltip { position: fixed; pointer-events: none; background: var(--ink); color: var(--page); font-size: 12px; padding: 6px 9px; border-radius: 6px; z-index: 100; display: none; max-width: 260px; }

.code { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; white-space: pre; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: var(--page); padding: 10px 14px; border-radius: 8px; display: none; z-index: 200; }
.note { font-size: 12px; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- shell: bell, user menu, dropdowns, toasts, modals ---------- */
.user-slot { display: flex; align-items: center; gap: 6px; }
.menu-wrap { position: relative; }
.bell { position: relative; display: inline-flex; align-items: center; padding: 6px 9px; }
.bell .count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--s1); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.bell .count.crit { background: var(--critical); }
.user-btn { display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px 3px 3px; }
.av-sm { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-2); }
.uname { font-size: 13px; color: var(--ink); }
@media (max-width: 700px) { .uname { display: none; } }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.14); min-width: 240px; z-index: 50; padding: 6px; }
#bellMenu { width: 380px; max-width: calc(100vw - 32px); }
.dd-head { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 8px 8px; border-bottom: 1px solid var(--grid); margin-bottom: 4px; }
.dd-head a { font-size: 12px; }
.dd-item { display: block; width: 100%; text-align: left; padding: 7px 8px; border: 0; background: none; border-radius: 6px; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 13px; }
.dd-item:hover { background: var(--surface-2); }
.dd-alert { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 8px; border-radius: 6px; text-decoration: none; color: var(--ink); align-items: center; }
.dd-alert:hover { background: var(--surface-2); }
.dd-alert .t { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-alert .muted { grid-column: 2; font-size: 11px; }
.dd-alert.acked { opacity: .65; }
.sev { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 1px 7px 1px 5px; border-radius: 99px; white-space: nowrap; color: var(--ink); background: var(--surface-2); }
.sev i { font-style: normal; font-size: 10px; }
.sev-info i { color: var(--s1); } .sev-warning i { color: var(--warning); } .sev-critical i { color: var(--critical); }
.sev-critical { background: color-mix(in srgb, var(--critical) 14%, var(--surface)); }
.toasts { position: fixed; bottom: 16px; right: 16px; flex-direction: column-reverse !important; display: flex; flex-direction: column; gap: 8px; z-index: 300; width: 360px; max-width: calc(100vw - 32px); }
.atoast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--s1); border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); cursor: pointer; animation: slidein .2s ease-out; }
.sev-border-warning { border-left-color: var(--warning); } .sev-border-critical { border-left-color: var(--critical); }
.atoast .row1 { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.atoast .row1 .x { margin-left: auto; }
.atoast .t { font-weight: 600; margin-top: 4px; }
.atoast .m { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.x { border: 0; background: none; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 400; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: 460px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--grid); font-size: 15px; }
.modal-body { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body .field input, .modal-body .field select, .modal-body .field textarea { width: 100%; }
.modal-err { color: var(--bad-ink); font-size: 13px; padding: 0 16px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--grid); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .row-2, .row-3 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: auto !important; }
.hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.strip a { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; max-width: 100%; }
.strip a span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle { position: relative; width: 34px; height: 20px; display: inline-block; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--axis); border-radius: 99px; cursor: pointer; transition: .15s; }
.toggle span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + span { background: var(--s1); }
.toggle input:checked + span::before { transform: translateX(14px); }
.toggle input:disabled + span { opacity: .5; cursor: default; }
