@font-face { font-family: 'Plex'; font-weight: 400; font-display: swap; src: url('fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plex'; font-weight: 500; font-display: swap; src: url('fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plex'; font-weight: 600; font-display: swap; src: url('fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); }

:root {
  --accent-base: #2F55D4;
  --accent: var(--accent-base);
  --bg: #F4F5F7; --surface: #FFFFFF; --sunk: #F0F2F5;
  --ink: #141B27; --ink2: #424D60; --muted: #637085;
  --line: #E0E4EA; --line2: #CDD3DC;
  --open: #9A4A06; --open-bg: #FCEFD9; --open-bar: #D9822B;
  --urgent: #B3261E; --urgent-bg: #FBE7E5;
  --done: #17703F; --done-bg: #E1F3E8;
  --shadow: 0 8px 28px rgba(15, 23, 42, .16);
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: color-mix(in srgb, var(--accent-base) 62%, white);
    --bg: #0E1219; --surface: #161C26; --sunk: #1C2330;
    --ink: #E9EDF3; --ink2: #BAC3D1; --muted: #93A0B3;
    --line: #28313F; --line2: #38445A;
    --open: #F0B26B; --open-bg: #34261A; --open-bar: #E09A45;
    --urgent: #FF8F86; --urgent-bg: #3A1F1E;
    --done: #6FD39A; --done-bg: #17301F;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: color-mix(in srgb, var(--accent-base) 62%, white);
  --bg: #0E1219; --surface: #161C26; --sunk: #1C2330;
  --ink: #E9EDF3; --ink2: #BAC3D1; --muted: #93A0B3;
  --line: #28313F; --line2: #38445A;
  --open: #F0B26B; --open-bg: #34261A; --open-bar: #E09A45;
  --urgent: #FF8F86; --urgent-bg: #3A1F1E;
  --done: #6FD39A; --done-bg: #17301F;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 'Plex', system-ui, 'Segoe UI', sans-serif; font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 16px; display: flex; align-items: baseline; gap: 8px; }
.brand-sub { font-weight: 400; color: var(--muted); font-size: 14px; }
.brand.big { font-size: 22px; margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; align-self: stretch; overflow-x: auto; }
.tab { display: flex; align-items: center; padding: 0 12px; color: var(--ink2); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.chip, .top-right .btn { white-space: nowrap; }
.chip { font: inherit; font-size: 13px; font-weight: 500; border-radius: 99px; padding: 5px 12px; border: 1px solid transparent; cursor: pointer; }
.chip.hot { background: var(--open-bg); color: var(--open); border-color: color-mix(in srgb, var(--open) 25%, transparent); }
.chip.calm { background: var(--done-bg); color: var(--done); cursor: default; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); }
.live.on i { background: var(--done); box-shadow: 0 0 0 3px color-mix(in srgb, var(--done) 22%, transparent); }
.demo-tag { font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--ink2); padding: 3px 8px; border-radius: 4px; }

/* layout */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.summary { color: var(--ink2); font-weight: 500; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 14px; }
.card.narrow { width: min(400px, 100%); }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head.pad { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.form-err { color: var(--urgent); font-size: 14px; min-height: 0; }
.form-err:empty { display: none; }

/* controls */
.btn { font: inherit; font-weight: 500; font-size: 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line2); border-radius: 6px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.3; }
.btn:hover { background: var(--sunk); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--urgent); border-color: var(--urgent); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink2); }
.btn.quiet:hover { background: var(--sunk); color: var(--ink); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 5px 10px; min-width: 34px; font-size: 16px; }
.btn.on { background: var(--sunk); }
.btn.wide { width: 100%; padding: 10px; }
.link { font: inherit; background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 600; }
.input { font: inherit; width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line2); border-radius: 6px; padding: 7px 10px; }
.input::placeholder { color: var(--muted); }
.input.num { width: 90px; } .input.sm { width: 100%; } .input.time { width: 112px; min-width: 0; } .input.date { width: 164px; }
.input.search { width: 260px; max-width: 100%; margin-left: auto; }
.input.area { resize: vertical; min-height: 64px; line-height: 1.45; }
.field { display: grid; gap: 4px; } .flabel { font-size: 13px; font-weight: 500; color: var(--ink2); } .hint { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.seg { display: inline-flex; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 14px; font-weight: 500; border: 0; background: none; color: var(--ink2); padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.nav { display: inline-flex; align-items: center; gap: 6px; } .month { min-width: 130px; text-align: center; font-weight: 600; }
.switch { width: 40px; height: 24px; border-radius: 99px; border: 0; background: var(--line2); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked='true'] { background: var(--done); }
.switch[aria-checked='true']::after { transform: translateX(16px); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-left: 8px; vertical-align: 1px; }
.badge.urgent { background: var(--urgent-bg); color: var(--urgent); } .badge.ok { background: var(--done-bg); color: var(--done); margin: 0; } .badge.off { background: var(--sunk); color: var(--muted); margin: 0; }

/* selection bar */
.selbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); font-weight: 500; }
.card.flush .selbar { border-radius: 0; border-width: 1px 0; }
.selbar[hidden] { display: none; }

/* calls table */
.table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.card.flush .table { border: 0; border-radius: 0; }
.trow { display: grid; grid-template-columns: 34px 112px minmax(130px, 1fr) 132px minmax(190px, 1.6fr) minmax(150px, 1.2fr) 72px 112px; gap: 12px; align-items: start; padding: 12px 16px 12px 13px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.tgroup:last-child .trow:last-child { border-bottom: 0; }
.thead { background: var(--sunk); font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 9px; padding-bottom: 9px; align-items: center; }
.trow.needs { border-left-color: var(--open-bar); } .trow.urgent { border-left-color: var(--urgent); }
.trow.is-done { color: var(--muted); } .trow.is-done .strong { color: var(--ink2); }
.trow.is-open { background: var(--sunk); border-bottom-color: transparent; }
.c-sel { padding-top: 2px; } .c-sel input { width: 17px; height: 17px; accent-color: var(--accent); }
.c-why { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.act { font-weight: 500; color: var(--ink); } .is-done .act { font-weight: 400; color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line2); }
.tel { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--line2); white-space: nowrap; } .tel:hover { color: var(--accent); }
.tick { font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 7px; border: 1px solid var(--line2); border-radius: 99px; background: var(--surface); color: var(--ink2); cursor: pointer; }
.tick svg { opacity: .35; }
.tick:hover { border-color: var(--done); color: var(--done); } .tick:hover svg { opacity: 1; }
.tick.on { background: var(--done-bg); color: var(--done); border-color: transparent; } .tick.on svg { opacity: 1; }
.detail { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(220px, 1fr); gap: 24px; padding: 4px 16px 18px 50px; background: var(--sunk); border-bottom: 1px solid var(--line); }
.transcript { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; max-height: 360px; overflow: auto; }
.line { padding: 3px 0; overflow-wrap: anywhere; } .line b { color: var(--muted); font-weight: 600; } .line.caller b { color: var(--accent); }
.detail-side { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-content: start; font-size: 14px; }
.detail-side dt { color: var(--muted); } .detail-side dd { margin: 0; overflow-wrap: anywhere; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 14px; flex-wrap: wrap; }
.card.flush .pager { border-top: 1px solid var(--line); }
.pager-btns { display: inline-flex; align-items: center; gap: 12px; }
.empty { background: var(--surface); border: 1px dashed var(--line2); border-radius: var(--r); padding: 40px 16px; text-align: center; display: grid; gap: 12px; justify-items: center; color: var(--ink2); }
.card.flush .empty { border: 0; }
.empty.err { color: var(--urgent); }

/* usage */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; }
.tile-l { font-size: 13px; color: var(--muted); font-weight: 500; } .tile-v { font-size: 34px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; } .tile-s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chart { position: relative; width: 100%; } .chart[hidden] { display: none; }
.ax { stroke: var(--line); stroke-width: 1; } .ax.base { stroke: var(--line2); }
.tick-t { fill: var(--muted); font-size: 11px; font-family: inherit; }
.bar { fill: var(--accent); } .hit:hover { fill: color-mix(in srgb, var(--accent) 8%, transparent); }
.tip { position: absolute; transform: translate(-50%, -100%); background: var(--surface); border: 1px solid var(--line2); box-shadow: var(--shadow); border-radius: 6px; padding: 6px 10px; font-size: 13px; pointer-events: none; white-space: nowrap; z-index: 2; }
.tip[hidden] { display: none; }
.table-wrap { max-height: 360px; overflow: auto; } .table-wrap[hidden] { display: none; }
table.plain { width: 100%; border-collapse: collapse; font-size: 14px; } table.plain th, table.plain td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); } table.plain th { color: var(--muted); font-weight: 600; } .r { text-align: right !important; }
.agent-state { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.agent-title { font-weight: 600; font-size: 17px; }
.note { margin-top: 6px; font-size: 13px; color: var(--open); background: var(--open-bg); padding: 6px 10px; border-radius: 6px; display: inline-block; }

/* archive */
.rule-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rule-row.last { border-bottom: 0; padding-bottom: 0; } .rule-row > div:first-child { max-width: 640px; }
.inline { display: inline-flex; align-items: center; gap: 10px; flex: none; }

/* settings */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subtab { padding: 8px 14px; color: var(--ink2); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtab.on { color: var(--ink); border-bottom-color: var(--accent); }
.sub-body, .sub-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.sub-body > .lock-note { margin-bottom: 0; }
.hrs { display: grid; } .hrs-row { display: grid; grid-template-columns: 120px 52px 1fr; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); } .hrs-row:last-child { border-bottom: 0; }
.hrs-d { font-weight: 500; } .times { display: inline-flex; align-items: center; gap: 10px; }
.edit-list { display: grid; gap: 0; }
.erow { display: grid; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); } .erow:last-child { border-bottom: 0; }
.erow.head { color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px 0; }
.erow.prod { grid-template-columns: minmax(160px, 2fr) minmax(90px, 1fr) minmax(110px, 1fr) 200px; }
.erow.head.prod span:last-child { text-align: right; }
.erow.rule { grid-template-columns: 1fr 200px; align-items: start; }
.erow.contact { grid-template-columns: minmax(140px, 1fr) minmax(150px, 1fr) minmax(140px, 1fr) auto; }
.erow.contact:has(.order) { grid-template-columns: 24px minmax(140px, 1fr) minmax(150px, 1fr) minmax(140px, 1fr) auto; }
.erow-tools { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.order { width: 24px; height: 24px; border-radius: 50%; background: var(--sunk); display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--ink2); }
.cur-in { display: flex; align-items: center; gap: 6px; }

/* toasts and dialog */
#toasts { position: fixed; left: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; justify-content: space-between; font-size: 14px; }
.toast.err { background: var(--urgent); color: #fff; } .toast .link { color: inherit; }
.dlg { border: 1px solid var(--line2); border-radius: 12px; padding: 24px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(10, 14, 22, .5); }
.dlg form { display: grid; gap: 12px; } .dlg p { color: var(--ink2); overflow-wrap: anywhere; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* narrow screens: rows become cards */
@media (max-width: 900px) {
  .trow { grid-template-columns: 1fr 1fr; gap: 8px 14px; } .thead { display: none; }
  .c-sel { grid-column: 1 / -1; grid-row: 1; padding: 0; } .c-sel input { margin: 0; }
  .c-when, .c-who, .c-from { grid-column: auto; }
  .c-why, .c-act { grid-column: 1 / -1; }
  [data-l]::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
  .c-tr, .c-done { grid-column: auto; } .c-done { justify-self: end; }
  .detail { grid-template-columns: 1fr; padding: 12px 16px 18px; gap: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .erow.prod { grid-template-columns: 1fr 1fr; } .erow.head { display: none; } .erow.prod .erow-tools { grid-column: 1 / -1; justify-content: space-between; }
  .erow.rule { grid-template-columns: 1fr; } .erow.contact, .erow.contact:has(.order) { grid-template-columns: 1fr; }
  .erow.contact .order { display: none; }
  .agent-state, .rule-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .input.search { margin-left: 0; width: 100%; }
  .top-in { gap: 8px 16px; } .tabs { order: 3; width: 100%; } .tab { padding: 10px 12px; }
  .hrs-row { grid-template-columns: 88px 48px minmax(0, 1fr); gap: 8px; }
  .times { width: 100%; gap: 6px; } .input.time { flex: 1; width: auto; padding: 7px 6px; }
  .top-right { gap: 8px; } .live { font-size: 0; } .top-right .btn { padding: 6px 8px; }
}

/* theme toggle */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 99px; border: 1px solid var(--line2); background: var(--surface); color: var(--ink2); cursor: pointer; flex: none; }
.theme-btn:hover { color: var(--ink); background: var(--sunk); }
.theme-btn svg { display: block; }

/* read only: controls the IT team manages. Greyed out, not clickable. */
.locked { opacity: .55; filter: grayscale(1); user-select: none; position: relative; }
.locked * { cursor: not-allowed !important; }
.lock-note { display: flex; gap: 10px; align-items: flex-start; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; color: var(--ink2); font-size: 13px; margin-bottom: 16px; }
.lock-note svg { flex: none; margin-top: 2px; color: var(--muted); }
.tick:disabled, .c-sel input:disabled { opacity: .45; cursor: not-allowed; }
.tag-ro { font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid var(--line2); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
