/* Selidik — UI stylesheet
   Layout: top bar / collapsible left sidebar / right canvas / footer bar (CSS grid).
   Tokens follow docs/UI_AUDIT.md: whole-pixel type scale, 4 px spacing grid, fixed control heights. */
:root {
  /* colour */
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #f1f4f8;
  --border: #e2e7ee; --border-strong: #cbd2dc;
  --text: #182230; --muted: #4f5b6d; --faint: #667085;
  /* brand palette (option D): deep trust blue → trust blue → electric cyan, grounded by slate neutrals */
  --brand-deep: #1e3a8a; --brand: #2563eb; --brand-cyan: #06b6d4;
  --accent: var(--brand); --accent-hover: #1d4ed8; --accent-strong: var(--brand-deep); --accent-soft: #eff4ff; --focus: rgba(37, 99, 235, .35);
  --accent-2: var(--brand-cyan); --accent-2-soft: #ecfeff;   /* cyan is decorative only — too light for text on white */
  --ok: #1d7a46; --ok-soft: #e5f5ec; --warn: #935e00; --warn-soft: #fdf2dd; --bad: #b42318; --bad-soft: #fdeceb;
  --info: #0e7490; --info-soft: #ecfeff; --info-border: #a5f3fc;
  --tooltip-bg: #182230;
  /* network graph: categorical entity colours + link colours */
  --n-person: #0b7a83; --n-company: #2556a8; --n-vessel: #7a5af5; --n-wallet: #c2410c; --n-address: #7d8797; --n-other: #64748b;
  --g-edge: #a9b4c4; --g-same: #c27c0e; --g-own: #2556a8;
  --wordmark: linear-gradient(90deg, var(--brand-deep) 0%, var(--brand) 50%, var(--brand-cyan) 100%);

  /* type scale (size / line-height) */
  --fs-xs: 12px;  --lh-xs: 16px;
  --fs-sm: 13px;  --lh-sm: 20px;
  --fs-md: 14px;  --lh-md: 20px;
  --fs-lg: 16px;  --lh-lg: 24px;
  --fs-xl: 20px;  --lh-xl: 28px;
  --fs-2xl: 24px; --lh-2xl: 32px;
  --fs-display: 36px; --lh-display: 44px;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  /* spacing (4 px grid) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* shape & elevation */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-full: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .06);

  /* controls & shell */
  --ctl-sm: 28px; --ctl-md: 36px; --ctl-lg: 40px;
  --topbar-h: 56px; --footer-h: 36px; --sidebar-w: 240px; --rail-w: 64px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
code, .mono { font-family: var(--mono); }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -.005em; }
h1 { font-size: var(--fs-2xl); line-height: var(--lh-2xl); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-1); }
h2 { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-4); }
h3 { font-size: var(--fs-md); line-height: var(--lh-md); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-2); }
h1 .muted, h2 .muted, h2 .faint, h2 .small, h3 .small { font-weight: var(--fw-regular); }
b, strong { font-weight: var(--fw-semibold); }
p { margin: 0 0 var(--sp-3); }
[hidden] { display: none !important; }

/* utilities */
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: var(--fs-sm); line-height: var(--lh-sm); }
.text-xs { font-size: var(--fs-xs); line-height: var(--lh-xs); }
.text-lg { font-size: var(--fs-lg); line-height: var(--lh-lg); }
.text-xl { font-size: var(--fs-xl); line-height: var(--lh-xl); }
.fw-semibold { font-weight: var(--fw-semibold); }
.nowrap { white-space: nowrap; } .right { text-align: right; }
.break-all { word-break: break-all; } .pre-wrap { white-space: pre-wrap; }
.m-0 { margin: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.narrow { max-width: 640px; } .narrow-sm { max-width: 480px; }
.plain-page { max-width: 640px; margin: var(--sp-12) auto; padding: 0 var(--sp-4); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Selidik wordmark — one fixed brand gradient (deep blue → blue → cyan). inline-block so the gradient spans the letters only. */
.wordmark { display: inline-block; font-weight: var(--fw-bold); letter-spacing: -.02em; color: var(--brand);
  background: var(--wordmark); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ---------- shell grid ---------- */
.shell { display: grid; height: 100vh; height: 100dvh;
  grid-template: "top top" var(--topbar-h) "side main" minmax(0, 1fr) "foot foot" var(--footer-h) / var(--sidebar-w) minmax(0, 1fr);
  transition: grid-template-columns .2s ease; }
.topbar { grid-area: top; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: var(--sp-3); padding: 0 var(--sp-4) 0 var(--sp-3); z-index: 30; }
.sidebar { grid-area: side; background: var(--surface); border-right: 1px solid var(--border); overflow-x: hidden; overflow-y: auto;
  padding: var(--sp-3); display: flex; flex-direction: column; z-index: 20; }
.canvas { grid-area: main; overflow-y: auto; padding: var(--sp-6) var(--sp-8) var(--sp-10); }
.footer { grid-area: foot; background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; gap: var(--sp-4); padding: 0 var(--sp-6); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); }
.footer a { color: var(--faint); }
.footer a:hover { color: var(--text); text-decoration: none; }
.footer .build { font-family: var(--mono); }

/* ---------- top bar ---------- */
.icon-btn { flex: none; display: inline-grid; place-items: center; width: var(--ctl-md); height: var(--ctl-md); border-radius: var(--r-md);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
svg.i { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand { display: flex; flex-direction: column; justify-content: center; white-space: nowrap; color: var(--text); padding-right: var(--sp-2); }
.brand:hover { text-decoration: none; }
.brand .wordmark { font-size: var(--fs-xl); line-height: 24px; align-self: flex-start; }   /* hug the letters, else the flex column stretches it and the gradient spans the subtitle width */
.brand small { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); font-weight: var(--fw-regular); }
.topsearch { position: relative; flex: 1; max-width: 560px; margin-left: var(--sp-6); }
.topsearch svg { position: absolute; left: var(--sp-3); top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.topsearch input[type=search] { height: var(--ctl-md); padding-left: var(--sp-10); padding-right: var(--sp-8); background: var(--surface-2); border-color: var(--border); text-overflow: ellipsis; }
.topsearch kbd { position: absolute; right: var(--sp-2); top: 50%; transform: translateY(-50%); pointer-events: none; }
.topsearch:focus-within kbd { display: none; }
kbd { font: var(--fs-xs)/1 var(--mono); color: var(--faint); background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 2px 5px; }
.topsearch input[type=search]:focus { background: var(--surface); }
.topbar .spacer { flex: 1; }

/* account menu (details/summary — works without JS) */
.account { position: relative; }
.account > summary { list-style: none; display: flex; align-items: center; gap: var(--sp-3); height: 40px; padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--r-md); cursor: pointer; user-select: none; }
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover, .account[open] > summary { background: var(--surface-3); }
.account .who { text-align: right; line-height: var(--lh-xs); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.account .who small { display: block; color: var(--faint); font-size: var(--fs-xs); font-weight: var(--fw-regular); text-transform: capitalize; }
.account .chev { width: 16px; height: 16px; color: var(--faint); transition: transform .15s ease; }
.account[open] .chev { transform: rotate(180deg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); flex: none; }
.menu { position: absolute; right: 0; top: calc(100% + var(--sp-2)); min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-1); z-index: 50; }
.menu-head { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-1); }
.menu-head b { display: block; font-size: var(--fs-sm); }
.menu-head span { font-size: var(--fs-xs); color: var(--faint); }
.menu a, .menu button { display: flex; align-items: center; gap: var(--sp-2); width: 100%; height: var(--ctl-md); padding: 0 var(--sp-3);
  border: 0; background: none; border-radius: var(--r-md); color: var(--text); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-3); text-decoration: none; }
.menu svg { width: 16px; height: 16px; color: var(--muted); }
.menu form { margin: 0; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-1) 0; }

/* ---------- sidebar ---------- */
.nav-section { font-size: var(--fs-xs); line-height: var(--lh-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--faint);
  font-weight: var(--fw-semibold); margin: var(--sp-5) var(--sp-3) var(--sp-2); white-space: nowrap; }
.nav-section:first-child { margin-top: var(--sp-1); }
.nav a { position: relative; display: flex; align-items: center; gap: var(--sp-3); height: var(--ctl-md); padding: 0 var(--sp-3);
  border-radius: var(--r-md); color: var(--muted); font-size: var(--fs-md); font-weight: var(--fw-medium); white-space: nowrap; }
.nav a + a { margin-top: 2px; }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
/* active item: soft blue tile + blue→cyan indicator bar (a background layer, so ::before/::after stay free for rail tooltips) */
.nav a.active { color: var(--accent);
  background: linear-gradient(180deg, var(--brand), var(--brand-cyan)) left 8px / 3px calc(100% - 16px) no-repeat, var(--accent-soft); }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav .nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar .scope { margin-top: auto; padding: var(--sp-4) var(--sp-3) var(--sp-1); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); }
.sidebar .scope b { color: var(--muted); }

/* collapsed rail (desktop only) */
@media (min-width: 981px) {
  .shell.collapsed { --sidebar-w: var(--rail-w); }
  .shell.collapsed .sidebar { overflow: visible; padding: var(--sp-3) var(--sp-2); }
  .shell.collapsed .nav-section { height: 1px; margin: var(--sp-3) var(--sp-2); background: var(--border); font-size: 0; color: transparent; }
  .shell.collapsed .nav-section:first-child { display: none; }
  .shell.collapsed .nav a { justify-content: center; padding: 0; width: 40px; height: 40px; margin-left: auto; margin-right: auto; }
  .shell.collapsed .nav .nav-label, .shell.collapsed .scope { display: none; }
  /* tooltip */
  .shell.collapsed .nav a::after { content: attr(data-tooltip); position: absolute; left: calc(100% + var(--sp-3)); top: 50%;
    transform: translate(-4px, -50%); background: var(--tooltip-bg); color: #fff; font-size: var(--fs-xs); line-height: var(--lh-xs);
    font-weight: var(--fw-medium); padding: 6px var(--sp-2); border-radius: var(--r-md); box-shadow: var(--shadow-md); white-space: nowrap;
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s; z-index: 60; }
  .shell.collapsed .nav a::before { content: ""; position: absolute; left: calc(100% + var(--sp-3) - 4px); top: 50%;
    border: 4px solid transparent; border-right-color: var(--tooltip-bg); border-left: 0; transform: translate(-4px, -50%);
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s; z-index: 60; }
  .shell.collapsed .nav a:hover::after, .shell.collapsed .nav a:focus-visible::after,
  .shell.collapsed .nav a:hover::before, .shell.collapsed .nav a:focus-visible::before {
    opacity: 1; visibility: visible; transform: translate(0, -50%); transition-delay: .15s, .15s, 0s; }
}

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.page-head .grow { flex: 1; min-width: 0; }
.page-head .muted { max-width: 860px; }
.crumbs { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--faint); margin-bottom: var(--sp-2); }
.crumbs a { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: var(--sp-5); margin-bottom: var(--sp-4); }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > h2, .card.flush > .table-foot, .card.flush > .rows-head, .card.flush > .rows-filter, .card.flush > .table-tools { position: sticky; left: 0; }
.card.flush > h2 { padding: var(--sp-4) var(--sp-5) 0; margin-bottom: var(--sp-3); }
.grid { display: grid; gap: var(--sp-4); }
.grid > .card, .grid > div > .card:last-child { margin-bottom: 0; }
.grid > div > .card + .card { margin-top: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: var(--sp-4); }
.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)); }
.span2 { grid-column: span 2; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-sm); }
.kpi .label { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--muted); font-weight: var(--fw-medium); }
.kpi .value { font-size: var(--fs-2xl); line-height: var(--lh-2xl); font-weight: var(--fw-semibold); letter-spacing: -.01em; margin-top: var(--sp-1);
  font-variant-numeric: tabular-nums; }
.kpi .value.text-xl { font-size: var(--fs-xl); line-height: var(--lh-xl); }
.kpi .value .faint { font-size: var(--fs-lg); font-weight: var(--fw-medium); }
.kpi .sub { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); margin-top: var(--sp-1); }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: var(--lh-sm); }
table.data th { text-align: left; font-weight: var(--fw-semibold); color: var(--muted); font-size: var(--fs-xs); line-height: var(--lh-xs);
  text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: var(--sp-2) var(--sp-3); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { padding-left: var(--sp-5); }
table.data th:last-child, table.data td:last-child { padding-right: var(--sp-5); }
table.data td { border-bottom: 1px solid var(--border); padding: var(--sp-3); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.card:not(.flush) table.data th:first-child, .card:not(.flush) table.data td:first-child { padding-left: var(--sp-3); }
.card:not(.flush) table.data th:last-child, .card:not(.flush) table.data td:last-child { padding-right: var(--sp-3); }
table.kv { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); line-height: var(--lh-sm); }
table.kv th { text-align: left; color: var(--muted); font-weight: var(--fw-medium); width: 180px; padding: var(--sp-2) var(--sp-4) var(--sp-2) 0; vertical-align: top; }
table.kv td { padding: var(--sp-2) 0; vertical-align: top; word-break: break-word; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid var(--surface-3); }
.table-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); }
/* pager under a long table (app.js renderPager; the data explorer renders the same markup server-side) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-5); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.pager-info { font-variant-numeric: tabular-nums; }
.pager-size { display: inline-flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.pager-size select { width: auto; height: var(--ctl-sm); padding: 0 var(--sp-2); font-size: var(--fs-sm); }
.pager-nav { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.pager-nav[hidden] { display: none; }
.pager-nav button, .pager-nav a { min-width: var(--ctl-sm); height: var(--ctl-sm); padding: 0 var(--sp-2); border: 1px solid transparent; border-radius: var(--r-md);
  background: none; color: var(--text); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.pager-nav button:hover:not(:disabled), .pager-nav a:hover { background: var(--surface-3); text-decoration: none; }
.pager-nav button:focus-visible, .pager-nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pager-nav [aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: var(--fw-semibold, 600); }
.pager-nav button:disabled, .pager-nav .off { color: var(--faint); cursor: default; }
.pager-nav .off { padding: 0 var(--sp-2); }
.pager-nav .gap { min-width: var(--sp-5); text-align: center; color: var(--faint); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: var(--fw-medium);
  border-radius: var(--r-full); padding: 2px var(--sp-2); white-space: nowrap; border: 1px solid transparent; }
.b-ok { background: var(--ok-soft); color: var(--ok); } .b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); } .b-info { background: var(--info-soft); color: var(--info); }
.b-neutral { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.b-accent { background: var(--accent-soft); color: var(--accent); }
.badge.lg { font-size: var(--fs-sm); line-height: var(--lh-sm); padding: 2px var(--sp-3); }
.tag { display: inline-block; font-size: var(--fs-xs); line-height: var(--lh-xs); background: var(--surface-3); color: var(--muted);
  padding: 2px 6px; border-radius: var(--r-sm); margin: 2px var(--sp-1) 2px 0; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--fw-medium); color: var(--text); margin-bottom: var(--sp-1); }
input[type=text], input[type=password], input[type=email], input[type=search], select {
  width: 100%; height: var(--ctl-md); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 0 var(--sp-3);
  font: inherit; font-size: var(--fs-md); background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s; }
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field { margin-bottom: var(--sp-4); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: var(--ctl-md); padding: 0 var(--sp-4);
  border-radius: var(--r-md); border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-size: var(--fs-md);
  font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.sm { height: var(--ctl-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn.lg { height: var(--ctl-lg); padding: 0 var(--sp-5); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-3); align-items: end; }
.filters > :first-child { grid-column: span 2; }
.filters .actions { display: flex; gap: var(--sp-2); align-items: center; }
.filters.f3 { grid-template-columns: 1fr 1fr auto; } .filters.f3 > :first-child { grid-column: auto; }
.inline-form { display: inline-flex; gap: var(--sp-2); align-items: center; margin: 0; }
.inline-form select, .inline-form input { height: var(--ctl-sm); font-size: var(--fs-sm); width: auto; padding: 0 var(--sp-2); }
.inline-form input.w-sm { width: 140px; }
.alert { border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); font-size: var(--fs-sm); line-height: var(--lh-sm); border: 1px solid; }
.alert.err { background: var(--bad-soft); color: var(--bad); border-color: #f5c2bd; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: #b8e2c8; }
.alert.info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }

/* ---------- pipeline stages ---------- */
.stages { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.stage { flex: 1; min-width: 120px; border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-3); background: var(--surface-2); }
.stage .n { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; }
.stage .t { font-weight: var(--fw-semibold); }
.stage.ok { border-color: #b8e2c8; background: var(--ok-soft); } .stage.warn { border-color: #f1d39d; background: var(--warn-soft); }
.stage.failed { border-color: #f5c2bd; background: var(--bad-soft); } .stage.running { border-color: var(--info-border); background: var(--info-soft); }
pre.log { background: #0f1a2b; color: #cfe0f5; border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); font: var(--fs-xs)/1.6 var(--mono);
  max-height: 320px; overflow: auto; white-space: pre-wrap; margin: 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: var(--fw-medium); font-size: var(--fs-sm); }
pre.json { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); font: var(--fs-xs)/1.6 var(--mono);
  overflow: auto; max-height: 360px; margin: 0 0 var(--sp-3); }

/* ---------- bars ---------- */
.bar { height: 6px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; margin-top: var(--sp-1); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-cyan)); border-radius: var(--r-full); }

/* ---------- network graph (static/js/graph.js) ---------- */
.graph-card { scroll-margin-top: var(--sp-4); }
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.graph-tools { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.seg button, .tool { height: var(--ctl-sm); padding: 0 var(--sp-3); border: 0; background: var(--surface); color: var(--muted); font: inherit;
  font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button:hover, .tool:hover { background: var(--surface-3); color: var(--text); }
.seg button[aria-pressed="true"], .tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.seg button:focus-visible, .tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tool { border: 1px solid var(--border-strong); border-radius: var(--r-md); }
.tool.icon { width: var(--ctl-sm); padding: 0; justify-content: center; }
.tool svg, .seg svg { width: 16px; height: 16px; }
.graph-menu { position: relative; }
.graph-menu > summary { list-style: none; color: var(--muted); }
.graph-menu > summary::-webkit-details-marker { display: none; }
.graph-menu .menu { min-width: 180px; }
.graph-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.graph-wrap { position: relative; min-width: 0; background: var(--surface-2);
  background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 20px 20px; }
#graph { display: block; width: 100%; height: 520px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; outline: none; }
#graph.panning, #graph.dragging { cursor: grabbing; }
#graph:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
#graph .node { cursor: pointer; outline: none; transition: opacity .15s; }
#graph .node .dot { fill: var(--n-other); stroke: var(--surface); stroke-width: 2; }
#graph .node .ring { fill: none; stroke: transparent; stroke-width: 2; }
#graph .node.root .ring { stroke: var(--border-strong); stroke-dasharray: 3 3; }
#graph .node:hover .ring, #graph .node:focus-visible .ring, #graph .node.selected .ring { stroke: var(--accent); stroke-dasharray: none; }
#graph .node.selected .ring { stroke-width: 3; }
#graph .node.listed .dot { stroke: var(--bad); stroke-width: 3; }
#graph .node.pinned .dot { stroke-dasharray: 2 2; }
#graph .node.listed.pinned .dot { stroke-dasharray: none; }
#graph .nlabel { font: calc(12px * var(--inv, 1)) var(--font); fill: var(--text); pointer-events: none; paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
#graph .node.root .nlabel { font-weight: var(--fw-semibold); }
#graph .more circle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.2; }
#graph .more text { font: 600 8px var(--font); fill: var(--accent); pointer-events: none; }
#graph .edge path { fill: none; stroke: var(--g-edge); stroke-width: 1.4; transition: opacity .15s; }
#graph .edge.rel-same_as path { stroke: var(--g-same); stroke-dasharray: 5 4; }
#graph .edge.hl path { stroke: var(--accent); stroke-width: 2; }
#graph .edge.rel-same_as.hl path { stroke: var(--g-same); }
#graph .elabel { font: calc(10px * var(--inv, 1)) var(--font); fill: var(--muted); pointer-events: none; paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; display: none; }
#graph.all-labels .elabel, #graph .edge.hl .elabel { display: block; }
#graph .edge.hl .elabel { fill: var(--text); font-weight: var(--fw-medium); }
#graph .arrow { fill: var(--g-edge); } #graph .arrow.hl { fill: var(--accent); }
#graph .node.dim { opacity: .22; } #graph .edge.dim { opacity: .12; }
#graph.far .node:not(.root):not(.selected):not(:hover) .nlabel { display: none; }
#graph.far.focused .node:not(.dim) .nlabel { display: block; }
/* entity-type colours: SVG nodes, legend swatches, side-panel swatch */
#graph .n-Person .dot, .swatch.n-Person { fill: var(--n-person); background: var(--n-person); }
#graph .n-Company .dot, .swatch.n-Company { fill: var(--n-company); background: var(--n-company); }
#graph .n-Vessel .dot, .swatch.n-Vessel { fill: var(--n-vessel); background: var(--n-vessel); }
#graph .n-CryptoWallet .dot, .swatch.n-CryptoWallet { fill: var(--n-wallet); background: var(--n-wallet); }
#graph .n-Address .dot, .swatch.n-Address { fill: var(--n-address); background: var(--n-address); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--n-other); flex: none; }
.swatch.listed { background: var(--surface); border: 2px solid var(--bad); }
.graph-tip { position: absolute; left: 0; top: 0; z-index: 5; max-width: 280px; display: flex; flex-direction: column; gap: 2px; pointer-events: none;
  background: var(--tooltip-bg); color: #fff; font-size: var(--fs-xs); line-height: var(--lh-xs); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); box-shadow: var(--shadow-md); }
.graph-tip b { font-size: var(--fs-sm); line-height: var(--lh-sm); } .graph-tip span { color: #c9d3e0; } .graph-tip .warn { color: #ffc9c2; }
.graph-hint { position: absolute; left: var(--sp-3); bottom: var(--sp-2); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); pointer-events: none;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent); padding: 2px 6px; border-radius: var(--r-sm); }
.graph-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: var(--sp-8); color: var(--muted); font-size: var(--fs-sm); pointer-events: none; }
.graph-empty span { max-width: 360px; margin-top: 96px; }
.graph-card.loading #graph { opacity: .55; }
.graph-panel { border-left: 1px solid var(--border); background: var(--surface); padding: var(--sp-4); overflow-y: auto; max-height: 520px; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.graph-panel h3 { margin: 0; word-break: break-word; } .graph-panel h4 { margin: var(--sp-4) 0 var(--sp-1); font-size: var(--fs-xs); line-height: var(--lh-xs);
  text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: var(--fw-semibold); }
.graph-panel-head { display: flex; gap: var(--sp-2); align-items: baseline; margin-bottom: var(--sp-2); }
.graph-help { margin: var(--sp-2) 0 0; padding-left: var(--sp-4); color: var(--muted); } .graph-help li { margin-bottom: var(--sp-1); }
.graph-facts { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-1) var(--sp-3); margin: var(--sp-3) 0 0; }
.graph-facts dt { color: var(--muted); } .graph-facts dd { margin: 0; word-break: break-word; }
.graph-links { list-style: none; margin: 0; padding: 0; } .graph-links li { padding: var(--sp-1) 0; border-top: 1px solid var(--surface-3); }
.graph-links li:first-child { border-top: 0; } .graph-links span { display: block; font-size: var(--fs-xs); line-height: var(--lh-xs); }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.graph-actions { margin-top: var(--sp-4); }
.graph-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); margin-top: var(--sp-3); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--muted); }
.legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); }
.legend-title { color: var(--faint); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; }
.legend-item, .legend-note { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--sp-2); border-radius: var(--r-full); }
.legend-item { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.legend-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.legend-item[aria-pressed="false"] { color: var(--faint); text-decoration: line-through; background: var(--surface-3); }
.legend-item[aria-pressed="false"] i { opacity: .35; }
.legend-item .n { color: var(--faint); font-variant-numeric: tabular-nums; }
.legend-note { padding: 0; }
.graph-legend i.line { width: 18px; height: 0; border-top: 2px solid var(--g-edge); }
.graph-legend i.line.rel-same_as { border-top: 2px dashed var(--g-same); }
.graph-legend i.plus { font-style: normal; font-weight: var(--fw-semibold); font-size: 9px; color: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-full); padding: 0 3px; line-height: 12px; }
/* full view */
.graph-card.max { position: fixed; inset: 0; z-index: 80; margin: 0; border-radius: 0; display: flex; flex-direction: column; overflow: auto; }
.graph-card.max .graph-body { flex: 1; min-height: 0; }
.graph-card.max #graph { height: 100%; min-height: 360px; touch-action: none; }
.graph-card.max .graph-panel { max-height: none; }
body.graph-max { overflow: hidden; }
@media (max-width: 900px) {
  .graph-body { grid-template-columns: 1fr; }
  .graph-panel { border-left: 0; border-top: 1px solid var(--border); max-height: 260px; }
  #graph { height: 420px; }
  .graph-card.max #graph { height: 60vh; }
}
/* ---------- data explorer: column cards, histograms, record-type tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-5) 0 0; }
.tabs a { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--ctl-md); padding: 0 var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.tabs a:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.tabs a .n { font-size: var(--fs-xs); color: var(--faint); font-variant-numeric: tabular-nums; }
.section-h { margin: var(--sp-6) 0 var(--sp-3); }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.col-card { margin: 0; padding: var(--sp-4); min-width: 0; }
.col-card h3 { margin: 0; }
.col-card .col-doc { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-card .col-body { margin-top: var(--sp-4); }
.bar.fill > span { background: var(--ok); }
.tv { display: block; color: var(--text); font-size: var(--fs-sm); line-height: var(--lh-sm); margin-bottom: var(--sp-2); border-radius: var(--r-sm); }
.tv:hover { text-decoration: none; } .tv:hover .tv-label { color: var(--accent); text-decoration: underline; }
.tv .tv-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; padding-right: var(--sp-3); }
.tv .bar { display: block; }
.tv .bar > span { background: var(--brand); }
.tv:hover .bar > span { background: var(--brand-deep); }
.hist { display: flex; align-items: stretch; gap: 2px; height: 64px; border-bottom: 1px solid var(--border-strong); }
.hb { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; }
.hb > span { display: block; width: 100%; background: var(--brand); border-radius: 2px 2px 0 0; }
.hb:hover { background: var(--surface-3); } .hb:hover > span { background: var(--brand-deep); }
.hist-axis { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint);
  margin-top: var(--sp-1); font-variant-numeric: tabular-nums; }
.hist-axis .hist-read { color: var(--text); font-weight: var(--fw-medium); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-axis .hist-read.idle { color: var(--faint); font-weight: var(--fw-regular); }
table.mini { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); line-height: var(--lh-xs); margin-top: var(--sp-3); }
table.mini th { text-align: left; color: var(--faint); font-weight: var(--fw-regular); padding: 2px var(--sp-2) 2px 0; white-space: nowrap; }
table.mini td { padding: 2px var(--sp-3) 2px 0; font-variant-numeric: tabular-nums; word-break: break-word; }
.uniq b { font-size: var(--fs-xl); line-height: var(--lh-xl); display: block; }
.rows-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-4) var(--sp-5) var(--sp-3); }
.rows-head h2 { margin: 0; }
.inline-form input.w-md { width: 240px; }
.rows-filter { padding: var(--sp-2) var(--sp-5); background: var(--accent-soft); border-top: 1px solid var(--border); display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
.table-scroll table.data { width: max-content; min-width: 100%; }
.table-scroll table.data td { max-width: 300px; overflow-wrap: break-word; }
.table-scroll table.data td:first-child { min-width: 160px; }
.table-scroll table.data th { white-space: nowrap; }
#rows { margin-top: var(--sp-6); scroll-margin-top: calc(var(--topbar-h) + var(--sp-4)); }
/* ---------- API access: code samples, one-time token ---------- */
.code { position: relative; margin: 0 0 var(--sp-3); }
.code pre { background: #0f1a2b; color: #dbe7f7; border-radius: var(--r-lg); padding: var(--sp-4); margin: 0; overflow-x: auto;
  font: var(--fs-sm)/1.6 var(--mono); white-space: pre; tab-size: 4; }
.code .copy { position: absolute; top: var(--sp-2); right: var(--sp-2); height: var(--ctl-sm); padding: 0 var(--sp-2); font-size: var(--fs-xs);
  background: rgba(255, 255, 255, .1); color: #dbe7f7; border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--r-sm); cursor: pointer; }
.code .copy:hover { background: rgba(255, 255, 255, .2); }
.token-once { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-top: var(--sp-2); }
.token-once code { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm); word-break: break-all; user-select: all; }
td.endpoint { font-family: var(--mono); font-size: var(--fs-xs); word-break: break-all; }

/* ---------- sign-in ---------- */
.auth { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: var(--sp-6) var(--sp-4); overflow: hidden; isolation: isolate;
  background:
    radial-gradient(640px 420px at 12% 8%, rgba(30, 58, 138, .12), transparent 70%),
    radial-gradient(560px 420px at 88% 18%, rgba(37, 99, 235, .12), transparent 70%),
    radial-gradient(620px 460px at 70% 100%, rgba(6, 182, 212, .12), transparent 70%),
    var(--bg); }
.auth::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;   /* faint dot grid */
  background-image: radial-gradient(rgba(24, 34, 48, .08) 1px, transparent 1px); background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 30%, transparent 100%); }
.auth-main { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; padding: var(--sp-8) 0; }
.auth-card { position: relative; width: 100%; max-width: 420px; background: rgba(255, 255, 255, .92); border: 1px solid rgba(226, 231, 238, .9);
  border-radius: 16px; box-shadow: 0 24px 48px -12px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .05);
  padding: var(--sp-10) var(--sp-8) var(--sp-8); overflow: hidden; animation: auth-in .4s cubic-bezier(.2, .8, .2, 1) both;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--wordmark); }
@keyframes auth-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.auth-brand { text-align: center; margin-bottom: var(--sp-8); }
.auth-brand .wordmark { font-size: var(--fs-display); line-height: var(--lh-display); margin: 0; }
.auth-brand p { margin: var(--sp-1) 0 0; color: var(--muted); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.auth-card h2 { font-size: var(--fs-xl); line-height: var(--lh-xl); margin: 0 0 var(--sp-5); }
.auth-card .field { margin-bottom: var(--sp-5); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: var(--sp-3); top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; transition: color .15s; }
.input-icon:focus-within > svg { color: var(--accent); }
.auth-card .input-icon input { height: 44px; padding-left: 40px; border-radius: var(--r-lg); background: var(--surface-2); border-color: var(--border); }
.auth-card .input-icon input:hover { border-color: var(--border-strong); }
.auth-card .input-icon input:focus { background: var(--surface); border-color: var(--accent); }
.auth-card .input-icon.has-toggle input { padding-right: 44px; }
.pw-toggle { position: absolute; right: var(--sp-1); top: 50%; transform: translateY(-50%); width: var(--ctl-md); height: var(--ctl-md);
  display: grid; place-items: center; border: 0; background: none; border-radius: var(--r-md); color: var(--faint); cursor: pointer; padding: 0; }
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle .eye-off, .pw-toggle[aria-pressed="true"] .eye { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }
.caps-hint { display: none; margin-top: var(--sp-1); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--warn); }
.caps-hint.on { display: block; }
.auth-card .btn { height: 44px; margin-top: var(--sp-2); border-radius: var(--r-lg); font-weight: var(--fw-semibold);
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent-hover) 60%, var(--brand-deep) 100%); border-color: var(--accent-hover);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 4px 12px -4px rgba(37, 99, 235, .5);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.auth-card .btn:hover { background: linear-gradient(135deg, var(--accent-hover) 0%, var(--brand-deep) 100%); transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(16, 24, 40, .1), 0 8px 20px -6px rgba(37, 99, 235, .55); }
.auth-card .btn:active { transform: none; }
.auth-card .btn svg { width: 18px; height: 18px; transition: transform .15s ease; }
.auth-card .btn:hover svg { transform: translateX(2px); }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: var(--sp-6) 0 0; padding-top: var(--sp-5);
  border-top: 1px solid var(--border); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); text-align: center; }
.auth-note svg { width: 14px; height: 14px; flex: none; }
.auth-foot { padding-top: var(--sp-4); font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--faint); text-align: center; }

/* ---------- changelog ---------- */
.prose h2 { font-size: var(--fs-lg); margin: var(--sp-6) 0 var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-size: var(--fs-md); margin: var(--sp-5) 0 var(--sp-2); }
.prose h4 { font-size: var(--fs-sm); margin: var(--sp-3) 0 var(--sp-1); color: var(--muted); }
.prose ul { margin: var(--sp-1) 0 var(--sp-2); padding-left: var(--sp-5); } .prose li { margin: 2px 0; }
.prose code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 var(--sp-1); }

/* ---------- usability pass (docs/UI_AUDIT.md §5) ---------- */
.skip-link { position: absolute; left: var(--sp-3); top: -48px; z-index: 100; background: var(--accent); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md); font-weight: var(--fw-medium); transition: top .12s; }
.skip-link:focus { top: var(--sp-2); text-decoration: none; }
.canvas:focus { outline: none; }
/* table tools: filter box + row count in the card header; sortable column headers */
.table-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-4) var(--sp-5) var(--sp-3); }
.table-tools h2 { margin: 0; }
.table-tools .count { font-weight: var(--fw-regular); color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.table-tools input[type=search] { width: 260px; max-width: 100%; height: var(--ctl-sm); font-size: var(--fs-sm); padding: 0 var(--sp-2); }
.th-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.th-sort::after { content: "↕"; opacity: .35; font-size: 11px; }
.th-sort:hover { color: var(--text); } .th-sort:hover::after { opacity: .8; }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--accent-strong); }
th[aria-sort="ascending"] .th-sort::after { content: "↑"; opacity: 1; } th[aria-sort="descending"] .th-sort::after { content: "↓"; opacity: 1; }
th.num .th-sort { flex-direction: row-reverse; }
/* clickable KPI tiles */
a.kpi { display: block; color: inherit; transition: border-color .12s, box-shadow .12s; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow-md); }
a.kpi .sub::after { content: " →"; color: var(--accent); }
a.rowlink { color: inherit; } a.rowlink:hover { color: var(--accent); }
/* busy buttons + request spinner */
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after, .spin::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.busy::after { position: absolute; color: #fff; } .btn.secondary.busy::after { color: var(--muted); }
.spin { display: inline-flex; vertical-align: middle; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.clear-link { font-size: var(--fs-sm); white-space: nowrap; }
.error-card { text-align: center; margin: var(--sp-10) auto; padding: var(--sp-10) var(--sp-6); }
.error-card .code { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: var(--fw-bold); color: var(--border-strong); letter-spacing: -.02em; }
.error-card .btn-row { justify-content: center; margin-top: var(--sp-5); }

.htmx-indicator { opacity: 0; transition: opacity .2s; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: var(--sp-8) var(--sp-3); }
.backdrop { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .brand small { display: none; }
}
@media (max-width: 980px) {
  .shell { grid-template: "top" var(--topbar-h) "main" minmax(0, 1fr) "foot" var(--footer-h) / minmax(0, 1fr); }
  .sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: 272px; box-shadow: var(--shadow-lg);
    transform: translateX(-100%); transition: transform .2s ease, visibility 0s linear .2s; visibility: hidden; z-index: 40; }
  .shell.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  .shell.drawer-open .backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(16, 24, 40, .32); z-index: 35; }
  .canvas { padding: var(--sp-5) var(--sp-5) var(--sp-8); }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; } .topsearch { margin-left: var(--sp-2); } .topsearch kbd { display: none; }
  .topbar .spacer { display: none; }
  .account .who { display: none; }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .filters, .filters.f3 { grid-template-columns: 1fr; } .filters > :first-child { grid-column: auto; }
  .page-head { flex-direction: column; align-items: stretch; }
  .canvas { padding: var(--sp-4) var(--sp-4) var(--sp-8); }
  .footer { padding: 0 var(--sp-4); }
  .auth-card { padding: var(--sp-8) var(--sp-6) var(--sp-6); }
  .auth-brand .wordmark { font-size: 30px; line-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Download jobs (harvested sources) on the Ingestion page */
/* A large source is a Connectors row; its period options and progress sit in a drawer row underneath (tr.drawer-row). */
table.data tr.drawer-row > td { background: var(--surface-2); padding: var(--sp-4) var(--sp-5); }
.drawer-toggle .chev { display: inline-block; transition: transform .15s; }
.drawer-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.harvest-sum .badge { margin-left: var(--sp-1); }
.harvest-bar.thin { height: 4px; margin-top: var(--sp-1); max-width: 260px; }
.harvest-bar { width: 100%; height: 8px; display: block; accent-color: var(--info); }
.harvest-form { flex-wrap: wrap; }
.harvest-job .b-bad { background: none; }
