/* Genealogic Management Portal — Blue Soft Design System v1
   Canonical no-build stylesheet. New UI should use ui-* classes; legacy selectors
   remain supported so existing finance/project screens can migrate gradually. */

:root {
  /* Brand — based on supplied Genealogic logo (#118CFE family). */
  --brand-50: #f2f8ff;
  --brand-100: #e2f1ff;
  --brand-200: #bfe2ff;
  --brand-300: #8dccff;
  --brand-400: #53b1ff;
  --brand-500: #118cfe;
  --brand-600: #0876e5;
  --brand-700: #0b6fd8;
  --brand-800: #0b5fbb;
  --brand-900: #104e92;

  /* Neutral / surfaces. */
  --bg: #f5f9fe;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f8fbff;
  --surface-blue: #eef6ff;
  --surface-blue-strong: #e3f1ff;
  --ink: #18263a;
  --ink-strong: #0f1d30;
  --muted: #64748a;
  --muted-2: #8a99ac;
  --line: #dde8f3;
  --line-strong: #c9daeb;

  /* Semantic aliases. */
  --accent: var(--brand-700);
  --accent-hover: #095fc0;
  --accent-active: #084f9f;
  --accent-bright: var(--brand-500);
  --accent-soft: var(--brand-100);
  --accent-faint: var(--brand-50);
  --focus: rgba(17, 140, 254, .23);

  --success: #18794e;
  --success-bg: #ecf9f2;
  --success-line: #bce9cf;
  --warning: #a85d00;
  --warning-bg: #fff7e6;
  --warning-line: #f2d6a0;
  --danger: #bd3447;
  --danger-bg: #fff0f2;
  --danger-line: #ffcbd2;
  --info: #2368b6;
  --info-bg: #eef6ff;
  --neutral-bg: #f2f5f9;

  /* Typography. */
  --font-sans: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text-xs: 10.5px;
  --text-sm: 11.5px;
  --text-md: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  --text-3xl: 27px;

  /* Spacing scale. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Shape / elevation. */
  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-xs: 0 1px 2px rgba(26, 62, 103, .035);
  --shadow-sm: 0 5px 18px rgba(29, 71, 116, .055);
  --shadow-md: 0 12px 34px rgba(29, 71, 116, .09);
  --shadow-focus: 0 0 0 3px var(--focus);

  /* Layout. */
  --sidebar-width: 224px;
  --topbar-height: 60px;
  --content-max: 1680px;
  --control-h: 34px;
  --control-h-lg: 40px;
  --table-row-y: 8px;
  --z-sidebar: 50;
  --z-topbar: 40;
  --z-overlay: 90;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
::selection { background: var(--brand-200); color: var(--ink-strong); }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .96);
  border-right: 1px solid var(--line);
  z-index: var(--z-sidebar);
  backdrop-filter: blur(12px);
}
.brand-wrap {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 17px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink-strong);
}
.brand-mark { width: 32px; height: 32px; flex: 0 0 auto; filter: drop-shadow(0 5px 10px rgba(17,140,254,.15)); }
.brand-copy { min-width: 0; }
.brand-name { display: block; font-weight: 780; line-height: 1.05; font-size: 14px; letter-spacing: -.015em; }
.brand-sub { display: block; color: var(--muted); font-size: 10.5px; margin-top: 3px; font-weight: 560; }
.side-nav { padding: 14px 10px 16px; overflow-y: auto; flex: 1; }
.nav-label { padding: 12px 10px 6px; color: var(--muted-2); font-size: 10px; text-transform: uppercase; letter-spacing: .085em; font-weight: 760; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 9px;
  color: #40536b;
  text-decoration: none;
  font-weight: 625;
  transition: background .13s ease, color .13s ease, transform .13s ease;
}
.nav-link:hover { background: var(--surface-blue); color: var(--accent); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active::before { content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 4px 4px 0; background: var(--accent-bright); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; color: currentColor; }
.sidebar-footer { margin: 10px; padding: 11px 12px; border: 1px solid var(--line); background: var(--surface-soft); border-radius: var(--radius-md); color: var(--muted); font-size: var(--text-sm); }
.sidebar-footer strong { display: block; color: var(--ink); font-size: 12px; margin-bottom: 2px; }
.app-main {
  /* Workspace text matches the readable 14px navigation baseline. */
  --text-xs: 13px;
  --text-sm: 14px;
  --text-md: 15px;
  --text-base: 14px;
  min-width: 0;
  margin-left: var(--sidebar-width);
  font-size: var(--text-base);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.topbar-context { color: var(--muted); font-size: var(--text-base); font-weight: 590; }
.topbar-context strong { color: var(--ink); font-weight: 720; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-accent { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--text-base); }
.topbar-leading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--brand-500); box-shadow: 0 0 0 4px var(--brand-50); }
.menu-toggle { display: none; width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; color: var(--ink); cursor: pointer; }
main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 26px 30px 48px; min-width: 0; }
main > :first-child { margin-top: 0; }

/* ---------- Typography / page anatomy ---------- */
h1, h2, h3 { color: var(--ink-strong); letter-spacing: -.018em; }
h1 { font-size: var(--text-3xl); line-height: 1.16; margin: 0 0 5px; font-weight: 770; }
h2 { font-size: var(--text-xl); line-height: 1.25; font-weight: 740; }
h3 { font-size: var(--text-lg); line-height: 1.35; font-weight: 730; }
p { margin-top: .55rem; margin-bottom: .55rem; }
p.lead { color: var(--muted); margin: 0 0 17px; max-width: 980px; }
.muted { color: var(--muted); }
.hint, .ui-help { color: var(--muted); font-size: var(--text-sm); margin: .48rem 0 0; }
.ui-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.ui-page-head__copy { min-width: 0; }
.ui-page-head__meta { color: var(--muted); font-size: var(--text-sm); margin-top: 5px; }
.ui-page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ui-section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 22px 0 9px; }
.ui-section-head h2, .ui-section-head h3 { margin: 0; }
.ui-eyebrow { color: var(--accent); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .09em; font-weight: 800; }

/* ---------- Buttons ---------- */
.ui-btn, button, .button {
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 690;
  font-size: var(--text-base);
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 3px 9px rgba(11,111,216,.14);
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .08s ease, box-shadow .14s ease;
}
.ui-btn:hover, button:hover, .button:hover { background: var(--accent-hover); box-shadow: 0 5px 13px rgba(11,111,216,.18); }
.ui-btn:active, button:active, .button:active { transform: translateY(1px); }
.ui-btn--secondary { color: var(--accent); background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.ui-btn--secondary:hover { background: var(--surface-blue); border-color: #a9cbee; color: var(--accent); }
.ui-btn--ghost { color: var(--accent); background: transparent; border-color: transparent; box-shadow: none; }
.ui-btn--ghost:hover { background: var(--accent-soft); box-shadow: none; }
.ui-btn--danger { color: #fff; background: var(--danger); }
.ui-btn--danger:hover { background: #a72d3d; }
.ui-btn--sm { min-height: 30px; padding: 4px 8px; font-size: 13px; }
.ui-btn--lg { min-height: var(--control-h-lg); padding: 8px 15px; font-size: 15px; }
.ui-icon-btn { width: var(--control-h); min-width: var(--control-h); padding: 0; }
.ui-btn[disabled], button[disabled] { cursor: not-allowed; opacity: .52; transform: none; box-shadow: none; }

/* ---------- Forms ---------- */
.ui-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.ui-col-12 { grid-column: span 12; } .ui-col-8 { grid-column: span 8; } .ui-col-6 { grid-column: span 6; } .ui-col-4 { grid-column: span 4; } .ui-col-3 { grid-column: span 3; }
.ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-label, label { color: #405269; font-size: var(--text-base); font-weight: 620; }
.ui-required { color: var(--danger); }
.ui-input, .ui-select, .ui-textarea,
input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="date"], input[type="datetime-local"], input[type="number"], input:not([type]), select, textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 6px 9px !important;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
textarea, .ui-textarea { min-height: 84px; resize: vertical; }
.ui-select[multiple] { min-height: 118px; }
input::placeholder, textarea::placeholder { color: #97a6b8; }
.ui-input:focus, .ui-select:focus, .ui-textarea:focus,
input:focus, select:focus, textarea:focus { border-color: var(--brand-400); box-shadow: var(--shadow-focus); }
.ui-input[disabled], .ui-select[disabled], input[disabled], select[disabled], textarea[disabled] { color: var(--muted); background: var(--neutral-bg); cursor: not-allowed; }
.ui-field--error .ui-input, .ui-field--error .ui-select, .ui-field--error .ui-textarea { border-color: #e58c98; box-shadow: 0 0 0 3px rgba(189,52,71,.09); }
.ui-error { color: var(--danger); font-size: var(--text-sm); }
.ui-check, .check { display: inline-flex; align-items: center; gap: 6px; color: #405269; font-size: var(--text-base); cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.ui-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.ui-inline { display: inline-flex; margin: 0; }

/* ---------- Cards / panels / KPIs ---------- */
.ui-card, .card, .bal-block, .filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.ui-card, .card { padding: 16px 17px; }
.card { margin-bottom: 12px; }
.ui-card--soft { background: var(--surface-soft); box-shadow: var(--shadow-xs); }
.ui-card--blue { background: var(--surface-blue); border-color: #d6e8fb; box-shadow: var(--shadow-xs); }
.ui-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ui-card__title { margin: 0; font-size: var(--text-lg); color: var(--ink-strong); font-weight: 740; }
.ui-grid, .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 14px 0; }
.ui-kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 18px; }
.ui-kpi { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: linear-gradient(180deg,#fff 0%,#fbfdff 100%); box-shadow: var(--shadow-sm); }
.ui-kpi__label { color: var(--muted); font-size: 13px; font-weight: 620; }
.ui-kpi__value { margin-top: 5px; color: var(--ink-strong); font-size: 20px; font-weight: 780; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.ui-kpi__meta { margin-top: 3px; color: var(--muted); font-size: 13px; }
.ui-kpi--accent { border-color: #cfe5fb; background: linear-gradient(180deg,#fff 0%,var(--brand-50) 100%); }

/* ---------- Tabs / chips / badges ---------- */
.ui-tabs, .tabs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin: 17px 0 18px; padding: 4px; width: max-content; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fbfdff; box-shadow: var(--shadow-xs); }
.ui-tab, .tabs a { padding: 7px 11px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: var(--text-base); font-weight: 665; border: 0; }
.ui-tab:hover, .tabs a:hover { color: var(--accent); background: var(--surface-blue); }
.ui-tab.is-active, .tabs a.active { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px #cfe5fb; }
.ui-chip, .chip, .cat-pill, .ui-badge, .badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; white-space: nowrap; }
.ui-chip, .chip { min-height: 28px; padding: 4px 9px; color: #52647a; background: var(--surface); border: 1px solid var(--line); font-size: var(--text-sm); box-shadow: var(--shadow-xs); }
.cat-pill { margin: 0 3px 3px 0; padding: 3px 7px; border: 1px solid #d3e7fb; background: var(--surface-blue); color: #40617e; font-size: var(--text-xs); font-weight: 655; }
.ui-badge, .badge { padding: 3px 7px; border: 1px solid transparent; font-size: var(--text-xs); font-weight: 730; }
.ui-badge--blue { background: var(--brand-100); color: var(--brand-800); border-color: #c7e4ff; }
.ui-badge--green { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.ui-badge--amber, .badge.soon { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.ui-badge--red, .badge.overdue { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.ui-badge--gray { background: var(--neutral-bg); color: #657487; border-color: #e0e6ee; }
.ui-badge--outline { background: #fff; color: var(--muted); border-color: var(--line-strong); }

/* ---------- Toolbar / filters ---------- */
.ui-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.ui-toolbar__group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ui-search { position: relative; min-width: 260px; max-width: 420px; flex: 1 1 280px; }
.ui-search input { padding-left: 34px !important; }
.ui-search__icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted-2); pointer-events: none; }
.filters { padding: 14px 15px; margin: 0 0 15px; }
.filter-block { border: 0; margin: 0 0 11px; padding: 0; }
.filter-block:last-child { margin-bottom: 0; }
.filter-block legend { color: var(--ink); font-weight: 720; font-size: var(--text-base); margin-bottom: 7px; }
.filter-options { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 13px; }
.filter-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.filter-actions a { text-decoration: none; font-size: var(--text-sm); }

/* ---------- Tables ---------- */
.ui-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-xs); }
.ui-table-wrap table { border: 0; border-radius: 0; box-shadow: none; min-width: 720px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; box-shadow: var(--shadow-xs); }
th, td { text-align: left; padding: var(--table-row-y) 10px; border-bottom: 1px solid #e8eff6; font-size: var(--text-sm); line-height: 1.35; vertical-align: top; }
th { background: #f6f9fd; color: #62758b; font-size: var(--text-xs); font-weight: 730; letter-spacing: .005em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f9fcff; }
tfoot td { background: #f8fbff; font-weight: 660; }
tr.overdue td { background: var(--danger-bg); }
tr.soon td { background: var(--warning-bg); }
tr.overdue:hover td { background: #ffe8eb; }
tr.soon:hover td { background: #fff1d2; }
.ui-table--compact th, .ui-table--compact td { padding-top: 6px; padding-bottom: 6px; }
.ui-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-money--negative, .num-debt { color: var(--danger); font-weight: 720; }
.num-block { color: var(--warning); font-weight: 720; }
.ui-secondary { color: var(--muted); font-size: 13px; }
.table-viewport { max-height: 22rem; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-xs); }
.table-viewport table { border: 0; border-radius: 0; box-shadow: none; }
.table-viewport thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--line); }

/* ---------- Entity / people patterns ---------- */
a.proj, .ui-entity-link { color: var(--accent); font-weight: 660; text-decoration: none; }
a.proj:hover, .ui-entity-link:hover { color: var(--brand-800); text-decoration: underline; text-underline-offset: 2px; }
.ui-avatar { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 999px; flex: 0 0 auto; color: var(--brand-800); background: var(--brand-100); border: 1px solid #c8e3ff; font-size: 13px; font-weight: 780; }
.ui-person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.ui-person__copy { min-width: 0; }
.ui-person__name { color: var(--ink); font-weight: 660; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-person__meta { color: var(--muted); font-size: 13px; }

/* ---------- Alerts / empty states ---------- */
.ui-alert, .alert { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); font-size: var(--text-base); margin: 10px 0; }
.alert-success, .ui-alert--success { background: var(--success-bg); border-color: var(--success-line); color: #17663f; }
.alert-error, .ui-alert--danger { background: var(--danger-bg); border-color: var(--danger-line); color: #9e2f3f; }
.alert-warning, .ui-alert--warning { background: var(--warning-bg); border-color: var(--warning-line); color: #8e5200; }
.ui-alert--info { background: var(--info-bg); border-color: #cce4fa; color: #245f9e; }
.ui-empty { display: grid; place-items: center; min-height: 180px; padding: 28px; text-align: center; border: 1px dashed #cbddec; border-radius: var(--radius-lg); background: linear-gradient(180deg,#fff 0%,#f8fbff 100%); }
.ui-empty__icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 13px; background: var(--brand-100); color: var(--accent); }
.ui-empty__title { margin: 0; font-size: var(--text-lg); font-weight: 740; color: var(--ink-strong); }
.ui-empty__text { max-width: 430px; margin: 5px 0 12px; color: var(--muted); font-size: var(--text-base); }

/* ---------- Finance patterns ---------- */
.bal-block { padding: 15px 16px; }
.bal-block h2 { margin: 0 0 4px; font-size: 14px; }
.bal-amt { font-size: 20px; font-weight: 780; letter-spacing: -.025em; margin: 4px 0; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.bal-meta { color: var(--muted); font-size: var(--text-sm); }
.stale-fresh .as-of { color: var(--muted); }
.stale-warm .as-of { color: var(--warning); font-weight: 650; }
.stale-aging .as-of { color: #9e5500; font-weight: 690; }
.stale-old .as-of { color: var(--danger); font-weight: 720; }
.stale-unknown .as-of { color: var(--muted); }
.acct-mask { font-variant-numeric: tabular-nums; }
.entity-section { margin-top: 21px; }
.entity-section h2 { font-size: 16px; margin: 0 0 8px; }

/* ---------- Native details ---------- */
details { border-radius: 7px; }
details summary { cursor: pointer; color: #405269; font-weight: 620; }
details[open] summary { margin-bottom: 6px; color: var(--accent); }

/* ---------- Auth pattern ---------- */
.ui-auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 520px) 1fr; background: #fff; }
.ui-auth-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 6vw, 76px); border-right: 1px solid var(--line); }
.ui-auth-logo { width: 150px; max-height: 110px; object-fit: contain; object-position: left center; margin-bottom: 28px; }
.ui-auth-title { margin: 0 0 7px; font-size: 28px; }
.ui-auth-copy { color: var(--muted); margin: 0 0 22px; }
.ui-auth-aside { position: relative; overflow: hidden; background: radial-gradient(circle at 26% 26%,#dff1ff 0%,#eef7ff 32%,#f6fbff 65%,#fff 100%); }
.ui-auth-aside::before, .ui-auth-aside::after { content: ""; position: absolute; border-radius: 999px; filter: blur(1px); }
.ui-auth-aside::before { width: 440px; height: 440px; right: 4%; top: 13%; background: rgba(17,140,254,.11); }
.ui-auth-aside::after { width: 260px; height: 260px; right: 26%; bottom: 14%; background: rgba(83,177,255,.15); }

/* ---------- Utility ---------- */
.ui-stack { display: flex; flex-direction: column; gap: 12px; }
.ui-row { display: flex; align-items: center; gap: 8px; }
.ui-row--between { justify-content: space-between; }
.ui-wrap { flex-wrap: wrap; }
.ui-divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
ul.plain { margin: .25rem 0; padding-left: 1.1rem; }
ul.plain li + li { margin-top: .25rem; }
.markdown-body { overflow-wrap: anywhere; line-height: 1.55; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body pre { overflow: auto; padding: 12px; border-radius: var(--radius-sm); background: var(--neutral-bg); }
.markdown-body code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.markdown-body table { margin: 12px 0; }

/* Compact scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c9d9ea transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #c9d9ea; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }

@media (max-width: 1280px) {
  .ui-kpi-grid { grid-template-columns: repeat(3, minmax(150px,1fr)); }
}
@media (max-width: 1100px) {
  :root { --sidebar-width: 202px; }
  main { padding: 22px 22px 42px; }
  th, td { padding-left: 8px; padding-right: 8px; }
  .ui-col-8, .ui-col-6, .ui-col-4, .ui-col-3 { grid-column: span 6; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-md); transition: transform .18s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .menu-toggle { display: inline-grid; place-items: center; }
  .topbar { padding: 0 14px; }
  main { padding: 18px 14px 36px; }
  h1 { font-size: 23px; }
  .ui-page-head { flex-direction: column; }
  .ui-page-actions { justify-content: flex-start; }
  .ui-tabs, .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; }
  .ui-tab, .tabs a { flex: 0 0 auto; }
  .ui-grid, .grid, .ui-kpi-grid { grid-template-columns: 1fr; }
  .ui-form-grid { grid-template-columns: 1fr; }
  .ui-col-12, .ui-col-8, .ui-col-6, .ui-col-4, .ui-col-3 { grid-column: 1; }
  .ui-toolbar { align-items: stretch; flex-direction: column; }
  .ui-search { min-width: 0; width: 100%; max-width: none; }
  .sidebar-scrim { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(18,35,58,.24); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .ui-auth-shell { grid-template-columns: 1fr; }
  .ui-auth-aside { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
