/* Admin Database Explorer */
.dbx-head .page-sub { max-width: 760px; }
.dbx-shell { min-width: 0; }
.dbx-card-head { align-items: center; gap: 12px; flex-wrap: wrap; }
.dbx-context { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.dbx-context-label { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--bfc-muted); }

/* ─────────── Browse: master–detail split ─────────── */
.dbx-browse {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(460px, 1.5fr);
  gap: 18px;
  align-items: start;
}

/* Left rail sticks under the topbar so search + list stay reachable while a
   long detail/preview scrolls in the right pane. */
.dbx-rail {
  position: sticky;
  top: 72px;
  align-self: start;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  max-height: calc(100vh - 92px);
}
.dbx-rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dbx-rail-head h3 { margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 800; color: var(--bfc-navy); }
.dbx-search { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.dbx-field { display: grid; gap: 4px; font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--bfc-muted); min-width: 0; }
.dbx-field.inline { grid-auto-flow: column; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; }

.dbx-table-list-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--bfc-line);
  border-radius: 16px;
  background: var(--bfc-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.dbx-table-scroll { flex: 1 1 auto; overflow: auto; min-height: 140px; }
.dbx-table-list { display: flex; flex-direction: column; }
.dbx-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--bfc-line);
  border-left: 3px solid transparent;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background .1s ease;
}
.dbx-table-row:hover { background: var(--bfc-soft); }
.dbx-table-row.active { background: var(--bfc-soft-2); border-left-color: var(--bfc-indigo); }
.dbx-table-row:last-child { border-bottom: 0; }
.dbx-tr-main { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dbx-tr-main .code-chip { overflow: hidden; text-overflow: ellipsis; }
.dbx-tr-type { font-size: 11px; color: var(--bfc-muted); white-space: nowrap; }
.dbx-tr-meta { justify-self: end; color: var(--bfc-muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dbx-tr-text { grid-column: 1 / -1; color: var(--bfc-copy); font-size: 12.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbx-list-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--bfc-line);
  color: var(--bfc-muted);
  font-size: 12px;
  background: var(--bfc-soft);
}
.dbx-pager { display: inline-flex; gap: 6px; }

/* ─────────── Right pane (hints or table detail) ─────────── */
.dbx-pane {
  border: 1px solid var(--bfc-line);
  border-radius: 18px;
  background: var(--bfc-surface);
  box-shadow: var(--shadow-card);
  padding: 18px;
  min-width: 0;
  display: grid;
  gap: 14px;
  align-content: start;
}

/* hints empty-state */
.dbx-hints-pane { display: grid; gap: 14px; }
.dbx-hints-intro { display: flex; gap: 14px; align-items: center; }
.dbx-hints-glyph { font-size: 26px; line-height: 1; }
.dbx-hints-intro h3 { margin: 0 0 2px; font-family: var(--font-display); font-size: 17px; color: var(--bfc-navy); }
.dbx-hints-intro p { margin: 0; }
.dbx-hint-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.dbx-hint-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.dbx-hint-card { border: 1px solid var(--bfc-line); border-radius: 14px; background: var(--bfc-soft); padding: 12px; display: grid; gap: 8px; align-content: start; }
.dbx-hint-title { font-family: var(--font-display); font-weight: 800; color: var(--bfc-navy); }
.dbx-hint-why { color: var(--bfc-muted); font-size: 12.5px; line-height: 1.4; }
.dbx-hint-tables { display: flex; flex-wrap: wrap; gap: 6px; }
.dbx-hint-table { border: 0; cursor: pointer; }

/* detail */
.dbx-detail { display: grid; gap: 14px; min-width: 0; }
/* min-width:0 lets these grid items collapse to the column width so the wide
   result grid scrolls INSIDE .dbx-result-wrap instead of running off-screen. */
.dbx-detail-view, #dbxDetailView, #dbxPreviewResult, #dbxSqlResults, #dbxFindResults { min-width: 0; }
.dbx-detail-head {
  border-radius: 16px;
  padding: 16px 18px;
  color: #fff;
  background: radial-gradient(circle at top right, rgba(63, 83, 216, .22), transparent 40%), linear-gradient(135deg, var(--bfc-navy-deep), var(--bfc-navy) 55%, var(--bfc-indigo-dark));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}
.dbx-detail-id { min-width: 0; }
.dbx-detail-head .eyebrow { text-transform: uppercase; letter-spacing: .13em; font-size: 10.5px; font-weight: 900; opacity: .72; }
.dbx-detail-head h2 { margin: 4px 0 3px; font-family: var(--font-display); font-size: clamp(19px, 2.4vw, 25px); letter-spacing: -.02em; overflow-wrap: anywhere; }
.dbx-detail-head p { margin: 0; color: rgba(255, 255, 255, .78); font-size: 13px; }
.dbx-detail-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dbx-detail-stats span { border: 1px solid rgba(255, 255, 255, .24); background: rgba(255, 255, 255, .1); border-radius: 999px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.dbx-detail-stats b { font-variant-numeric: tabular-nums; }
.dbx-stat-skel { width: 84px; height: 28px; border-radius: 999px; background: rgba(255, 255, 255, .18); }

.dbx-detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dbx-detail-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(220px, .85fr); gap: 16px; align-items: start; }
.dbx-subpanel { display: grid; gap: 10px; min-width: 0; }
.dbx-cols-wrap { max-height: 460px; overflow: auto; border: 1px solid var(--bfc-line); border-radius: 12px; }
.dbx-cols { min-width: 420px; }
.dbx-cols th:nth-child(1) { width: 30%; }
.dbx-cols th:nth-child(2) { width: 22%; }
.dbx-cols th:nth-child(3) { width: 48%; }
.dbx-mini-stack { display: grid; gap: 14px; }
.dbx-mini-stack strong { display: block; margin-bottom: 4px; color: var(--bfc-navy); }
.dbx-mini-row { display: flex; justify-content: space-between; gap: 9px; border-top: 1px solid var(--bfc-line); padding-top: 7px; margin-top: 7px; color: var(--bfc-muted); font-size: 12.5px; }

/* preview controls + result grids */
.dbx-preview-controls { display: flex; gap: 10px 12px; align-items: flex-end; flex-wrap: wrap; }
.dbx-preview-controls .dbx-field.grow { flex: 1 1 180px; }
.dbx-preview-controls select, .dbx-preview-controls input { min-width: 110px; }
.dbx-preview-controls .dbx-field.grow input { min-width: 0; width: 100%; }
.dbx-preview-meta { min-height: 16px; }
.dbx-run-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dbx-run-hint { color: var(--bfc-muted); font-size: 12px; }

.dbx-result-wrap { max-width: 100%; max-height: 460px; overflow: auto; border: 1px solid var(--bfc-line); border-radius: 12px; }
.dbx-results { table-layout: auto; }
.dbx-result-wrap table.data thead th { position: sticky; top: 0; z-index: 1; }
/* Data grid = spreadsheet: one line per value, ellipsis when it's too long
   (full value on hover via the cell title), horizontal scroll for wide/
   many-column result sets. NEVER wrap mid-character — that turns a 33-column
   table into unreadable vertical text. */
table.data.dbx-results th,
table.data.dbx-results td {
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
/* Schema table: the Text/description column word-wraps (at spaces, never
   mid-word) so long column descriptions stay readable. */
table.data.dbx-cols th,
table.data.dbx-cols td { white-space: normal; overflow-wrap: break-word; word-break: normal; vertical-align: top; }

/* SQL + Find consoles */
.dbx-console { padding: 18px 22px; display: grid; gap: 16px; }
.dbx-sql-text { width: 100%; min-height: 200px; resize: vertical; font-family: var(--font-mono); font-size: 13px; line-height: 1.45; padding: 12px 14px; border: 1px solid var(--bfc-line-strong); border-radius: 12px; background: var(--bfc-surface); color: var(--bfc-ink); }
.dbx-sql-text:focus { outline: none; border-color: var(--bfc-teal); box-shadow: 0 0 0 3px rgba(35, 177, 165, 0.18); }
.dbx-find-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* shared: empty / loading / error */
.pane-note.danger { color: var(--bfc-danger-text); }
.mini-empty { border: 1px dashed var(--bfc-line-strong); border-radius: 14px; padding: 16px; color: var(--bfc-muted); background: var(--bfc-soft); font-size: 13px; margin: 12px; }
.dbx-skel-list { display: grid; gap: 8px; padding: 12px; }
.dbx-skel-row { height: 46px; border-radius: 10px; }
.dbx-error { padding: 28px 22px; text-align: center; display: grid; gap: 8px; justify-items: center; color: var(--bfc-muted); }
.dbx-error-glyph { font-size: 24px; color: var(--bfc-danger-text); line-height: 1; }
.dbx-error-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--bfc-navy); }
.dbx-error-msg { font-size: 13px; max-width: 460px; overflow-wrap: anywhere; }

@media (max-width: 1050px) {
  .dbx-browse { grid-template-columns: 1fr; }
  .dbx-rail { position: static; max-height: none; }
  .dbx-table-scroll { max-height: 420px; }
  .dbx-detail-grid { grid-template-columns: 1fr; }
  .dbx-detail-head { flex-direction: column; align-items: flex-start; }
  .dbx-detail-stats { justify-content: flex-start; }
}
@media (max-width: 700px) {
  .dbx-browse, .dbx-console { padding: 14px; }
  .dbx-search { grid-template-columns: 1fr; }
  .dbx-hint-search { grid-template-columns: 1fr; }
}
