/* ═══════════════════════════════════════════════════════════
   R4XN Dashboard AI — Main Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── Custom Properties ────────────────────────────────────── */
:root {
  --bg-base:        #f4f6fb;
  --bg-surface:     #ffffff;
  --bg-elevated:    #eef0f8;
  --bg-hover:       #e6e9f5;
  --border:         #e2e6f0;
  --border-strong:  #c8cedf;

  --text-primary:   #0f1221;
  --text-secondary: #4b5675;
  --text-muted:     #8892a8;
  --text-inverse:   #ffffff;

  --accent:         #6366f1;
  --accent-hover:   #5254e0;
  --accent-soft:    rgba(99, 102, 241, 0.10);
  --accent-glow:    rgba(99, 102, 241, 0.25);

  --green:          #16a34a;
  --red:            #dc2626;
  --amber:          #d97706;
  --blue:           #2563eb;
  --purple:         #9333ea;
  --cyan:           #0891b2;

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.07),0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 4px 16px rgba(0,0,0,.08),0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:      0 8px 32px rgba(99,102,241,.12),0 2px 8px rgba(0,0,0,.07);

  --font-head:      'Poppins', system-ui, sans-serif;
  --font:           'Inter', system-ui, sans-serif;
  --mono:           'JetBrains Mono', 'Fira Code', monospace;

  --transition:     150ms ease;
  --topbar-h:       56px;
  --stepnav-h:      52px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-family: var(--font-head); font-size: 2rem;   font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
h2 { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-family: var(--font-head); font-size: 1.1rem; font-weight: 600; }
p  { color: var(--text-secondary); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.link-btn {
  background: none; border: none; font-family: var(--font);
  color: var(--accent); cursor: pointer; font-size: inherit;
  text-decoration: underline; padding: 0;
}
.link-btn:hover { color: var(--accent-hover); }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.spinner-dark {
  border-color: rgba(0,0,0,.15);
  border-top-color: var(--accent);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.topbar-brand {
  display: flex; align-items: center; gap: 10px;
}
.topbar-logo { width: 28px; height: 28px; flex-shrink: 0; }
.topbar-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ── Step Nav ─────────────────────────────────────────────── */
.step-nav {
  height: var(--stepnav-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 24px;
}

.step-item {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted);
  font-size: 12px; font-weight: 500;
  transition: color var(--transition);
}
.step-item.active { color: var(--text-primary); }
.step-item.done   { color: var(--green); }

.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.step-item.active .step-num {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.step-item.done .step-num {
  background: var(--green); border-color: var(--green); color: #fff;
}

.step-divider {
  width: 40px; height: 1px;
  background: var(--border);
  margin: 0 8px;
}

/* ── Step Views ───────────────────────────────────────────── */
.step-view {
  display: none;
  min-height: calc(100vh - var(--topbar-h) - var(--stepnav-h));
  padding: 40px 24px;
  max-width: 900px;
  margin: 0 auto;
}
.step-view.active { display: block; }
.step-view--full {
  max-width: 100%;
  padding: 0;
}

/* ── Upload Step ──────────────────────────────────────────── */
.upload-hero {
  text-align: center;
  margin-bottom: 36px;
}
.upload-title { margin-bottom: 10px; }
.upload-sub { font-size: 15px; }

.upload-card {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-card:hover,
.upload-card.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,.05);
  box-shadow: 0 0 0 4px rgba(99,102,241,.08);
}
.upload-card.drag-over { transform: scale(1.01); }

.drop-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(139,92,246,.12));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--accent);
  box-shadow: 0 4px 16px rgba(99,102,241,.15);
}
.drop-icon svg { width: 40px; height: 40px; }

.drop-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.drop-sub   { margin-bottom: 8px; }
.drop-types { font-size: 12px; color: var(--text-muted); }

.upload-progress {
  margin-top: 24px;
  text-align: center;
}
.progress-bar-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}
.progress-label { margin-top: 8px; font-size: 13px; color: var(--text-muted); }

.upload-error {
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
}

/* ── Mapping Step ─────────────────────────────────────────── */
.section-header { margin-bottom: 24px; }
.section-title  { margin-bottom: 6px; }
.section-sub    { font-size: 13px; }

.mapping-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.meta-chip {
  padding: 4px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}
.meta-chip strong { color: var(--text-primary); }

.mapping-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mapping-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.mapping-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.mapping-table tbody tr:last-child td { border-bottom: none; }
.mapping-table tbody tr { background: var(--bg-surface); }
.mapping-table tbody tr:hover { background: var(--bg-elevated); }

.col-name {
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
}

.type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.type-badge--numeric     { background: rgba(22,163,74,.12);  color: #15803d; }
.type-badge--date        { background: rgba(37,99,235,.12);  color: #1d4ed8; }
.type-badge--categorical { background: rgba(147,51,234,.12); color: #7e22ce; }

.type-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.type-select:focus { border-color: var(--accent); }

.sample-values {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--mono);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-stat {
  font-size: 11px;
  color: var(--text-muted);
}

.mapping-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px;
}

/* ── Generating Step ──────────────────────────────────────── */
#step-generating {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#step-generating.active { display: flex; }

.generating-wrap { text-align: center; max-width: 400px; }

.generating-animation {
  position: relative;
  width: 100px; height: 100px;
  margin: 0 auto 32px;
  display: flex; align-items: center; justify-content: center;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}
.pulse-ring--2 { animation-delay: 0.6s; }
.pulse-ring--3 { animation-delay: 1.2s; }

@keyframes pulse {
  0%   { transform: scale(.6); opacity: .7; }
  100% { transform: scale(1.4); opacity: 0; }
}

.generating-icon {
  width: 40px; height: 40px;
  color: var(--accent);
  animation: slow-spin 4s linear infinite;
}
@keyframes slow-spin { to { transform: rotate(360deg); } }

.generating-title { font-size: 1.4rem; margin-bottom: 8px; }
.generating-sub   { margin-bottom: 24px; }

.generating-steps { text-align: left; }
.gen-step {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.gen-step.done    { color: var(--green); }
.gen-step.active  { color: var(--text-primary); }
.gen-step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
  transition: background var(--transition);
}
.gen-step.done .gen-step-dot   { background: var(--green); }
.gen-step.active .gen-step-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ── Dashboard Step ───────────────────────────────────────── */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}
.dashboard-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dashboard-title-text { font-size: 16px; font-weight: 700; }
.dashboard-row-count { font-size: 12px; color: var(--text-muted); }

.dashboard-toolbar-actions { display: flex; align-items: center; gap: 8px; }

.dashboard-canvas {
  padding: 16px;
  min-height: calc(100vh - var(--topbar-h) - var(--stepnav-h) - 56px);
}

/* ── Grid Stack Overrides ─────────────────────────────────── */
.grid-stack-item-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.grid-stack-item.ui-resizable-se .ui-resizable-handle {
  right: 4px; bottom: 4px;
}
.grid-stack.layout-editing .grid-stack-item-content {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.grid-stack.layout-editing .grid-stack-item > .grid-stack-item-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  z-index: 2;
  pointer-events: none;
}

/* ── Module Cards ─────────────────────────────────────────── */
.module-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.module-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.module-type-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

.module-body {
  flex: 1;
  padding: 12px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* KPI Module */
.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); }
.kpi-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.08;
  color: var(--accent);
}
.kpi-icon svg { width: 56px; height: 56px; }

/* Chart canvas wrapper */
.chart-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}
.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Table Module */
.module-table-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.module-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.module-table th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.module-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.module-table tbody tr:hover { background: var(--bg-elevated); }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 11px;
  color: var(--text-muted);
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Error state */
.module-error {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  color: var(--red);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; z-index: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  min-width: 360px;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}
.modal-title { margin-bottom: 6px; }
.modal-sub   { font-size: 13px; margin-bottom: 16px; }
.modal-close { width: 100%; margin-top: 12px; justify-content: center; }

.share-link-row { display: flex; gap: 8px; }
.share-link-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
}
.share-link-input:focus { border-color: var(--accent); }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  animation: slide-in 0.2s ease;
  max-width: 320px;
}
.toast--success { border-color: var(--green); }
.toast--error   { border-color: var(--red);   }
.toast--info    { border-color: var(--accent); }

@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } }
@keyframes slide-out { to   { transform: translateX(110%); opacity: 0; } }
.toast.leaving { animation: slide-out 0.2s ease forwards; }

/* ── Phase 2 — Semantic Model Review ─────────────────────── */

.model-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 8px;
}
.model-header-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 4px; }

.model-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: capitalize;
}
.model-badge--type { background: rgba(99,102,241,.12); color: var(--accent); }
.model-badge--conf { background: rgba(22,163,74,.12);  color: #15803d; }
.model-badge--info { background: var(--bg-elevated);   color: var(--text-secondary); }
.model-badge--warn { background: rgba(239,68,68,.10);  color: #dc2626; }

/* Loading */
.model-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px;
  padding: 80px 0;
}
.model-loading-inner {
  position: relative; width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.model-loading-icon {
  width: 28px; height: 28px; color: var(--accent);
  animation: slow-spin 2s linear infinite;
}

/* Sections */
.model-section { margin-bottom: 32px; }
.model-section-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Warnings */
.model-warning {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 8px;
}
.model-warning--warning { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25); color: #92400e; }
.model-warning--error   { background: rgba(239,68,68,.08);  border: 1px solid rgba(239,68,68,.25);  color: #991b1b; }
.model-warning--info    { background: rgba(99,102,241,.06); border: 1px solid rgba(99,102,241,.18); color: var(--text-secondary); }
.model-warning-icon     { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
#model-warnings         { margin-bottom: 24px; }

/* Table cards */
.model-tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.model-table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.model-table-card:hover { box-shadow: var(--shadow); }

.model-table-header {
  padding: 14px 16px 10px;
  background: var(--bg-elevated);
}
.model-table-name-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.model-table-icon { font-size: 14px; }
.model-table-name { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.model-table-meta { display: flex; align-items: center; justify-content: space-between; }
.model-table-rows { font-size: 11px; color: var(--text-muted); }

.model-table-role-row {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.model-role-select {
  width: 100%; background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 5px 8px; font-size: 12px;
  font-family: var(--font); cursor: pointer; outline: none;
}
.model-role-select:focus { border-color: var(--accent); }

.model-table-cols { padding: 10px 16px 14px; }
.model-col-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0;
  font-size: 11px;
}
.model-col-icon  { width: 14px; text-align: center; flex-shrink: 0; }
.model-col-name  { flex: 1; color: var(--text-primary); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-col-type  { color: var(--text-muted); font-size: 10px; }
.model-col-more  { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Relationship list */
.model-rel-list { display: flex; flex-direction: column; gap: 8px; }
.model-rel-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px; flex-wrap: wrap;
}
.model-rel-row--m2m {
  border-color: rgba(239,68,68,.3);
  background: rgba(239,68,68,.03);
}
.model-rel-tables { display: flex; align-items: center; gap: 2px; }
.model-rel-table  { font-weight: 600; color: var(--text-primary); }
.model-rel-col    { color: var(--text-muted); }
.model-rel-arrow  { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 120px; }
.model-rel-line   { width: 40px; height: 8px; color: var(--border-strong); }

.model-card-badge {
  padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700;
  white-space: nowrap;
}
.model-conf-badge {
  padding: 2px 7px; border-radius: 10px; font-size: 10px; font-weight: 700;
  color: var(--text-secondary); white-space: nowrap;
}
.model-tag {
  padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 600;
  background: var(--bg-elevated); color: var(--text-muted); text-transform: uppercase;
}
.model-tag--virtual { background: rgba(6,182,212,.12); color: #0e7490; }

/* Measures */
.model-measures-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.model-measure-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; font-size: 12px; font-weight: 500;
  transition: border-color var(--transition), background var(--transition);
}
.model-measure-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.model-measure-chip input { accent-color: var(--accent); }
.model-measure-chip:has(input:checked) {
  border-color: rgba(99,102,241,.4);
  background: rgba(99,102,241,.06);
}
.model-measure-name { color: var(--text-primary); }
.model-measure-fmt  { margin-left: 2px; }

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.font-mono   { font-family: var(--mono); }

/* Layout editing mode indicator */
.layout-editing-banner {
  position: fixed;
  top: calc(var(--topbar-h) + var(--stepnav-h));
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 6px 16px;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 12px;
  font-weight: 600;
  z-index: 50;
  display: none;
}
.layout-editing-banner.visible { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Computed Columns ─────────────────────────────────────── */
.computed-section {
  margin: 24px 0 8px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}
.computed-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.computed-title {
  font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0 0 2px;
}
.computed-sub {
  font-size: 12px; color: var(--text-muted); margin: 0;
}
.computed-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.computed-name {
  flex: 0 0 160px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--body);
}
.computed-name:focus { outline: none; border-color: var(--accent); }
.computed-eq { color: var(--text-muted); font-size: 13px; padding: 0 2px; }
.computed-row select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}
.computed-colA, .computed-colB { flex: 1; min-width: 120px; }
.computed-op { flex: 0 0 60px; text-align: center; }
.computed-remove { padding: 6px 10px; flex-shrink: 0; }

/* ── Intent Step ──────────────────────────────────────────── */
.intent-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 60px 20px; color: var(--text-muted);
}
.intent-loading-label { font-size: 14px; }

.intent-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 0 0 28px;
}
.intent-chip {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: flex; flex-direction: column; gap: 8px;
}
.intent-chip:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99,102,241,.08);
  transform: translateY(-1px);
}
.intent-chip.selected {
  border-color: var(--accent);
  background: rgba(99,102,241,.06);
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}
.intent-chip-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.intent-chip-title {
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  line-height: 1.3;
}
.intent-chip-badge {
  font-size: 10px; font-weight: 600; letter-spacing: .4px;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap; flex-shrink: 0;
}
.intent-chip-badge--simple   { background: rgba(22,163,74,.12);  color: #15803d; }
.intent-chip-badge--medium   { background: rgba(234,179, 8,.12); color: #a16207; }
.intent-chip-badge--advanced { background: rgba(99,102,241,.12); color: var(--accent); }

.intent-chip-desc {
  font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin: 0;
}
.intent-chip-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 4px;
}
.intent-chip-charts { display: flex; gap: 4px; }
.chart-type-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}
.chart-type-icon svg { width: 12px; height: 12px; }
.intent-chip-focus {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 200px;
}

.intent-fallback {
  grid-column: 1 / -1;
  padding: 20px;
  background: var(--surface-raised);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
}

.intent-custom-wrap {
  margin-bottom: 28px;
}
.intent-custom-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.intent-custom-input {
  width: 100%; max-width: 700px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--body);
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.intent-custom-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.intent-custom-input::placeholder { color: var(--text-muted); }

.intent-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-top: 8px;
}
.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* Responsive */
@media (max-width: 640px) {
  .step-nav { gap: 0; }
  .step-label { display: none; }
  .step-view { padding: 20px 12px; }
  .upload-card { padding: 40px 20px; }
  .dashboard-toolbar { flex-direction: column; align-items: flex-start; }
  .intent-chips { grid-template-columns: 1fr; }
}
