@font-face { font-family: 'Inter'; src: url('../fonts/Inter-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #F5F6F8; --surface: #FFFFFF; --surface-2: #F8F9FB; --surface-3: #EFF1F5;
  /* ink-3 was #667085, which reads 4.4:1 on --surface-3 and so missed 4.5:1 wherever a
     muted label sits on a tinted chip (.tab .count, .seg button). ink-4 was #98A0B3,
     which is 2.6:1 on white: too faint even for an icon, which needs 3:1. */
  --ink: #0E1630; --ink-2: #3A435C; --ink-3: #626D80; --ink-4: #8089A1;
  --line: #E3E6ED; --line-2: #EDEFF3; --line-3: #CFD5E0;
  --brand: #0030DB; --brand-2: #0028B4; --brand-50: #EEF2FF; --brand-100: #DCE4FF; --brand-ink: #001F9C;
  --ai-a: #7A5AF8; --ai-b: #0030DB;
  --good: #087A55; --good-bg: #E3F5ED; --warn: #9A5B00; --warn-bg: #FCF0D8; --bad: #BF2A1F; --bad-bg: #FCEAE8; --info: #2447C8; --info-bg: #EAF0FF; --violet: #6038C9; --violet-bg: #F0EAFD;
  --c1: #0030DB; --c2: #0FA3A3; --c3: #E8930C; --c4: #7A5AF8; --c5: #D6409F; --c6: #5B6B8A; --c-muted: #C5CDDE; --c-bad: #D4483B; --c-good: #17A673;
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --sh-1: 0 1px 2px rgba(14, 22, 48, .06);
  --sh-2: 0 1px 2px rgba(14, 22, 48, .05), 0 6px 20px rgba(14, 22, 48, .07);
  --sh-3: 0 20px 56px rgba(14, 22, 48, .22);
  --line-4: #B9C1D1; --bad-line: #EBC4C0; --violet-line: #E0D4FA;
  --top-bg: rgba(255, 255, 255, .92); --bg-0: rgba(245, 246, 248, 0); --bg-2: #F6F7F9;
  --inverse-bg: #0E1630; --inverse-ink: #FFFFFF; --scrim: rgba(14, 22, 48, .42);
  /* A toast is painted in the opposite theme, so its link colour has to flip with it. */
  --toast-act: #A9BBFF;
  --scroll-shade: rgba(14, 22, 48, .24);
  --side-w: 264px; --top-h: 56px; --panel-w: 460px;
  --sans: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
table { border-collapse: collapse; width: 100%; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
h1:focus-visible, h2:focus-visible, main:focus-visible, .msgs:focus-visible, .composer textarea:focus-visible { outline: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--inverse-bg); color: var(--inverse-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--ai-a), var(--ai-b)); display: grid; place-items: center; color: #fff; }
.brand-mark .ic { width: 17px; height: 17px; stroke-width: 2; }
.brand b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; }
.brand small { display: block; font-size: 12px; color: var(--ink-3); }
.side-new { margin: 4px 12px 10px; }
.side nav { padding: 0 8px; }
.nav-a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; }
.nav-a:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.nav-a[aria-current="page"] { background: var(--brand-50); color: var(--brand-ink); }
.nav-a[aria-current="page"] .ic { color: var(--brand); }
.side-sec { margin: 14px 18px 6px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.recent { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 0; }
.recent a { display: block; padding: 6px 10px; border-radius: 7px; color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent a:hover { background: var(--surface-3); text-decoration: none; }
.recent a[aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: 500; }
.recent .none { padding: 6px 10px; font-size: 12.5px; color: var(--ink-3); }
.recent a.all { color: var(--brand); font-weight: 500; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.side-foot b { font-size: 13px; font-weight: 600; display: block; }
.side-foot small { font-size: 12px; color: var(--ink-3); }
.ws-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--ink-2); flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.top { height: var(--top-h); background: var(--top-bg); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.top .grow { flex: 1; }
.icon-btn.menu-btn { display: none; }
.search { position: relative; flex: 1 1 460px; max-width: 460px; }
.search input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 12px 0 36px; background: var(--surface-2); font-size: 13.5px; }
.search input::placeholder { color: var(--ink-3); }
.search input:focus { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.search > .ic { position: absolute; left: 11px; top: 9px; color: var(--ink-3); pointer-events: none; }
.search-pop { position: absolute; left: 0; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3); padding: 6px; max-height: 420px; overflow: auto; z-index: 40; }
.search-pop .grp { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.search-pop a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: 13.5px; }
.search-pop a small { color: var(--ink-3); margin-left: auto; font-size: 12px; white-space: nowrap; }
.search-pop a:hover, .search-pop a.on { background: var(--brand-50); text-decoration: none; }
.search-pop .none { padding: 14px 10px; color: var(--ink-3); font-size: 13px; }
.user-btn { display: flex; align-items: center; gap: 9px; border: 1px solid transparent; background: none; padding: 4px 8px 4px 4px; border-radius: 10px; text-align: left; }
.user-btn:hover { background: var(--surface-3); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.alt { background: var(--surface-3); color: var(--ink-2); }
.user-btn b { display: block; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-btn small { display: block; font-size: 12px; color: var(--ink-3); line-height: 1.2; }
.rolebar { background: var(--violet-bg); color: var(--violet); border-bottom: 1px solid var(--violet-line); padding: 0 20px; height: 45px; font-size: 13px; display: flex; align-items: center; gap: 10px; overflow: hidden; white-space: nowrap; position: sticky; top: var(--top-h); z-index: 19; }
.rolebar span { overflow: hidden; text-overflow: ellipsis; }
.rolebar b { font-weight: 600; }
#view { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 28px 56px; }
.page-h { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-h h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.page-h .sub { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; }
.page-h .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumb a { color: var(--ink-3); }
h2.sec { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 28px 0 10px; }
h2.sec:first-child { margin-top: 0; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-3); background: var(--surface); font-weight: 500; font-size: 13.5px; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--line-4); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink-3); flex: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.on { color: var(--warn); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--ink-3); }
.field .err { font-size: 12.5px; color: var(--bad); }
.input, .select, textarea.input { height: 36px; border: 1px solid var(--line-3); border-radius: 9px; padding: 0 11px; background: var(--surface); width: 100%; font-size: 13.5px; }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 72px; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.select.sm, .input.sm { height: 30px; font-size: 13px; border-radius: 8px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; padding: 5px 0; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--brand); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.switch:last-child { border-bottom: none; }
.switch b { display: block; font-weight: 500; font-size: 13.5px; }
.switch small { color: var(--ink-3); font-size: 12.5px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-3); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: none; background: none; height: 26px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: none; background: none; padding: 9px 12px; font-size: 13.5px; font-weight: 500; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tab .count { font-size: 12px; background: var(--surface-3); color: var(--ink-3); border-radius: 999px; padding: 0 7px; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.violet { background: var(--violet-bg); color: var(--violet); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-3); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
button.chip:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-50); }
.chip.filter, .chip.ex-chip { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-ink); padding-right: 4px; }
.chip .x { width: 20px; height: 20px; border: none; background: none; border-radius: 50%; display: grid; place-items: center; color: inherit; padding: 0; }
.chip .x:hover { background: var(--brand-100); }
.chip.locked { background: var(--violet-bg); border-color: var(--violet-line); color: var(--violet); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card.pad { padding: 18px; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.card-h h2, .card-h h3 { font-size: 14px; font-weight: 600; }
.card-h .acts { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tbl-wrap {
  overflow-x: auto; position: relative;
  background:
    linear-gradient(to right, var(--surface), rgba(0, 0, 0, 0)) 0 0 / 22px 100% no-repeat local,
    linear-gradient(to left, var(--surface), rgba(0, 0, 0, 0)) 100% 0 / 22px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shade), rgba(0, 0, 0, 0)) 0 0 / 18px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shade), rgba(0, 0, 0, 0)) 100% 0 / 18px 100% no-repeat scroll;
}
.tbl th, .tbl td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; vertical-align: middle; }
.tbl th { font-size: 12px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.act { text-align: right; white-space: nowrap; width: 1%; }
.tbl .strong { font-weight: 600; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.tbl th button { border: none; background: none; font: inherit; color: inherit; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button:hover { color: var(--ink); }
.tbl.dense th, .tbl.dense td { padding: 7px 12px; font-size: 13px; }
.tbl.nowrap td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.cell-main { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--ink-3); }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--ink-3); }
.pager .grow { flex: 1; }
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty .ic { width: 28px; height: 28px; color: var(--ink-4); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty p { font-size: 13.5px; margin-bottom: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; }
.toolbar .search-in { position: relative; flex: 1; max-width: 320px; min-width: 180px; }
.toolbar .search-in .input { width: 100%; padding-left: 34px; }
.toolbar .search-in .ic { position: absolute; left: 10px; top: 9px; color: var(--ink-3); }

/* ---------- overlays ---------- */
.menu { position: fixed; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3); padding: 6px; min-width: 200px; max-width: 320px; z-index: 80; max-height: 70vh; overflow: auto; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; color: var(--ink); }
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: var(--surface-3); text-decoration: none; }
.menu button.danger { color: var(--bad); }
.menu button[aria-checked="true"] { font-weight: 600; }
.menu button .ic.end { margin-left: auto; color: var(--brand); }
.menu .sep { height: 1px; background: var(--line-2); margin: 5px 4px; }
.menu .hd { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 5px; }
.menu .who b { display: block; font-size: 13.5px; }
.menu .who small { color: var(--ink-3); font-size: 12.5px; }
.menu .menu-search { padding: 4px 4px 6px; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 60; display: grid; place-items: center; padding: 20px; }
.dialog { background: var(--surface); border-radius: 16px; box-shadow: var(--sh-3); width: 100%; max-width: 480px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.dialog.wide { max-width: 720px; }
.dialog-h { padding: 18px 20px 6px; display: flex; align-items: flex-start; gap: 10px; }
.dialog-h h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; flex: 1; }
.dialog-b { padding: 10px 20px 4px; overflow: auto; }
.dialog-b > p { color: var(--ink-2); margin-bottom: 14px; }
.dialog-f { padding: 14px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--inverse-bg); color: var(--inverse-ink); padding: 11px 14px; border-radius: 10px; box-shadow: var(--sh-3); font-size: 13.5px; display: flex; gap: 12px; align-items: center; max-width: 380px; }
.toast button, .toast a { background: none; border: none; color: var(--toast-act); font-weight: 600; padding: 0; white-space: nowrap; }
.tip { position: fixed; z-index: 95; background: var(--inverse-bg); color: var(--inverse-ink); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; pointer-events: none; max-width: 260px; box-shadow: var(--sh-2); line-height: 1.4; }
.tip b { font-weight: 600; }
.panel { position: fixed; right: 0; top: 0; bottom: 0; width: var(--panel-w); max-width: 100vw; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--sh-3); z-index: 50; display: flex; flex-direction: column; }
.panel-h { padding: 16px 18px 0; display: flex; gap: 10px; align-items: flex-start; }
.panel-h h2 { font-size: 16px; font-weight: 600; flex: 1; letter-spacing: -.01em; }
.panel-h .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.panel .tabs { margin: 10px 18px 0; }
.panel-b { padding: 16px 18px 24px; overflow: auto; flex: 1; }
.panel-b h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
.panel-b h3:first-child { margin-top: 0; }

/* ---------- ask home ---------- */
.home { width: 100%; max-width: 860px; margin: 0 auto; padding: 7vh 24px 56px; }
.home-h { text-align: center; margin-bottom: 22px; }
.home-h h1 { font-size: 32px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }
.home-h p { color: var(--ink-3); font-size: 14.5px; margin-top: 8px; }
.composer { background: var(--surface); border: 1px solid var(--line-3); border-radius: var(--r-xl); box-shadow: var(--sh-2); padding: 12px 12px 10px 16px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-100), var(--sh-2); }
.composer textarea { width: 100%; border: none; resize: none; font-size: 15.5px; line-height: 1.5; padding: 6px 0 4px; background: none; min-height: 30px; max-height: 180px; display: block; }
.composer textarea::placeholder { color: var(--ink-3); }
.composer-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.composer-row .grow { flex: 1; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 500; color: var(--ink-2); max-width: 100%; }
.pill-btn:hover { border-color: var(--line-3); background: var(--surface-3); color: var(--ink); }
.pill-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send { width: 34px; height: 34px; border-radius: 10px; border: none; background: var(--brand); color: #fff; display: grid; place-items: center; margin-left: auto; }
.send:hover { background: var(--brand-2); }
.send[disabled] { background: var(--line-3); cursor: not-allowed; }
.sq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.sq li { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px 10px 14px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.sq li:hover { border-color: var(--brand); box-shadow: var(--sh-1); }
.sq li > .ic { color: var(--brand); }
.sq li span { flex: 1; font-size: 13.5px; color: var(--ink); }
.sq li .icon-btn { color: var(--ink-3); }
.sq li:hover .icon-btn { color: var(--brand); }
.home h2.sec { margin-top: 34px; display: flex; align-items: center; }
.home h2.sec a { margin-left: auto; font-size: 13px; font-weight: 500; }
.attn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.attn-c { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.attn-c .badge { align-self: flex-start; }
.attn-c .v { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.attn-c .t { font-size: 13.5px; font-weight: 500; color: var(--ink); flex: 1; }
.attn-c .btn { align-self: flex-start; margin-top: 6px; }
.lists { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.list-c h3 { font-size: 13px; font-weight: 600; padding: 12px 14px 4px; display: flex; align-items: center; }
.list-c h3 a { margin-left: auto; font-size: 12.5px; font-weight: 500; }
.list-c ul { padding: 2px 6px 8px; }
.list-c li a { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; color: var(--ink-2); font-size: 13.5px; }
.list-c li a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-c li a:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.list-c li a .ic { color: var(--ink-4); }
.list-c .none { padding: 6px 14px 14px; color: var(--ink-3); font-size: 13px; }

/* ---------- conversation ---------- */
.chat { flex: none; display: flex; flex-direction: column; min-height: 0; height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); }
.chat.has-role { height: calc(100vh - var(--top-h) - 45px); height: calc(100dvh - var(--top-h) - 45px); }
.chat.not-owner .ans [data-act="share"] { display: none; }
.chat-h { padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-h h1 { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; margin-right: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-h .acts { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.ctx { padding: 8px 24px; background: var(--surface-2); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.ctx .lbl { color: var(--ink-3); }
.ctx .chip { height: 26px; font-size: 12.5px; }
.msgs { flex: 1; overflow-y: auto; padding: 24px 24px 12px; scroll-behavior: smooth; }
.msgs-in { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.msg-u { align-self: flex-end; max-width: 78%; background: var(--brand); color: #fff; padding: 10px 14px; border-radius: 16px 16px 4px 16px; font-size: 14.5px; }
.msg-a { display: flex; gap: 12px; align-items: flex-start; }
.ai-mark { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--ai-a), var(--ai-b)); display: grid; place-items: center; color: #fff; flex: none; margin-top: 2px; }
.ai-mark .ic { width: 15px; height: 15px; stroke-width: 2; }
.ans { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 18px 20px 14px; }
.ans-title { font-size: 18px; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; margin-bottom: 6px; }
.ans p { color: var(--ink-2); font-size: 14.5px; margin: 6px 0; max-width: 72ch; }
.ans p b, .ans li b { color: var(--ink); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); min-width: 0; }
.kpi .l { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.kpi .v.bad { color: var(--bad); } .kpi .v.good { color: var(--good); }
.delta { font-weight: 600; font-size: 12.5px; }
.delta.up-good, .delta.down-good { color: var(--good); } .delta.up-bad, .delta.down-bad { color: var(--bad); } .delta.flat { color: var(--ink-3); }
.viz { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0; overflow: hidden; }
.viz-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 14px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); flex-wrap: wrap; }
.viz-bar .t { font-size: 13px; font-weight: 600; min-width: 120px; }
.viz-bar .t + .badge { margin-right: auto; }
.viz-bar .t:last-child, .viz-bar .t:not(:has(+ .badge)) { flex: 1; }
.viz-body { padding: 14px; }
.viz-body.flush { padding: 0; }
.viz-note { font-size: 12.5px; color: var(--ink-3); padding: 0 14px 12px; }
.findings { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.findings li { display: flex; gap: 9px; font-size: 14px; color: var(--ink-2); align-items: flex-start; }
.findings li::before { content: ''; width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--ink-4); }
.findings li.bad::before { background: var(--c-bad); } .findings li.good::before { background: var(--c-good); } .findings li.warn::before { background: var(--c3); }
.trust { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-3); margin-top: 14px; }
.trust .grow { flex: 1; }
.trust .links { display: flex; gap: 2px; flex-wrap: wrap; }
.link-btn { border: none; background: none; color: var(--brand); font-weight: 500; font-size: 12.5px; padding: 3px 7px; border-radius: 6px; }
.link-btn:hover { background: var(--brand-50); }
.ans-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.ans-acts .sp { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.ans-acts .btn.ai { color: var(--violet); border-color: var(--violet-line); }
.ans-acts .btn.ai:hover { background: var(--violet-bg); }
.apps { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--ink-3); margin-top: 10px; }
.apps a { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.follow { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.follow .l { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 13.5px; padding: 4px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ai-a); animation: dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.chat-foot { padding: 10px 24px 14px; background: linear-gradient(to bottom, var(--bg-0), var(--bg) 30%); }
.chat-foot .in { max-width: 860px; margin: 0 auto; }
.chat-foot .composer { border-radius: 16px; padding: 8px 8px 8px 14px; }
.chat-foot .hint { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 7px; }
.state { border: 1px dashed var(--line-3); border-radius: 12px; padding: 16px; background: var(--surface-2); display: flex; gap: 12px; align-items: flex-start; margin: 8px 0; }
.state .ic { color: var(--ink-3); margin-top: 2px; }
.state b { display: block; font-size: 14px; }
.state p { margin: 2px 0 10px; font-size: 13.5px; }
.whatif { margin: 14px 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; }
.whatif .ctl { display: flex; flex-direction: column; gap: 14px; }
.range label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.range label output { font-variant-numeric: tabular-nums; color: var(--brand-ink); font-weight: 600; }
.range input[type=range] { width: 100%; accent-color: var(--brand); }
.whatif .res { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.whatif .res .big { font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.whatif .res dl { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 13px; margin-top: 10px; }
.whatif .res dt { color: var(--ink-3); } .whatif .res dd { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------- charts ---------- */
/* The chart library owns everything inside .chart; this only gives it a box to live in. */
.chart { width: 100%; position: relative; height: 300px; }
.chart.is-html { height: auto; }
.chart > div { width: 100%; height: 100%; }
.chart svg { display: block; }
.chart text { font-family: var(--sans); }
.chart-wait { height: 100%; min-height: 160px; border-radius: 10px; background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: chart-wait 1.4s linear infinite; }
@keyframes chart-wait { to { background-position: -150% 0; } }
@media (prefers-reduced-motion: reduce) { .chart-wait { animation: none; } }
.chart-err { display: grid; place-content: center; height: 100%; min-height: 140px; color: var(--ink-3); font-size: 13px; }
.chart-bar { display: flex; align-items: center; gap: 4px; padding: 0 10px 10px; flex-wrap: wrap; }
.viz[data-vizview="table"] .chart-bar { display: none; }
.chart-bar .btn.ghost { color: var(--ink-3); }
.chart-bar .btn.ghost:hover { color: var(--ink); }
.chart-bar .icon-btn { margin-left: auto; }
.spark { display: block; width: 108px; height: 32px; }
.spark svg { width: 108px; height: 32px; }

/* ---------- discover, dashboards, data, metrics ---------- */
.ins { display: flex; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.ins:last-child { border-bottom: none; }
.ins .sev { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ins .sev.bad { background: var(--bad-bg); color: var(--bad); } .ins .sev.warn { background: var(--warn-bg); color: var(--warn); } .ins .sev.good { background: var(--good-bg); color: var(--good); } .ins .sev.info { background: var(--info-bg); color: var(--info); }
.ins .body { flex: 1; min-width: 0; }
.ins h3 { font-size: 14.5px; font-weight: 600; }
.ins p { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.ins .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--ink-3); align-items: center; }
.ins .val { font-size: 17px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; text-align: right; }
.ins .side-acts { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.dash-card { padding: 16px; display: flex; flex-direction: column; gap: 4px; position: relative; }
/* The card's menu button is positioned over the top right corner, so the title has to
   leave room for it: "Workforce and capacity" ran straight into the dots. */
.dash-card a.t { font-size: 15px; font-weight: 600; color: var(--ink); padding-right: 32px; }
.dash-card .prev { display: flex; gap: 4px; align-items: flex-end; height: 44px; margin: 10px 0 6px; }
.dash-card .prev i { flex: 1; background: var(--brand-100); border-radius: 3px 3px 0 0; }
.dash-card .icon-btn { position: absolute; right: 8px; top: 8px; }
/* Tiles on a row stretch to the tallest of them, which is the grid default and what this
   was before tiles gained their own widths. `align-items: start` let each card stop at its
   natural height, so a short chart beside a tall one left a gap of empty page under it -
   90px and 175px on the seeded Operations overview - and the cards no longer lined up.
   `.tile-b` already takes the slack with `flex: 1`, so stretching costs nothing. */
.tiles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.tile { grid-column: span 6; display: flex; flex-direction: column; min-width: 0; }
.tile.k { grid-column: span 3; }
.tile.w { grid-column: span 12; }
/* The widths a tile can be given, after .k so a number tile that was resized keeps the size
   the reader chose rather than the one its kind defaults to. */
.tile.s3 { grid-column: span 3; }
.tile.s4 { grid-column: span 4; }
.tile.s6 { grid-column: span 6; }
.tile.s12 { grid-column: span 12; }
.tile.dragging { opacity: .5; }
.tile.over { outline: 2px solid var(--brand); outline-offset: -1px; }
.tile-h { display: flex; align-items: center; gap: 6px; padding: 12px 8px 0 8px; }
.tile-h h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-b { padding: 8px 14px 14px; flex: 1; }
.grip { display: grid; place-items: center; width: 22px; height: 26px; border: none; background: none; color: var(--ink-3); cursor: grab; border-radius: 6px; flex: none; }
.grip:hover { background: var(--surface-3); color: var(--ink-2); }
.grip:active { cursor: grabbing; }
.tile-note { display: flex; align-items: center; gap: 6px; padding: 0 14px 12px; font-size: 12px; color: var(--ink-3); }
.tile-note.big { padding: 18px 0 20px; font-size: 13.5px; justify-content: center; text-align: center; }
.dash-filters .reach { font-size: 12px; }
.tile.k .v { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile.k .d { font-size: 12.5px; color: var(--ink-3); }
.tile .sum p { font-size: 13.5px; color: var(--ink-2); margin-bottom: 8px; }
/* A source badge takes its colour from the source record, written straight onto the element
   as a `background` shorthand, so the stylesheet cannot choose a readable pair and cannot
   even add a background-image - the shorthand resets it. What it can do is settle the glyph
   on white in both themes and lay a fixed shade over whatever colour arrives, as a layer of
   its own. The worst colour in the sample workspace is the orange #E8930C, which white read
   at 2.44:1 before; at a 30% shade it reaches only 4.52:1, two hundredths above the floor
   and inside the audit's own rounding tolerance, so the shade is 34% and the worst case is
   4.95:1. The real fix is to pick the source colours at a readable tone where they are
   defined, in the data. */
.src-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none;
  position: relative; isolation: isolate; }
.src-ico::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: rgba(6, 10, 20, .34); z-index: -1; }
.cell-flex { display: flex; align-items: center; gap: 10px; }
.explorer { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.tree { padding: 8px; position: sticky; top: calc(var(--top-h) + 16px); max-height: calc(100vh - var(--top-h) - 40px); overflow: auto; }
.tree .src { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 8px 8px 4px; }
.tree a { display: block; padding: 6px 8px 6px 14px; border-radius: 7px; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree a:hover { background: var(--surface-3); text-decoration: none; }
.tree a[aria-current="page"] { background: var(--brand-50); color: var(--brand-ink); font-weight: 500; }
.tree-select { display: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.formula { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; color: var(--brand-ink); overflow-wrap: anywhere; }
.metric-c { padding: 16px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.metric-c .t { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.metric-c .t b { font-size: 14.5px; font-weight: 600; }
.metric-c .t .link-btn:hover { color: var(--brand); background: none; text-decoration: underline; }
.metric-c .m { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px 14px; flex-wrap: wrap; }
.metric-c .cur { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.sql { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: #0F172A; color: #D6DEEB; border-radius: 10px; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sql .kw { color: #82AAFF; } .sql .st { color: #C3E88D; } .sql .fn { color: #F78C6C; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); } .kv dd { text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.lineage { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.lineage .node { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: var(--surface-2); }
.lineage .node small { display: block; color: var(--ink-3); font-size: 12px; }
.lineage .arr { align-self: center; color: var(--ink-4); }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 8px; }
.steps li { counter-increment: s; display: flex; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.steps li::before { content: counter(s); width: 20px; height: 20px; border-radius: 50%; background: var(--brand-50); color: var(--brand-ink); font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none; margin-top: 1px; }
.drop { border: 1.5px dashed var(--line-3); border-radius: 14px; padding: 28px 18px; text-align: center; background: var(--surface-2); transition: border-color .12s, background .12s; }
.drop.over { border-color: var(--brand); background: var(--brand-50); }
.drop .ic { width: 26px; height: 26px; color: var(--ink-3); }
.drop b { display: block; margin: 8px 0 2px; }
.drop p { color: var(--ink-3); font-size: 13px; margin-bottom: 12px; }
.conn-g { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.conn { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--surface); font-size: 13.5px; font-weight: 500; text-align: left; }
.conn:hover { border-color: var(--brand); background: var(--brand-50); }
.conn-h { font-size: 12px; font-weight: 600; color: var(--ink-3); margin: 4px 0 7px; }
.done-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; gap: 12px; align-items: center; }
.done-card > .ok { width: 34px; height: 34px; border-radius: 50%; background: var(--good-bg); color: var(--good); display: grid; place-items: center; flex: none; }
.usage-bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; }
.usage-bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); height: 100%; }
.usage-bars i { width: 100%; background: var(--c1); border-radius: 4px 4px 0 0; min-height: 2px; display: block; }

/* ---------- responsive ---------- */
@media (min-width: 1800px) {
  .page { max-width: 1400px; }
  .home { max-width: 920px; }
  .msgs-in, .chat-foot .in { max-width: 920px; }
}
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile.k, .tile.s3, .tile.s4 { grid-column: span 6; }
  .explorer { grid-template-columns: minmax(0, 1fr); }
  .tree { display: none; }
  .tree-select { display: block; margin-bottom: 12px; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(var(--side-w), 86vw); transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--sh-3); z-index: 70; }
  .side.open { transform: none; }
  .side-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 65; }
  .icon-btn.menu-btn { display: inline-grid; }
  .top { padding: 0 12px; }
  .top .grow { display: none; }
  .search { max-width: none; }
  .user-btn .who-txt { display: none; }
  .g3, .lists, .attn { grid-template-columns: minmax(0, 1fr); }
  .tile, .tile.s3, .tile.s4, .tile.s6 { grid-column: span 12; }
  .whatif { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .page { padding: 20px 16px 48px; }
  .home { padding: 28px 16px 48px; }
  .home-h h1 { font-size: 26px; }
  .g2, .g4, .sq { grid-template-columns: minmax(0, 1fr); }
  .tile.k, .tile.s3, .tile.s4 { grid-column: span 12; }
  .chat-h, .ctx { padding-left: 14px; padding-right: 14px; }
  .msgs { padding: 16px 12px 8px; }
  .chat-foot { padding: 8px 12px 12px; }
  .ans { padding: 14px 14px 12px; }
  .msg-a { gap: 0; } .msg-a > .ai-mark { display: none; }
  .msg-u { max-width: 90%; }
  .ans-title { font-size: 16.5px; }
  .panel { width: 100vw; border-left: none; }
  .ins { flex-wrap: wrap; } .ins .side-acts { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: flex-start; align-items: center; }
  .ins .val { white-space: normal; text-align: left; width: 100%; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .page-h .acts { margin-left: 0; width: 100%; }
}
/* On a phone every control is hit with a finger rather than pointed at, so nothing a reader
   has to tap may be smaller than 32px in either direction. The compact sizes the product
   uses on a desktop - a 30px small button, a 26px segment, a 25px text link, an 18px column
   sort - were all under that. Sizes rather than padding, so a row of them still lines up,
   and nothing above 640px changes. */
@media (max-width: 640px) {
  .btn.sm { height: 32px; padding: 0 12px; }
  .chip, .ctx .chip { height: 32px; }
  .seg button { height: 32px; }
  .select.sm, .input.sm, .ex-search input { height: 32px; }
  .link-btn { min-height: 32px; display: inline-flex; align-items: center; padding: 3px 8px; }
  .chip.filter, .chip.ex-chip { height: 36px; padding-right: 5px; }
  .chip .x { width: 32px; height: 32px; }
  /* Tighter so the three pills and the send button make one row at 390 rather than two;
     a longer scope name still wraps, and the send button is pushed to the end either way. */
  .pill-btn { height: 32px; padding: 0 8px; }
  .composer-row { gap: 5px; }
  /* A settings toggle is the control on the row, and 38x22 is too small to hit reliably.
     The track grows to 48x32 and the knob and its travel grow with it. */
  .switch input { width: 48px; height: 32px; }
  .switch input::after { width: 26px; height: 26px; top: 3px; left: 3px; }
  .switch input:checked::after { transform: translateX(16px); }
  .tbl th button, .tbl.dense th button { min-height: 32px; min-width: 32px; }
  /* A link inside a table cell is only as tall as its own line, so a 36px row offered a
     16px target. The negative margin lets the hit area fill the row without making the
     row any taller, and the numbers stay right-aligned. */
  .tbl td a, .tbl td button.link-btn { display: inline-flex; align-items: center; min-height: 32px; min-width: 32px; margin: -8px 0; }
  .tbl td.num a, .tbl td.num button.link-btn { justify-content: flex-end; }
  .ex-field { padding: 8px; }
  .recent a { padding: 8px 10px; }
  .grip { height: 32px; width: 32px; }
  /* A six-column admin table cannot be made to fit a phone. Squeezing it turned every job
     title into three stacked words and every row into 80px of ragged text; letting the
     columns take their natural width and the card scroll keeps one row on one line. The
     wrapper draws a shadow at the edge it has been scrolled away from, so there is a cue.
     A cell that genuinely has to wrap sets white-space in its own style attribute, which
     still wins. */
  .tbl th, .tbl td, .tbl .cell-main, .tbl .cell-sub { white-space: nowrap; }
  /* Links that act as a control rather than as a word in a sentence: a breadcrumb, a
     "View all" beside a heading, a card title, a row action. */
  .crumb a, h2.sec > a, .list-c h3 a, .dash-card a.t, .page-h .acts a, .tbl td.act a.btn {
    min-height: 32px; display: inline-flex; align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .side, .top, .chat-foot, .ans-acts, .follow, .panel, .toasts { display: none !important; }
  .app { display: block; } body { background: var(--surface); }
}

/* Ask AI conversational replies */
.ans.chat { padding: 12px 16px 10px; }
.chat-reply p { color: var(--ink); font-size: 14.5px; margin: 4px 0 8px; max-width: 72ch; line-height: 1.55; }
.chat-reply ul { list-style: disc; margin: 4px 0 8px 20px; padding: 0; color: var(--ink); font-size: 14.5px; max-width: 72ch; }
.chat-reply li { margin: 3px 0; line-height: 1.5; }
.chat-reply b { font-weight: 600; }
.ans.chat .follow { margin-top: 6px; }
.interp { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12.5px; margin: 0 0 6px; }

/* Ask AI: live stages while an answer is being prepared */
.ans .thinking .t-el{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--ink-3,#61707F);font-size:12px}
.ans .stages{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:4px}
.ans .stages li{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--ink-2,#475569)}
.ans .stages li .ic{color:var(--good);flex:none}
.ans .stages li small{margin-left:auto;color:var(--ink-3,#61707F);font-variant-numeric:tabular-nums}

/* hotfix 2026-10-05: an answer card with class .chat must not inherit the chat window's full-height flex layout */
.ans.chat { display: block; height: auto; flex: 1; }
.chat.has-role .ans.chat { height: auto; }

/* live narration while Ask AI works */
.live-feed { display: grid; gap: 6px; }
.live-feed .lf-line { margin: 0; color: var(--ink-2, #475569); font-size: 14px; line-height: 1.5; max-width: 72ch; animation: lfIn .25s ease-out; }
.live-feed .lf-now { margin: 2px 0 0; display: flex; align-items: center; gap: 10px; color: var(--ink, #0f172a); font-size: 14px; }
.live-feed .lf-now .t-el { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-3, #61707F); font-size: 12px; }
@keyframes lfIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .live-feed .lf-line { animation: none; } }

/* uploaded file overview */
.ov-top { margin-bottom: 16px; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.ov-grid.small { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.ov-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; min-width: 0; }
.ov-card header { display: flex; flex-direction: column; gap: 2px; }
.ov-card header h3 { margin: 0; font-size: 16px; }
.ov-card header .muted { font-size: 12.5px; }
.ov-ks { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.ov-k { background: var(--bg-2, #f6f7f9); border-radius: 10px; padding: 8px 10px; }
.ov-k .l { font-size: 12px; color: var(--ink-3, #61707F); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-k .v { font-size: 17px; font-weight: 600; color: var(--ink, #0f172a); font-variant-numeric: tabular-nums; }
.ov-k .d { font-size: 12px; color: var(--ink-3, #61707F); }
.ov-viz { border-top: 1px solid var(--line, #e5e7eb); padding-top: 8px; min-width: 0; }
.ov-vt { font-size: 12.5px; font-weight: 600; color: var(--ink-2, #475569); margin-bottom: 6px; }
.ov-card footer { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.ov-h { margin: 22px 0 10px; font-size: 15px; }
@media (max-width: 560px) { .ov-grid, .ov-grid.small { grid-template-columns: 1fr; } }

/* MCP connectors */
.mcp-using { margin: 0 0 8px; }
.mcp-chip { height: 24px; font-size: 12px; padding: 0 9px; background: #E7F5F1; border-color: #BFE3D8; color: #0E7C66; }
.mcp-tools { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.mcp-tools li { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.mcp-tools li .mono { color: var(--ink); overflow-wrap: anywhere; }
.mcp-sugg { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.mcp-sugg > div { flex: 1; }
@media (max-width: 640px) { .mcp-tools li { grid-template-columns: 1fr; gap: 2px; } }


/* ---------- explore ---------- */
.explore { max-width: 1480px; }
.ex-grid { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 16px; align-items: start; }
.ex-rail { padding: 14px; position: sticky; top: calc(var(--top-h) + 16px); max-height: calc(100vh - var(--top-h) - 40px); overflow: auto; }
.ex-rail-h { position: sticky; top: -14px; background: var(--surface); padding-bottom: 10px; margin: -2px 0 2px; z-index: 2; }
.ex-search { max-width: none; }
.ex-search input { height: 32px; font-size: 13px; }
.ex-fields { display: flex; flex-direction: column; gap: 12px; }
.ex-grp-h { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding: 2px 4px 5px; }
.ex-field { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 6px 8px; font-size: 13px; color: var(--ink-2); cursor: grab; }
.ex-field:hover { background: var(--surface-3); color: var(--ink); }
.ex-field.on { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-ink); font-weight: 500; }
.ex-field.dragging { opacity: .45; }
.ex-field .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-field .ic { color: var(--ink-4); flex: none; }
.ex-field.on .ic { color: var(--brand); }
.ex-cert { margin-left: auto; color: var(--good); display: inline-flex; }
.ex-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ex-shelves { display: flex; flex-direction: column; gap: 8px; }
.ex-shelf { display: flex; align-items: flex-start; gap: 12px; border: 1px dashed var(--line-3); border-radius: 12px; padding: 9px 12px; background: var(--surface); min-height: 48px; }
.ex-shelf.over { border-color: var(--brand); border-style: solid; background: var(--brand-50); }
.ex-shelf-l { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); width: 76px; flex: none; padding-top: 7px; }
.ex-shelf-b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.ex-hint { font-size: 12.5px; color: var(--ink-3); padding: 6px 0; }
.explore-chart .viz-bar { border-bottom: 1px solid var(--line-2); }
.explore-chart .viz-bar .t { flex: 1; }
.explore-chart.empty-card { padding: 10px; }
.ex-trust { border: none; padding: 0 4px; }
/* The tile a selection came from: outlined rather than filtered, so the bar that was clicked
   stays visible beside the ones it is being compared against. */
.tile.x-source { box-shadow: inset 0 0 0 1.5px var(--brand); }
.dash-filters .chip.filter { height: 28px; font-size: 12.5px; }
.ex-rail-f { border-top: 1px solid var(--line-2); margin-top: 12px; padding-top: 12px; }
.ex-rail-f .btn { width: 100%; justify-content: center; }

/* A chip whose text is a button: the whole label opens the control that set it, and the cross
   beside it removes it. Two targets in one chip, so a filter can be changed without being
   removed and added again. */
.chip .chip-main { border: none; background: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-main:hover { text-decoration: underline; }
.chip-tag { margin-left: 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--brand); background: var(--brand-100); border-radius: 4px; padding: 1px 5px; }
.chip.on { border-color: var(--brand); background: var(--brand-50); color: var(--brand-ink); }

/* The drill trail. A breadcrumb rather than a back button, because a reader who has gone three
   levels in wants to say which level to come back to. */
.ex-trail { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); padding: 0 4px; }
.ex-trail .ic { color: var(--ink-4); }
.ex-trail [aria-current] { color: var(--ink); font-weight: 600; }

/* Where a filter could not do what it was asked. Said on screen rather than left looking like
   no data, which is the same rule a dashboard tile follows for a filter it did not understand. */
.ex-notes { display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }
.ex-notes > div { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.ex-notes .ic { color: var(--warn); flex: none; margin-top: 1px; }

/* ---------- the chart gallery ---------- */
.gal-grp + .gal-grp { margin-top: 16px; }
.gal-grp h3 { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.gal-card { display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 10px; align-items: center; text-align: left; border: 1px solid var(--line-3); border-radius: 10px; background: var(--surface); padding: 9px 10px; color: var(--ink-2); }
.gal-card:hover:not([disabled]) { border-color: var(--brand); background: var(--brand-50); color: var(--brand-ink); }
.gal-card.on { border-color: var(--brand); background: var(--brand-50); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand); }
.gal-card[disabled] { opacity: .55; cursor: not-allowed; }
.gal-thumb { grid-row: 1 / span 2; display: grid; place-items: center; color: var(--brand); }
.gal-card[disabled] .gal-thumb { color: var(--ink-4); }
.gal-n { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.gal-card[disabled] .gal-n { color: var(--ink-2); }
.gal-note { font-size: 11.5px; line-height: 1.35; color: var(--ink-3); }

/* The condition box's worked examples, written from this chart's own fields. */
.cd-eg { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.cd-eg .link-btn { font-size: 12.5px; font-family: var(--mono, ui-monospace, monospace); }

@media (max-width: 1040px) {
  .ex-grid { grid-template-columns: 1fr; }
  /* Stacked above the chart the rail is as wide as the page, so its groups sit side by side
     rather than in one tall column. Before this, a 320px cap on a single column showed only
     the groupings: at 1024 the page said "pick a measure" with no measure anywhere on it,
     and nothing to say the box scrolled. */
  .ex-rail { position: static; max-height: 440px; }
  .ex-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 16px; align-items: start; }
  .ex-shelf { flex-direction: column; gap: 6px; }
  .ex-shelf-l { width: auto; padding-top: 0; }
}
@media (max-width: 560px) {
  .gal-grid { grid-template-columns: 1fr; }
  .chip .chip-main { max-width: 22ch; }
}

/* ---------- chart types ---------- */
.ct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.ct-card { padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.ct-h { display: flex; align-items: baseline; gap: 8px; }
.ct-h h2 { font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.ct-h code { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-left: auto; }
.ct-chart { min-height: 90px; }
.ct-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; margin-top: auto; }
.ct-needs { display: flex; gap: 7px; font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; line-height: 1.45; }
.ct-needs .ic { flex: none; margin-top: 1px; }
.ct-none { display: grid; place-content: center; min-height: 120px; border-radius: 10px; background: var(--surface-2); color: var(--ink-3); font-size: 13px; text-align: center; padding: 14px; }
.ct-acts { display: flex; gap: 8px; }

/* ---------- dark ----------
   The ink, surface and line values are the chart library's own dark theme (packages/charts
   theme.js), so a chart never sits on a background from a different system. Everything else
   is the same hue as its light counterpart, darkened until it reads: the product should feel
   like the same product with the lights off, not like a second design. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0F18; --surface: #111726; --surface-2: #161E30; --surface-3: #1E2740;
  --ink: #EEF1F8; --ink-2: #C3CAD9; --ink-3: #8D97AC; --ink-4: #7A84A0;
  --line: #273150; --line-2: #1D2538; --line-3: #39425C; --line-4: #4A5573;
  --brand: #6C8BFF; --brand-2: #8AA2FF; --brand-50: #18203A; --brand-100: #222E52; --brand-ink: #B9C8FF;
  --ai-a: #A98CFF; --ai-b: #6C8BFF;
  --good: #4ED1A1; --good-bg: #0F2A22; --warn: #E8B45C; --warn-bg: #2E2413; --bad: #FF8578; --bad-bg: #2E1714;
  --info: #8FA8FF; --info-bg: #182143; --violet: #B79BFF; --violet-bg: #231B3D;
  --bad-line: #4A2420; --violet-line: #3A2E63;
  --c-muted: #39425C; --c-bad: #FF8578; --c-good: #4ED1A1;
  --top-bg: rgba(17, 23, 38, .9); --bg-0: rgba(11, 15, 24, 0); --bg-2: #161E30;
  --inverse-bg: #E8EBF4; --inverse-ink: #0E1630; --scrim: rgba(3, 5, 10, .64);
  /* The toast is light here, so the light theme's link blue is the readable one. */
  --toast-act: #0030DB;
  --scroll-shade: rgba(0, 0, 0, .62);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .45);
  --sh-3: 0 20px 56px rgba(0, 0, 0, .6);
}
/* The series colours come from the chart library too, so a legend swatch next to a chart is
   the colour in the chart. */
:root[data-theme="dark"] { --c1: #7FA0FF; --c2: #3FC9C0; --c3: #F0A53C; --c4: #AD8CFF; --c5: #FF7FC7; --c6: #94A3C4; }
:root[data-theme="dark"] .sql { background: #0A0F1C; color: #C6D2EA; }
:root[data-theme="dark"] .mcp-chip { background: #0F2A22; border-color: #1F4A3D; color: #6FD9B4; }
:root[data-theme="dark"] .brand-mark, :root[data-theme="dark"] .ai-mark { color: #0B0F18; }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .send, :root[data-theme="dark"] .avatar:not(.alt) { color: #0B0F18; }
:root[data-theme="dark"] .msg-u { color: #0B0F18; }
:root[data-theme="dark"] .switch input::after { background: #0B0F18; }
