/* Lex — light theme, enterprise, zero-GPU-waste (no animations except the chat spinner) */
:root{
  --bg:#f6f7f9; --panel:#ffffff; --ink:#1a2233; --muted:#6b7280; --line:#e5e7eb;
  --brand:#2456e6; --brand-ink:#ffffff; --ok:#16a34a; --bad:#dc2626; --warn:#d97706;
  --radius:10px; --shadow:0 1px 2px rgba(16,24,40,.06),0 1px 3px rgba(16,24,40,.08);
}
*{box-sizing:border-box}
body{margin:0;font:15px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Roboto,Arial,sans-serif;background:var(--bg);color:var(--ink)}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
.shell{min-height:100vh;display:flex;flex-direction:column}
/* ---- Layout: fixed dark sidebar + slim topbar (one menu, every viewport) -- */
.sidebar{position:fixed;top:0;left:0;bottom:0;width:240px;background:#0f1729;color:#c7d0e0;
  display:flex;flex-direction:column;border-right:1px solid #1e293b;z-index:30}
.sbrand{display:flex;align-items:center;gap:9px;padding:20px 18px 16px;
  font-weight:700;font-size:18px;color:#fff;letter-spacing:.2px}
.sbrand .mark{display:block;flex:0 0 auto;width:19px;height:19px;color:#5b8cff}
.snav{flex:1;overflow-y:auto;padding:4px 10px 12px}
.snav::-webkit-scrollbar{width:8px}
.snav::-webkit-scrollbar-thumb{background:#243350;border-radius:8px}
.sgrp{padding:14px 10px 6px;font-size:10.5px;font-weight:700;letter-spacing:.09em;
  text-transform:uppercase;color:#64748b}
.snav a{display:block;padding:9px 12px;margin:1px 0;border-radius:8px;color:#c7d0e0;
  font-weight:500;font-size:14px}
.snav a:hover{background:#1c2740;color:#fff;text-decoration:none}
.snav a.on{background:#2456e6;color:#fff}
.snav a.slogin{margin-top:6px;background:#2456e6;color:#fff;text-align:center}
.snav a.slogin:hover{filter:brightness(1.08)}
.snav a .nav-badge{display:inline-block;margin-left:8px;padding:1px 7px;border-radius:999px;
  background:#e6611c;color:#fff;font-size:11px;font-weight:700;line-height:15px;vertical-align:1px}
.snav a.on .nav-badge{background:#fff;color:#2456e6}
.sfoot{border-top:1px solid #1e293b;padding:12px 14px 14px;background:#0c1322}
.suser{display:flex;align-items:center;gap:10px;padding:6px 6px 10px;color:#e6ebf3;
  font-weight:600;font-size:13.5px}
.suser:hover{text-decoration:none}
.savatar{flex:0 0 32px;width:32px;height:32px;border-radius:50%;background:#2456e6;color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:12.5px;font-weight:700;
  letter-spacing:.3px}
.sident{display:flex;flex-direction:column;min-width:0}
.sname{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.srole{font-size:11.5px;font-weight:500;color:#8ea0bd}
.slinks{display:flex;gap:14px;margin-bottom:2px}
.slinks a{font-size:12.5px;color:#9fb0c9;font-weight:500}
.slinks a:hover{color:#fff;text-decoration:none}
.sbackdrop{display:none}
.shell-right{flex:1;min-width:0;display:flex;flex-direction:column;padding-left:240px}
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:14px;
  padding:0 22px;height:56px;background:var(--panel);border-bottom:1px solid var(--line)}
.page-title{font-size:15.5px;font-weight:650;color:var(--ink);white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis}
.top-right{margin-left:auto;display:flex;align-items:center;gap:10px}
.ingest-progress{display:inline-flex;align-items:center;gap:7px;padding:5px 11px;border-radius:999px;
  background:rgba(36,86,230,.09);border:1px solid rgba(36,86,230,.22);color:#1e3fae;
  font-size:12.5px;font-weight:600;white-space:nowrap;line-height:1}
.ingest-progress::before{content:"";width:7px;height:7px;border-radius:50%;background:#2456e6;
  animation:ingest-pulse 1.4s ease-in-out infinite}
@keyframes ingest-pulse{0%,100%{opacity:.35;transform:scale(.85)}50%{opacity:1;transform:scale(1)}}
@media (prefers-reduced-motion: reduce){.ingest-progress::before{animation:none;opacity:1}}
.top-right .lang-switch select{border:1px solid var(--line);border-radius:8px;
  background:var(--panel);color:var(--ink);padding:7px 10px;font:inherit;font-size:13px;
  max-width:150px}
.menu-btn{display:none}
.main{flex:1;width:100%;padding:22px}
.foot{padding:18px;text-align:center;color:var(--muted);font-size:12.5px;border-top:1px solid var(--line);margin-top:auto}
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:18px 20px;margin-bottom:18px}
.card h1{margin:0 0 4px;font-size:22px}
.card h2{margin:0 0 10px;font-size:17px}
.card h3{margin:14px 0 6px;font-size:15px}
.muted{color:var(--muted)}
.small{font-size:12.5px}
.error{color:var(--bad);font-weight:500}
.grid3{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;margin-bottom:18px}
.stat .n{font-size:26px;font-weight:700}
.stat .l{color:var(--muted);font-size:13px}
.narrow{max-width:560px}
.auth{max-width:420px;margin:60px auto}
label{display:block;font-size:13.5px;font-weight:600;margin:12px 0 5px}
input,select,textarea{width:100%;padding:9px 11px;border:1px solid var(--line);border-radius:8px;font:inherit;background:#fff}
textarea{resize:vertical}
input:focus,select:focus,textarea:focus{outline:2px solid #c7d7fe;border-color:var(--brand)}
.btn{display:inline-block;background:var(--brand);color:var(--brand-ink);border:0;border-radius:8px;padding:10px 18px;font:inherit;font-weight:600;cursor:pointer;margin-top:12px}
.btn:hover{filter:brightness(1.07);text-decoration:none}
.btn.ghost{background:transparent;color:var(--brand);border:1px solid var(--brand)}
.btn.small{padding:6px 12px;font-size:13px;margin-top:0}
.btn.danger{background:var(--bad);color:#fff}
.btn.danger:hover{filter:brightness(1.08);color:#fff}
.btn.danger:disabled,.btn:disabled{opacity:.5;cursor:not-allowed;filter:none}
.link{background:none;border:0;color:var(--brand);cursor:pointer;font:inherit;padding:0}
.link.danger{color:var(--bad)}
.inline{display:inline}
.rowadd{display:flex;gap:8px;margin:10px 0 14px;flex-wrap:wrap}
.rowadd input,.rowadd select{width:auto;flex:1;min-width:140px;margin:0}
.chk{display:flex;align-items:center;gap:9px;margin-top:14px;font-weight:500;cursor:pointer}
.chk input[type=checkbox]{width:auto;margin:0;flex:none}
.chk span{font-weight:500}
.tbl{width:100%;border-collapse:collapse;font-size:14px}
.tbl th{text-align:left;color:var(--muted);font-size:12.5px;text-transform:uppercase;letter-spacing:.03em;padding:8px 10px;border-bottom:1px solid var(--line)}
.tbl td{padding:9px 10px;border-bottom:1px solid var(--line);vertical-align:middle}
.tbl td.rowacts{text-align:right;white-space:nowrap}
.tbl input.cell,.tbl select.cell{width:auto;min-width:120px;padding:6px 9px;font-size:13.5px;border-radius:7px}
.tbl select.cell{max-width:220px}
/* collections visibility switch + slug: keep the row actions inside the card */
.dt-wrap .tbl select[name=visibility]{width:auto;min-width:100px;max-width:150px}
.tbl td.slug{max-width:170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tbl input.cell:focus,.tbl select.cell:focus{outline:2px solid #c7d7fe;border-color:var(--brand)}
/* Row-action cells (Collections "Manage" + org-tree actions): the inline
   controls used to be forced onto ONE line (white-space:nowrap), giving the
   column a hard min-width wider than the card → the table overflowed and the
   save/delete buttons bled past the border. Let the controls WRAP instead so
   the column's min-width is bounded by its widest single control and the
   table always fits its card at any viewport width (no horizontal scroll). */
.tbl td.rowacts{text-align:right;white-space:normal;vertical-align:top}
.tbl td.rowacts form.inline{display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px;justify-content:flex-end}
.tbl td.rowacts .cell{min-width:0}
.tbl td.rowacts input[name=name].cell{flex:1 1 150px;max-width:200px}
.tbl td.rowacts select.cell{flex:0 1 auto;max-width:200px}
/* org tree: the re-parent select has no .cell class, so cap it directly */
.orgtree select[name=new_parent]{max-width:200px}
/* documents table: in-cell "move to collection" dropdown — keep it narrow so
   the Collection column doesn't blow out the table layout */
.tbl td select.moveselect{max-width:220px;font-size:.85rem}
/* Collections page: compact "Edit" disclosure (replaces the always-visible
   inline textboxes/Save/Delete that made every row look messy). Collapsed, only
   the "Edit" summary shows; expanding grows the row with a tidy labelled form. */
.tbl td.rowacts details.coll-edit{display:inline-block;vertical-align:middle;text-align:right}
.tbl td.rowacts details.coll-edit summary{list-style:none;cursor:pointer;color:var(--brand);font-size:13px}
.tbl td.rowacts details.coll-edit summary::-webkit-details-marker{display:none}
.tbl td.rowacts details.coll-edit[open] summary{color:var(--muted);margin-bottom:6px}
.tbl td.rowacts details.coll-edit[open]{display:block;min-width:320px;max-width:420px}
.tbl td.rowacts details.coll-edit .fld{display:block;font-size:11.5px;color:var(--muted);margin:0 0 6px;text-align:left}
.tbl td.rowacts details.coll-edit .fld input.cell,.tbl td.rowacts details.coll-edit .fld select.cell{display:block;width:100%;margin-top:2px}
.tbl td.rowacts details.coll-edit form.coll-del,.tbl td.rowacts details.coll-edit form.inline-del{margin-top:6px}
.tbl td.rowacts details.coll-edit .delreason{display:block;font-size:11px;color:var(--muted);margin-top:2px;max-width:220px;text-align:left}
/* owner dropdown (Documents "Owner" col + Collections admin owner transfer) */
.tbl td select.ownersel{max-width:220px;font-size:.85rem}
/* inline admin password-reset (People) — a <details> wrapping a tiny form in
   the Password column. Collapsed: only the "reset" link shows (fits the narrow
   column). Open: the password field + "set" button expand inline in the cell.

   (Earlier version floated the form as an absolutely-positioned popover above
   the row, but details.cell-reset kept overflow:hidden in ALL states and the
   .dt-wrap table wrapper is overflow:auto — both clip an abs-positioned child,
   so the popover rendered invisible. That's why admin "couldn't reset a
   password." The inline form has no clipping ancestor: when open it grows the
   row, and .dt-wrap scrolls if needed. No overflow:hidden anywhere on the path.) */
.tbl details.cell-reset{display:inline-block;vertical-align:middle;white-space:nowrap}
.tbl details.cell-reset summary{list-style:none;cursor:pointer;display:inline-block}
.tbl details.cell-reset summary::-webkit-details-marker{display:none}
.tbl details.cell-reset form{display:none}
.tbl details.cell-reset[open] form{display:inline-flex;flex-wrap:nowrap;align-items:center;gap:6px;margin:4px 0 0}
.tbl details.cell-reset input[name=password]{width:170px;min-width:170px}
.tbl details.cell-reset button{flex:0 0 auto}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 16px}
.span2{grid-column:1/-1}
.ask{display:grid;grid-template-columns:1fr 2fr auto;gap:10px;align-items:end}
.ask.wide{grid-template-columns:1fr}
.ask textarea,.ask select{margin-top:0}
.ask .btn{margin-top:0}
.answer p{white-space:pre-wrap}
.cites li{margin-bottom:6px}
.tag{display:inline-block;font-size:11.5px;font-weight:600;padding:2px 8px;border-radius:999px;background:#eef2ff;color:var(--brand)}
.tag-public{background:#dcfce7;color:#166534}
.tag-department{background:#fef3c7;color:#92400e}
.tag-restricted{background:#fee2e2;color:#991b1b}
.tag-confidential{background:#111827;color:#f9fafb}
.pill{font-size:11.5px;font-weight:700;padding:2px 9px;border-radius:999px;background:#eef2ff;color:var(--brand)}
.pill.role-admin{background:#111827;color:#fff}
.pill.role-manager{background:#fef3c7;color:#92400e}
.pill.role-user{background:#e0e7ff;color:#3730a3}
.st{font-size:12px;font-weight:600}
.st-ready{color:var(--ok)} .st-failed{color:var(--bad)} .st-processing,.st-pending{color:var(--warn)}
/* Documents status cell: badge + a Retry button (failed docs keep their file) */
.stcell{white-space:nowrap}
.stcell .btn.retry{margin-left:8px;padding:2px 9px;font-size:11.5px;background:transparent;color:var(--brand);border:1px solid var(--brand);cursor:pointer}
.stcell .btn.retry:hover{background:var(--brand-soft);filter:none}
.stcell .inline-del{display:inline;margin:0}
/* AI Settings status: green/red dot + state pills (was role-active/role-disabled, which never existed in CSS) */
.status-dot{display:inline-block;width:11px;height:11px;border-radius:50%;vertical-align:-1px;margin-right:7px}
.status-dot.ok{background:var(--ok);box-shadow:0 0 0 3px rgba(22,163,74,.16)}
.status-dot.warn{background:var(--warn);box-shadow:0 0 0 3px rgba(217,119,6,.16)}
.status-dot.down{background:var(--bad);box-shadow:0 0 0 3px rgba(220,38,38,.14)}
.pill.st-ok{background:#dcfce7;color:#166534}
.pill.st-restarting{background:#fef3c7;color:#92400e}
.pill.st-down{background:#fee2e2;color:#991b1b}
.dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:2px}
.dot.ok{background:var(--ok)} .dot.bad{background:var(--bad)}
.list{list-style:none;margin:8px 0;padding:0}
.list li{padding:7px 0;border-bottom:1px dashed var(--line)}
.grants{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.grantchip{display:inline-flex;align-items:center;gap:6px;background:#f3f4f6;border:1px solid var(--line);border-radius:999px;padding:4px 6px 4px 12px;font-size:13px}
/* v1.6.0: version-control + usage-report styling */
.tag-ok{background:#dcfce7;color:#166534}
.tag-warn{background:#fef3c7;color:#92400e}
.mt{margin-top:18px}
.right{text-align:right}
.tbl tr.hl td{background:var(--brand-soft)}
.usbar{height:8px;background:#f3f4f6;border-radius:99px;overflow:hidden;min-width:80px}
.usbar span{display:block;height:100%;background:var(--brand);border-radius:99px}
/* doc_view "Compare" diff page: title left, back button pushed to the far right */
.doc-diff-card .head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.doc-diff-card .head h2{margin:0}
.doc-diff-card .head .back{flex:0 0 auto}
.doc-diff-card .sub{margin-top:8px}
.diff-head{display:flex;gap:14px;align-items:center;margin:2px 0 8px;font-size:12.5px;color:var(--muted);flex-wrap:wrap}
.diff-head b{color:var(--ink)}
.diff{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12.5px;line-height:1.5;border:1px solid var(--line);border-radius:8px;padding:10px 0;max-height:560px;overflow:auto}
.diff .dl{padding:0 14px;white-space:pre-wrap;word-break:break-word}
.diff .dl-add{background:#dcfce7;color:#14532d}
.diff .dl-del{background:#fee2e2;color:#7f1d1d;text-decoration:line-through}
.diff .dl-same{color:var(--muted)}
.grantchip .x{border:0;background:#e5e7eb;border-radius:50%;width:20px;height:20px;cursor:pointer;font-weight:700;line-height:1;color:#374151}
.grantadd{display:flex;gap:8px;margin-top:8px}
.grantadd select{width:auto;flex:1}
/* ---- Grants combobox (searchable multi-select) ---- */
.grantbox{position:relative;margin-top:6px}
.grantbox input#grant-chooser{width:100%}
.grant-results{position:absolute;z-index:30;top:100%;left:0;right:0;max-height:280px;overflow-y:auto;
  background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:0 8px 24px rgba(16,24,40,.12);margin-top:4px}
.grant-results .grp{padding:6px 12px 2px;font-size:11px;font-weight:700;letter-spacing:.04em;
  text-transform:uppercase;color:var(--muted);position:sticky;top:0;background:#fff}
.grant-results .opt{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;cursor:pointer;font-size:14px}
.grant-results .opt:hover{background:#eef2ff}
.grant-results .opt.sel{background:#f5f8ff}
.grant-results .opt .tag{margin-left:8px}
.grant-results .opt .chk{font-weight:700;color:var(--brand)}
.grant-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;min-height:4px}
.grant-chip{display:inline-flex;align-items:center;gap:7px;background:#f3f4f6;border:1px solid var(--line);
  border-radius:999px;padding:4px 6px 4px 12px;font-size:13px;font-weight:500}
.grant-chip .t{font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;
  padding:1px 7px;border-radius:999px}
.grant-chip .t.user{background:#e0e7ff;color:#3730a3}
.grant-chip .t.dept{background:#fef3c7;color:#92400e}
.grant-chip button{border:0;background:#e5e7eb;border-radius:50%;width:18px;height:18px;cursor:pointer;
  font-weight:700;line-height:1;color:#374151;font-size:12px}
.grant-chip button:hover{background:#d1d5db}
.grant-empty{color:var(--muted);font-size:13px}
.granthelp{margin:10px 0 0}
.bubble.md .md-table-wrap{overflow-x:auto;margin:6px 0;border:1px solid var(--line);border-radius:3px}
.bubble.md .md-table{border-collapse:collapse;width:100%;font-size:13.5px}
.bubble.md .md-table th,.bubble.md .md-table td{padding:7px 11px;border-bottom:1px solid var(--line);border-right:1px solid var(--line);text-align:left}
.bubble.md .md-table th:last-child,.bubble.md .md-table td:last-child{border-right:0}
.bubble.md .md-table thead th{background:#f4f6f9;font-weight:600;border-bottom:1.5px solid var(--line);white-space:nowrap}
.bubble.md .md-table tbody tr:last-child td{border-bottom:0}
.bubble.md .md-table tbody tr:hover{background:#fafbfc}
.bubble.md .md-table th[align=right],.bubble.md .md-table td[align=right]{text-align:right}
.bubble.md .md-table th[align=center],.bubble.md .md-table td[align=center]{text-align:center}
/* ---- Audit data table controls ---- */
.audit-controls{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:6px 0 14px}
.audit-controls input[type=text]{width:auto;flex:1;min-width:220px;margin:0}
.audit-controls select{width:auto;margin:0}
.audit-controls .btn{margin-top:0}
.tbl-wrap{overflow-x:auto}
.tbl td.detail{max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.audit-pager{display:flex;gap:6px;align-items:center;margin-top:14px;flex-wrap:wrap}
.audit-pager .pg{display:inline-flex;align-items:center;justify-content:center;min-width:34px;padding:6px 10px;
  border:1px solid var(--line);border-radius:8px;font-size:13.5px;font-weight:500;text-decoration:none}
.audit-pager .pg:hover{background:#eef2ff;text-decoration:none}
.audit-pager .pg.on{background:var(--brand);color:#fff;border-color:var(--brand);font-weight:700}
.audit-pager .pg.disabled{opacity:.4;cursor:default;pointer-events:none}
.audit-pager .pg.ell{border:0;background:none;cursor:default}
/* ---- shared DataTable chrome (Documents/Collections/Departments/Users) ---- */
.dt-wrap{margin-top:6px;overflow-x:auto}
.dt-controls{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:0 0 12px}
.dt-controls input[type=search]{flex:1;min-width:220px;width:auto;margin:0}
.dt-per{display:inline-flex;align-items:center;gap:6px;color:var(--muted);font-size:13px}
.dt-per select{width:auto;margin:0;padding:5px 8px;font-size:13px}
.dt-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:14px}
.dt-info{color:var(--muted);font-size:13px}
.dt-pager{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.dt-pager .pg{display:inline-flex;align-items:center;justify-content:center;min-width:34px;padding:6px 10px;
  border:1px solid var(--line);border-radius:8px;font-size:13.5px;font-weight:500;text-decoration:none}
.dt-pager a.pg:hover{background:#eef2ff;text-decoration:none}
.dt-pager a.pg.on{background:var(--brand);color:#fff;border-color:var(--brand);font-weight:700}
.dt-pager .pg.disabled{opacity:.4;cursor:default;pointer-events:none;border-color:transparent;background:none}
.dt-pager .pg.ell{border:0;background:none;cursor:default}
.dt-wrap table.tbl{width:100%}
.flash{padding:11px 14px;border-radius:8px;margin-bottom:14px;font-size:14px;font-weight:500}
.flash-upload_ok,.flash-acl_ok,.flash-del_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-upload_error,.flash-acl_err{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.flash-ai_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-ai_warn{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
.flash-ai_err{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.flash-chat_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-sso_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-sso_err{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.flash-sso_warn{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
.flash-coll_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-coll_err{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.flash-move_ok,.flash-owner_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-move_err,.flash-owner_err{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.flash-pw_ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.flash-pw_err{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.hero{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:38px 30px;text-align:center;margin-bottom:18px}
.hero h1{margin:0 0 6px;font-size:26px}
.hero .ask{max-width:640px;margin:18px auto 0;text-align:left}
/* ============ Chat (Ask) ============ */
.chat-card{display:flex;flex-direction:column}
.chat-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}
.chat-head h2{margin:0}
.thread{display:flex;flex-direction:column;gap:14px;margin:6px 0 18px;padding:2px 0}
.turn{display:flex;flex-direction:column;gap:6px}
.turn-q{align-self:flex-end;max-width:75%;background:var(--brand);color:var(--brand-ink);
  border-radius:12px 12px 3px 12px;padding:9px 13px;font-weight:500;font-size:14.5px;
  white-space:pre-wrap;word-break:break-word}
.turn-a{display:flex;flex-direction:column;gap:4px}
.who-row{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.02em}
.bubble{background:#f8fafc;border:1px solid var(--line);border-radius:3px 12px 12px 12px;
  padding:12px 14px;max-width:92%}
.bubble p{margin:0 0 4px;white-space:normal}
.bubble p:last-of-type{margin-bottom:0}
/* Markdown answer (ChatGPT-like rendered formatting). .md replaces the old
   single <p> so nested structure (lists/code/headings) renders cleanly. */
.bubble.md{font-size:14.5px;line-height:1.6}
.bubble.md > :first-child{margin-top:0}
.bubble.md > :last-child{margin-bottom:0}
.bubble.md p{margin:0 0 8px}
.bubble.md p:last-child{margin-bottom:0}
.bubble.md h1,.bubble.md h2,.bubble.md h3,.bubble.md h4,.bubble.md h5,.bubble.md h6{
  margin:14px 0 6px;font-weight:700;line-height:1.3}
.bubble.md h1{font-size:18px}.bubble.md h2{font-size:16.5px}.bubble.md h3{font-size:15.5px}
.bubble.md h4,.bubble.md h5,.bubble.md h6{font-size:14.5px}
.bubble.md ul,.bubble.md ol{margin:0 0 8px;padding-left:22px}
.bubble.md li{margin:3px 0}
.bubble.md li>ul,.bubble.md li>ol{margin:3px 0}
.bubble.md code{background:#eef2ff;color:#3730a3;padding:1.5px 6px;border-radius:5px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px}
.bubble.md pre{background:#0f172a;color:#e2e8f0;border-radius:8px;padding:12px 14px;
  overflow-x:auto;margin:0 0 10px;border:0}
.bubble.md pre code{background:transparent;color:inherit;padding:0;font-size:13px;line-height:1.5}
.bubble.md blockquote{margin:0 0 8px;padding:6px 14px;border-left:3px solid var(--line);
  color:var(--muted);background:#fff}
.bubble.md a{color:var(--brand);text-decoration:underline;text-underline-offset:2px}
.bubble.md a:hover{color:#1e40af}
.bubble.md hr{border:0;border-top:1px solid var(--line);margin:12px 0}
.bubble.md img{max-width:100%;border-radius:8px;margin:4px 0}
.bubble.md del{color:var(--muted)}
.srcs{margin-top:8px}
.srcs summary{cursor:pointer;font-size:12.5px;font-weight:600;color:var(--muted);
  user-select:none;list-style-position:inside}
.srcs summary:hover{color:var(--brand)}
.srcs[open] summary{margin-bottom:6px}
.srcs .cites{margin:0 0 0 4px;padding-left:18px}
/* grouped sources: one <li> per document, passages nested under it */
.srcs .cites li.src-doc{list-style:none;margin:0 0 10px}
.srcs .cites li.src-doc:last-child{margin-bottom:2px}
.srcs .cites li.src-doc > a{font-weight:600}
.src-doc-name{font-weight:600}
.passage{margin:4px 0 0 4px}
.cite-n{font-weight:700;color:var(--brand);font-size:12px}
.snippet{margin:3px 0 0;padding:6px 10px;border-left:2px solid var(--line);
  background:#f8fafc;color:var(--muted);font-size:12.5px;line-height:1.5}
.composer{display:flex;flex-direction:column;gap:8px;border-top:1px solid var(--line);padding-top:14px}
.composer select{width:220px}
.composer textarea{width:100%}
.composer .btn{align-self:flex-end;margin-top:0}
.composer .btn[disabled],.btn[disabled]{opacity:.45;cursor:not-allowed}
/* pending turn shown the instant Ask is clicked */
.turn.pending .bubble{background:#fff}
.thinking{position:fixed;inset:0;z-index:50;background:rgba(246,247,249,.82);
  backdrop-filter:blur(2px);display:flex;flex-direction:column;align-items:center;
  justify-content:center;gap:14px}
.thinking[hidden]{display:none}
.think-label{font-weight:600;font-size:15px;text-align:center;line-height:1.5}
.spin{width:38px;height:38px;border-radius:50%;border:3px solid var(--line);
  border-top-color:var(--brand);animation:lexspin .8s linear infinite}
@keyframes lexspin{to{transform:rotate(360deg)}}

/* ============ Mobile ============
   Desktop layout: fixed dark sidebar (nav) + slim top bar (page title,
   language). On a phone the sidebar becomes an off-canvas drawer opened
   by the hamburger; content below just needs breathing room. */
@media (max-width:768px){
  /* ---- Mobile: the sidebar becomes an off-canvas drawer -------------------
     The SAME .sidebar (grouped nav + user + language) slides in from the
     left; the top bar keeps [hamburger] [page title] [language].
     No-JS fallback: .js gate means with JavaScript off the sidebar stays a
     static full-width block above the content — every action stays reachable. */
  .shell{flex-direction:column}
  .shell-right{padding-left:0}
  .sidebar{position:static;height:auto;width:auto;max-width:none;
    border-right:0;border-bottom:1px solid #1e293b}
  .js .sidebar{position:fixed;top:0;left:0;bottom:0;height:100dvh;width:290px;
    max-width:86vw;transform:translateX(-104%);transition:transform .22s ease;
    box-shadow:0 0 48px rgba(2,6,23,.4);border-right:1px solid #1e293b}
  .js .sidebar.open{transform:translateX(0)}
  body.nav-open{overflow:hidden}                       /* lock page scroll while open */
  .sbackdrop{display:block;position:fixed;inset:0;background:rgba(8,12,24,.45);z-index:25}
  .sbackdrop[hidden]{display:none}
  .topbar{height:52px;padding:0 12px;gap:10px}
  .page-title{font-size:14.5px}
  .top-right .lang-switch select{max-width:118px;padding:6px 8px}
  .js .menu-btn{display:inline-flex;flex:0 0 auto;align-items:center;justify-content:center;
            width:40px;height:40px;border:1px solid var(--line);border-radius:8px;
            background:var(--panel);color:var(--ink);cursor:pointer}
  .menu-btn:active{background:#f1f5f9}
  .main{padding:14px}
  .card{padding:14px}
  /* stat grid: desktop minmax(180px,1fr) overflows a 390px screen
     (2×180 + gap = 374px > 362px content). Drop the floor so 2 cols fit. */
  .grid3{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
  .auth{margin:14px auto}
  .hero{padding:24px 16px}
  .hero h1{font-size:21px}
  .card h1{font-size:20px}
  /* dashboard ask form (collection select + textarea + button) → stack */
  .ask{grid-template-columns:1fr}
  .grid2{grid-template-columns:1fr}
  .stat .n{font-size:22px}
  /* chat */
  .chat-head{flex-wrap:wrap}
  .turn-q{max-width:90%}
  .bubble{max-width:100%}
  .composer{gap:10px}
  .composer select{width:100%}
  .composer .btn{align-self:stretch}
  /* tables keep their horizontal scroll (.dt-wrap/.tbl-wrap) — just tighten
     the controls that had desktop-sized min-widths */
  .dt-controls input[type=search]{min-width:120px}
  .audit-controls input[type=text]{min-width:120px}
  .rowadd input,.rowadd select{min-width:110px}
  .tbl details.cell-reset input[name=password]{width:130px;min-width:130px}
  .tbl td.rowacts details.coll-edit[open]{min-width:260px;max-width:320px}
  .foot{padding:14px 10px}
  .btn{padding:11px 16px}                          /* bigger touch target */
}

/* ============ Login page (chrome=bare) ============
   No sidebar, no top bar, no hamburger — a self-contained two-face card:
   dark brand panel (left) + form (right), language switcher top-right.
   On a phone the faces stack: brand becomes a compact header band. */
.bare-main{padding:0}
.login{min-height:100vh;display:flex;flex-direction:column;align-items:center;
  justify-content:center;padding:48px 18px;
  background:radial-gradient(900px 480px at 50% -10%, #e9edf5 0%, var(--bg) 60%)}
.lang-corner{position:fixed;top:14px;right:18px;z-index:10}
.lang-corner .lang-switch select{border:1px solid var(--line);border-radius:8px;
  background:var(--panel);color:var(--ink);padding:7px 10px;font:inherit;
  font-size:13px;max-width:150px;box-shadow:var(--shadow)}
.lcard{display:grid;grid-template-columns:0.92fr 1.08fr;width:100%;max-width:880px;
  background:var(--panel);border:1px solid var(--line);border-radius:16px;overflow:hidden;
  min-height:520px;
  box-shadow:0 1px 2px rgba(16,24,40,.05),0 12px 32px rgba(15,23,41,.10)}
.lbrand{background:linear-gradient(160deg,#0f1729 0%,#131f38 55%,#17264a 100%);
  color:#c7d0e0;padding:34px 32px 26px;display:flex;flex-direction:column;
  position:relative;overflow:hidden}
.lbrand::after{content:"";position:absolute;right:-34px;bottom:-52px;width:190px;height:190px;
  background:rgba(91,140,255,.07);pointer-events:none;
  -webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g stroke='%23000' stroke-width='1.7' stroke-linecap='round'><line x1='12' y1='12' x2='12' y2='4'/><line x1='12' y1='12' x2='4.6' y2='18'/><line x1='12' y1='12' x2='19.4' y2='18'/></g><g fill='%23000'><circle cx='12' cy='4' r='2.4'/><circle cx='4.6' cy='18' r='2.4'/><circle cx='19.4' cy='18' r='2.4'/><circle cx='12' cy='12' r='3.1'/></g></svg>") no-repeat center / contain;
  mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g stroke='%23000' stroke-width='1.7' stroke-linecap='round'><line x1='12' y1='12' x2='12' y2='4'/><line x1='12' y1='12' x2='4.6' y2='18'/><line x1='12' y1='12' x2='19.4' y2='18'/></g><g fill='%23000'><circle cx='12' cy='4' r='2.4'/><circle cx='4.6' cy='18' r='2.4'/><circle cx='19.4' cy='18' r='2.4'/><circle cx='12' cy='12' r='3.1'/></g></svg>") no-repeat center / contain}
.lb-top{display:flex;align-items:center;gap:9px;font-weight:700;font-size:19px;
  color:#fff;letter-spacing:.2px}
.lb-mark{display:block;flex:0 0 auto;width:20px;height:20px;color:#5b8cff}
.lb-kicker{margin:30px 0 6px;font-size:11.5px;font-weight:700;letter-spacing:.14em;
  text-transform:uppercase;color:#8ea0bd}
.lb-tag{margin:0;font-size:15.5px;line-height:1.55;font-weight:500;color:#dbe3f0;
  max-width:32ch}
.lb-feats{list-style:none;margin:28px 0 0;padding:0;display:flex;
  flex-direction:column;gap:14px}
.lb-feats li{display:flex;gap:10px;font-size:13.5px;line-height:1.5;color:#b9c6dd}
.lb-feats li::before{content:"";flex:0 0 7px;width:7px;height:7px;border-radius:2px;
  background:#5b8cff;margin-top:5px}
.lb-foot{margin-top:auto;padding-top:26px;font-size:11.5px;color:#64748b}
.lform{padding:42px 44px 34px;display:flex;flex-direction:column;justify-content:center}
.lform h1{margin:0 0 6px;font-size:25px;letter-spacing:-.2px}
.lform .muted{margin:0 0 22px;font-size:14.5px}
.lform form label{margin-bottom:14px}
.lform .btn.primary{width:100%;margin-top:18px;padding:12px 18px;font-size:15px;
  border-radius:9px}
.sso-row{margin-top:18px}
.sso-div{display:flex;align-items:center;gap:12px;margin-bottom:14px}
.sso-div span{font-size:12px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;
  color:var(--muted);white-space:nowrap}
.sso-div::before,.sso-div::after{content:"";flex:1;height:1px;background:var(--line)}
.btn.sso{display:block;width:100%;text-align:center;margin-top:0;padding:11px 18px;
  font-size:15px;border-radius:9px;background:var(--panel);color:var(--ink);
  border:1px solid var(--line);font-weight:600;transition:border-color .12s ease,background .12s ease}
.btn.sso:hover{border-color:var(--brand);background:rgba(36,86,230,.04);text-decoration:none}
.lform .sso-hint{margin-top:16px;line-height:1.5}
.lform .muted.small{margin-top:12px;line-height:1.5}
.login-note{margin:16px 0 0;font-size:12px;color:var(--muted)}
@media (max-width:768px){
  .login{padding:70px 14px 26px}
  .lcard{grid-template-columns:1fr;max-width:520px;min-height:0}
  .lbrand{padding:24px 24px 20px}
  .lb-top{font-size:17px}
  .lb-kicker{margin:18px 0 4px}
  .lb-tag{max-width:none;font-size:14.5px}
  .lb-feats{margin-top:16px;gap:9px}
  .lb-feats li{font-size:13px}
  .lb-foot{display:none}   /* the page carries no footer — keep the band light */
  .lform{padding:26px 22px 26px}
  .lform h1{font-size:22px}
  .lform .muted{margin-bottom:18px}
}
