:root, :root[data-theme="dark"] {
  --bg: #08090e; --bg2: #0e1018; --panel: #11141d; --panel2: #161a25; --line: rgba(170, 160, 140, .13); --line2: rgba(170, 160, 140, .24);
  --text: #f1ede4; --muted: #958f80; --faint: #6c6759; --a1: #f6b94a; --a2: #2dd4bf; --ok: #34d399; --bad: #fb7185; --warn: #f6b94a; --info: #93c5fd;
  --c1: #f6b94a; --c2: #2dd4bf; --c3: #a78bfa; --c4: #fb7185; --c5: #93c5fd; --c6: #fda4af;
  --code: #0a0c12; --shadow: 0 20px 50px -25px rgba(0, 0, 0, .7); --r: 14px;
}
:root[data-theme="light"] {
  --bg: #f5f2ea; --bg2: #ece7dc; --panel: #fffdf8; --panel2: #f8f4eb; --line: rgba(60, 50, 30, .12); --line2: rgba(60, 50, 30, .22);
  --text: #17140e; --muted: #6b6456; --faint: #938b7b; --a1: #b7791f; --a2: #0f8f84; --ok: #059669; --bad: #e11d48; --warn: #b45309; --info: #2563eb;
  --c1: #c28420; --c2: #0f8f84; --c3: #7c3aed; --c4: #e11d48; --c5: #2563eb; --c6: #db2777;
  --code: #f3eee3; --shadow: 0 18px 40px -26px rgba(60, 45, 20, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--a2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: "Cascadia Code", "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--a2); outline-offset: 2px; border-radius: 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 7px 10px; min-height: 34px; }
input[type="checkbox"] { min-height: 0; accent-color: var(--a2); width: 16px; height: 16px; }
textarea { width: 100%; min-height: 80px; }
.small { font-size: 12px; }
.lx-muted { color: var(--muted); }
.lx-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lx-spacer { flex: 1; }
.lx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 8px 14px; font-weight: 650; cursor: pointer;
  background: linear-gradient(100deg, var(--a1), color-mix(in srgb, var(--a1) 45%, var(--a2))); color: #17120a; transition: transform .15s, filter .15s; text-decoration: none !important; }
:root[data-theme="light"] .lx-btn:not(.ghost):not(.danger) { color: #fff; }
.lx-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.lx-btn:disabled { opacity: .5; cursor: default; transform: none; }
.lx-btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); }
.lx-btn.danger { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.lx-btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.lx-btn.wide { width: 100%; padding: 11px; }
.lx-icon { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; display: inline-grid; place-items: center; }

/* login */
.lx-login { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(50% 50% at 50% 30%, color-mix(in srgb, var(--a1) 12%, transparent), transparent 70%), var(--bg); }
.lx-login-box { width: min(380px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.lx-login-box h1 { margin: 22px 0 4px; font-size: 24px; letter-spacing: -.02em; }
.lx-login-box form { display: grid; gap: 14px; margin: 22px 0 14px; }
.lx-login-box label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.lx-err { color: var(--bad); min-height: 1em; margin: 0; font-size: 13px; }

/* shell */
.lx-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lx-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--bg2); }
.lx-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 18px; letter-spacing: -.02em; text-decoration: none !important; }
.lx-brand b { color: var(--a1); }
.lx-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.lx-nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 550; }
.lx-nav a i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
.lx-nav a:hover { background: var(--line); color: var(--text); }
.lx-nav a.on { background: color-mix(in srgb, var(--a1) 14%, transparent); color: var(--text); box-shadow: inset 2px 0 0 var(--a1); }
.lx-nav-h { margin: 14px 10px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.lx-side-foot { margin-top: auto; display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.lx-main { min-width: 0; display: flex; flex-direction: column; }
.lx-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 22px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.lx-bar h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.lx-menu { display: none; }
.lx-filters { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lx-seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; }
.lx-seg button { border: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.lx-seg button.on { background: var(--line2); color: var(--text); }
.lx-view { padding: 22px; display: grid; gap: 18px; align-content: start; outline: none; }

/* cards & grids */
.lx-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.lx-grid2 > *, .lx-grid2e > * { min-width: 0; }
.lx-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; position: relative; overflow: hidden; }
.lx-kpi b { display: block; font-size: 24px; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.lx-kpi span { color: var(--muted); font-size: 12.5px; }
.lx-kpi small { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.lx-kpi::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--a1) 14%, transparent), transparent); }
.lx-grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.lx-grid2e { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lx-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.lx-card > h2, .lx-card-h h2 { font-size: 14.5px; margin: 0 0 12px; letter-spacing: -.005em; }
.lx-card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lx-card-h h2 { margin: 0; }
.lx-card-h .lx-row { margin-left: auto; }
.lx-hint { color: var(--muted); font-size: 12.5px; margin: -6px 0 12px; }
.lx-empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.lx-empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* tables */
.lx-tw { overflow-x: auto; }
table.lx-t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lx-t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.lx-t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lx-t tr.click { cursor: pointer; }
.lx-t tr.click:hover td { background: color-mix(in srgb, var(--a1) 6%, transparent); }
.lx-t .num { text-align: right; white-space: nowrap; }
.lx-t .cut { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-t th[data-sort] { cursor: pointer; }
.lx-t th.sorted { color: var(--text); }
.lx-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.lx-pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.lx-pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.lx-pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.lx-bar-mini { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 60px; }
.lx-bar-mini i { display: block; height: 100%; background: linear-gradient(90deg, var(--a1), var(--a2)); }
.lx-avatar { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; color: #17120a; vertical-align: middle; margin-right: 8px; }
.lx-pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }

/* charts */
.lx-chart { width: 100%; height: 220px; display: block; }
.lx-chart text { fill: var(--muted); font-size: 11px; }
.lx-chart .grid { stroke: var(--line); }
.lx-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.lx-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lx-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; }
.lx-heat { display: grid; grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10.5px; color: var(--muted); }
.lx-heat div { aspect-ratio: 1.6; border-radius: 3px; }
.lx-heat .lab { aspect-ratio: auto; display: flex; align-items: center; }
.lx-hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.lx-hbar .lx-bar-mini { height: 8px; }
.lx-hbar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* session replay */
.lx-sess-h { display: grid; gap: 10px; }
.lx-sess-h h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.lx-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.lx-tabs button { border: 1px solid var(--line2); background: var(--panel2); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.lx-tabs button.on { color: var(--text); border-color: var(--a1); background: color-mix(in srgb, var(--a1) 12%, transparent); }
.lx-tl { display: grid; gap: 10px; }
.lx-msg { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); min-width: 0; }
.lx-msg-h { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.lx-msg-h b { color: var(--text); font-size: 12.5px; }
.lx-msg.user { border-left: 3px solid var(--a1); background: color-mix(in srgb, var(--a1) 5%, var(--panel)); }
.lx-msg.user.corr { border-left-color: var(--bad); }
.lx-msg.ai { border-left: 3px solid var(--a2); }
.lx-msg.sys { border-style: dashed; color: var(--muted); font-size: 12.5px; padding: 8px 12px; }
.lx-body { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.lx-body pre { background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre; }
.lx-body code { background: var(--code); padding: 1px 5px; border-radius: 5px; }
.lx-body pre code { padding: 0; background: none; }
details.lx-fold { border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; background: var(--panel2); }
details.lx-fold > summary { cursor: pointer; padding: 6px 10px; font-size: 12.5px; color: var(--muted); list-style: none; display: flex; gap: 8px; align-items: center; }
details.lx-fold > summary::-webkit-details-marker { display: none; }
details.lx-fold > summary::before { content: "▸"; transition: transform .15s; }
details.lx-fold[open] > summary::before { transform: rotate(90deg); }
details.lx-fold > div { padding: 8px 10px; border-top: 1px solid var(--line); max-height: 520px; overflow: auto; }
details.lx-fold.err > summary { color: var(--bad); }
.lx-tool { font-family: "Cascadia Code", ui-monospace, monospace; font-size: 12px; color: var(--text); }
mark { background: color-mix(in srgb, var(--a1) 45%, transparent); color: inherit; border-radius: 3px; }
.lx-flag { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); margin: 6px 0; }
.lx-flag b { font-size: 13px; }
.lx-flag span { color: var(--muted); font-size: 12.5px; }
.lx-cluster { display: grid; gap: 8px; }
.lx-ex { border-left: 2px solid var(--line2); padding: 4px 10px; color: var(--muted); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.lx-ex a { color: var(--faint); font-size: 11.5px; }

/* forms, modal, toast */
.lx-form { display: grid; gap: 12px; max-width: 560px; }
.lx-form > button, .lx-form > .lx-row { justify-self: start; }
.lx-form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.lx-check { display: flex !important; flex-direction: row; gap: 8px; align-items: center; color: var(--text) !important; font-size: 13.5px !important; }
.lx-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); padding: 16px; }
.lx-modal[hidden] { display: none; }
.lx-modal-box { position: relative; width: min(720px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.lx-modal-x { position: absolute; top: 14px; right: 14px; }
.lx-modal-box h2 { margin: 0 0 8px; }
.lx-secret { display: flex; gap: 8px; align-items: stretch; margin: 8px 0 14px; }
.lx-secret pre { flex: 1; margin: 0; background: var(--code); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; overflow-x: auto; color: var(--a2); white-space: pre-wrap; word-break: break-all; }
.lx-toast { position: fixed; right: 18px; bottom: 18px; z-index: 70; background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; }
.lx-toast.show { opacity: 1; transform: none; }
.lx-toast.bad { border-color: var(--bad); color: var(--bad); }
.lx-skel { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--panel), var(--panel2), var(--panel)); background-size: 200% 100%; animation: lx-sk 1.2s infinite; }
@keyframes lx-sk { to { background-position: -200% 0; } }

@media (max-width: 1100px) { .lx-grid2, .lx-grid2e { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .lx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lx-kpi b { font-size: 20px; } }
@media (min-width: 821px) { body:not(.lx-login) { background: linear-gradient(90deg, var(--bg2) 232px, var(--bg) 232px); } .lx-side { border-right: 0; box-shadow: 1px 0 0 var(--line); } }
@media (max-width: 820px) {
  .lx-shell { grid-template-columns: 1fr; }
  .lx-side { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .lx-side.open { transform: none; }
  .lx-menu { display: inline-grid; }
  .lx-bar { padding: 10px 14px; }
  .lx-filters { margin-left: 0; width: 100%; }
  .lx-view { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
