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

:root {
  --teal: #1A93A5;
  --teal-dark: #105F6B;
  --teal-light: #e8f7f9;
  --sidebar-bg: #0f1923;
  --sidebar-text: #a8b8c8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #1a2535;
  --sidebar-active: #1a3040;
  --content-bg: #f7f8fa;
  --card-bg: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--content-bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* === Login Screen === */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1923 0%, #1a2535 50%, #0f2030 100%);
  padding: 24px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-logo-img { height: 36px; width: auto; display: block; }

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-brand {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.logo-product {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 13px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 147, 165, 0.12);
}

.otp-input-large {
  font-size: 28px !important;
  font-weight: 700 !important;
  letter-spacing: 0.3em !important;
  text-align: center !important;
}

.otp-sent-msg {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 13px;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 12px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--teal);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); }

.btn-secondary {
  background: var(--teal-light);
  color: var(--teal-dark);
}
.btn-secondary:hover:not(:disabled) { background: #d0eff3; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; border-color: #d1d5db; }

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
}
.btn-danger:hover:not(:disabled) { background: #fecaca; }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* === App Shell === */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0;
  width: 240px;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 8px;
}

.sidebar-logo-img { height: 28px; width: auto; display: block; }

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  font-size: 10px;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-product {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.nav-links {
  list-style: none;
  padding: 4px 8px;
  flex: 1;
}

.nav-links li { margin: 1px 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: all 0.12s;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-link.active {
  background: var(--teal-dark);
  color: white;
  font-weight: 500;
}

.nav-icon { font-size: 14px; width: 18px; text-align: center; opacity: 0.8; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-link {
  display: block;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 12px;
  padding: 6px 0;
  transition: color 0.12s;
}
.sidebar-link:hover { color: var(--teal); }

.sidebar-user {
  font-size: 12px;
  color: var(--sidebar-text);
  padding: 6px 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Main Content === */
.main-content {
  min-height: 100vh;
  background: var(--content-bg);
  overflow-x: hidden;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* === Page Layout === */
.page-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header-left h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header-left p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-body {
  padding: 24px 32px;
  max-width: 1200px;
}

/* === Cards === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

/* === Grid === */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* === Stats Cards === */
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-teal { background: var(--teal-light); color: var(--teal-dark); }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* === Lists === */
.list-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background 0.1s;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #fafafa; }

.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.list-item-content { flex: 1; min-width: 0; }

.list-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.list-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* === Progress Bar === */
.progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-dark));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* === Score Display === */
.score-table {
  width: 100%;
  border-collapse: collapse;
}

.score-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}

.score-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
}

.score-table tr:last-child td { border-bottom: none; }
.score-table tr.best td { background: #f0fdf4; }

.score-cell { text-align: center; font-weight: 600; }
.score-5 { color: #059669; }
.score-4 { color: #10b981; }
.score-3 { color: #f59e0b; }
.score-2 { color: #ef4444; }
.score-1 { color: #dc2626; }

/* === Forms === */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  width: 100%;
}

.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

select[multiple] {
  height: 140px;
}

/* === Question Builder === */
.question-item {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}

.question-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.question-number {
  background: var(--teal);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.question-type-badge {
  flex: 1;
}

.question-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.12s;
}
.question-remove:hover { color: #dc2626; }

/* === SSE Log === */
.sse-log {
  background: #0f1923;
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #a8b8c8;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.8;
}

.sse-log .log-model { color: var(--teal); font-weight: 600; }
.sse-log .log-ok { color: #10b981; }
.sse-log .log-error { color: #ef4444; }
.sse-log .log-dim { color: #4b5563; }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 40px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 320px; margin: 0 auto 20px; }

/* === Loading Spinner === */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-row {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* === Tooltip === */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 4px;
}

/* === Model Grid === */
.model-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.model-card:hover {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26,147,165,0.08);
}

.model-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-all;
}

.model-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* === Pull Model === */
.pull-section {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.pull-section .form-group {
  flex: 1;
  margin: 0;
}

.pull-progress { margin-top: 12px; }
.pull-status { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* === Responsive === */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .page-header { padding: 20px 16px 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* === Dashboard quick links === */
.quick-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.quick-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.12s;
  cursor: pointer;
}

.quick-link:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-light);
}

/* === Result Highlight === */
.best-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== LAYOUT OVERHAUL ===== */

/* Ensure app fills viewport correctly */
html, body { height: 100%; overflow: hidden; }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}

.main-content {
  overflow-y: auto;
  height: 100vh;
}

/* Forms: full width, no squishing */
.page-body .form-section { max-width: 800px; }
.form-group { width: 100%; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; box-sizing: border-box; }

/* Benchmark form - readable selects */
#bench-kb, #bench-testset, #bench-judge { height: 42px; }
#bench-models { height: 120px; min-width: 200px; }

/* Make form rows stack on narrow viewports */
@media (max-width: 900px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Run benchmark button visibility */
.form-actions { 
  padding: 20px 0 40px; 
  display: flex; 
  gap: 12px; 
  align-items: center;
}

/* Dashboard stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Table full width */
table { width: 100%; }

/* Empty state centering */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}


/* ================================================================
   Knowledge Base Wizard Styles
   ================================================================ */

/* Overlay */
.kb-wizard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.kb-wizard-modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 960px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
}

.kb-wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kb-wizard-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.kb-wizard-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}
.kb-wizard-close:hover { color: var(--text-primary); }

/* Step bar */
.kb-wizard-steps {
  padding: 16px 24px 0;
  flex-shrink: 0;
}

.wizard-step-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wizard-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e5e7eb;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.wizard-step.active .wizard-step-num {
  background: var(--teal);
  color: white;
}

.wizard-step.done .wizard-step-num {
  background: #10b981;
  color: white;
}

.wizard-step-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.wizard-step.active .wizard-step-label { color: var(--teal-dark); font-weight: 700; }
.wizard-step.done .wizard-step-label { color: #059669; }

.wizard-step-line {
  flex: 1;
  min-width: 12px;
  height: 2px;
  background: #e5e7eb;
  margin: 0 6px;
  flex-shrink: 1;
}
.wizard-step-line.done { background: #10b981; }

/* Wizard body */
.kb-wizard-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.kb-wizard-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Wizard sections */
.wizard-section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.wizard-section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.5;
}

.wizard-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

.wizard-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* Radio list */
.wizard-radio-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.wizard-radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  flex-wrap: wrap;
}

.wizard-radio-item:hover {
  border-color: var(--teal);
  background: var(--teal-light);
}

.wizard-radio-item input[type=radio] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--teal);
}

.wizard-radio-label {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  color: var(--text-primary);
}

.wizard-radio-key {
  font-family: 'SF Mono','Fira Code',monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Evidence Tree */
.wizard-tree-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.wizard-tree {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.tree-node {
  padding: 0;
}

.tree-node-root {
  background: #f9fafb;
}

.tree-node-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  flex-wrap: wrap;
}

.tree-node-label input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  flex-shrink: 0;
}

.tree-node-label:hover { background: rgba(26,147,165,0.06); }

.tree-node-icon { font-size: 14px; }

.tree-node-key {
  font-family: 'SF Mono','Fira Code',monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 2px 5px;
  border-radius: 3px;
  margin-left: auto;
}

.tree-node-role {
  font-size: 11px;
  color: var(--text-secondary);
  background: #e5e7eb;
  padding: 2px 6px;
  border-radius: 4px;
}

.tree-children {
  padding-left: 28px;
  border-top: 1px solid var(--border);
}

.tree-rp-children {
  background: #fcfcfc;
}

.tree-node-evidence .tree-node-label {
  padding: 7px 14px;
  font-size: 13px;
}

.tree-section-label {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f3f4f6;
  border-top: 1px solid var(--border);
}

.tree-section-header {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: #f3f4f6;
  border-top: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tree-node-rp {
  border-top: 1px solid var(--border);
}

.tree-empty {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Wizard log */
.wizard-log {
  background: #0f1923;
  border-radius: 8px;
  padding: 14px;
  font-family: 'SF Mono','Fira Code',monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #a8b8c8;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 16px;
}

.wizard-log-line { padding: 1px 0; }
.wizard-log-success { color: #34d399; }
.wizard-log-error { color: #f87171; }
.wizard-log-warning { color: #fbbf24; }

/* Page header right */
.page-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Badge teal */
.badge-teal {
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid rgba(26,147,165,0.2);
}

/* ============================================================
   Model Browser
   ============================================================ */

.model-browser-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .model-browser-grid {
    grid-template-columns: 1fr;
  }
}

.model-browser-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  transition: box-shadow 0.15s;
}

.model-browser-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.model-maker-badge {
  display: inline-block;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
  vertical-align: middle;
}

.model-tag-pill {
  display: inline-block;
  background: color-mix(in srgb, var(--pill-color, #64748b) 12%, white);
  color: var(--pill-color, #64748b);
  border: 1px solid color-mix(in srgb, var(--pill-color, #64748b) 25%, white);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.model-use-cases {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.model-use-case-chip {
  background: #f9fafb;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
}

.model-size-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.model-size-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--border);
}

.model-size-table td {
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-primary);
  vertical-align: middle;
}

.model-size-table tr:last-child td {
  border-bottom: none;
}

.model-tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.model-tag-filter-pill {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.model-tag-filter-pill:hover {
  background: color-mix(in srgb, var(--pill-color, #64748b) 10%, white);
  border-color: var(--pill-color, #64748b);
  color: var(--pill-color, #64748b);
}

.model-tag-filter-pill.active {
  background: color-mix(in srgb, var(--pill-color, #64748b) 15%, white);
  border-color: var(--pill-color, #64748b);
  color: var(--pill-color, #64748b);
  font-weight: 600;
}

.model-search-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.model-search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26,147,165,0.1);
}
