:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #6b7686;
  --border: #e3e7ee;
  --brand: #1f5fbf;
  --brand-dark: #16478f;
  --topbar: #13233d;
  --good: #1a8a4a;
  --good-bg: #e3f4ea;
  --warn: #b86e00;
  --warn-bg: #fdf0d9;
  --bad: #c7362f;
  --bad-bg: #fbe5e3;
  --info: #1f5fbf;
  --info-bg: #e3edfb;
  --none-bg: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--none-bg); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
h1 { font-size: 1.6rem; margin: 0 0 .2rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small, small { font-size: .86em; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 2rem; padding: 0 1.5rem; height: 56px;
  background: var(--topbar); color: #fff;
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand svg { fill: #6fa8ff; }
.topbar nav { display: flex; gap: .25rem; }
.topbar nav a { color: #c9d4e5; padding: .45rem .85rem; border-radius: 6px; font-weight: 500; }
.topbar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.freshness { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; color: #aab7cc; font-size: .9rem; }
.freshness b { color: #fff; font-weight: 600; }
.jobs { display: inline-flex; align-items: center; gap: .4rem; color: #aab7cc; padding: .25rem .6rem; border-radius: 99px; background: rgba(255,255,255,.07); }
.jobs:hover { text-decoration: none; color: #fff; }
.jobs .spinner { display: none; }
.jobs.busy { color: #fff; background: rgba(111,168,255,.25); }
.jobs.busy .spinner { display: inline-block; border-color: rgba(255,255,255,.35); border-top-color: #fff; }

main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.page-head { margin-bottom: 1rem; }
.page-head p { margin: 0; }
.section-title { margin: 1.5rem 0 .75rem; }

/* --- cards / grid --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.cards .card { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 .card { margin-bottom: 1rem; }
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .topbar { gap: 1rem; } .freshness span { display: none; } }

.stat-label { color: var(--muted); font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 700; margin: .15rem 0 .35rem; letter-spacing: -.5px; }
.stat-value small { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat-deltas { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 1.6rem; }
.stat-foot { margin-top: .45rem; font-size: .85rem; }
.compare-line { margin: -.25rem 0 1rem; }

.delta { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; font-weight: 600; padding: .1rem .45rem; border-radius: 5px; white-space: nowrap; }
.delta small { font-weight: 500; opacity: .8; }
.delta.good { color: var(--good); background: var(--good-bg); }
.delta.bad { color: var(--bad); background: var(--bad-bg); }
.delta.neutral { color: var(--muted); background: var(--none-bg); }

.chart { position: relative; height: 260px; }
.chart.short { height: 200px; }

/* --- period bar --- */
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-bottom: 1rem; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.segmented a { padding: .35rem .9rem; border-radius: 6px; color: var(--text); font-weight: 500; }
.segmented a:hover { text-decoration: none; background: var(--none-bg); }
.segmented a.active { background: var(--brand); color: #fff; }
.period-select { display: inline-flex; align-items: center; gap: .3rem; }
.period-select select { font: inherit; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); min-width: 170px; }
.icon-btn { font: inherit; font-size: 1.15rem; line-height: 1; width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; cursor: pointer; }
.icon-btn:hover { background: var(--none-bg); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.period-meta { color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.period-meta b { color: var(--text); }

/* --- buttons / pills --- */
.btn { font: inherit; font-weight: 600; padding: .5rem 1rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--none-bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger-outline { color: var(--bad); border-color: #efb9b5; }
.btn.danger-outline:hover:not(:disabled) { background: var(--bad-bg); }
.btn.confirming { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; background: var(--none-bg); color: var(--muted); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }

.alert { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert.bad { background: var(--bad-bg); border-color: #efb9b5; color: #7d1d18; }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; opacity: .8; }
.spinner.big { width: 34px; height: 34px; border-width: 3px; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 3.5rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty h2 { margin: .75rem 0 .35rem; }

/* --- tables --- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: bottom; }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 2px solid var(--border); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.kpi-name { font-weight: 600; }
.kpi-what { color: var(--muted); font-size: .85rem; }
.kpi-table tr.unused { opacity: .55; }
.score-cell { width: 170px; }
.team-row td { background: #f8fafc; font-weight: 600; }

.score-bar { position: relative; height: 22px; background: var(--none-bg); border-radius: 5px; overflow: hidden; min-width: 120px; }
.score-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.score-bar em { position: relative; display: block; font-style: normal; font-weight: 700; font-size: .82rem; line-height: 22px; padding-left: 8px; }
.score-bar.good span { background: #9fdcb7; }
.score-bar.warn span { background: #f6cf8a; }
.score-bar.bad span { background: #f2aaa4; }
.score-bar.none em { color: var(--muted); }

.matrix th { text-align: right; }
.matrix th:first-child { text-align: left; }
.heat { font-weight: 600; }
.heat.good { background: var(--good-bg); color: var(--good); }
.heat.warn { background: var(--warn-bg); color: var(--warn); }
.heat.bad { background: var(--bad-bg); color: var(--bad); }
.heat.none { color: var(--muted); }
.matrix td { border-bottom: 2px solid var(--surface); }

/* --- scorecard summary --- */
.team-summary { display: flex; gap: 1rem; flex-wrap: wrap; }
.team-summary .card { margin-bottom: 1rem; }
.grow { flex: 1 1 420px; }
.ring-card { display: flex; align-items: center; gap: 1.5rem; flex: 0 1 460px; }
.ring { --c: var(--muted); width: 140px; height: 140px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--none-bg) 0); }
.ring.good { --c: var(--good); } .ring.warn { --c: #e69a1e; } .ring.bad { --c: var(--bad); }
.ring > div { width: 110px; height: 110px; border-radius: 50%; background: var(--surface); display: grid; place-content: center; text-align: center; }
.ring b { font-size: 2rem; line-height: 1; }
.ring small { color: var(--muted); }
.ring-meta { display: grid; gap: .45rem; }

details.person { padding: 0; }
details.person summary { cursor: pointer; padding: .85rem 1.2rem; display: flex; align-items: center; gap: 1.25rem; list-style: none; }
details.person summary::-webkit-details-marker { display: none; }
details.person summary::before { content: "▸"; color: var(--muted); }
details.person[open] summary::before { content: "▾"; }
details.person summary .strong { min-width: 160px; }
.person-score { width: 220px; }
details.person .kpi-table { margin: 0 1.2rem 1rem; width: calc(100% - 2.4rem); }

/* --- sync page --- */
.jobs-cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)) !important; }
.job { display: flex; flex-direction: column; }
.job-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.job-head h3 { margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0 0 .8rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.job-live { background: var(--info-bg); color: var(--info); border-radius: 7px; padding: .5rem .7rem; margin-bottom: .7rem; font-weight: 500; }
.job-msg { margin: 0 0 .8rem; font-size: .9rem; color: var(--muted); }
.job-msg.bad { color: var(--bad); }
.job-actions { margin-top: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.runs .msg { max-width: 420px; font-size: .88rem; color: var(--muted); }
.log-row pre { margin: 0; max-height: 420px; overflow: auto; background: #0f1a2b; color: #d5deeb; padding: .9rem 1rem; border-radius: 7px; font-size: .82rem; white-space: pre-wrap; }

.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--topbar); color: #fff; padding: .75rem 1.1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; z-index: 50; }
.toast.bad { background: var(--bad); }

/* --- AI report --- */
.ai-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .ai-layout { grid-template-columns: 1fr; } }
.ai-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.ai-card { padding: 1.6rem 2rem; }
.ai-kicker { font-size: .82rem; color: var(--brand); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.ai-headline { font-size: 1.45rem; margin: .35rem 0 1rem; line-height: 1.3; }
.ai-section h3 { margin: 1.4rem 0 .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.ai-list { margin: 0; padding-left: 1.2rem; }
.ai-list li { margin-bottom: .35rem; }
.ai-point, .ai-person { border-left: 3px solid var(--brand); padding: .35rem 0 .35rem .9rem; margin-bottom: .8rem; }
.ai-person { border-left-color: var(--grey, #9aa5b5); }
.ai-point p, .ai-person p { margin: .25rem 0; }
.ai-point-title { font-weight: 700; }
.ai-num { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .75rem; margin-right: .5rem; }
.ai-check { color: #39475a; }
.ai-table { width: 100%; border-collapse: collapse; }
.ai-table th { text-align: left; color: var(--muted); font-size: .85rem; font-weight: 600; padding: .45rem .5rem; border-bottom: 1px solid var(--border); }
.ai-table td { padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.ai-table .num { text-align: right; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--none-bg); color: var(--muted); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.ai-form { display: grid; gap: .75rem; }
.ai-form label { display: grid; gap: .3rem; font-weight: 600; }
.ai-form select, .ai-form textarea { font: inherit; font-weight: 400; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.ai-form textarea { resize: vertical; }
.hint { margin: 0; font-size: .85rem; color: var(--warn); }
.table.compact td { padding: .35rem .4rem; }
.table tr.current td { background: var(--info-bg); }
.ai-meta summary { cursor: pointer; font-weight: 600; }
.ai-meta .kv { margin-top: .8rem; }
pre.plain { margin: 0; white-space: pre-wrap; font-size: .85rem; }
pre.left { text-align: left; max-width: 800px; margin: 1rem auto 0; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
a.btn { display: inline-block; }
a.btn:hover { text-decoration: none; }

/* --- scorecard filter --- */
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.card-head h3 { margin: 0; }
.filter-wrap { position: relative; }
.small-btn { padding: .35rem .75rem; display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; }
.small-btn.active { border-color: var(--brand); color: var(--brand); background: var(--info-bg); }
.filter-count { background: var(--brand); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .4rem; }
.filter-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 320px; display: grid; gap: .45rem; margin: 0; box-shadow: 0 8px 24px rgba(16,24,40,.15); }
.filter-kpis { display: grid; gap: .3rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.filter-sub { font-weight: 600; font-size: .85rem; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; cursor: pointer; }
.table tr[hidden] { display: none; }

/* --- settings --- */
.settings-nav { display: flex; gap: 1rem; margin-bottom: 1rem; }
.settings-table td { vertical-align: middle; }
.setting-label { width: 280px; font-weight: 600; }
.setting-input { width: 320px; }
.setting-input .check { margin-right: .8rem; }
.settings-form input[type=number], .settings-form input[type=time], .recompute-choice input[type=time] {
  font: inherit; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.num-input { width: 90px; text-align: right; }
.sc-settings td { vertical-align: top; }
.bands { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.band { display: inline-flex; align-items: center; gap: .25rem; background: var(--none-bg); border-radius: 7px; padding: .2rem .3rem; }
.band input { width: 72px; text-align: right; }
.band-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }
.band-del:hover { color: var(--bad); }
.form-actions { margin-top: 1rem; }
.recompute-choice { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.alert.good { background: var(--good-bg); border-color: #a9dcbd; color: #155d34; }
.alert ul.errors { margin: .3rem 0 0; padding-left: 1.2rem; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd6e0; border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }

/* per-person matrix: values or scores */
.matrix .s { display: none; }
.matrix:not(.show-values) .s { display: inline; }
.matrix:not(.show-values) .v { display: none; }
.segmented.small a { padding: .2rem .7rem; font-size: .85rem; }

/* --- scorecard: agent filter --- */
.scorecard-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.scorecard-bar .period-bar { flex: 1; }
.agent-filter .filter-panel { width: 300px; }
.info-alert { background: var(--info-bg); border-color: #b8cff3; color: #173f7a; }

/* --- settings: agents --- */
.agents-table td { vertical-align: middle; padding: .4rem .4rem; }
.agents-table tr.off td { opacity: .55; }
.agents-table tr.off td:first-child, .agents-table tr.off td:nth-child(2) { opacity: 1; }
.agents-table input[type=date] { font: inherit; font-size: .85rem; padding: .25rem .3rem; border: 1px solid var(--border); border-radius: 6px; }
.text-input { font: inherit; font-size: .88rem; padding: .3rem .45rem; border: 1px solid var(--border); border-radius: 6px; width: 100%; min-width: 130px; background: var(--surface); }
.num-input.small { width: 64px; }
.center { text-align: center; }
.add-agent { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.add-agent .text-input { width: 220px; }

.filter-panel[hidden] { display: none; }

/* --- login --- */
.auth-page { display: grid; place-items: center; min-height: 100vh; background: var(--topbar); }
.auth-box { width: min(380px, 92vw); background: var(--surface); border-radius: 12px; padding: 1.8rem 2rem; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.auth-box h1 { font-size: 1.3rem; margin: .8rem 0 1rem; }
.auth-brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; color: var(--topbar); }
.auth-brand svg { fill: var(--brand); }
.auth-form { display: grid; gap: .8rem; margin-bottom: .8rem; }
.auth-form label { display: grid; gap: .3rem; font-weight: 600; }
.auth-form input { font: inherit; font-weight: 400; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 7px; }
.ms-btn { display: block; text-align: center; margin-bottom: .8rem; }
.card.narrow { max-width: 460px; }

/* --- top bar: user + ask --- */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; color: #fff; padding: .25rem .6rem; border-radius: 6px; background: rgba(255,255,255,.07); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: .6rem .8rem; display: grid; gap: .4rem; min-width: 190px; z-index: 30; }
.ask-btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: .35rem; background: var(--brand); color: #fff; border: 0; border-radius: 99px; padding: .3rem .8rem; cursor: pointer; }
.ask-btn:hover { background: #2a6fd6; }

/* --- chat panel --- */
.chat-drawer { position: fixed; top: 56px; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(16,24,40,.12); display: flex; flex-direction: column; z-index: 40; }
.chat-drawer[hidden] { display: none; }
body.chat-open main { margin-right: 440px; }
@media (max-width: 1300px) { body.chat-open main { margin-right: auto; } }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.chat-head-actions { display: flex; align-items: center; gap: .8rem; }
.chat-context { padding: .35rem 1rem; background: #f8fafc; border-bottom: 1px solid var(--border); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.chat-messages.static { overflow: visible; padding: 0; }
.chat-empty { display: grid; gap: .5rem; }
.chat-suggest { font: inherit; text-align: left; background: var(--info-bg); color: var(--info); border: 0; border-radius: 8px; padding: .5rem .7rem; cursor: pointer; }
.chat-msg { max-width: 92%; padding: .6rem .8rem; border-radius: 10px; line-height: 1.45; }
.chat-msg p { margin: 0 0 .4rem; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { margin: .2rem 0 .4rem; padding-left: 1.2rem; }
.chat-msg h4 { margin: .4rem 0 .3rem; font-size: .95rem; }
.chat-msg.user { align-self: flex-end; background: var(--brand); color: #fff; }
.chat-msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); }
.chat-msg.thinking { color: var(--muted); }
.chat-msg.error { align-self: flex-start; background: var(--bad-bg); color: var(--bad); }
.chat-msg.user .chat-tools { color: rgba(255,255,255,.75); }
.chat-tools { margin-top: .4rem; font-size: .78rem; color: var(--muted); }
.chat-table { border-collapse: collapse; margin: .3rem 0; font-size: .88rem; }
.chat-table th, .chat-table td { border-bottom: 1px solid var(--border); padding: .25rem .5rem; text-align: left; }
.chat-input { display: flex; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--border); }
.chat-input textarea { flex: 1; font: inherit; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; }
.chat-foot { padding: 0 1rem .6rem; }

/* --- chats page --- */
.chat-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-list { display: grid; gap: .2rem; max-height: 75vh; overflow-y: auto; }
.chat-list-item { display: grid; gap: .1rem; padding: .5rem .6rem; border-radius: 7px; color: var(--text); }
.chat-list-item:hover { background: var(--none-bg); text-decoration: none; }
.chat-list-item.current { background: var(--info-bg); }
.chat-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-filter select { font: inherit; width: 100%; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 7px; margin-bottom: .5rem; }

/* --- settings: users --- */
.inline-form { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.inline-form select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--border); border-radius: 6px; }
.users-table tr.off td { opacity: .55; }
.add-agent select { font: inherit; padding: .3rem .45rem; border: 1px solid var(--border); border-radius: 6px; }

/* --- overview breakdowns --- */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-3 .card { margin-bottom: 1rem; }
@media (max-width: 1200px) { .grid-3 { grid-template-columns: 1fr; } }
.sla-ok { color: var(--good); }
.sla-low { color: var(--bad); }

/* --- Tickets tab --- */
.tk-nav { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .8rem; }
.tk-nav a { padding: .35rem .8rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500; font-size: .92rem; }
.tk-nav a:hover { text-decoration: none; background: var(--none-bg); }
.tk-nav a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tk-filters { display: grid; gap: .6rem; padding: .8rem 1rem; }
.tk-f { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.tk-f label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; }
.tk-f input[type=date], .tk-f select { font: inherit; font-weight: 400; padding: .3rem .45rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.tk-presets { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.tk-presets button { font: inherit; font-size: .82rem; border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: .2rem .6rem; cursor: pointer; }
.tk-presets button:hover { background: var(--info-bg); }
.segmented label { padding: .2rem .7rem; border-radius: 6px; cursor: pointer; font-weight: 500; }
.segmented label input { display: none; }
.segmented label.active { background: var(--brand); color: #fff; }
.tk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.tk-tiles > a, .tk-tiles > div { text-decoration: none; }
.tk-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem .9rem; display: grid; gap: .15rem; height: 100%; }
a .tk-tile:hover { border-color: var(--brand); }
.tk-tile b { font-size: 1.55rem; color: var(--text); letter-spacing: -.3px; }
.tk-tile span { color: var(--muted); font-size: .85rem; font-weight: 500; }
.tk-tile.good b { color: var(--good); } .tk-tile.bad b { color: var(--bad); } .tk-tile.warn b { color: var(--warn); }
.tk-sub { margin: -.5rem 0 1rem; }
.tk-col-title { margin: 0 0 .6rem; }
.feas { display: grid; gap: .3rem; }
.feas-row, .vbar { display: grid; grid-template-columns: minmax(110px, 30%) 1fr 44px; align-items: center; gap: .6rem; color: var(--text); padding: .1rem .2rem; border-radius: 5px; }
a.feas-row:hover, a.vbar:hover { background: var(--none-bg); text-decoration: none; }
.feas-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.feas-bar { display: flex; height: 20px; border-radius: 4px; overflow: hidden; background: var(--none-bg); font-size: .75rem; font-weight: 600; color: #fff; }
.feas-bar span { display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.feas-bar .ok, .feas-legend .ok { background: #3fa66b; }
.feas-bar .late, .feas-legend .late { background: #d65a4f; }
.feas-bar .none, .feas-legend .none { background: #3c6e8f; }
.feas-n { text-align: right; }
.feas-legend { margin-top: .5rem; display: flex; gap: .4rem 1rem; flex-wrap: wrap; align-items: center; }
.feas-legend span { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: -.6rem; }
.feas-bar.lead span.b0, .feas-legend .b0 { background: #dbe9fa; color: #1c2430; } .feas-bar.lead span.b1, .feas-legend .b1 { background: #b8d4f5; color: #1c2430; }
.feas-bar.lead span.b2, .feas-legend .b2 { background: #8fbbee; } .feas-bar.lead span.b3, .feas-legend .b3 { background: #65a1e4; }
.feas-bar.lead span.b4, .feas-legend .b4 { background: #3f86d6; } .feas-bar.lead span.b5, .feas-legend .b5 { background: #2a6cbb; }
.feas-bar.lead span.b6, .feas-legend .b6 { background: #1f5296; } .feas-bar.lead span.b7, .feas-legend .b7 { background: #13233d; }
.vbars { display: grid; gap: .25rem; }
.vbar-track { height: 16px; background: var(--none-bg); border-radius: 4px; overflow: hidden; }
.vbar-track span { display: block; height: 100%; background: #a9c9f2; }
.vbar-v { text-align: right; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart.tall { height: 340px; }
.tk-table td { font-size: .87rem; vertical-align: top; }
.tk-desc { min-width: 220px; max-width: 360px; }
.tk-grid td, .tk-grid th { font-size: .82rem; padding: .3rem .4rem; }
.tk-search { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.tk-search .text-input { width: 260px; }
.tk-customer-title { margin: .2rem 0 .8rem; }
.tk-crumb { font-size: .9rem; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable[data-dir=asc]::after { content: " ▲"; font-size: .7em; } th.sortable[data-dir=desc]::after { content: " ▼"; font-size: .7em; }
hr.soft { border: 0; border-top: 1px solid var(--border); margin: .6rem 0; }
.spark svg { display: block; }

/* Settings: first time fix rule */
.rule-choice{border:1px solid var(--line,#e3e7ee);border-radius:8px;padding:10px 14px;margin:14px 0}
.rule-choice legend{font-weight:600;padding:0 6px}
.rule-choice label{display:block;margin:6px 0}


/* Statistics filter: active date preset, customer multi-select */
.tk-presets button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tk-ms { position: relative; display: inline-flex; align-items: center; gap: .4rem; }
.tk-ms-label { font-weight: 600; font-size: .9rem; }
.tk-ms-toggle { font: inherit; font-size: .88rem; min-width: 12rem; max-width: 20rem; display: inline-flex; justify-content: space-between; gap: .5rem;
  align-items: center; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: .3rem .55rem; cursor: pointer; text-align: left; }
.tk-ms-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ms-caret { color: var(--muted, #6b7686); font-size: .75rem; }
.tk-ms-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 22rem; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 30, 60, .14);
  padding: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.tk-ms-panel[hidden] { display: none; }
.tk-ms-mode { align-self: flex-start; }
.tk-ms-search { width: 100%; box-sizing: border-box; }
.tk-ms-list { max-height: 16rem; overflow-y: auto; border-top: 1px solid var(--border); padding-top: .3rem; }
.tk-ms .tk-ms-item { display: flex; width: 100%; box-sizing: border-box; align-items: center; justify-content: flex-start; gap: .45rem; padding: .2rem .25rem; border-radius: 4px; font-size: .88rem; font-weight: 400; cursor: pointer; text-align: left; }
.tk-ms .tk-ms-item input { margin: 0; flex: none; }
.tk-ms .tk-ms-item:hover { background: var(--info-bg); }
.tk-ms .tk-ms-item[hidden] { display: none; }
.tk-ms-foot { display: flex; justify-content: space-between; align-items: center; }

/* Hover hints: any element with data-tip (Statistics tiles, KPI Scorecard); positioned by app.js */
[data-tip] { cursor: help; }
a [data-tip], a[data-tip] { cursor: pointer; }
[data-tip]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tip-box { position: fixed; z-index: 1000; max-width: 280px; padding: .45rem .6rem; border-radius: 6px; background: #1d2633;
  color: #fff; font-size: .8rem; font-weight: 400; line-height: 1.4; text-align: left; white-space: pre-line;
  box-shadow: 0 6px 18px rgba(15, 30, 60, .22); pointer-events: none; }
.tip-box[hidden] { display: none; }
/* Settings: KPI switched off */
tr.kpi-off td:not(:first-child) { opacity: .45; }
.switch input { width: 1.05rem; height: 1.05rem; cursor: pointer; }


/* Statistics: customer attention list */
.att-rule { display: inline-block; margin: .25rem .3rem 0 0; padding: .1rem .5rem; border-radius: 99px; background: var(--info-bg); font-size: .78rem; }
.att-signal { display: inline-block; margin: .1rem .3rem .1rem 0; padding: .12rem .5rem; border-radius: 6px; background: #fdecea; color: #a12a24; font-size: .8rem; }
.att-table td { vertical-align: top; }

/* Statistics: repeats */
.rep-tickets a { display: inline-block; margin: 0 .45rem .1rem 0; white-space: nowrap; }
.rep-tickets a.muted { color: var(--muted, #6b7686); }
.rep-table td { vertical-align: top; }


/* Settings: e-mail reports */
.report-item { border: 1px solid var(--border); border-radius: 8px; padding: .55rem .8rem; margin: .5rem 0; }
.report-item > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.report-form { margin-top: .7rem; display: grid; gap: .6rem; }
.report-grid { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: end; }
.report-grid label, .rf-recipients { display: flex; flex-direction: column; gap: .2rem; font-size: .88rem; font-weight: 600; }
.report-grid label[hidden], .rf-sections[hidden] { display: none; }
.rf-recipients textarea { width: 100%; box-sizing: border-box; font-weight: 400; }
.rf-sections { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: center; font-size: .88rem; font-weight: 600; }
.rf-sections .check { font-weight: 400; }
.report-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.pill.good { background: #e3f4ea; color: #1a8a4a; }

.sender-form { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: .4rem 0 .8rem; }
.sender-form label { display: inline-flex; gap: .4rem; align-items: center; font-weight: 600; font-size: .9rem; }
.sender-form input { min-width: 16rem; }


.cache-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }


/* top bar: refresh button */
.refresh-btn { font: inherit; font-size: 1.05rem; line-height: 1; width: 2rem; height: 2rem; border-radius: 6px; border: 1px solid rgba(255,255,255,.25);
  background: transparent; color: inherit; cursor: pointer; }
.refresh-btn:hover { background: rgba(255,255,255,.12); }
.refresh-btn.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tk-ms .tk-ms-nc { border-top: 1px solid var(--border); padding-top: .4rem; margin-top: .1rem; }


/* KPI Scorecard: manual registration quality */
.reg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem 1.2rem; margin: .4rem 0 .6rem; }
.reg-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.reg-row select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }

a.att-signal { text-decoration: none; }
a.att-signal:hover { background: #f8d6d2; text-decoration: none; }


/* chat: voice */
.chat-mic-wrap { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.mic-btn { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.mic-btn:hover { background: var(--info-bg); }
.mic-btn.recording { background: #c7362f; border-color: #c7362f; color: #fff; animation: mic-pulse 1.2s ease-in-out infinite; }
.mic-btn.busy { opacity: .6; cursor: progress; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 6px rgba(199, 54, 47, .25); } }
.mic-timer { font-size: .72rem; color: #c7362f; font-variant-numeric: tabular-nums; }
.chat-listen { font-size: .8rem; margin-top: .25rem; }
.chat-play { margin-top: .3rem; }
.chat-voice-btn { font-size: .95rem; }
