:root{--bg:#f5f7fb;--panel:#fff;--ink:#16202e;--muted:#5b6778;--line:#e3e8f0;--brand:#1558d6;--brand-ink:#fff;--brand-soft:#e8f0fe;
--ok:#12805c;--ok-soft:#e5f5ee;--warn:#9a6700;--warn-soft:#fff5da;--bad:#c62828;--bad-soft:#fdecec;--radius:10px;
font-family:Inter,"Segoe UI",system-ui,-apple-system,sans-serif;font-size:14.5px;color:var(--ink);background:var(--bg)}
*{box-sizing:border-box}body{margin:0;background:var(--bg)}a{color:var(--brand);text-decoration:none}a:hover{text-decoration:underline}
h1{font-size:22px;margin:0 0 4px}h2{font-size:17px;margin:24px 0 10px}h3{font-size:15px;margin:0 0 8px}
.muted{color:var(--muted)}.small{font-size:12.5px}.right{text-align:right}.nowrap{white-space:nowrap}.mono{font-family:ui-monospace,Consolas,monospace;font-size:13px}
.layout{display:flex;min-height:100vh}
.side{width:236px;background:#0f1b2d;color:#c9d4e5;padding:18px 12px;display:flex;flex-direction:column;position:sticky;top:0;height:100vh;flex-shrink:0}
.brand{display:flex;align-items:center;gap:10px;padding:4px 8px 18px;color:#fff;font-weight:700;font-size:18px}
.brand .dot{width:28px;height:28px;border-radius:8px;background:linear-gradient(135deg,#3b82f6,#22c1a3);display:grid;place-items:center;font-size:14px}
.side a.nav{display:flex;align-items:center;gap:10px;color:#c9d4e5;padding:8px 10px;border-radius:8px;margin:1px 0;font-weight:500}
.side a.nav:hover{background:#1b2a42;text-decoration:none;color:#fff}.side a.nav.on{background:#1e3a66;color:#fff}
.side .sec{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:#7d8ba3;padding:14px 10px 4px}
.side .me{margin-top:auto;border-top:1px solid #22334f;padding:12px 8px 0;font-size:12.5px}
.side .me button{background:none;border:0;color:#9fb3d1;padding:0;cursor:pointer;font:inherit}
.badge{display:inline-block;padding:2px 8px;border-radius:99px;font-size:11.5px;font-weight:600;background:var(--brand-soft);color:var(--brand)}
.badge.ok{background:var(--ok-soft);color:var(--ok)}.badge.warn{background:var(--warn-soft);color:var(--warn)}.badge.bad{background:var(--bad-soft);color:var(--bad)}.badge.grey{background:#eef1f5;color:var(--muted)}
.side .badge{margin-left:auto}
main{flex:1;min-width:0;padding:26px 32px 60px;max-width:1280px}
.head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:18px;flex-wrap:wrap}
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:18px}
.grid{display:grid;gap:14px}.g4{grid-template-columns:repeat(auto-fit,minmax(190px,1fr))}.g2{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}
.stat .v{font-size:26px;font-weight:700;margin-top:4px}.stat .l{color:var(--muted);font-size:12.5px;text-transform:uppercase;letter-spacing:.05em}
table{width:100%;border-collapse:collapse;background:var(--panel)}th,td{text-align:left;padding:9px 12px;border-bottom:1px solid var(--line);vertical-align:top}
th{font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:600;background:#fafbfd}
.tablewrap{border:1px solid var(--line);border-radius:var(--radius);overflow:auto}.tablewrap table tr:last-child td{border-bottom:0}
.btn{display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border-radius:8px;border:1px solid var(--line);background:#fff;color:var(--ink);font:inherit;font-weight:600;cursor:pointer}
.btn:hover{text-decoration:none;border-color:#c6d0de}.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}.btn.primary:hover{background:#0f4bbd}
.btn.danger{color:var(--bad)}.btn.sm{padding:5px 10px;font-size:13px}.btn:disabled{opacity:.6;cursor:not-allowed}
form.inline{display:inline}
label{display:block;font-weight:600;font-size:13px;margin:14px 0 5px}.help{font-weight:400;color:var(--muted);font-size:12.5px;margin-top:4px}
input[type=text],input[type=email],input[type=password],input[type=number],input[type=time],input[type=datetime-local],select,textarea{width:100%;padding:9px 11px;border:1px solid #cfd7e3;border-radius:8px;font:inherit;background:#fff;color:var(--ink)}
textarea{min-height:110px;resize:vertical;font-family:inherit}textarea.code{font-family:ui-monospace,Consolas,monospace;font-size:13px}
input:focus,select:focus,textarea:focus{outline:2px solid #b7cdf6;border-color:var(--brand)}
.check{display:flex;align-items:center;gap:8px;font-weight:500;margin:12px 0}.check input{width:16px;height:16px}
.row{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
.actions{display:flex;gap:10px;margin-top:20px;flex-wrap:wrap;align-items:center}
.flash{padding:10px 14px;border-radius:8px;margin-bottom:14px;background:var(--ok-soft);color:var(--ok);border:1px solid #bfe5d3}
.flash.err{background:var(--bad-soft);color:var(--bad);border-color:#f3c2c2}
.note{padding:12px 14px;border-radius:8px;background:var(--warn-soft);border:1px solid #f0dc9e;color:#6b4a00}
.info{padding:12px 14px;border-radius:8px;background:var(--brand-soft);border:1px solid #c9dafc;color:#153e8a}
.filters{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.filters select{width:auto}
.bar{height:8px;background:#edf1f7;border-radius:99px;overflow:hidden}.bar i{display:block;height:100%;background:var(--brand)}
.spark{display:flex;align-items:flex-end;gap:3px;height:90px;padding-top:6px}.spark i{flex:1;background:#7aa7f0;border-radius:3px 3px 0 0;min-height:2px}
/* auth pages */
.authwrap{min-height:100vh;display:grid;place-items:center;padding:20px}
.authcard{width:100%;max-width:420px;background:#fff;border:1px solid var(--line);border-radius:14px;padding:30px}
.authcard .brand{color:var(--ink);padding:0 0 14px}.qr{background:#fff;padding:8px;border:1px solid var(--line);border-radius:10px;width:220px;margin:10px auto}.qr svg{width:100%;height:auto;display:block}
/* chat */
.chat{display:grid;grid-template-columns:240px 1fr;gap:16px;height:calc(100vh - 150px);min-height:480px}
.convlist{overflow:auto;background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:8px}
.convlist a{display:block;padding:8px 10px;border-radius:7px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13.5px}
.convlist a.on,.convlist a:hover{background:var(--brand-soft);text-decoration:none}
.chatmain{display:flex;flex-direction:column;background:#fff;border:1px solid var(--line);border-radius:var(--radius);min-width:0}
.msgs{flex:1;overflow:auto;padding:18px 20px}
.msg{margin:0 0 14px;max-width:88%;width:fit-content;padding:11px 14px;border-radius:12px;line-height:1.5;overflow-wrap:anywhere}
.msg.user{margin-left:auto;background:var(--brand);color:#fff;border-bottom-right-radius:4px;white-space:pre-wrap}
.msg.assistant{background:#f3f6fa;border:1px solid var(--line);border-bottom-left-radius:4px}
.msg.assistant pre{background:#0f1b2d;color:#e6edf7;padding:10px;border-radius:8px;overflow:auto;font-size:12.5px}
.msg.assistant code{background:#e6ebf2;padding:1px 4px;border-radius:4px;font-size:13px}.msg.assistant pre code{background:none;padding:0}
.msg.tool{font-family:ui-monospace,Consolas,monospace;font-size:12px;color:var(--muted);background:none;padding:2px 14px;margin:-6px 0 10px}
.msg.err{background:var(--bad-soft);color:var(--bad);border:1px solid #f3c2c2}
.composer{border-top:1px solid var(--line);padding:12px;display:flex;gap:10px;align-items:flex-end}
.composer textarea{min-height:48px;max-height:220px}
.working{color:var(--muted);font-size:13px;padding:0 20px 10px}.working .dots::after{content:"…";animation:d 1.2s steps(3) infinite}
@keyframes d{0%{content:"."}33%{content:".."}66%{content:"..."}}
.empty{color:var(--muted);text-align:center;padding:40px 10px}
details summary{cursor:pointer;font-weight:600}
pre.out{background:#0f1b2d;color:#e6edf7;padding:12px;border-radius:8px;overflow:auto;max-height:520px;font-size:12.5px;white-space:pre-wrap}
@media (max-width:900px){.layout{flex-direction:column}.side{width:100%;height:auto;position:static;flex-direction:row;flex-wrap:wrap;gap:2px;padding:10px}
.side .sec,.side .me{display:none}.brand{padding:4px 8px}main{padding:18px 16px}.chat{grid-template-columns:1fr;height:auto}.convlist{display:none}.msgs{min-height:50vh}}
.msg.event{background:#fff8e6;border:1px dashed #e8c66a;color:#6b4a00;font-size:13px;margin-left:auto;margin-right:auto;text-align:center}
.callbar{display:flex;gap:8px;flex-wrap:wrap;padding:6px 20px 8px}.callbar .chip{background:#eef3fd;border:1px solid #c9dafc;color:#153e8a;border-radius:99px;padding:4px 10px;font-size:12.5px}
/* chat-scroll-fix v1: fixed chat box, messages scroll inside */
body:has(.chat) main{padding-bottom:16px}
.chat{grid-template-rows:minmax(0,1fr);height:calc(100vh - 118px);height:calc(100dvh - 118px);min-height:420px}
.chat>*{min-height:0}
.convlist{overscroll-behavior:contain}
.chatmain{position:relative;overflow:hidden;min-height:0}
.msgs{min-height:0;overscroll-behavior:contain;scroll-behavior:auto}
.composer{flex-shrink:0}
.jump{position:absolute;right:18px;bottom:84px;z-index:2;border:1px solid var(--line);background:#fff;color:var(--brand);font:inherit;font-weight:600;font-size:12.5px;padding:6px 12px;border-radius:99px;box-shadow:0 2px 8px rgba(15,27,45,.15);cursor:pointer}
.jump:hover{background:var(--brand-soft)}
@media (max-width:900px){.chat{height:auto;min-height:0}.chatmain{height:calc(100dvh - 190px);min-height:360px}.msgs{min-height:0}}
/* calltx-fix v1: call transcript in a fixed box, scrolls inside */
.calltx-wrap{position:relative}
.calltx{height:calc(100vh - 360px);height:calc(100dvh - 360px);min-height:320px;max-height:760px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--line);border-radius:8px;padding:14px 16px;background:#fbfcfe}
.msg.caller{margin-left:auto;background:#eef3fd;border:1px solid #d5e2fb;border-bottom-right-radius:4px;white-space:pre-wrap}
.calltx .msg.assistant{white-space:pre-wrap}
.msg .who{display:block;font-size:11.5px;color:var(--muted);font-weight:600;margin-bottom:2px}
.calltx-wrap .jump{bottom:14px}
@media (max-width:900px){.calltx{height:60vh;min-height:280px}}
/* charts & health */
svg.chart{width:100%;height:150px;display:block}svg.chart .grid{stroke:#e5e9f0;stroke-width:1}svg.chart .ax{font-size:10px;fill:#8190a5}
.legend{display:flex;gap:14px;font-size:12px;color:var(--muted);margin-top:4px}.legend .lg i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:5px;vertical-align:-1px}
.bar{height:8px;background:#eef1f5;border-radius:99px;overflow:hidden;margin:3px 0}.bar i{display:block;height:100%;background:var(--ok)}.bar i.warn{background:var(--warn)}.bar i.bad{background:var(--bad)}.bar i.grey{background:#c5cdd8}
.score{display:inline-flex;align-items:center;justify-content:center;width:46px;height:46px;border-radius:50%;font-weight:700;font-size:16px;background:var(--ok-soft);color:var(--ok)}
.score.warn{background:var(--warn-soft);color:var(--warn)}.score.bad{background:var(--bad-soft);color:var(--bad)}.score.grey{background:#eef1f5;color:var(--muted)}
.diff{white-space:pre-wrap;font-family:ui-monospace,monospace;font-size:12px;background:#f7f9fc;border:1px solid var(--line);border-radius:8px;padding:10px;max-height:420px;overflow:auto}
.diff .add{background:#e7f7ec;color:#14532d;display:block}.diff .del{background:#fdecec;color:#7f1d1d;display:block;text-decoration:line-through}
.mailist a.row{display:block;padding:10px 12px;border-bottom:1px solid var(--line);color:inherit}.mailist a.row.unread{font-weight:600}.mailist a.row:hover{background:#f7f9fc}
pre.mailbody{white-space:pre-wrap;font-family:inherit;font-size:14px;line-height:1.5;margin:0}
.dns td{font-family:ui-monospace,monospace;font-size:12px;word-break:break-all}
.boxlink{display:block;padding:8px 10px;border-radius:8px;color:inherit}.boxlink:hover{background:#f7f9fc}.boxlink.on{background:var(--brand-soft)}
.side{overflow-y:auto}.brand .ver{font-size:11px;font-weight:600;color:#7d8ba3;background:#1b2a42;border-radius:99px;padding:2px 7px;margin-left:auto}
.side a.pulse{display:flex;flex-wrap:wrap;gap:6px 12px;margin-top:auto;padding:10px 8px;border-top:1px solid #22334f;color:#c9d4e5;font-size:12px}
.side a.pulse:hover{text-decoration:none;background:#1b2a42;border-radius:8px}.side a.pulse + .me{margin-top:0}
.pi{display:inline-flex;align-items:center;gap:5px;white-space:nowrap}
.pd{display:inline-block;width:9px;height:9px;border-radius:50%;background:#7d8ba3}.pd.ok{background:#22c55e;box-shadow:0 0 0 3px rgba(34,197,94,.18)}
.pd.warn{background:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.2)}.pd.bad{background:#ef4444;box-shadow:0 0 0 3px rgba(239,68,68,.22);animation:pdpulse 1.4s infinite}
@keyframes pdpulse{50%{box-shadow:0 0 0 6px rgba(239,68,68,0)}}
.dashsec{margin:22px 0 8px;display:flex;align-items:baseline;gap:10px}.dashsec h2{margin:0}.dashsec a{font-size:13px}
.kv{display:flex;justify-content:space-between;padding:6px 0;border-bottom:1px solid var(--line);font-size:13.5px}.kv:last-child{border-bottom:0}
.ctxbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:8px 12px;margin:-4px 0 16px}
.ctxbar label{margin:0;font-weight:700;font-size:13px}.ctxbar select{width:auto;min-width:260px;margin:0}
.ctxbar.on{border-color:#1558d6;background:#eef4ff;box-shadow:inset 4px 0 0 #1558d6}

/* client tree picker (group > sector > company) */
.ctree{position:relative;display:block;width:100%}
.ctree.inline{display:inline-block;width:auto;min-width:260px;vertical-align:middle}
.ctree-btn{display:block;width:100%;text-align:left;font:inherit;color:#1b2430;background:#fff;border:1px solid #cfd6e0;border-radius:6px;padding:7px 30px 7px 10px;cursor:pointer;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ctree-btn::after{content:"▾";position:absolute;right:10px;top:50%;transform:translateY(-50%);color:#6b7686}
.ctree-panel{position:absolute;z-index:60;left:0;top:calc(100% + 4px);min-width:100%;width:max-content;max-width:min(460px,90vw);background:#fff;color:#1b2430;border:1px solid #cfd6e0;border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.15);padding:6px;box-sizing:border-box}
.ctree-panel[hidden]{display:none}
.ctree-q{width:100%;box-sizing:border-box;margin:0 0 6px}
.ctree-list{max-height:320px;overflow:auto}
.ctree-row{display:flex;align-items:center;gap:6px;padding:5px 8px;border-radius:5px;cursor:pointer;white-space:nowrap}
.ctree-row:hover{background:#eef3fa}
.ctree-row.on{font-weight:600;background:#e4edf9}
.ctree-tgl{width:14px;flex:none;text-align:center;color:#6b7686}
.ctree-tgl[data-tgl]{cursor:pointer}
.ctree-tgl[data-tgl]:hover{color:#1b2430}
.ctree-kind{margin-left:auto;font-size:11px;color:#6b7686;padding-left:12px}
.ctree-empty{padding:6px 8px;color:#6b7686}

/* currency toggle (sidebar) */
.me form.curtoggle{display:flex;align-items:center;gap:4px;margin-top:6px;color:#9fb3d1;font-size:12px}
.me .curtoggle button{background:transparent;border:1px solid #33465f;color:#c9d6ea;border-radius:99px;padding:1px 8px;font-size:11.5px;cursor:pointer}
.me .curtoggle button.on{background:#1558d6;border-color:#1558d6;color:#fff}
a.ver{color:inherit;text-decoration:none}a.ver:hover{text-decoration:underline}
.langgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:2px 14px;max-height:420px;overflow:auto;border:1px solid var(--line);border-radius:8px;padding:8px 10px}
.langgrid label.check{margin:3px 0;font-weight:400;font-size:13px}
.langgrid .lg-h{grid-column:1/-1;font-weight:700;font-size:12px;color:var(--muted);margin-top:6px;text-transform:uppercase;letter-spacing:.04em}
.cl-ver{display:flex;gap:10px;align-items:baseline}.cl-ver h2{margin:0}
.mfa-switch{display:flex;border:1px solid var(--line);border-radius:10px;overflow:hidden;margin:6px 0 16px}
.mfa-switch a{flex:1;text-align:center;padding:9px 6px;font-weight:600;font-size:13.5px;color:var(--muted);text-decoration:none;background:#f7f9fc}
.mfa-switch a.on{background:var(--brand);color:#fff}
