/* ============================================================
   R12 Data Explorer — design system
   Dark, dense, developer-tool aesthetic
   ============================================================ */

:root {
  /* Layered surfaces — cool warm-neutral dark */
  --bg-0: oklch(0.155 0.012 250);
  --bg-1: oklch(0.18 0.012 250);
  --bg-2: oklch(0.215 0.014 250);
  --bg-3: oklch(0.26 0.014 250);
  --bg-4: oklch(0.31 0.014 250);
  --bg-elev: oklch(0.22 0.014 250 / 0.92);

  /* Ink */
  --fg-0: oklch(0.96 0.005 250);
  --fg-1: oklch(0.82 0.008 250);
  --fg-2: oklch(0.65 0.012 250);
  --fg-3: oklch(0.5 0.012 250);
  --fg-4: oklch(0.4 0.012 250);

  /* Lines */
  --line: oklch(0.3 0.014 250);
  --line-soft: oklch(0.24 0.014 250);
  --line-strong: oklch(0.4 0.014 250);

  /* Accents */
  --accent: oklch(0.75 0.13 200);
  --accent-2: oklch(0.78 0.14 90);
  --warn: oklch(0.72 0.14 60);
  --bad: oklch(0.7 0.16 25);
  --ok: oklch(0.74 0.13 145);

  /* Modules (same family as data.js, brighter for UI) */
  --m-GL:     oklch(0.74 0.13 250);
  --m-AP:     oklch(0.76 0.13 60);
  --m-AR:     oklch(0.74 0.13 175);
  --m-HZ:     oklch(0.76 0.13 200);
  --m-ZX:     oklch(0.74 0.13 15);
  --m-XLA:    oklch(0.74 0.13 305);
  --m-PO:     oklch(0.76 0.13 35);
  --m-OE:     oklch(0.74 0.13 220);
  --m-ORG:    oklch(0.76 0.13 95);
  --m-FA:     oklch(0.74 0.13 330);
  --m-IBY:    oklch(0.72 0.13 270);
  --m-QC:     oklch(0.68 0.03 250);
  --m-ORI_SO: oklch(0.76 0.13 145);
  --m-ORI_PU: oklch(0.72 0.13 165);
  --m-ORI_FT: oklch(0.76 0.13 125);

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ============================================================
   App layout
   ============================================================ */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 52px 1fr;
  background:
    radial-gradient(ellipse 1200px 600px at 20% 0%, oklch(0.21 0.03 250 / 0.5), transparent 60%),
    var(--bg-0);
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: oklch(0.165 0.012 250 / 0.85);
  backdrop-filter: blur(12px);
  gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: 220px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, oklch(0.5 0.16 200), oklch(0.5 0.16 145));
  display: grid; place-items: center;
  color: white; font-size: 15px;
  box-shadow: 0 0 0 1px oklch(0.5 0.13 200 / 0.4),
              0 2px 12px oklch(0.45 0.13 200 / 0.35);
}
.brand-title { font-weight: 700; font-size: 14px; letter-spacing: -0.005em; }
.brand-sub { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); margin-top: 1px; }

.tabs {
  display: flex; gap: 2px;
  background: var(--bg-1);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--line-soft);
}
.tab {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
  background: transparent;
  border: none;
  border-radius: 6px;
  transition: all 0.13s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--fg-0); background: var(--bg-2); }
.tab.on {
  background: var(--bg-3);
  color: var(--fg-0);
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.2);
}
.tab .tab-icon { font-size: 13px; opacity: 0.85; }
.tab .tab-counter {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg-4);
  border-radius: 3px;
  color: var(--fg-2);
  margin-left: 2px;
}

.global-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.global-search input {
  width: 100%;
  padding: 7px 30px 7px 30px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--fg-0);
  font-size: 12.5px;
  outline: none;
}
.global-search input:focus { border-color: var(--accent); }
.global-search input::placeholder { color: var(--fg-3); }
.global-search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--fg-3); font-size: 13px;
}
.global-search-shortcut {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10px;
  background: var(--bg-3); color: var(--fg-3);
  padding: 1px 5px; border-radius: 3px;
}
.global-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 32px oklch(0 0 0 / 0.4);
  max-height: 460px; overflow-y: auto;
  z-index: 100;
}
.gs-section { padding: 8px 4px; }
.gs-section-label {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 4px 12px 6px;
  font-weight: 600;
}
.gs-item {
  padding: 7px 12px; cursor: pointer;
  border-radius: 5px;
  margin: 0 4px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
}
.gs-item:hover { background: var(--bg-3); }
.gs-item .gs-name { color: var(--fg-0); font-weight: 500; }
.gs-item .gs-meta { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.gs-item code { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); background: var(--bg-3); padding: 1px 5px; border-radius: 3px; }

.btn-icon {
  width: 30px; height: 30px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg-2);
  display: grid; place-items: center;
  font-size: 14px;
  transition: all 0.13s;
}
.btn-icon:hover { background: var(--bg-2); color: var(--fg-0); border-color: var(--line-strong); }

/* ============================================================
   Module pills
   ============================================================ */
.mpill {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
  color: oklch(0.15 0.01 250);
  text-transform: uppercase;
  white-space: nowrap;
}
.mpill[data-mod="GL"]    { background: var(--m-GL); }
.mpill[data-mod="AP"]    { background: var(--m-AP); }
.mpill[data-mod="AR"]    { background: var(--m-AR); }
.mpill[data-mod="HZ"]    { background: var(--m-HZ); }
.mpill[data-mod="ZX"]    { background: var(--m-ZX); }
.mpill[data-mod="XLA"]   { background: var(--m-XLA); }
.mpill[data-mod="PO"]    { background: var(--m-PO); }
.mpill[data-mod="OE"]    { background: var(--m-OE); }
.mpill[data-mod="ORG"]   { background: var(--m-ORG); }
.mpill[data-mod="FA"]    { background: var(--m-FA); }
.mpill[data-mod="IBY"]   { background: var(--m-IBY); }
.mpill[data-mod="QC"]    { background: var(--m-QC); }
.mpill[data-mod="ORI_SO"]{ background: var(--m-ORI_SO); }
.mpill[data-mod="ORI_PU"]{ background: var(--m-ORI_PU); }
.mpill[data-mod="ORI_FT"]{ background: var(--m-ORI_FT); }

/* ============================================================
   BROWSE view — main interaction
   ============================================================ */
.browse {
  height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr 380px;
  min-height: 0;
}
.browse-tree {
  background: oklch(0.165 0.012 250);
  border-right: 1px solid var(--line);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.tree-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.tree-search input {
  width: 100%;
  padding: 6px 28px 6px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg-0);
  font-size: 12px;
  outline: none;
}
.tree-search input:focus { border-color: var(--accent); }
.tree-clear {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  background: var(--bg-3); color: var(--fg-2);
  border: none; width: 18px; height: 18px;
  border-radius: 4px; font-size: 10px;
}
.tree-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.tree-section {
  margin-bottom: 2px;
}
.tree-system-head {
  font-size: 9.5px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.14em;
  padding: 12px 14px 6px;
  font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.tree-system-head:not(:first-child) { border-top: 1px solid var(--line-soft); margin-top: 4px; }
.tree-system-head::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
}
.tree-system-head[data-sys="R12"]::before { background: var(--m-GL); }
.tree-system-head[data-sys="ORION"]::before { background: var(--m-ORI_SO); }
.tree-module-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px 5px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 11.5px;
  color: var(--fg-1);
  font-weight: 600;
}
.tree-module-head:hover { background: var(--bg-1); }
.tree-module-head .caret {
  font-size: 9px;
  color: var(--fg-3);
  width: 12px; display: inline-block;
  transition: transform 0.15s;
}
.tree-module-head.open .caret { transform: rotate(90deg); }
.tree-module-name { display: flex; align-items: center; gap: 7px; }
.tree-module-count { font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); }
.tree-tables { padding: 0; }
.tree-table {
  display: block;
  padding: 4px 14px 4px 32px;
  cursor: pointer;
  font-size: 12px;
  color: var(--fg-2);
  border-left: 2px solid transparent;
  transition: background 0.1s;
  position: relative;
}
.tree-table:hover { background: var(--bg-1); color: var(--fg-0); }
.tree-table.sel {
  background: var(--bg-2);
  color: var(--fg-0);
  border-left-color: var(--accent);
  font-weight: 500;
}
.tree-table .ttname { font-family: var(--font-mono); font-size: 11.5px; display: block; }
.tree-table .tttitle { font-size: 10.5px; color: var(--fg-3); margin-top: 1px; display: block; }
.tree-table.sel .tttitle { color: var(--fg-2); }

/* ============================================================
   BROWSE — table detail (middle panel)
   ============================================================ */
.tdetail {
  overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg-0);
}
.tdetail-empty {
  flex: 1;
  display: grid; place-items: center;
  color: var(--fg-3);
  text-align: center;
  padding: 40px;
}
.tdetail-empty h2 { color: var(--fg-1); font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.tdetail-empty p { font-size: 13px; max-width: 360px; line-height: 1.55; }

.tdetail-head {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line);
  background: oklch(0.175 0.012 250);
}
.tdetail-head .crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--fg-3);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.tdetail-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 12px;
}
.tdetail-head .tid {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-2);
  margin: 0 0 8px;
  letter-spacing: -0.005em;
}
.tdetail-head .tdesc {
  font-size: 13px;
  color: var(--fg-1);
  line-height: 1.55;
  max-width: 820px;
  margin: 6px 0 0;
}
.tdetail-meta { display: flex; gap: 14px; margin-top: 12px; font-size: 11.5px; }
.tdetail-meta .mmeta { color: var(--fg-3); display: flex; gap: 5px; }
.tdetail-meta .mmeta b { color: var(--fg-0); font-weight: 600; }

.tdetail-body {
  flex: 1; overflow-y: auto;
  padding: 16px 24px 24px;
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 10px;
}
.section-head h3 {
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0;
  font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.section-head h3 .scnt {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--bg-2); color: var(--fg-2);
  padding: 1px 6px; border-radius: 3px;
  letter-spacing: 0;
}
.section-head:first-child { margin-top: 0; }

/* Columns grid */
.cols-grid {
  display: grid; gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}
.col-row {
  display: grid;
  grid-template-columns: 1fr 100px 1fr;
  gap: 0;
  background: var(--bg-1);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  align-items: center;
  transition: background 0.08s;
  position: relative;
}
.col-row:hover { background: var(--bg-2); }
.col-row.sel {
  background: oklch(0.27 0.04 200);
  box-shadow: inset 3px 0 0 var(--accent);
}
.col-row.is-pk-row::before {
  content: 'PK'; font-family: var(--font-mono); font-size: 8.5px;
  background: oklch(0.32 0.1 90); color: oklch(0.94 0.04 90);
  padding: 1px 5px; border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-right: 8px;
}
.col-row.is-fk-row::before {
  content: 'FK'; font-family: var(--font-mono); font-size: 8.5px;
  background: oklch(0.32 0.1 200); color: oklch(0.94 0.04 200);
  padding: 1px 5px; border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-right: 8px;
}
.col-row .cname {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-0);
  display: flex; align-items: center;
  font-weight: 500;
}
.col-row .ctype {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
}
.col-row .cfk {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  text-align: right;
}
.col-row .cfk .ariw { color: var(--fg-3); margin: 0 6px; }
.col-row .cfk b { color: var(--accent); font-weight: 500; }

/* Join cards */
.join-cards { display: flex; flex-direction: column; gap: 4px; }
.jcard {
  padding: 8px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
}
.jcard:hover { background: var(--bg-2); border-color: var(--line); }
.jcard.hi { background: oklch(0.24 0.04 200); border-color: var(--accent); }
.jcard .jrow { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.jcard .jother { display: flex; align-items: center; gap: 6px; min-width: 0; }
.jcard .jother-name { color: var(--fg-0); font-weight: 500; font-size: 12.5px; }
.jcard .jother-title { color: var(--fg-3); font-size: 11px; }
.jcard .jon {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-2);
  grid-column: 1 / 3;
}
.jcard .jon b { color: var(--accent); font-weight: 500; }
.jcard .jsoft {
  font-family: var(--font-mono); font-size: 9.5px;
  background: var(--bg-3); color: var(--fg-3);
  padding: 1px 5px; border-radius: 3px;
  letter-spacing: 0.04em;
}
.jcard .jlabel {
  font-size: 10.5px; color: var(--fg-3); font-style: italic;
  grid-column: 1 / 3;
}

/* ============================================================
   BROWSE — column detail (right panel)
   ============================================================ */
.coldetail {
  background: oklch(0.17 0.012 250);
  border-left: 1px solid var(--line);
  overflow-y: auto;
}
.coldetail-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--fg-3);
}
.coldetail-empty h3 { color: var(--fg-1); font-size: 14px; margin: 0 0 6px; }
.coldetail-empty p { font-size: 12px; line-height: 1.55; }

.cd-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.cd-eyebrow {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: 8px;
}
.cd-name {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: -0.005em;
  word-break: break-all;
  margin-bottom: 6px;
}
.cd-flags { display: flex; gap: 6px; }
.cd-flag {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.04em;
}
.cd-flag.pk { background: oklch(0.32 0.1 90); color: oklch(0.94 0.04 90); }
.cd-flag.fk { background: oklch(0.32 0.1 200); color: oklch(0.94 0.04 200); }
.cd-flag.ref { background: oklch(0.32 0.1 145); color: oklch(0.94 0.04 145); }

.cd-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.cd-section h4 {
  font-size: 10px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 8px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.cd-section h4 .cd-cnt {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--bg-2); color: var(--fg-2);
  padding: 1px 6px; border-radius: 3px;
  letter-spacing: 0;
}
.cd-list { display: flex; flex-direction: column; gap: 3px; }
.cd-row {
  padding: 7px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.1s;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.cd-row:hover { background: var(--bg-2); border-color: var(--line); }
.cd-row .cdr-name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-0);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cd-row .cdr-title { font-size: 10.5px; color: var(--fg-3); margin-top: 1px; display: block; }
.cd-row .cdr-arrow { color: var(--fg-3); font-size: 12px; }
.cd-row b { color: var(--accent); font-weight: 500; }

.cd-empty {
  font-size: 11.5px; color: var(--fg-3); padding: 6px 4px; font-style: italic;
}

/* Quick SQL snippet */
.cd-sql {
  padding: 12px 20px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.cd-sql-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cd-sql-head h4 {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin: 0; font-weight: 700;
}
.btn-copy {
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--fg-1); font-size: 10.5px;
  padding: 3px 8px; border-radius: 4px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.btn-copy:hover { background: var(--bg-3); color: var(--fg-0); }
.btn-copy.ok { color: var(--ok); border-color: var(--ok); }
pre.snip {
  margin: 0;
  background: oklch(0.12 0.012 250);
  color: oklch(0.92 0 0);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid var(--line-soft);
}
pre.snip .k { color: oklch(0.85 0.14 60); font-weight: 600; }
pre.snip .s { color: oklch(0.78 0.12 145); }
pre.snip .c { color: oklch(0.55 0.015 250); font-style: italic; }
pre.snip .t { color: oklch(0.85 0.06 200); }
pre.snip .n { color: oklch(0.78 0.14 290); }

/* ============================================================
   SQL BUILDER view
   ============================================================ */
.builder {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%; min-height: 0;
}
.builder-side {
  background: oklch(0.165 0.012 250);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.bs-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.bs-head h3 {
  margin: 0 0 4px; font-size: 14px; font-weight: 700;
  letter-spacing: -0.005em;
}
.bs-head p { margin: 0; font-size: 11.5px; color: var(--fg-3); line-height: 1.45; }

.bs-path {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: oklch(0.18 0.012 250);
}
.bs-path label {
  display: block;
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600; margin-bottom: 5px;
}
.bs-path select {
  width: 100%; margin-bottom: 6px;
  padding: 6px 8px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--fg-0); font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
}
.bs-path select:focus { border-color: var(--accent); }
.bs-path-btn {
  width: 100%;
  padding: 7px;
  background: linear-gradient(135deg, oklch(0.55 0.16 200), oklch(0.55 0.16 250));
  border: none; border-radius: 5px;
  color: white; font-size: 12px; font-weight: 600;
  margin-top: 4px;
}
.bs-path-btn:hover { filter: brightness(1.1); }
.bs-path-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.bs-tables {
  padding: 10px 14px;
  flex: 1;
  overflow-y: auto;
}
.bs-tables h4 {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600; margin: 4px 0 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.bs-tables h4 .clrbtn {
  background: none; border: none;
  color: var(--fg-3); font-size: 10px;
  text-transform: none; letter-spacing: 0;
  cursor: pointer;
}
.bs-tables h4 .clrbtn:hover { color: var(--bad); }

.bs-table {
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  margin-bottom: 5px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.bs-table .bs-tname { font-family: var(--font-mono); font-size: 11px; color: var(--fg-0); flex: 1; word-break: break-all; }
.bs-table .bs-ttitle { font-size: 10.5px; color: var(--fg-3); display: block; }
.bs-table .bs-rm {
  background: transparent; border: none;
  color: var(--fg-3); font-size: 14px;
  padding: 0; width: 18px; height: 18px;
  border-radius: 3px;
  cursor: pointer;
}
.bs-table .bs-rm:hover { background: oklch(0.35 0.12 25); color: white; }
.bs-table .bs-idx {
  width: 18px; height: 18px;
  background: var(--bg-3);
  border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--fg-2);
}

.bs-add {
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--fg-2);
  font-size: 12px;
  width: 100%;
  text-align: center;
  cursor: pointer;
}
.bs-add:hover { background: var(--bg-2); color: var(--fg-0); }

/* Builder right panel: SQL + options */
.builder-main {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.bm-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: oklch(0.175 0.012 250);
  flex-wrap: wrap;
}
.bm-opt {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--fg-2);
}
.bm-opt label { color: var(--fg-3); font-size: 11px; }
.bm-opt input, .bm-opt select {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 6px;
  color: var(--fg-0); font-size: 11.5px;
  font-family: var(--font-mono);
  outline: none;
}
.bm-opt input[type="number"] { width: 60px; }
.bm-opt input[type="text"] { width: 80px; }
.bm-opt input:focus, .bm-opt select:focus { border-color: var(--accent); }
.bm-divider { width: 1px; height: 18px; background: var(--line); }
.bm-actions { margin-left: auto; display: flex; gap: 6px; }
.btn-pri {
  background: linear-gradient(135deg, oklch(0.55 0.16 200), oklch(0.55 0.16 250));
  border: none; color: white; font-weight: 600;
  font-size: 11.5px; padding: 5px 12px; border-radius: 5px;
}
.btn-pri:hover { filter: brightness(1.1); }
.btn-sec {
  background: var(--bg-1); border: 1px solid var(--line);
  color: var(--fg-1); font-size: 11.5px;
  padding: 4px 10px; border-radius: 5px;
}
.btn-sec:hover { background: var(--bg-2); color: var(--fg-0); }

.bm-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.bm-cols {
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  max-height: 36vh;
  overflow-y: auto;
  padding: 12px 16px;
}
.bm-cols h4 {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin: 0 0 8px; font-weight: 700;
}
.bm-cols-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px;
}
.bm-col {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  font-size: 11.5px;
  cursor: pointer;
}
.bm-col input[type="checkbox"] {
  accent-color: var(--accent);
}
.bm-col .bmc-name {
  font-family: var(--font-mono);
  font-size: 11px;
  flex: 1;
}
.bm-col .bmc-table {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--fg-3);
}
.bm-col.pk { border-color: oklch(0.4 0.1 90 / 0.4); }
.bm-col.checked { background: oklch(0.28 0.05 200); border-color: var(--accent); }

.bm-where {
  padding: 8px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}
.bm-where label {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600;
}
.bm-where textarea {
  width: 100%;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 6px 9px;
  color: var(--fg-0); font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  resize: vertical;
  min-height: 38px;
  margin-top: 4px;
}
.bm-where textarea:focus { border-color: var(--accent); }

.bm-sql {
  flex: 1; min-height: 0;
  background: oklch(0.12 0.012 250);
  position: relative;
  overflow: auto;
  padding: 16px 20px;
}
.bm-sql pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: oklch(0.92 0 0);
  white-space: pre;
}
.bm-sql pre .k { color: oklch(0.85 0.14 60); font-weight: 600; }
.bm-sql pre .s { color: oklch(0.78 0.12 145); }
.bm-sql pre .c { color: oklch(0.55 0.015 250); font-style: italic; }
.bm-sql pre .t { color: oklch(0.85 0.06 200); }
.bm-sql pre .n { color: oklch(0.78 0.14 290); }

.bm-empty {
  flex: 1; display: grid; place-items: center;
  color: var(--fg-3); padding: 40px; text-align: center;
}
.bm-empty h2 { color: var(--fg-1); font-size: 17px; margin: 0 0 8px; }
.bm-empty p { font-size: 13px; max-width: 380px; line-height: 1.55; }
.bm-empty .ill { font-size: 48px; color: var(--bg-4); margin-bottom: 12px; }

/* ============================================================
   Table picker modal
   ============================================================ */
.modal-bg {
  position: fixed; inset: 0;
  background: oklch(0.1 0.01 250 / 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: grid; place-items: center;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 540px; max-width: 90vw;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px oklch(0 0 0 / 0.5);
}
.modal h3 {
  margin: 0; padding: 14px 18px;
  font-size: 15px; font-weight: 700;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal h3 button {
  background: transparent; border: none;
  color: var(--fg-3); font-size: 18px;
}
.modal-search { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.modal-search input {
  width: 100%; padding: 8px 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--fg-0); font-size: 13px;
  outline: none;
}
.modal-search input:focus { border-color: var(--accent); }
.modal-list { flex: 1; overflow-y: auto; padding: 6px; }
.modal-row {
  padding: 8px 12px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
}
.modal-row:hover { background: var(--bg-2); }
.modal-row .mrname { font-family: var(--font-mono); font-size: 12px; color: var(--fg-0); flex: 1; }
.modal-row .mrtitle { font-size: 11px; color: var(--fg-3); }

/* ============================================================
   LIBRARY view
   ============================================================ */
.library {
  height: 100%;
  overflow-y: auto;
  padding: 28px 32px;
}
.lib-head {
  margin-bottom: 28px;
  max-width: 800px;
}
.lib-head h2 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.015em;
  margin: 0 0 8px;
}
.lib-head p { color: var(--fg-2); font-size: 14px; line-height: 1.55; margin: 0; }
.lib-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}
.lib-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  border-left: 4px solid var(--accent);
  display: flex; flex-direction: column;
}
.lib-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.lib-card .lib-tab {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.lib-card h4 { margin: 0 0 6px; font-size: 16px; font-weight: 700; letter-spacing: -0.005em; }
.lib-card p { font-size: 12.5px; color: var(--fg-2); line-height: 1.5; margin: 0 0 12px; flex: 1; }
.lib-card .lib-meta {
  display: flex; gap: 6px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 10px; color: var(--fg-3);
  margin-bottom: 10px;
}
.lib-card .lib-meta b { color: var(--fg-1); font-weight: 600; }
.lib-card .lib-tables {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--fg-3); line-height: 1.55;
  background: var(--bg-0);
  padding: 8px 10px; border-radius: 5px;
  border: 1px solid var(--line-soft);
}

/* ============================================================
   NETWORK / GRAPH view (reuses existing)
   ============================================================ */
.network {
  height: 100%;
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 0;
}
.network-side {
  background: oklch(0.165 0.012 250);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  overflow-y: auto;
}
.network-side h4 {
  font-size: 10px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin: 0 4px 8px;
  font-weight: 700;
}
.netleg {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 5px;
  cursor: pointer; font-size: 11.5px;
  background: transparent; border: 1px solid transparent;
  width: 100%; text-align: left;
  margin-bottom: 2px;
}
.netleg:hover { background: var(--bg-2); }
.netleg.off { opacity: 0.4; }
.netleg .nlc {
  width: 9px; height: 9px; border-radius: 2px;
}
.netleg .nlname { flex: 1; color: var(--fg-1); }
.netleg .nlcnt { font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); }

.network-canvas {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 800px 500px at 50% 50%, oklch(0.18 0.012 250), oklch(0.14 0.012 250));
}
.netctl {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 3px;
  background: oklch(0.2 0.012 250 / 0.9);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px;
  backdrop-filter: blur(8px);
}
.netctl button {
  width: 26px; height: 26px;
  background: transparent; border: none;
  color: var(--fg-1); font-size: 13px;
  border-radius: 4px;
}
.netctl button:hover { background: var(--bg-3); color: var(--fg-0); }
.nethint {
  position: absolute; bottom: 14px; left: 14px;
  font-family: var(--font-mono); font-size: 10.5px;
  background: oklch(0.18 0.012 250 / 0.7);
  padding: 4px 8px; border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--fg-3);
}

/* ============================================================
   ABOUT / Settings view
   ============================================================ */
.about {
  height: 100%; overflow-y: auto;
  padding: 40px 48px 80px;
}
.about-content { max-width: 760px; }
.about-content h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.about-content .sub { font-size: 14px; color: var(--fg-2); margin: 0 0 32px; }
.about-content h2 { font-size: 17px; font-weight: 700; margin: 28px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.about-content h2:first-of-type { padding-top: 0; border-top: none; margin-top: 0; }
.about-content p { font-size: 13.5px; color: var(--fg-1); line-height: 1.6; margin: 0 0 10px; }
.about-content ul { padding-left: 22px; line-height: 1.65; color: var(--fg-1); font-size: 13.5px; }
.about-content code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--bg-2); padding: 1px 6px;
  border-radius: 4px; color: var(--accent);
  border: 1px solid var(--line-soft);
}
.about-content pre {
  background: oklch(0.12 0.012 250);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: oklch(0.92 0 0);
  overflow-x: auto;
  line-height: 1.55;
  margin: 12px 0 20px;
  white-space: pre;
}

/* ============================================================
   Scrollbars
   ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-3); border-radius: 5px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--bg-4); background-clip: padding-box;
  border: 2px solid transparent;
}

/* ============================================================
   Network join-column detail panel
   ============================================================ */
.net-detail-panel {
  position: absolute;
  bottom: 48px;
  right: 16px;
  width: 316px;
  max-height: 420px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 32px oklch(0 0 0 / 0.45);
  z-index: 20;
}
.net-detail-header {
  padding: 9px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.net-detail-meta {
  font-size: 9.5px;
  color: var(--fg-3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}
.net-detail-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-0);
  word-break: break-all;
}
.net-detail-close {
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  margin-top: -1px;
}
.net-detail-close:hover { color: var(--fg-0); }
.net-detail-body {
  overflow-y: auto;
  flex: 1;
}
.net-detail-empty {
  padding: 16px;
  color: var(--fg-3);
  font-size: 12px;
  text-align: center;
}
.net-detail-group {
  padding: 7px 12px 7px;
  border-bottom: 1px solid var(--line-soft);
}
.net-detail-group:last-child { border-bottom: none; }
.net-detail-group-hd {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.net-detail-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.net-detail-other {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-0);
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.net-detail-mod {
  font-size: 9px;
  color: var(--fg-4);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.net-detail-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 11px;
  margin-bottom: 2px;
}
.net-detail-col {
  font-size: 9.5px;
  font-family: var(--font-mono);
  padding: 0;
  background: none;
  border: none;
}
.net-detail-col.out  { color: oklch(0.78 0.12 60); }
.net-detail-col.in   { color: oklch(0.73 0.10 175); }
.net-detail-col.other { color: var(--fg-2); }
.net-detail-arrow { font-size: 9px; color: var(--fg-4); flex-shrink: 0; }
.net-detail-soft {
  font-size: 9px;
  color: var(--fg-4);
  flex-shrink: 0;
  title: "soft join";
}
.net-detail-note {
  font-size: 9px;
  color: var(--fg-4);
  cursor: help;
  flex-shrink: 0;
}
