/* dbomni — calm, minimal UI */

:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f6f6f8;
  --sidebar: #f7f7f9;
  --hover: rgba(20, 20, 40, 0.045);
  --active: rgba(20, 20, 40, 0.075);
  --border: #ececf0;
  --border-strong: #dcdce2;
  --text: #17171c;
  --text-2: #4f4f5a;
  --muted: #868692;
  --faint: #b5b5be;
  --accent: #5e5ce6;
  --accent-2: #7c7aff;
  --accent-soft: rgba(94, 92, 230, 0.09);
  --accent-text: #4b48d6;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.08);
  --ok: #2c9f66;
  --ok-soft: rgba(44, 159, 102, 0.1);
  --warn: #c27a0e;
  --warn-soft: rgba(229, 154, 30, 0.12);
  --pg: #4c7fd1;
  --mysql: #e48b1f;
  --num: #2c5fcf;
  --str: #17171c;
  --kw: #7c3aed;
  --sql-str: #0f8a5f;
  --sql-num: #c2410c;
  --sql-com: #9a9aa6;
  --shadow-sm: 0 1px 2px rgba(16, 16, 32, 0.04);
  --shadow: 0 1px 2px rgba(16, 16, 32, 0.04), 0 6px 24px -6px rgba(16, 16, 32, 0.08);
  --shadow-lg: 0 24px 64px -12px rgba(16, 16, 32, 0.22), 0 2px 6px rgba(16, 16, 32, 0.05);
  --ring: 0 0 0 3px rgba(94, 92, 230, 0.18);
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sidebar-w: 268px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0b0e;
  --surface: #121216;
  --surface-2: #16161b;
  --sidebar: #0e0e11;
  --hover: rgba(255, 255, 255, 0.045);
  --active: rgba(255, 255, 255, 0.08);
  --border: #1e1e25;
  --border-strong: #2a2a33;
  --text: #ececf1;
  --text-2: #b3b3bf;
  --muted: #7d7d8a;
  --faint: #50505b;
  --accent: #7c7aff;
  --accent-2: #9d9bff;
  --accent-soft: rgba(124, 122, 255, 0.13);
  --accent-text: #aeacff;
  --danger: #ff6369;
  --danger-soft: rgba(255, 99, 105, 0.1);
  --ok: #3dd68c;
  --ok-soft: rgba(61, 214, 140, 0.1);
  --warn: #f1a10d;
  --warn-soft: rgba(241, 161, 13, 0.12);
  --num: #8ab4ff;
  --str: #ececf1;
  --kw: #c4a7ff;
  --sql-str: #6ee7b7;
  --sql-num: #fdba74;
  --sql-com: #5f5f6c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 28px 72px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --ring: 0 0 0 3px rgba(124, 122, 255, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
code, pre, kbd, .mono { font-family: var(--mono); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ icons */
.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}
#i-play path { fill: currentColor; stroke-width: 1.2; }
.muted, .i.muted { color: var(--muted); }
.accent { color: var(--accent); }
.small { font-size: 12px; }
.grow { flex: 1 1 auto; }
.min0 { min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.center { justify-content: center; }
.gap-xs { gap: 6px; } .gap-sm { gap: 10px; } .gap-md { gap: 14px; }
.push { margin-left: auto; }
:root[data-theme="dark"] .when-light, :root:not([data-theme="dark"]) .when-dark { display: none; }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font: 500 10.5px/1 var(--font);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* ------------------------------------------------------------------ progress + toast */
#progress {
  position: fixed; inset: 0 auto auto 0; height: 2px; width: 0; z-index: 100;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px var(--accent);
  opacity: 0; transition: width .25s ease, opacity .3s ease;
}
#progress.run { opacity: 1; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 90;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); transition: all .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ buttons + inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-weight: 500; font-size: 13px; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-sm .i { width: 15px; height: 15px; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--text); }
.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(60, 50, 200, .25), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
:root[data-theme="dark"] .btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-primary kbd { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.2); color: rgba(255,255,255,.85); margin-left: 2px; }
.btn-block { width: 100%; height: 40px; font-size: 14px; }
.btn.is-on { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.disabled { opacity: .35; pointer-events: none; }

input[type="text"], input[type="search"], input[type="password"], input:not([type]), textarea, select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  height: 34px; padding: 0 11px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; }

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap select { width: 100%; }
.select-wrap .select-caret { position: absolute; right: 9px; pointer-events: none; color: var(--muted); width: 14px; height: 14px; }
.select-wrap.compact select { height: 30px; font-size: 12.5px; }
.select-wrap.with-icon select { padding-left: 32px; }
.select-wrap .select-icon { position: absolute; left: 10px; pointer-events: none; color: var(--muted); width: 15px; height: 15px; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; }
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--sidebar); border-right: 1px solid var(--border);
}
.main { min-width: 0; height: 100vh; overflow: auto; scroll-behavior: auto; }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 10px 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand-mark { width: 24px; height: 24px; }
.brand-mark.lg { width: 44px; height: 44px; }
.bm-bg { fill: var(--accent); }
.bm-top, .bm-body { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }

.conn-menu { position: relative; margin: 0 10px 10px; }
.conn-menu > summary { list-style: none; }
.conn-menu > summary::-webkit-details-marker { display: none; }
.conn-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: border-color .12s;
}
.conn-pill:hover { border-color: var(--border-strong); }
.conn-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.conn-text strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-text small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.engine-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.engine-postgres { --engine: var(--pg); }
.engine-mysql { --engine: var(--mysql); }
.engine-dot.engine-postgres { background: var(--pg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pg) 18%, transparent); }
.engine-dot.engine-mysql { background: var(--mysql); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mysql) 18%, transparent); }

.menu-pop {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  padding: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop .14s ease-out;
}
.menu-pop.right { left: auto; right: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; border-radius: 6px; border: 0; background: none;
  font-size: 13px; text-align: left; cursor: pointer; color: var(--text);
}
.menu-item:hover { background: var(--hover); }
.menu-item.active { font-weight: 550; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item .i { color: var(--muted); }
.menu-item.danger .i { color: inherit; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.menu-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }

.side-selects { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 10px; }
.select-field { position: relative; display: flex; align-items: center; }
.select-field select {
  width: 100%; height: 32px; padding-left: 32px; font-size: 13px; font-weight: 500;
  background: transparent; border-color: transparent;
}
.select-field select:hover { background: var(--hover); }
.select-field select:focus { background: var(--surface); }
.select-label { position: absolute; left: 10px; display: grid; color: var(--muted); pointer-events: none; }
.select-field .select-caret { position: absolute; right: 9px; width: 14px; height: 14px; color: var(--muted); pointer-events: none; }

.side-search { position: relative; margin: 2px 10px 6px; display: flex; align-items: center; }
.side-search > .i { position: absolute; left: 10px; color: var(--muted); width: 15px; height: 15px; }
.side-search input { width: 100%; height: 32px; padding-left: 32px; padding-right: 30px; font-size: 13px; background: var(--surface); border-color: var(--border); }
.side-search kbd { position: absolute; right: 8px; }
.side-search input:focus + kbd { opacity: 0; }

.tlist { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 12px; scrollbar-width: thin; }
.tgroup {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.tgroup .count { font-weight: 500; letter-spacing: 0; color: var(--faint); }
.titem {
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 8px; border-radius: 6px;
  color: var(--text-2); font-size: 13px;
  transition: background .08s, color .08s;
}
.titem .i { color: var(--faint); width: 15px; height: 15px; }
.titem:hover, .titem.kb { background: var(--hover); color: var(--text); }
.titem.active { background: var(--surface); color: var(--text); font-weight: 550; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.titem.active .i { color: var(--accent); }
.tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcount { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tname mark { background: none; color: var(--accent-text); font-weight: 650; }
.side-empty { padding: 18px 10px; color: var(--muted); font-size: 12.5px; text-align: center; }

.side-foot { display: flex; gap: 4px; padding: 8px; border-top: 1px solid var(--border); }
.side-link {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px;
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.side-link:first-child { flex: 1; }
.side-link:hover, .side-link.active { background: var(--hover); color: var(--text); }
.side-link .i { color: var(--muted); }
.side-link kbd { margin-left: auto; }
.side-link:last-child span { display: none; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 20px 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; overflow: hidden; }
.crumb {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 6px;
  color: var(--muted); font-size: 13px; white-space: nowrap; min-width: 0;
}
.crumb span { overflow: hidden; text-overflow: ellipsis; }
.crumb .i { width: 14px; height: 14px; }
a.crumb:hover { background: var(--hover); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 550; }
.crumb-sep { color: var(--faint); font-size: 13px; }
.topbar-actions { display: flex; gap: 6px; }
.only-mobile { display: none; }

.page { padding: 26px 28px 60px; max-width: 100%; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .4; transform: translateY(2px); } }

/* ------------------------------------------------------------------ hero + headings */
.hero { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; }
.hero-icon {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 13px;
  background: linear-gradient(140deg, var(--accent-soft), transparent 80%), var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  color: var(--accent);
}
.hero-icon .i { width: 22px; height: 22px; stroke-width: 1.6; }
.hero-icon.engine-postgres { color: var(--pg); background: linear-gradient(140deg, color-mix(in srgb, var(--pg) 14%, transparent), transparent 80%), var(--surface); }
.hero-icon.engine-mysql { color: var(--mysql); background: linear-gradient(140deg, color-mix(in srgb, var(--mysql) 14%, transparent), transparent 80%), var(--surface); }
.hero-icon.sm { width: 40px; height: 40px; border-radius: 11px; }
.hero-icon.sm .i { width: 19px; height: 19px; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.022em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 .i { color: var(--muted); }
.count { font-weight: 500; color: var(--muted); font-size: .9em; margin-left: 4px; }
h3 .count { margin-left: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); font-size: 12px; white-space: nowrap;
}
.chip .i { width: 13px; height: 13px; color: var(--muted); }
.chip b { font-weight: 600; color: var(--text); }
.chip.comment { max-width: 320px; overflow: hidden; text-overflow: ellipsis; font-style: italic; }

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px;
  font-size: 11px; font-weight: 550; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-table { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge-view, .badge-matview { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-foreign { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-accent { background: var(--accent); color: #fff; border-color: transparent; }
.badge-strong { color: var(--text); border-color: var(--border-strong); background: transparent; }
.badge-soft { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; height: 18px; font-size: 10.5px; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.mini-search { position: relative; display: flex; align-items: center; }
.mini-search .i { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--muted); }
.mini-search input { height: 30px; width: 200px; padding-left: 29px; font-size: 12.5px; }

/* ------------------------------------------------------------------ tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile-icon {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.tile:hover .tile-icon { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.tile-body { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.tile-body strong { font-weight: 600; font-size: 14px; }
.tile-body small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-go { color: var(--faint); transition: transform .14s, color .14s; }
.tile:hover .tile-go { color: var(--accent); transform: translateX(2px); }
.empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }

.fold > summary {
  display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 500; padding: 6px 2px; margin-bottom: 8px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { color: var(--text); }
.fold-caret { transition: transform .15s; width: 14px; height: 14px; }
.fold[open] .fold-caret { transform: rotate(90deg); }

/* ------------------------------------------------------------------ cards + list tables */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card:not(.flush) > .card-head { margin: -16px -16px 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list-table th {
  text-align: left; font-weight: 550; font-size: 11.5px; letter-spacing: .02em;
  color: var(--muted); padding: 9px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.list-table td { padding: 9px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list-table tbody tr:last-child td { border-bottom: 0; }
.list-table tbody tr { transition: background .08s; }
.list-table tbody tr:hover { background: var(--hover); }
.list-table tr[data-href] { cursor: pointer; }
.list-table .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.list-table .actions { text-align: right; white-space: nowrap; }
.list-table .w-idx { width: 44px; }
.comment-cell { max-width: 320px; }
.rel-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; }
.rel-name .i { color: var(--muted); width: 15px; height: 15px; }
.rel-name:hover { color: var(--accent-text); }
.rel-name:hover .i { color: var(--accent); }
.link-sm { font-size: 12px; color: var(--muted); padding: 3px 7px; border-radius: 5px; }
.link-sm:hover { background: var(--hover); color: var(--text); }
code.type {
  display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;
}
code.default { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.col-name { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.col-name b { font-weight: 600; font-family: var(--mono); font-size: 12.5px; }
.key-tag { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--warn-soft); color: var(--warn); }
.key-tag .i { width: 13px; height: 13px; }
.fk-ref {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-family: var(--mono);
  color: var(--accent-text); background: var(--accent-soft); padding: 1px 7px 1px 5px; border-radius: 5px;
}
.fk-ref .i { width: 12px; height: 12px; }
.fk-ref:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ table head + tabs */
.table-head { margin-bottom: 18px; }
.table-head h1 { font-size: 21px; font-family: var(--font); }
.table-head .chips { margin-top: 6px; }
.tabs { display: flex; gap: 2px; margin-top: 18px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px 11px; font-size: 13px; font-weight: 500; color: var(--muted);
  transition: color .12s;
}
.tab .i { width: 15px; height: 15px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}
.tab.active .i { color: var(--accent); }

/* ------------------------------------------------------------------ browse toolbar + filters */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.search-box { position: relative; display: flex; align-items: center; width: 300px; max-width: 100%; }
.search-box .i { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted); }
.search-box input { width: 100%; height: 30px; padding-left: 32px; font-size: 13px; }
.page-info { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.page-info b { color: var(--text); font-weight: 600; }
.pager { display: inline-flex; align-items: center; gap: 2px; padding: 0 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); height: 30px; }
.pager .icon-btn { width: 26px; height: 26px; }
.pager-num { font-size: 12px; color: var(--text-2); padding: 0 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filters {
  margin: -2px 0 12px; padding: 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  animation: pop .14s ease-out;
}
.filter-list { display: flex; flex-direction: column; gap: 6px; }
.filter-list:empty { display: none; }
.filter-row { display: flex; gap: 6px; align-items: center; }
.filter-row .select-wrap { width: 200px; }
.filter-row .select-wrap.op { width: 140px; }
.filter-row select, .filter-row input { height: 30px; font-size: 12.5px; }
.filter-row input { font-family: var(--mono); min-width: 120px; }
.filter-row input.is-hidden { visibility: hidden; }
.filter-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.filter-list:empty + template + .filter-actions { margin-top: 0; }

/* ------------------------------------------------------------------ data grid */
.grid-wrap {
  position: relative; overflow: auto; max-height: calc(100vh - 290px); min-height: 120px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
}
.results .grid-wrap { max-height: calc(100vh - 220px); }
.grid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
.grid th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); text-align: left; font-weight: 500;
  border-bottom: 1px solid var(--border-strong); padding: 0; white-space: nowrap;
}
.grid th + th, .grid td + td { border-left: 1px solid var(--border); }
.th-link { display: flex; flex-direction: column; gap: 0; padding: 7px 26px 7px 12px; position: relative; line-height: 1.3; }
a.th-link:hover { background: var(--hover); }
.th-name { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text); font-size: 12.5px; }
.th-name .i { width: 12px; height: 12px; }
.th-name .pk { color: var(--warn); }
.th-name .fkicon { color: var(--accent); }
.th-type { font-family: var(--mono); font-size: 10.5px; color: var(--faint); font-weight: 400; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.th-link .sort { position: absolute; right: 7px; top: 50%; margin-top: -7px; width: 14px; height: 14px; color: var(--accent); }
.grid th.sorted .th-name { color: var(--accent-text); }

.grid td {
  padding: 6px 12px; max-width: 380px; height: 32px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 12px; color: var(--str);
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { cursor: default; }
.grid.data tbody tr[data-row] { cursor: pointer; }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.grid tbody tr.picked td { background: var(--accent-soft); }
.grid td.rownum, .grid th.rownum {
  position: sticky; left: 0; z-index: 1; width: 1%;
  text-align: right; color: var(--faint); font-size: 11px; padding: 6px 10px;
  background: var(--surface); font-variant-numeric: tabular-nums;
}
.grid th.rownum { z-index: 3; }
.v-null { color: var(--faint) !important; font-style: italic; font-size: 11px !important; letter-spacing: .03em; }
.v-num { text-align: right; color: var(--num) !important; font-variant-numeric: tabular-nums; }
.v-bool { color: var(--kw) !important; }
.v-json { color: var(--text-2) !important; }
.v-date { color: var(--text-2) !important; font-variant-numeric: tabular-nums; }
.v-bin { color: var(--muted) !important; }
td.has-fk span { margin-right: 4px; }
td .fk {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; vertical-align: -3px;
  color: var(--accent); opacity: .45; transition: opacity .1s, background .1s;
}
td .fk .i { width: 12px; height: 12px; }
tr:hover td .fk { opacity: 1; }
td .fk:hover { background: var(--accent-soft); }
.grid-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 46px 20px; color: var(--muted); }
.grid-empty .i { width: 26px; height: 26px; stroke-width: 1.4; color: var(--faint); }

.sql-peek { margin-top: 12px; }
.sql-peek > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  font-size: 12px; color: var(--muted); padding: 4px 6px; border-radius: 6px;
}
.sql-peek > summary::-webkit-details-marker { display: none; }
.sql-peek > summary:hover { background: var(--hover); color: var(--text); }
.sql-peek > summary .i { width: 14px; height: 14px; }
.sql-peek-body { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
.sql-peek-body pre { flex: 1; margin: 0; }

pre.sql {
  margin: 0; padding: 14px 16px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  color: var(--text);
}
.card > pre.sql { border: 0; background: transparent; padding: 0; }
pre.ddl { font-size: 13px; }
.tok-kw { color: var(--kw); font-weight: 500; }
.tok-str { color: var(--sql-str); }
.tok-num { color: var(--sql-num); }
.tok-com { color: var(--sql-com); font-style: italic; }
.tok-id { color: var(--accent-text); }
.tok-fn { color: var(--num); }

/* ------------------------------------------------------------------ SQL console */
.console-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.console-head h1 { font-size: 21px; }
.editor {
  position: relative; height: 240px; min-height: 120px; resize: vertical; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s;
}
.editor:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.editor-hl, .editor textarea, .editor-mirror {
  position: absolute; inset: 0; margin: 0; padding: 14px 16px;
  font: 13.5px/1.65 var(--mono); letter-spacing: 0; tab-size: 2;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; overflow: auto;
  border: 0; border-radius: 0;
}
.editor-hl { pointer-events: none; color: var(--text); }
.editor-mirror { visibility: hidden; pointer-events: none; overflow: hidden; }
.editor-hl code { font: inherit; }
.editor textarea {
  width: 100%; height: 100%; resize: none; background: transparent; box-shadow: none !important;
  color: transparent; caret-color: var(--text); -webkit-text-fill-color: transparent;
}
.editor textarea::placeholder { -webkit-text-fill-color: var(--faint); color: var(--faint); }
.editor textarea::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); -webkit-text-fill-color: transparent; }
.console-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.hint { font-size: 12px; color: var(--faint); margin-left: 4px; }
.history { position: relative; }
.history > summary { list-style: none; }
.history > summary::-webkit-details-marker { display: none; }
.history-pop { width: 440px; max-height: 380px; overflow: auto; }
.hist-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.hist-item:hover { background: var(--hover); }
.hist-item code { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.hist-item small { font-size: 11px; color: var(--muted); }

.results { margin-top: 22px; }
.result-meta { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.result-meta b { color: var(--text); font-weight: 600; }
.ok-dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.ok-dot .i { width: 12px; height: 12px; stroke-width: 2.5; }

/* ------------------------------------------------------------------ SQL autocomplete */
.ac {
  position: fixed; z-index: 70; width: 340px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop .1s ease-out;
}
.ac-list { max-height: 260px; overflow-y: auto; padding: 4px; scrollbar-width: thin; }
.ac-item {
  display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.ac-item.active { background: var(--accent-soft); }
.ac-badge {
  display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 5px;
  font: 600 10.5px/1 var(--mono); color: #fff;
}
.ac-keyword { background: var(--kw); }
.ac-function { background: var(--num); }
.ac-table { background: var(--accent); }
.ac-view { background: var(--ok); }
.ac-column { background: var(--warn); }
:root[data-theme="dark"] .ac-badge { color: var(--bg); }
.ac-label { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-label b { color: var(--text); font-weight: 650; }
.ac-item.active .ac-label { color: var(--text); }
.ac-detail { flex: none; max-width: 45%; font-family: var(--mono); font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-foot {
  display: flex; gap: 12px; padding: 6px 10px; border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: 11px; color: var(--muted);
}
.ac-foot span { display: inline-flex; align-items: center; gap: 3px; }
.ac-foot kbd { height: 16px; min-width: 16px; font-size: 10px; padding: 0 4px; }

/* ------------------------------------------------------------------ alerts + empty states */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 14px;
}
.alert > .i { margin-top: 1px; }
.alert p, .alert pre { margin: 2px 0 0; color: var(--text-2); white-space: pre-wrap; word-break: break-word; font-size: 12.5px; }
.alert pre { font-family: var(--mono); }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-error strong { color: var(--danger); }

.empty-state { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state .empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); margin-bottom: 8px; }
.empty-state .empty-icon .i { width: 24px; height: 24px; stroke-width: 1.5; }
.empty-state p { color: var(--muted); margin-bottom: 12px; }

/* ------------------------------------------------------------------ drawer */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 20, .28); backdrop-filter: blur(2px); animation: fadein .18s ease; }
:root[data-theme="dark"] .drawer-backdrop { background: rgba(0, 0, 0, .5); }
@keyframes fadein { from { opacity: 0; } }
.drawer-panel {
  position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(560px, calc(100vw - 20px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: slidein .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: 16px; }
.drawer-body { flex: 1; overflow: auto; padding: 8px 12px 20px; }
.field-item { padding: 10px 8px; border-bottom: 1px solid var(--border); position: relative; }
.field-item:last-child { border-bottom: 0; }
.field-item .fi-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.field-item .fi-name { font-weight: 600; font-size: 12.5px; font-family: var(--mono); }
.field-item .fi-type { font-size: 11px; color: var(--faint); font-family: var(--mono); }
.field-item .fi-copy { margin-left: auto; opacity: 0; width: 24px; height: 24px; }
.field-item:hover .fi-copy { opacity: 1; }
.field-item pre { margin: 0; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: var(--text); max-height: 320px; overflow: auto; }
.field-item pre.null { color: var(--faint); font-style: italic; }
.refs { padding: 12px 8px 4px; }
.refs .menu-label { padding-left: 0; }
.refs-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ref-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-family: var(--mono); }
.ref-chip .i { width: 12px; height: 12px; }
.ref-chip:hover { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ auth */
body[data-layout="bare"] { overflow: auto; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 40px 16px; position: relative; overflow: hidden; }
.auth-glow {
  position: absolute; inset: -40% -10% auto; height: 80vh; pointer-events: none;
  background:
    radial-gradient(40% 50% at 30% 40%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(35% 45% at 72% 30%, color-mix(in srgb, var(--pg) 12%, transparent), transparent 70%);
  filter: blur(20px);
}
.auth-wrap { position: relative; width: 100%; max-width: 440px; }
.auth-wrap.narrow { max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 22px; }
.auth-brand p { color: var(--muted); font-size: 13.5px; }
.auth-card { padding: 22px; box-shadow: var(--shadow); }
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; margin-bottom: 18px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label > span {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 32px; border-radius: 7px;
  font-size: 13px; font-weight: 550; color: var(--muted); cursor: pointer; transition: all .14s;
}
.segmented label > span:hover { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { box-shadow: var(--ring); }
.fields { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.field-row { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field > span em { font-style: normal; font-weight: 400; color: var(--faint); margin-left: 4px; }
.field input { width: 100%; height: 38px; }
.w-port { width: 96px; flex: none; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch-track { position: relative; width: 32px; height: 19px; border-radius: 99px; background: var(--border-strong); transition: background .15s; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(13px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.fineprint { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 11.5px; color: var(--muted); text-align: center; }
.fineprint .i { width: 13px; height: 13px; }
.saved { margin-top: 20px; }
.saved .menu-label { padding-left: 4px; }
.saved-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .12s, transform .12s;
}
.saved-item:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.saved-item strong { display: block; font-size: 13.5px; font-weight: 600; }
.saved-item small { display: block; font-size: 12px; color: var(--muted); }
.error-card { text-align: center; padding: 30px; }
.error-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; }
.error-icon .i { width: 22px; height: 22px; }
.error-card h2 { font-size: 18px; margin-bottom: 12px; }
.error-msg {
  text-align: left; white-space: pre-wrap; word-break: break-word; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 20px; color: var(--text-2); max-height: 260px; overflow: auto;
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.side-open .sidebar { transform: none; }
  .only-mobile { display: inline-grid; }
  .page { padding: 18px 16px 50px; }
  .topbar { padding: 0 12px; }
  .hint, .crumb span { display: none; }
  .crumb.current span { display: inline; }
  .search-box { width: 100%; }
  .filter-row { flex-wrap: wrap; }
  .filter-row .select-wrap, .filter-row .select-wrap.op { width: calc(50% - 3px); }
  .grid-wrap { max-height: none; }
  .field-row { flex-direction: column; }
  .w-port { width: 100%; }
}
