:root {
    --bg: #0f1117;
    --bg-card: #1a1d28;
    --bg-input: #262936;
    --border: #2e3140;
    --text: #e6e8f0;
    --text-dim: #8b8fa3;
    --accent: #6c7bff;
    --accent-hover: #8590ff;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 6px;
    --font-mono: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --type-numeric: #5eead4;
    --type-timestamp: #fbbf24;
    --type-boolean: #c084fc;
    --type-text: #94a3b8;
    --profile-cat: #7c8fd9;
    --profile-val: #e2e8f0;
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #3a3d50 var(--bg);
  }
  
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: #3a3d50; border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: #4a4e64; }
  ::-webkit-scrollbar-corner { background: var(--bg); }
  
  html, body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100%;
  }
  
  h1 { font-size: 1.6rem; font-weight: 600; margin-bottom: 0.5rem; }
  h2 { font-size: 1.2rem; font-weight: 600; margin: 1.2rem 0 0.5rem; color: var(--text); }
  h3 { font-size: 1rem; font-weight: 600; margin: 0.8rem 0 0.3rem; color: var(--text-dim); }
  
  a { color: var(--accent); text-decoration: none; }
  a:hover { color: var(--accent-hover); }
  
  .container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  .container > #mainTabs:not(.hidden) {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .container > #mainTabs:not(.hidden) > .tabs {
    flex: 0 0 auto;
  }
  
  /* Header */
  .header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
  }
  .header h1 { margin-bottom: 0.25rem; }
  .header p { color: var(--text-dim); font-size: 0.85rem; }
  
  /* File upload */
  .upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 1rem;
  }
  .upload-zone:hover,
  .upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(108, 123, 255, 0.05);
  }
  .upload-zone input[type="file"] { display: none; }
  .upload-zone .label { color: var(--text-dim); font-size: 0.9rem; }
  .upload-zone .label strong { color: var(--text); }
  
  .file-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
  }
  .file-tag {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-dim);
  }
  .file-tag .remove {
    cursor: pointer;
    margin-left: 0.4rem;
    color: var(--error);
  }
  
  /* Output Mode selector */
  .output-mode-section {
    margin-bottom: 1rem;
  }
  .output-mode-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
  }
  .output-mode-options {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
  }
  .output-mode-card {
    flex: 1 1 0;
    min-width: 220px;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  }
  .output-mode-card:hover {
    border-color: var(--accent);
    background: rgba(108, 123, 255, 0.04);
  }
  .output-mode-card:has(input:checked) {
    border-color: var(--accent);
    background: rgba(108, 123, 255, 0.08);
    box-shadow: 0 0 0 1px var(--accent);
  }
  .output-mode-card input[type="radio"] {
    accent-color: var(--accent);
    margin-top: 0.2rem;
    flex-shrink: 0;
  }
  .output-mode-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
  }
  .output-mode-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.35;
  }
  .output-mode-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.08rem 0.4rem;
    border-radius: 3px;
    background: rgba(108, 123, 255, 0.15);
    color: var(--accent);
    vertical-align: middle;
    margin-left: 0.3rem;
  }
  .output-mode-desc {
    font-size: 0.76rem;
    color: var(--text-dim);
    line-height: 1.45;
  }
  
  /* Buttons */
  button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }
  button:hover { background: var(--border); }
  button:disabled { opacity: 0.4; cursor: not-allowed; }
  
  .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
  }
  .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn-primary:disabled { background: var(--accent); }
  
  .btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
  
  /* Tabs */
  .tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    gap: 0;
  }
  .tab-btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.15s, border-color 0.15s;
  }
  .tab-btn:hover { color: var(--text); }
  .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
  
  .tab-content { display: none; }
  .tab-content.active { display: block; }
  
  /* Active tab fills space below the tab bar (full-height app layout) */
  #mainTabs:not(.hidden) > .tab-content.active {
    flex: 1 1 auto;
    min-height: 0;
  }
  #tab-analysis.tab-content.active {
    overflow-y: auto;
  }
  
  /* Query Explorer: section 4 uses most of the viewport; results scroll inside the card */
  #tab-explorer.tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  #tab-explorer.tab-content.active > h2,
  #tab-explorer.tab-content.active > .card:not(.query-card) {
    flex: 0 0 auto;
  }
  #tab-explorer.tab-content.active > .query-card {
    flex: 1 1 auto;
    min-height: min(72dvh, 820px);
    display: flex;
    flex-direction: column;
  }
  
  /* Tables */
  .data-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 420px;
    margin: 0.5rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
  }
  table.data-table th {
    background: var(--bg-input);
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
  }
  table.data-table td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  table.data-table tr:hover td { background: rgba(108, 123, 255, 0.04); }
  
  .quality-bar {
    display: inline-block;
    height: 6px;
    border-radius: 3px;
    background: var(--accent);
    min-width: 2px;
  }
  .conflict-tag {
    background: var(--error);
    color: #fff;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
  }
  
  /* Cards / sections */
  .card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.5rem;
  }
  /* Explorer cards get a tighter bottom gap -- the section heading provides the breathing room */
  #tab-explorer > .card {
    margin-bottom: 0;
  }
  
  /* Progress */
  .progress-bar-wrap {
    background: var(--bg-input);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
    margin: 0.5rem 0;
  }
  .progress-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
    border-radius: 4px;
  }
  #progressText { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.2rem; }
  
  /* ---- Explorer section headings ----------------------------------------- */
  .explorer-section-heading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 1.75rem 0 0.6rem;
    padding: 0.5rem 0.85rem 0.5rem 0.7rem;
    background: linear-gradient(
      90deg,
      color-mix(in srgb, var(--accent) 12%, transparent) 0%,
      transparent 70%
    );
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
  }
  /* Remove top margin for the very first section */
  #tab-explorer > .explorer-section-heading:first-child {
    margin-top: 0.25rem;
  }
  .section-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
    line-height: 1;
  }
  .section-optional {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-dim);
    letter-spacing: 0.03em;
  }
  
  /* ---- Results table dual scroll ----------------------------------------- */
  .results-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg-input);
    cursor: col-resize;
  }
  .results-scroll-top::-webkit-scrollbar {
    height: 6px;
  }
  .results-scroll-top::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
    opacity: 0.7;
  }
  /* When top scroll bar is present, flatten the top of the table */
  .results-scroll-top:not(.hidden) + .results-table-wrap {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }
  
  /* Explorer section */
  .join-checkbox { margin: 0.3rem 0; display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; flex-wrap: wrap; }
  .join-checkbox input[type="checkbox"] { accent-color: var(--accent); }
  .join-subheading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 0.6rem 0 0.25rem;
  }
  .join-checkbox.join-custom .join-remove {
    margin-left: auto;
    padding: 0.15rem 0.45rem;
    font-size: 0.72rem;
  }
  .join-safety-alerts {
    margin-top: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--card) 85%, transparent);
    padding: 0.45rem 0.55rem;
  }
  .join-safety-block {
    padding-top: 0.3rem;
  }
  .join-safety-rationale {
    margin: 0.15rem 0 0.2rem;
    line-height: 1.35;
  }
  .join-safety-refs {
    margin-top: 0.15rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
  }
  .custom-join-form {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.35rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .custom-join-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
  }
  .custom-join-row label { min-width: 2.5rem; }
  .custom-join-select {
    flex: 1;
    min-width: 120px;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.8rem;
  }
  .mb-05 { margin-bottom: 0.35rem; }
  .mt-05 { margin-top: 0.35rem; }
  
  .explorer-grid {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  .explorer-col {
    min-width: 170px;
    max-width: 220px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem;
    background: var(--bg-card);
  }
  .explorer-col .col-name { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; word-break: break-all; }
  .explorer-col .sample-val {
    font-size: 0.75rem;
    color: var(--profile-val);
    font-family: var(--font-mono);
  }
  .explorer-col .profile-stat { font-size: 0.75rem; color: var(--text-dim); }
  .explorer-col .profile-stat strong:not(.explorer-cat-label) { color: var(--profile-val); }
  
  .explorer-col select,
  .explorer-col input[type="checkbox"] {
    accent-color: var(--accent);
  }
  .explorer-col select {
    width: 100%;
    padding: 0.25rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 0.78rem;
  }
  
  /* Expander / collapsible */
  .expander {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
  }
  .expander-header {
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
  }
  .expander-header .arrow { transition: transform 0.2s; display: inline-block; }
  .expander.open .expander-header .arrow { transform: rotate(90deg); }
  .expander-body { display: none; padding: 0.8rem; }
  .expander.open .expander-body { display: block; }
  
  /* Query layout -- 3-panel (fills remaining height in section 4) */
  .query-card {
    padding: 0.6rem;
  }
  .query-card > .flex-gap {
    flex: 0 0 auto;
  }
  .query-card > .query-layout {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 0.5rem;
  }
  .query-layout {
    display: flex;
    align-items: stretch;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 0;
    max-height: none;
  }
  
  /* Left sidebar: field list (Query tab) */
  .fields-sidebar {
    width: 200px;
    min-width: 170px;
    flex-shrink: 0;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    min-height: 0;
    align-self: stretch;
    padding: 0.5rem 0;
  }
  .sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    padding: 0.3rem 0.6rem;
    text-transform: uppercase;
  }
  .fields-list { padding: 0; }
  .field-group-header {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    padding: 0.35rem 0.6rem 0.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    user-select: none;
  }
  .field-group-header:hover { color: var(--accent-hover); }
  .field-group-header .arrow {
    display: inline-block;
    transition: transform 0.15s;
    font-size: 0.65rem;
  }
  .field-group-header.collapsed .arrow { transform: rotate(-90deg); }
  .field-group-items { padding: 0; }
  .field-group-header.collapsed + .field-group-items { display: none; }
  .field-item {
    font-size: 0.78rem;
    font-family: var(--font-mono);
    padding: 0.2rem 0.6rem 0.2rem 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.3rem;
    color: var(--text);
    transition: background 0.1s;
  }
  .field-item:hover { background: rgba(108, 123, 255, 0.08); }
  .field-item .field-type {
    font-size: 0.65rem;
    background: var(--bg-input);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    white-space: nowrap;
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid var(--border);
  }
  .field-type.field-type--numeric { color: var(--type-numeric); border-color: rgba(94, 234, 212, 0.35); }
  .field-type.field-type--timestamp { color: var(--type-timestamp); border-color: rgba(251, 191, 36, 0.35); }
  .field-type.field-type--boolean { color: var(--type-boolean); border-color: rgba(192, 132, 252, 0.35); }
  .field-type.field-type--text { color: var(--type-text); border-color: rgba(148, 163, 184, 0.35); }
  
  /* Center main area */
  .query-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .query-editor-results-split {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .editor-pane {
    flex: 0 0 clamp(140px, 22vh, 220px);
    min-height: 120px;
    max-height: 48%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .editor-pane .editor-container {
    flex: 1 1 auto;
    min-height: 100px;
    max-height: none;
    border-bottom: none;
  }
  .query-split-handle {
    flex: 0 0 10px;
    cursor: row-resize;
    background: linear-gradient(180deg, #2e3140 0%, #3d4154 50%, #2e3140 100%);
    position: relative;
    touch-action: none;
    flex-shrink: 0;
  }
  .query-split-handle:hover,
  .query-split-handle:focus {
    outline: none;
    background: linear-gradient(180deg, #4a5080 0%, #6c7bff 50%, #4a5080 100%);
    opacity: 1;
  }
  .query-split-handle::after {
    content: "";
    position: absolute;
    left: 10%;
    right: 10%;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.22);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  }
  .query-bottom-pane {
    flex: 1 1 55%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 0.6rem 0.5rem;
  }
  .query-bottom-pane > #warningsPanel {
    flex: 0 0 auto;
    padding-top: 0.35rem;
  }
  .results-section-wrap:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  .results-section-wrap:not(.hidden) .data-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    margin-bottom: 0;
  }
  
  /* Highlighted SQL editor overlay */
  .editor-container {
    position: relative;
    min-height: 180px;
    max-height: 300px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
  }
  .query-main .editor-container {
    max-height: none;
  }
  .editor-container .highlight-layer,
  .editor-container .edit-layer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    margin: 0;
    padding: 0.6rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: auto;
    border: none;
    border-radius: 0;
  }
  .editor-container .highlight-layer {
    pointer-events: none;
    z-index: 1;
    background: transparent;
    color: var(--text);
  }
  .editor-container .highlight-layer code {
    font-family: inherit;
    font-size: inherit;
    background: none !important;
    padding: 0 !important;
    white-space: pre-wrap;
  }
  .editor-container .edit-layer {
    z-index: 2;
    background: transparent;
    color: transparent;
    caret-color: var(--text);
    resize: none;
    outline: none;
    width: 100%;
    height: 100%;
    min-height: 180px;
  }
  .editor-container .edit-layer::selection {
    background: rgba(108, 123, 255, 0.25);
    color: transparent;
  }
  
  /* Override Prism tomorrow theme background inside our editor */
  .editor-container .highlight-layer[class*="language-"],
  .editor-container .highlight-layer code[class*="language-"] {
    background: none !important;
    text-shadow: none !important;
  }
  
  /* Right panel: column profile */
  .column-profile-panel {
    width: 250px;
    min-width: 220px;
    flex-shrink: 0;
    background: var(--bg);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    min-height: 0;
    align-self: stretch;
    padding: 0.5rem 0;
  }
  .profile-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.6rem;
  }
  .btn-close-profile {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: var(--radius);
  }
  .btn-close-profile:hover { color: var(--error); border-color: var(--error); }
  .profile-col-name {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.2rem 0.6rem 0.5rem;
    word-break: break-all;
    color: var(--accent);
  }
  .profile-stats { padding: 0 0.6rem; }
  .profile-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid rgba(46, 49, 64, 0.5);
  }
  .profile-stat-row .stat-label {
    color: var(--profile-cat);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .profile-stat-row .stat-value {
    color: var(--profile-val);
    font-family: var(--font-mono);
    font-weight: 600;
  }
  .profile-stat-kv {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
    padding: 0.12rem 0;
    border-bottom: 1px solid rgba(46, 49, 64, 0.45);
  }
  .profile-stat-cat {
    color: var(--profile-cat);
    font-weight: 600;
    flex-shrink: 0;
  }
  .profile-stat-val {
    color: var(--profile-val);
    font-family: var(--font-mono);
    text-align: right;
    word-break: break-all;
  }
  .explorer-cat-label { color: var(--profile-cat); }
  
  /* Distribution bars */
  .profile-distribution { padding: 0 0.6rem; }
  .dist-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    margin: 0.25rem 0;
  }
  .dist-label {
    min-width: 70px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--profile-cat);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.68rem;
  }
  .dist-count {
    color: var(--profile-val);
    font-family: var(--font-mono);
    font-weight: 600;
    min-width: 2rem;
    text-align: right;
    font-size: 0.68rem;
  }
  .dist-bar-wrap {
    flex: 1;
    height: 10px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
  }
  .dist-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
  }
  
  /* Results toolbar (meta + clear filters + columns) */
  .results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
  }
  .results-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
  }
  .btn-results-clear {
    border-color: var(--warning);
    color: var(--warning);
    background: transparent;
  }
  .btn-results-clear:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: var(--warning);
    color: var(--warning);
  }
  
  /* Result table column headers: controls on top, name below */
  table.data-table th.result-col-th {
    user-select: none;
    vertical-align: top;
    padding: 0.45rem 0.5rem;
    min-width: 4.5rem;
    max-width: 14rem;
    white-space: normal;
    text-align: left;
  }
  .result-col-hdr-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    min-width: 0;
  }
  .result-col-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    flex-shrink: 0;
  }
  .btn-col-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
  }
  .btn-col-icon:hover {
    color: var(--text);
    border-color: var(--text-dim);
    background: var(--border);
  }
  .btn-col-icon .col-act-svg {
    display: block;
    pointer-events: none;
  }
  .sort-glyph .sort-up-shape,
  .sort-glyph .sort-down-shape {
    fill: var(--text-dim);
    opacity: 0.45;
  }
  .btn-col-sort:hover .sort-up-shape,
  .btn-col-sort:hover .sort-down-shape {
    opacity: 0.75;
  }
  .btn-col-sort[data-sort-state="asc"] .sort-up-shape {
    fill: var(--success);
    opacity: 1;
  }
  .btn-col-sort[data-sort-state="asc"] .sort-down-shape {
    fill: var(--text-dim);
    opacity: 0.2;
  }
  .btn-col-sort[data-sort-state="desc"] .sort-down-shape {
    fill: var(--success);
    opacity: 1;
  }
  .btn-col-sort[data-sort-state="desc"] .sort-up-shape {
    fill: var(--text-dim);
    opacity: 0.2;
  }
  .btn-col-filter.is-active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(108, 123, 255, 0.12);
  }
  .result-col-title {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    line-height: 1.35;
    transition: color 0.15s;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: left;
  }
  .result-col-title:hover { color: var(--accent); }
  table.data-table th.result-col-th.has-col-filter {
    box-shadow: inset 0 -1px 0 0 rgba(108, 123, 255, 0.35);
  }
  table.data-table th.result-col-th.active .result-col-title {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 0 var(--accent);
  }
  
  /* Columns visibility popover */
  .results-columns-popover {
    min-width: 240px;
    max-width: min(320px, calc(100vw - 16px));
    max-height: min(70vh, 420px);
    overflow-y: auto;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
  .results-columns-popover.hidden { display: none !important; }
  .results-columns-popover:not(.hidden) { display: block; }
  .results-columns-popover-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text);
  }
  .results-columns-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.55rem;
  }
  .results-columns-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: var(--font-mono);
    word-break: break-all;
  }
  .results-columns-row input { accent-color: var(--accent); }
  .results-columns-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .results-columns-actions .btn-sm { flex: 1; min-width: 72px; }
  
  /* Legacy: analysis tables with plain clickable headers */
  table.data-table th.result-col-hdr {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
  }
  table.data-table th.result-col-hdr:hover { color: var(--accent); }
  table.data-table th.result-col-hdr.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
  }
  
  /* Popover: filter column in results */
  .results-filter-popover {
    min-width: 220px;
    max-width: min(320px, calc(100vw - 16px));
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
  .results-filter-popover.hidden { display: none !important; }
  .results-filter-popover:not(.hidden) { display: block; }
  .results-filter-popover-title {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.45rem;
    color: var(--accent);
    word-break: break-all;
  }
  .results-filter-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin: 0.35rem 0 0.2rem;
  }
  .results-filter-op,
  .results-filter-val {
    width: 100%;
    font-size: 0.8rem;
  }
  .results-filter-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.55rem;
    flex-wrap: wrap;
  }
  .results-filter-actions .btn-sm { flex: 1; min-width: 72px; }
  
  /* Warnings */
  .alert { padding: 0.6rem 0.8rem; border-radius: var(--radius); margin: 0.4rem 0; font-size: 0.82rem; }
  .alert-warning { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); color: var(--warning); }
  .alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--error); }
  .alert-info { background: rgba(108, 123, 255, 0.1); border: 1px solid rgba(108, 123, 255, 0.3); color: var(--accent); }
  
  /* Filters row */
  .filter-row { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin: 0.4rem 0; }
  .filter-row label { font-size: 0.8rem; color: var(--text-dim); display: block; margin-bottom: 0.2rem; }
  .filter-row select, .filter-row input[type="text"] {
    padding: 0.35rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 0.82rem;
  }
  .filter-row input[type="text"] { width: 200px; }
  .filter-row .btn-remove-filter {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    color: var(--error);
    border-color: var(--error);
    background: transparent;
  }
  .filter-row .btn-remove-filter:hover { background: rgba(239, 68, 68, 0.1); }
  .filter-row .logic-select {
    min-width: 60px;
  }
  
  /* Row count badge */
  .row-count {
    display: inline-block;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
  }
  
  /* General form elements */
  select, input[type="text"] {
    padding: 0.4rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--font-body);
  }
  select:focus, input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
  }
  label { cursor: pointer; }
  
  /* Save-context modal */
  .modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .modal-overlay.hidden { display: none !important; }
  .modal-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .modal-title {
    font-weight: 600;
    font-size: 0.95rem;
  }
  .modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
  }
  .modal-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
  }
  .modal-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
    resize: vertical;
    min-height: 60px;
  }
  .modal-textarea:focus {
    outline: none;
    border-color: var(--accent);
  }
  .context-preview {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.5;
  }
  .context-preview strong {
    color: var(--text);
  }
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--border);
  }
  
  /* Data Modeling & Structure cards */
  .modeling-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
  }
  .modeling-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    overflow: hidden;
  }
  .modeling-card-header {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    border-bottom: 1px solid var(--border);
  }
  .modeling-card-body {
    padding: 0.6rem 0.75rem;
  }
  .modeling-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    font-size: 0.82rem;
  }
  .modeling-label {
    color: var(--text-dim);
    min-width: 50px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
  }
  .modeling-value {
    flex: 1;
  }
  .modeling-confidence {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
  }
  .modeling-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .modeling-badge-rule {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
  }
  .modeling-badge-ai {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
  }
  .modeling-badge-hybrid {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
  }
  .modeling-signals {
    font-size: 0.73rem;
    color: var(--text-dim);
    padding-top: 0.3rem;
    border-top: 1px solid var(--border);
    margin-top: 0.3rem;
  }
  .modeling-table-desc-cell {
    white-space: normal;
    max-width: 22rem;
    word-break: break-word;
    vertical-align: top;
    line-height: 1.35;
  }
  .modeling-description {
    padding-bottom: 0.45rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  }
  .modeling-desc-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.25rem;
  }
  .modeling-desc-text {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text);
    white-space: normal;
    word-break: break-word;
  }
  .modeling-explanation {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-style: italic;
    margin-top: 0.25rem;
  }
  
  /* Compact modeling summary for Query Explorer */
  .modeling-compact {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    padding: 0.25rem 0.5rem 0.25rem 1.6rem;
    color: var(--text-dim);
  }
  .modeling-compact-entity {
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
  }
  .modeling-compact-type {
    text-transform: capitalize;
  }
  .modeling-compact-sep {
    color: var(--text-dim);
    opacity: 0.5;
  }
  .modeling-compact-grain {
    font-family: var(--font-mono);
    font-size: 0.74rem;
  }
  
  /* LLM status notice */
  .modeling-llm-notice {
    grid-column: 1 / -1;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.25);
    color: #fbbf24;
    margin-bottom: 0.5rem;
  }
  .modeling-llm-notice.modeling-llm-ok {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.25);
    color: #34d399;
  }
  
  /* Tab badge */
  .tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    margin-left: 0.35rem;
    vertical-align: middle;
  }
  .tab-badge.hidden { display: none !important; }
  
  /* Saved context table */
  .ctx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
  }
  .ctx-table th,
  .ctx-table td {
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  .ctx-table th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-input);
    position: sticky;
    top: 0;
  }
  .ctx-table tr:hover td { background: rgba(108, 123, 255, 0.04); }
  .ctx-sql-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.78rem;
  }
  .ctx-empty {
    color: var(--text-dim);
    font-size: 0.82rem;
    padding: 2rem;
    text-align: center;
  }
  
  /* ERD diagram */
  .erd-container {
    background: var(--bg);
    border-radius: var(--radius);
    overflow-x: auto;
  }
  .erd-container svg {
    display: block;
  }
  .erd-table-rect {
    fill: var(--bg-input);
    stroke: var(--border);
    stroke-width: 1.5;
    rx: 5;
    ry: 5;
  }
  .erd-table-header-rect {
    fill: var(--accent);
    rx: 5;
    ry: 5;
  }
  .erd-table-header-mask {
    fill: var(--accent);
  }
  .erd-table-name {
    fill: #fff;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 12px;
  }
  .erd-col-text {
    fill: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
  }
  .erd-col-type {
    fill: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 10px;
  }
  .erd-col-key {
    fill: var(--warning);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
  }
  .erd-join-line {
    stroke: var(--accent);
    stroke-width: 1.5;
    fill: none;
    opacity: 0.6;
  }
  .erd-join-line:hover {
    stroke-width: 2.5;
    opacity: 1;
  }
  .erd-join-dot {
    fill: var(--accent);
    opacity: 0.8;
  }
  .erd-empty {
    color: var(--text-dim);
    font-size: 0.82rem;
    padding: 1.5rem;
    text-align: center;
  }
  
  /* Data Cleaning */
  .cleaning-sev {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  .sev-critical { background: #c0392b; color: #fff; }
  .sev-warning  { background: #e67e22; color: #fff; }
  .sev-info     { background: #2980b9; color: #fff; }
  
  .cleaning-sql {
    font-size: 0.75rem;
    background: var(--card);
    padding: 2px 5px;
    border-radius: 3px;
    word-break: break-all;
    white-space: pre-wrap;
  }
  
  .cleaning-suggestions {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    background: color-mix(in srgb, var(--card) 80%, transparent);
  }
  .cleaning-suggestions-title {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .cleaning-suggestion-row {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 2px 0;
    font-size: 0.78rem;
  }
  .cleaning-suggestion-block:hover .cleaning-suggestion-row {
    background: color-mix(in srgb, var(--accent) 6%, transparent);
  }
  .cleaning-msg {
    flex: 1;
    line-height: 1.35;
  }
  .cleaning-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }
  .cleaning-actions-cell {
    white-space: nowrap;
  }
  .cleaning-actions-wide {
    white-space: normal;
    min-width: 12rem;
    vertical-align: top;
  }
  
  .cleaning-suggestion-block {
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    padding-bottom: 0.35rem;
    margin-bottom: 0.35rem;
  }
  .cleaning-suggestion-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }
  
  .cleaning-explore {
    margin: 0.35rem 0 0.25rem 0;
    font-size: 0.75rem;
  }
  .cleaning-explore > summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    user-select: none;
  }
  .cleaning-explore-inline {
    margin-left: 0;
    margin-top: 0.25rem;
  }
  .cleaning-explore-inner {
    margin-top: 0.35rem;
    padding-left: 0.25rem;
    border-left: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  }
  .cleaning-explore-grp {
    margin-bottom: 0.5rem;
  }
  .cleaning-explore-grp-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
  }
  .cleaning-explore-btns {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }
  .cleaning-explore-btns .btn-cleaning-explore {
    text-align: left;
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
  }
  .cleaning-actions-block {
    margin-top: 0.25rem;
  }
  .btn-cleaning-explore {
    background: color-mix(in srgb, #2980b9 12%, var(--card));
    border-color: #2980b9;
    color: #7fb3d5;
  }
  .btn-cleaning-explore:hover {
    background: color-mix(in srgb, #2980b9 28%, var(--card));
  }
  .btn-cleaning {
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    background: var(--card);
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
  }
  .btn-cleaning:hover {
    border-color: var(--accent);
  }
  .btn-cleaning-analyse {
    background: color-mix(in srgb, #2980b9 15%, var(--card));
    border-color: #2980b9;
    color: #5dade2;
  }
  .btn-cleaning-analyse:hover {
    background: color-mix(in srgb, #2980b9 30%, var(--card));
  }
  .btn-cleaning-apply {
    background: color-mix(in srgb, #27ae60 15%, var(--card));
    border-color: #27ae60;
    color: #58d68d;
  }
  .btn-cleaning-apply:hover {
    background: color-mix(in srgb, #27ae60 30%, var(--card));
  }
  
  /* WebLLM option */
  .webllm-opt {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
  }
  .llm-preload-status {
    font-size: 0.72rem;
    font-style: italic;
    color: var(--text-dim);
    margin-left: 0.2rem;
  }
  .llm-preload-status.loading { color: var(--type-timestamp); }
  .llm-preload-status.ready   { color: var(--accent); }
  .llm-preload-status.error   { color: var(--danger); }
  
  /* ---- Context Download tab ------------------------------------------------ */
  
  .dbt-mode-label {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    vertical-align: middle;
    background: #1e3a2a;
    color: #6ee7b7;
    letter-spacing: 0.04em;
  }
  .dbt-mode-label[data-mode="metadata_only"] {
    background: #2d1f4e;
    color: #c084fc;
  }
  
  .dbt-download-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
  }
  
  .dbt-empty {
    color: var(--text-dim);
    font-size: 0.85rem;
    padding: 1.5rem 0;
  }
  
  .dbt-artifact-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .dbt-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
  }
  
  .dbt-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
  }
  
  .dbt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .dbt-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  .dbt-type-badge {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    flex-shrink: 0;
  }
  
  .dbt-type-yaml  { background: #1e3a5f; color: #7dd3fc; }
  .dbt-type-json  { background: #2d1f4e; color: #c084fc; }
  .dbt-type-markdown { background: #1e3a2a; color: #6ee7b7; }
  
  .dbt-filename {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
  }
  
  .dbt-size {
    font-size: 0.72rem;
    color: var(--text-dim);
    flex-shrink: 0;
  }
  
  .dbt-card-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.45;
    margin: 0;
  }
  
  .dbt-card-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.15rem;
  }
  
  .dbt-preview {
    margin-top: 0.4rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
  }
  
  .dbt-preview-pre {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    white-space: pre;
    overflow-x: auto;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg);
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
    line-height: 1.5;
  }
  
  /* Utility */
  .mt-1 { margin-top: 0.5rem; }
  .mt-2 { margin-top: 1rem; }
  .mb-1 { margin-bottom: 0.5rem; }
  .mb-05 { margin-bottom: 0.25rem; }
  .text-dim { color: var(--text-dim); }
  .text-sm { font-size: 0.8rem; }
  .flex-gap { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
  .hidden { display: none !important; }
  