:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --line: #e1e6ee;
  --text: #15202e;
  --muted: #5d6b7e;
  --brand: #0d6f7a;
  --brand-soft: #e2f1f2;
  --gold: #b98526;
  --gold-soft: #f7eedc;
  --shadow: 0 1px 2px rgba(21,32,46,0.06), 0 4px 16px rgba(21,32,46,0.05);
  --s-none: #8a97a8;     --s-none-bg: #eef1f5;
  --s-sched: #2f6fd1;    --s-sched-bg: #e5eefc;
  --s-follow: #8a5cd1;   --s-follow-bg: #efe8fb;
  --s-view: #0d7f8a;     --s-view-bg: #e0f3f4;
  --s-champ: #b98526;    --s-champ-bg: #f8eed9;
  --s-missed: #c8503b;   --s-missed-bg: #fbe8e4;
  --s-partial: #4f8a2f;  --s-partial-bg: #e8f3df;
  --s-down: #1f7a4d;     --s-down-bg: #dcf2e6;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151d; --surface: #161e29; --surface-2: #1b2533; --line: #273345; --text: #e8edf3; --muted: #97a4b6;
    --brand: #4cc0c9; --brand-soft: rgba(76,192,201,0.14); --gold: #e3b45d; --gold-soft: rgba(227,180,93,0.14);
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px rgba(0,0,0,0.25);
    --s-none: #a3afc0; --s-none-bg: rgba(163,175,192,0.14);
    --s-sched: #7aa8f2; --s-sched-bg: rgba(122,168,242,0.15);
    --s-follow: #b69af0; --s-follow-bg: rgba(182,154,240,0.15);
    --s-view: #4cc0c9; --s-view-bg: rgba(76,192,201,0.15);
    --s-champ: #e3b45d; --s-champ-bg: rgba(227,180,93,0.15);
    --s-missed: #ef8a76; --s-missed-bg: rgba(239,138,118,0.15);
    --s-partial: #9fd27a; --s-partial-bg: rgba(159,210,122,0.14);
    --s-down: #5ed39a; --s-down-bg: rgba(94,211,154,0.15);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151d; --surface: #161e29; --surface-2: #1b2533; --line: #273345; --text: #e8edf3; --muted: #97a4b6;
  --brand: #4cc0c9; --brand-soft: rgba(76,192,201,0.14); --gold: #e3b45d; --gold-soft: rgba(227,180,93,0.14);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px rgba(0,0,0,0.25);
  --s-none: #a3afc0; --s-none-bg: rgba(163,175,192,0.14);
  --s-sched: #7aa8f2; --s-sched-bg: rgba(122,168,242,0.15);
  --s-follow: #b69af0; --s-follow-bg: rgba(182,154,240,0.15);
  --s-view: #4cc0c9; --s-view-bg: rgba(76,192,201,0.15);
  --s-champ: #e3b45d; --s-champ-bg: rgba(227,180,93,0.15);
  --s-missed: #ef8a76; --s-missed-bg: rgba(239,138,118,0.15);
  --s-partial: #9fd27a; --s-partial-bg: rgba(159,210,122,0.14);
  --s-down: #5ed39a; --s-down-bg: rgba(94,211,154,0.15);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--body); font-size: 14px; }
button, select, input { font: inherit; color: inherit; }
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }

/* Sidebar */
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.logo .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--surface); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 17px; }
.logo b { font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.logo small { display: block; color: var(--muted); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { appearance: none; border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.nav button svg { width: 18px; height: 18px; flex: none; }
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on { background: var(--brand-soft); color: var(--brand); }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; line-height: 1.5; }

/* Top bar */
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.top h1 { font-family: var(--display); font-weight: 700; font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.top .sp { flex: 1; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.field select, .field input { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; min-width: 0; }
.tier { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); white-space: nowrap; align-self: flex-end; margin-bottom: 6px; }
.content { padding: 24px max(16px, env(safe-area-inset-right, 0px)) 40px 28px; display: flex; flex-direction: column; gap: 20px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card h2 small { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .v { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }

.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 120px minmax(0, 1fr) 34px; align-items: center; gap: 10px; font-size: 13px; }
.bar .track { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; }

/* Tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.who { display: flex; align-items: center; gap: 10px; }
.av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; background: var(--brand-soft); color: var(--brand); }
.sub { color: var(--muted); font-size: 12px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* Status pill and select */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
select.status { appearance: none; border: 0; cursor: pointer; font-size: 12px; font-weight: 700; padding: 5px 26px 5px 12px; border-radius: 999px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px; background-repeat: no-repeat; }
.st-none { color: var(--s-none); background-color: var(--s-none-bg); }
.st-sched { color: var(--s-sched); background-color: var(--s-sched-bg); }
.st-follow { color: var(--s-follow); background-color: var(--s-follow-bg); }
.st-view { color: var(--s-view); background-color: var(--s-view-bg); }
.st-champ { color: var(--s-champ); background-color: var(--s-champ-bg); }
.st-missed { color: var(--s-missed); background-color: var(--s-missed-bg); }
.st-partial { color: var(--s-partial); background-color: var(--s-partial-bg); }
.st-down { color: var(--s-down); background-color: var(--s-down-bg); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn { appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chipbtn.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.chipbtn .c { font-variant-numeric: tabular-nums; opacity: 0.75; margin-left: 4px; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--surface); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:focus-visible, .nav button:focus-visible, .chipbtn:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }

/* Calendar */
.calhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.weeklabel { font-family: var(--display); font-weight: 700; font-size: 18px; }
.cal { display: grid; grid-template-columns: 190px repeat(7, minmax(118px, 1fr)); min-width: 1020px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.cal > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px; min-height: 92px; }
.cal .h { min-height: 0; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 8px; }
.cal .h.today { color: var(--brand); }
.cal .agentcell { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.cal .occ { font-size: 11.5px; color: var(--muted); }
.cal .day.today { background: var(--brand-soft); }
.slot { border-radius: 8px; padding: 6px 7px; margin-bottom: 6px; font-size: 11.5px; line-height: 1.3; border-left: 3px solid currentColor; cursor: default; }
.slot b { display: block; font-size: 12px; color: var(--text); }
.slot .p { color: var(--text); opacity: 0.8; }
.slot .t { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; }

/* Modal and toast */
.scrim { position: fixed; inset: 0; background: rgba(10,16,24,0.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: min(460px, 100%); background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); padding: 22px; display: grid; gap: 14px; border: 1px solid var(--line); }
.modal h3 { margin: 0; font-family: var(--display); font-size: 20px; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .field select, .modal .field input { width: 100%; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,0.25); max-width: min(420px, calc(100vw - 40px)); z-index: 30; animation: up 0.25s ease-out; display: flex; gap: 10px; align-items: flex-start; }
.toast .wa { width: 20px; height: 20px; border-radius: 50%; background: #25a35a; flex: none; display: grid; place-items: center; color: #fff; font-size: 11px; }
.note { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); padding: 18px; text-align: center; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .bar .fill { transition: none; } }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px max(16px, env(safe-area-inset-left, 0px)); border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav button { padding: 8px 10px; }
  .side .foot { display: none; }
  .top { padding-left: max(16px, env(safe-area-inset-left, 0px)); position: static; }
  .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar { grid-template-columns: 124px minmax(0, 1fr) 28px; }
}

/* ---------- Additions for the live portal ---------- */
body { margin: 0; }
a { color: var(--brand); }
.err { color: var(--s-missed); font-size: 13px; font-weight: 600; }
.ok-text { color: var(--s-down); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .who b { display: block; font-size: 13.5px; }
.iconbtn { appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.iconbtn:hover { color: var(--text); background: var(--surface-2); }
.iconbtn svg { width: 18px; height: 18px; }
.search { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; width: 240px; max-width: 100%; }
.toolbar .grow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn.danger { color: var(--s-missed); border-color: var(--s-missed-bg); }
.btn.danger:hover { background: var(--s-missed-bg); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
td .btnrow { justify-content: flex-start; flex-wrap: nowrap; }
.linkbtn { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; font-weight: 700; color: var(--text); text-align: left; }
.linkbtn:hover { color: var(--brand); text-decoration: underline; }
.slot { cursor: pointer; }
.slot:hover { filter: brightness(0.97); }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.secret { background: var(--surface-2); border: 1px dashed var(--line); padding: 10px 12px; border-radius: 10px; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login .hero { background: linear-gradient(150deg, var(--brand) 0%, #0a4f57 70%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login .hero h2 { font-family: var(--display); font-size: 40px; line-height: 1.05; margin: 0 0 14px; letter-spacing: -0.02em; max-width: 14ch; }
.login .hero p { opacity: 0.85; max-width: 42ch; line-height: 1.55; margin: 0; }
.login .hero .stats { display: flex; gap: 28px; flex-wrap: wrap; }
.login .hero .stats b { display: block; font-family: var(--display); font-size: 26px; color: #f3d9a4; }
.login .hero .stats span { font-size: 12.5px; opacity: 0.8; }
.login .hero .logo .mark { background: #fff; color: var(--brand); }
.login .hero .logo small { color: rgba(255,255,255,0.75); }
.login .panel { display: grid; place-items: center; padding: 32px 16px; background: var(--bg); }
.login form { width: min(380px, 100%); display: grid; gap: 14px; }
.login form h1 { font-family: var(--display); margin: 0; font-size: 28px; }
.login .field input { padding: 11px 12px; width: 100%; }
.login .btn.primary { padding: 12px; font-size: 15px; }

/* Modal variations */
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { width: min(760px, 100%); }
.modal .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.modal textarea, .field textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; color: inherit; width: 100%; min-height: 70px; resize: vertical; }
.modal .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal .closex { appearance: none; border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
.kv div span { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.kv div b { font-weight: 600; }
.timeline { display: grid; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; margin-left: 4px; }
.timeline .ev { position: relative; font-size: 13px; }
.timeline .ev::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.timeline .ev .sub { display: block; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 4px 0 -4px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; font-size: 13px; }
.checks label { display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login .hero { padding: 28px 20px; gap: 24px; }
  .login .hero h2 { font-size: 30px; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal .row3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) { .modal .row2, .modal .row3, .checks { grid-template-columns: minmax(0, 1fr); } .search { width: 100%; } }
button.slot { display: block; width: 100%; text-align: left; border-top: 0; border-right: 0; border-bottom: 0; font-family: inherit; appearance: none; }
