/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  /* spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  /* radius */
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px;
  /* type */
  --font-ui: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.72rem; --fs-sm: 0.8rem; --fs-base: 0.85rem; --fs-md: 0.95rem; --fs-lg: 1.15rem;
  /* light palette (default) */
  --bg: #f3f4f2;
  --surface: #f7f8f6;
  --surface-raised: #ffffff;
  --surface-hover: #ecefe9;
  --border: #dde2da;
  --border-strong: #c3cbbf;
  --text-primary: #1c2a4a;
  --text-secondary: #52607c;
  --text-muted: #838f8a;
  --accent: #2f7a4f;
  --accent-contrast: #ffffff;
  --success: #2f7a4f;
  --warning: #a8760a;
  --danger: #b2452e;
  --focus-ring: #2f7a4f;
  color-scheme: light;
}
/* dark palette: system preference, unless explicit data-theme="light" wins */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1015;
    --surface: #10151c;
    --surface-raised: #171f27;
    --surface-hover: #1d2731;
    --border: #2b333c;
    --border-strong: #3a4450;
    --text-primary: #e4eae2;
    --text-secondary: #aebbd6;
    --text-muted: #8996a3;
    --accent: #59c98a;
    --accent-contrast: #06140d;
    --success: #59c98a;
    --warning: #e0ac4c;
    --danger: #e58a6d;
    --focus-ring: #59c98a;
    color-scheme: dark;
  }
}
/* explicit dark (theme selector) wins regardless of system setting */
:root[data-theme="dark"] {
  --bg: #0c1015;
  --surface: #10151c;
  --surface-raised: #171f27;
  --surface-hover: #1d2731;
  --border: #2b333c;
  --border-strong: #3a4450;
  --text-primary: #e4eae2;
  --text-secondary: #aebbd6;
  --text-muted: #8996a3;
  --accent: #59c98a;
  --accent-contrast: #06140d;
  --success: #59c98a;
  --warning: #e0ac4c;
  --danger: #e58a6d;
  --focus-ring: #59c98a;
  color-scheme: dark;
}
/* legacy variable names kept as aliases -- referenced by inline JS (cyStyle()) */
:root {
  --paper: var(--bg);
  --paper-raised: var(--surface-raised);
  --ink: var(--text-primary);
  --ink-soft: var(--text-secondary);
  --ink-faint: var(--text-muted);
  --rule: var(--border);
  --high: var(--success);
  --medium: var(--warning);
  --low: var(--danger);
  --unknown: var(--text-muted);
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }
/* cualquier elemento con [hidden] debe ocultarse SIEMPRE, sin importar que otra
   regla de la misma especificidad (ej. .icon-btn{display:flex}) le gane por orden
   de aparicion en la hoja -- bug real encontrado dos veces en esta sesion. */
[hidden] { display: none !important; }
html { font-family: var(--font-ui); }
body { margin: 0; background: var(--bg); color: var(--text-primary); font-size: var(--fs-base); }
code, .mono { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
button { font-family: var(--font-ui); }

/* ==========================================================================
   Header
   ========================================================================== */
header {
  position: sticky; top: 0; z-index: 50;
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: center;
}
.brand { display: flex; align-items: center; gap: var(--space-2); }
header h1 { font-size: var(--fs-lg); margin: 0; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar-toggle {
  border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-secondary);
  width: 28px; height: 28px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.sidebar-toggle:hover { color: var(--text-primary); border-color: var(--border-strong); }

.kpis { display: flex; gap: var(--space-1); }
.kpi-wrap { display: flex; align-items: center; gap: 2px; }
.kpi-info {
  border: none; background: none; color: var(--text-muted); cursor: pointer;
  width: 16px; height: 16px; border-radius: 50%; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex: none; padding: 0;
}
.kpi-info:hover { color: var(--accent); background: var(--surface-hover); }
.kpi-popover {
  position: fixed; z-index: 2000; max-width: 280px; font-size: var(--fs-sm); line-height: 1.5;
  color: var(--text-primary); background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-3); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.kpi {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  border: 1px solid transparent; background: none; cursor: pointer;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-md);
  color: var(--text-secondary); line-height: 1.15; transition: background-color 150ms, border-color 150ms;
}
.kpi:hover { background: var(--surface-hover); }
.kpi[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.kpi .kpi-value { font-size: var(--fs-md); font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi[aria-pressed="true"] .kpi-value { color: var(--accent); }
.kpi .kpi-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }

.header-spacer { flex: 1; }
.whoami { font-size: var(--fs-sm); color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }
.theme-select, .lang-select {
  padding: var(--space-1) var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-raised); color: var(--text-primary); font-size: var(--fs-sm); cursor: pointer;
}

/* ==========================================================================
   Shell / layout
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--nav-w, 220px) 1fr var(--handle-w, 6px) var(--detail-w, 380px);
  min-height: calc(100vh - 57px);
  transition: grid-template-columns 160ms ease;
}
.shell.nav-collapsed { --nav-w: 0px; }
.shell.detail-collapsed { --detail-w: 0px; --handle-w: 0px; }

nav#domains-wrap {
  border-right: 1px solid var(--border); overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
}
.shell.nav-collapsed nav#domains-wrap { border-right: none; }
.nav-search-wrap { padding: var(--space-3) var(--space-3) 0; flex: none; }
.nav-search {
  width: 100%; padding: var(--space-1) var(--space-2); font-size: var(--fs-sm);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text-primary);
}
#domains { padding: var(--space-2) var(--space-3) var(--space-3); overflow-y: auto; flex: 1; }
#domains a {
  display: flex; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-1) var(--space-2); color: var(--text-secondary); text-decoration: none;
  border-radius: var(--radius-sm); font-size: var(--fs-sm); border-left: 2px solid transparent;
}
#domains a .count { font-variant-numeric: tabular-nums; color: var(--text-muted); }
#domains a:hover { background: var(--surface-hover); color: var(--text-primary); }
#domains a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text-primary); border-left-color: var(--accent); font-weight: 600; }

main { padding: var(--space-4) var(--space-5); overflow-y: auto; overflow-x: hidden; min-width: 0; }

aside#detail {
  border-left: 1px solid var(--border); overflow-y: auto; min-width: 0;
  display: flex; flex-direction: column;
}
.shell.detail-collapsed aside#detail { border-left: none; }
#detail-inner { padding: var(--space-4) var(--space-5); flex: 1; min-width: 0; }
.detail-resize-handle {
  position: relative; cursor: col-resize; background: transparent;
}
.detail-resize-handle::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; right: 0;
}
.detail-resize-handle:hover, .detail-resize-handle.dragging { background: color-mix(in srgb, var(--accent) 40%, transparent); }
.shell.detail-collapsed .detail-resize-handle { display: none; }

.detail-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); flex: none;
}
.detail-toolbar .detail-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-secondary);
  width: 26px; height: 26px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--nav-w, 200px) 1fr var(--handle-w, 6px) var(--detail-w, 340px); }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .detail-resize-handle { display: none; }
  nav#domains-wrap, aside#detail { position: fixed; top: 57px; bottom: 0; z-index: 60; width: min(320px, 85vw); background: var(--surface); box-shadow: 0 0 0 2000px rgba(0,0,0,0.35); }
  nav#domains-wrap { left: 0; transform: translateX(-100%); transition: transform 160ms; }
  aside#detail { right: 0; transform: translateX(100%); transition: transform 160ms; border-left: 1px solid var(--border); }
  .shell:not(.nav-collapsed) nav#domains-wrap { transform: translateX(0); }
  .shell:not(.detail-collapsed) aside#detail { transform: translateX(0); }
}

/* ==========================================================================
   View tabs
   ========================================================================== */
.view-tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.view-tab {
  padding: var(--space-2) var(--space-4); border: none; border-bottom: 2px solid transparent;
  background: none; color: var(--text-secondary); font-size: var(--fs-base); font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.view-tab:hover { color: var(--text-primary); }
.view-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }

/* ==========================================================================
   Search
   ========================================================================== */
.search-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.search-field { position: relative; flex: 1; max-width: 480px; }
.search-field svg.search-icon { position: absolute; left: var(--space-2); top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); pointer-events: none; }
.search {
  width: 100%; padding: var(--space-2) var(--space-6) var(--space-2) calc(var(--space-2) + 20px);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--text-primary);
  font-size: var(--fs-base);
}
.search:focus-visible { border-color: var(--accent); }
.search-clear {
  position: absolute; right: var(--space-1); top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--text-muted); cursor: pointer; width: 22px; height: 22px;
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
}
.search-clear:hover { color: var(--text-primary); background: var(--surface-hover); }
.search-kbd {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-muted); font-size: var(--fs-xs); padding: 1px 5px; font-family: var(--font-mono);
}
.results-count { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }

/* ==========================================================================
   Filter chips
   ========================================================================== */
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.filter-chips:empty { display: none; margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1); max-width: 320px;
  background: var(--surface-hover); border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 4px 2px var(--space-2); font-size: var(--fs-sm); color: var(--text-primary);
}
.chip .chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-label code { font-size: 0.85em; }
.chip button {
  border: none; background: none; color: var(--text-muted); cursor: pointer; width: 18px; height: 18px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex: none;
}
.chip button:hover { background: var(--border); color: var(--text-primary); }
.chip-clear-all { border: none; background: none; color: var(--accent); cursor: pointer; font-size: var(--fs-sm); padding: 2px var(--space-1); }
.chip-clear-all:hover { text-decoration: underline; }

/* ==========================================================================
   Tables
   ========================================================================== */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); table-layout: fixed; }
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
th { white-space: nowrap; color: var(--text-secondary); font-weight: 600; font-size: var(--fs-sm); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }
th.sortable[aria-sort="ascending"], th.sortable[aria-sort="descending"] { color: var(--accent); }
th.sortable:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
td { overflow: hidden; }
.ident { font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
.ident-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ident-row .ident { min-width: 0; flex: 1; }
.ident-row .copy-btn { flex: none; opacity: 0; }
tr:hover .ident-row .copy-btn, tr:focus-within .ident-row .copy-btn { opacity: 1; }
#tables-thead th:nth-child(1) { width: 18%; }
#tables-thead th:nth-child(2) { width: 30%; }
#tables-thead th:nth-child(3) { width: 18%; }
#tables-thead th:nth-child(4) { width: 14%; }
#tables-thead th:nth-child(5) { width: 12%; }
#databases-thead th:nth-child(1) { width: 34%; }
#databases-thead th:nth-child(2) { width: 14%; }
#databases-thead th:nth-child(3) { width: 40%; }
#databases-thead th:nth-child(4) { width: 12%; }
.purpose-warn { color: var(--danger); font-weight: 600; }
td.business-cell, td.domain-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.table-row { cursor: pointer; }
tr.table-row:hover { background: var(--surface-hover); }
tr.table-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
tr.table-row.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
tr.table-row.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.rows-cell { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
tr.database-row { cursor: pointer; }
tr.database-row:hover { background: var(--surface-hover); }

/* skeleton loading rows */
.skeleton-bar { display: inline-block; height: 0.8em; border-radius: 4px; background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 37%, var(--border) 63%); background-size: 400% 100%; animation: dd-shimmer 1.4s ease infinite; width: 100%; }
@keyframes dd-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   Pills / badges
   ========================================================================== */
.pill { display: inline-block; font-size: var(--fs-xs); padding: 0.15em 0.55em; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; white-space: nowrap; }
.pill.high { background: color-mix(in srgb, var(--high) 18%, transparent); color: var(--high); }
.pill.medium { background: color-mix(in srgb, var(--medium) 18%, transparent); color: var(--medium); }
.pill.low { background: color-mix(in srgb, var(--low) 18%, transparent); color: var(--low); }
.pill.unknown { background: color-mix(in srgb, var(--unknown) 24%, transparent); color: var(--text-secondary); }

.sync-badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.03em; padding: 0.2em 0.6em; border-radius: var(--radius-sm); white-space: nowrap; font-family: var(--font-mono); }
.sync-badge.push { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.sync-badge.pull { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.sync-badge.both { background: color-mix(in srgb, var(--text-secondary) 18%, transparent); color: var(--text-primary); }

/* ==========================================================================
   Detail panel content
   ========================================================================== */
#detail-inner h2 { font-size: var(--fs-lg); margin: 0 0 var(--space-1); }
.detail-physical-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.detail-physical-row .ident { font-size: var(--fs-sm); color: var(--text-muted); width: auto; }
.detail-domain-tag { font-size: var(--fs-sm); color: var(--text-secondary); }
#detail-inner h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: var(--space-5) 0 var(--space-2); display: flex; align-items: center; justify-content: space-between; }
#detail-inner p.description { font-size: var(--fs-md); line-height: 1.55; color: var(--text-primary); }
.empty-hint { color: var(--text-muted); font-size: var(--fs-base); }
.copy-btn { border: none; background: none; color: var(--text-muted); cursor: pointer; padding: 1px 4px; border-radius: var(--radius-sm); font-size: 0.78em; vertical-align: middle; }
.copy-btn:hover { color: var(--accent); background: var(--surface-hover); }
.copy-btn.copied { color: var(--success); }
.column-search { width: 100%; padding: var(--space-1) var(--space-2); font-size: var(--fs-sm); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text-primary); margin-bottom: var(--space-2); }
.empty-detail { padding: var(--space-6) var(--space-2); }
.empty-detail h3 { font-size: var(--fs-md); color: var(--text-primary); text-transform: none; letter-spacing: normal; margin: 0 0 var(--space-2); }
.empty-detail ul { margin: var(--space-2) 0 0; padding-left: var(--space-4); color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.8; }

.spinner { display: inline-block; width: 0.9em; height: 0.9em; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: dd-spin 0.7s linear infinite; vertical-align: -0.15em; }
@keyframes dd-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Overview diagram
   ========================================================================== */
#overview-diagram-wrap { padding: var(--space-3) 0; }
.overview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.overview-actions { display: flex; gap: var(--space-2); }
.btn-sm {
  border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-secondary);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-sm);
  display: inline-flex; align-items: center; gap: var(--space-1); white-space: nowrap; text-decoration: none;
}
.btn-sm:hover { color: var(--text-primary); border-color: var(--border-strong); }
.cy-canvas { width: 100%; height: 600px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); }
.modal-diagram-wrap .cy-canvas { height: 100%; border: none; border-radius: 0; }
.overview-info-panel {
  display: none; align-items: center; gap: var(--space-4); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); margin-bottom: var(--space-2);
  font-size: var(--fs-sm);
}
.overview-info-panel.visible { display: flex; }
.overview-info-panel .oip-title { font-weight: 650; color: var(--text-primary); }
.overview-info-panel .oip-stat { color: var(--text-secondary); }
.overview-info-panel button { margin-left: auto; }

/* ==========================================================================
   Diagram (mini + expand button)
   ========================================================================== */
.expand-diagram-btn { border: none; background: none; color: var(--text-secondary); cursor: pointer; font-size: var(--fs-sm); vertical-align: middle; padding: 2px var(--space-1); border-radius: var(--radius-sm); }
.expand-diagram-btn:hover { color: var(--accent); background: var(--surface-hover); }
.mini-diagram-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); padding: var(--space-2); overflow: auto; }
.diagram-legend { display: flex; gap: var(--space-3); font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--space-2); }
.diagram-legend .lg-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }
.diagram-legend .lg-current .lg-swatch { background: var(--accent); }
.diagram-legend .lg-related .lg-swatch { background: var(--surface-hover); border: 1px solid var(--border); }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal { position: fixed; inset: 0; background: rgba(6, 9, 13, 0.65); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal[hidden] { display: none; }
.modal-content { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); width: min(94vw, 1400px); height: min(90vh, 940px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); }
.modal-toolbar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); flex: none; }
.modal-toolbar button { padding: var(--space-1) var(--space-3); border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-primary); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-sm); }
.modal-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
#zoom-level { font-size: var(--fs-sm); color: var(--text-secondary); min-width: 3.5em; text-align: center; }
.modal-close { margin-left: auto; }
.modal-diagram-wrap { flex: 1; overflow: auto; padding: var(--space-6); cursor: grab; position: relative; }
.modal-diagram-wrap:active { cursor: grabbing; }
#modal-diagram { transform-origin: top left; display: inline-block; }
#modal-diagram.fitted { transition: transform 160ms ease-out; }

/* ==========================================================================
   Doc panel (QuickBooks)
   ========================================================================== */
.doc-panel { max-width: 860px; }
.doc-header-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); flex-wrap: wrap; }
.doc-panel h2 { font-size: 1.3rem; margin: 0; font-weight: 650; }
.doc-updated { font-size: var(--fs-xs); color: var(--text-muted); }
.doc-lede { font-size: var(--fs-md); line-height: 1.6; color: var(--text-secondary); margin-top: 0; }
.doc-panel h3 { font-size: var(--fs-md); margin: var(--space-6) 0 var(--space-2); color: var(--text-primary); font-weight: 650; padding-bottom: var(--space-1); border-bottom: 1px solid var(--border); }
.doc-panel p { line-height: 1.6; color: var(--text-secondary); }
.doc-panel ul { line-height: 1.7; color: var(--text-secondary); padding-left: var(--space-5); }
.doc-panel li { margin-bottom: var(--space-1); }
.doc-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin: var(--space-2) 0 var(--space-4); }
.doc-table th, .doc-table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.doc-table th { color: var(--text-muted); font-weight: 650; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.token-list { display: flex; flex-direction: column; gap: 3px; }
.token-list code { font-size: var(--fs-sm); white-space: nowrap; }
.doc-callout {
  display: flex; gap: var(--space-2); align-items: flex-start;
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); margin: var(--space-3) 0 var(--space-5);
  font-size: var(--fs-base); line-height: 1.55; background: color-mix(in srgb, var(--warning) 8%, transparent);
}
.doc-callout .callout-icon { flex: none; color: var(--warning); font-size: 1rem; line-height: 1.4; }
.code-block {
  position: relative; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-3); margin: var(--space-2) 0 var(--space-3);
  font-family: var(--font-mono); font-size: var(--fs-sm); overflow-x: auto; white-space: pre;
}
.code-block .copy-btn { position: absolute; top: var(--space-2); right: var(--space-2); border: 1px solid var(--border); background: var(--surface); }
.doc-q { color: var(--text-primary); }
.access-list { list-style: none; padding: 0; margin: 0 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.access-row:last-child { border-bottom: none; }
.access-add-row { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.access-add-row input { padding: var(--space-2); }

/* ==========================================================================
   Misc / utility
   ========================================================================== */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
