@charset "UTF-8";

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: rgba(var(--bg-secondary-rgb), 0.82);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: width 0.2s ease;
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.app-main {
  flex: 1;
  min-width: 0;                    /* prevent flex blowout from wide children */
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

.app-sidebar.collapsed + .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

.app-header {
  height: var(--header-height);
  background: rgba(var(--bg-secondary-rgb), 0.72);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-content {
  flex: 1;
  min-width: 0;                    /* prevent flex blowout from wide content */
  padding: 24px;
  max-width: 1600px;
}

.app-content-full {
  min-width: 0;
  max-width: none;
}

.app-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  min-width: 0;                    /* prevent card from pushing parent flex container */
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.app-card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-secondary:hover { background: rgba(0,0,0,0.04); }
html[data-theme="dark"] .btn-secondary:hover { background: rgba(255,255,255,0.06); }
.btn-secondary:active { transform: scale(0.97); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

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

.form-input {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

.form-input::placeholder { color: var(--text-secondary); opacity: 0.6; }

select.form-input { appearance: auto; }

textarea.form-input { resize: vertical; min-height: 80px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-blue { background: rgba(0,113,227,0.1); color: var(--accent); }
.badge-green { background: rgba(52,199,89,0.1); color: var(--success); }
.badge-orange { background: rgba(255,149,0,0.1); color: var(--warning); }
.badge-red { background: rgba(255,59,48,0.1); color: var(--danger); }
.badge-gray { background: rgba(120,120,128,0.1); color: var(--text-secondary); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-primary);
}

html[data-theme="dark"] .nav-link:hover {
  background: rgba(255,255,255,0.06);
}

.nav-link.active {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
}

html[data-theme="dark"] .nav-link.active {
  background: rgba(0,113,227,0.18);
}

/* Sidebar structure */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin: 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease;
}
.sidebar-brand:hover { background: rgba(0,0,0,0.04); }
html[data-theme="dark"] .sidebar-brand:hover { background: rgba(255,255,255,0.06); }

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-group-header:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-primary);
}
html[data-theme="dark"] .nav-group-header:hover {
  background: rgba(255,255,255,0.06);
}
.nav-group-header.active {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
}
html[data-theme="dark"] .nav-group-header.active {
  background: rgba(0,113,227,0.18);
}

/* ── Sidebar drag-to-reorder ── */
.nav-drag-wrapper {
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-radius: 8px;
  cursor: grab;
}
.nav-drag-wrapper.drag-active {
  cursor: grabbing;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.1);
  transform: scale(1.02);
  z-index: 10;
  background: var(--bg-tertiary);
}
.nav-drag-wrapper.dragging {
  opacity: 0.4;
}
.nav-drag-wrapper.drag-over {
  box-shadow: 0 2px 0 0 var(--accent);
  background: rgba(0,113,227,0.05);
}
.nav-drag-wrapper .nav-link,
.nav-drag-wrapper .nav-group-header {
  pointer-events: auto;
}

.nav-children {
  position: relative;
  margin-left: 20px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-children::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border);
}

.nav-child {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-child:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-primary);
}
html[data-theme="dark"] .nav-child:hover {
  background: rgba(255,255,255,0.06);
}
.nav-child.active {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
}
html[data-theme="dark"] .nav-child.active {
  background: rgba(0,113,227,0.18);
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}
.header-icon-btn:hover { background: rgba(0,0,0,0.05); }
html[data-theme="dark"] .header-icon-btn:hover { background: rgba(255,255,255,0.06); }

.rotate-180 { transform: rotate(180deg); }

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.data-table td {
  word-break: break-word;          /* prevent long unbreakable strings from blowing out layout */
}

.data-table th {
  background: rgba(0,0,0,0.02);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

html[data-theme="dark"] .data-table th {
  background: rgba(255,255,255,0.03);
}

.data-table tr:hover { background: rgba(0,0,0,0.015); }
html[data-theme="dark"] .data-table tr:hover { background: rgba(255,255,255,0.02); }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

.quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.module-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.tab-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.tab-link:hover { color: var(--text-primary); }
.tab-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.folder-card {
  background: var(--bg-secondary);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.folder-card:hover { transform: translateY(-2px); }

.bg-tertiary { background: var(--bg-tertiary); }

@media (max-width: 1023px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .app-content {
    padding: 16px;
  }
}

/* ── LLM / ChatGPT-style sidebar ──────────── */
.llm-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: rgba(var(--bg-secondary-rgb), 0.88);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.llm-sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.llm-new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 4px;
  transition: background 0.15s ease;
}
.llm-new-chat-btn:hover { background: var(--accent-hover); }
.llm-kb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  margin-bottom: 8px;
}
.llm-kb-link:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }
html[data-theme="dark"] .llm-kb-link:hover { background: rgba(255,255,255,0.06); }

.llm-section-label {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.llm-project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.llm-project-item:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }
html[data-theme="dark"] .llm-project-item:hover { background: rgba(255,255,255,0.06); }
.llm-project-item.active { background: rgba(0,113,227,0.08); color: var(--accent); }
html[data-theme="dark"] .llm-project-item.active { background: rgba(0,113,227,0.18); }
.llm-translate-item {
  color: var(--accent);
  font-weight: 600;
}

.llm-chat-item {
  display: block;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease;
}
.llm-chat-item:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }
html[data-theme="dark"] .llm-chat-item:hover { background: rgba(255,255,255,0.06); }
.llm-chat-item.active { background: rgba(0,113,227,0.08); color: var(--accent); }

.llm-chat-row {
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}
.llm-chat-row:hover { background: rgba(0,0,0,0.04); }
html[data-theme="dark"] .llm-chat-row:hover { background: rgba(255,255,255,0.06); }
.llm-chat-row.active { background: rgba(0,113,227,0.08); }
.llm-chat-row .llm-chat-item { padding: 7px 4px 7px 14px; border-radius: 0; }
.llm-chat-row .llm-chat-item:hover { background: transparent; }
.llm-chat-row .llm-chat-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.llm-chat-row:hover .llm-chat-actions { opacity: 1; }
.llm-chat-actions button {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: 6px; color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.llm-chat-actions button:hover {
  background: rgba(0,0,0,0.08); color: var(--text-primary);
}
html[data-theme="dark"] .llm-chat-actions button:hover { background: rgba(255,255,255,0.1); }

/* ── LLM Main Area ────────────────────────── */
.llm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.llm-main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.llm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(var(--bg-secondary-rgb), 0.6);
  backdrop-filter: blur(12px);
  gap: 12px;
  flex-shrink: 0;
}
.llm-tab {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.llm-tab:hover { color: var(--text-primary); border-color: var(--accent); }
.llm-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── LLM Composer ─────────────────────────── */
.llm-composer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: rgba(var(--bg-secondary-rgb), 0.6);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.llm-input {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  resize: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.llm-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,0.12); }
.llm-input::placeholder { color: var(--text-secondary); opacity: 0.5; }

.llm-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.llm-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}
.llm-attachment-chip .remove-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
}
.llm-attachment-chip .remove-attach:hover { color: var(--danger); background: rgba(255,59,48,0.1); }

/* ── Translation result ───────────────────── */
.fh-translation-result {
  padding: 4px 0;
}
.fh-pinned-term {
  /* pinned term table card */
}
.fh-pinned-term .data-table { font-size: 12px; }
.fh-pinned-term .data-table th { font-size: 11px; }

/* ── Responsive ───────────────────────────── */
@media (max-width: 1023px) {
  .llm-sidebar {
    position: fixed;
    left: 0; top: 56px; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .llm-sidebar.open {
    transform: translateX(0);
  }
}

@media (max-width: 767px) {
  .app-header h1 {
    font-size: 16px;
  }
}

/* ── Project Chat Rows ──────────────────────── */
.project-chat-row {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.project-chat-row:hover {
  border-color: var(--accent) !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* ── Knowledge Base Scholar Page ────────────── */
.kb-scholar-hero {
  background: linear-gradient(180deg, rgba(0,113,227,0.03) 0%, transparent 100%);
}
.kb-hero-input {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.kb-hero-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,113,227,0.08);
}
.kb-tag-chip {
  transition: all 0.2s ease;
}
.kb-tag-chip:hover {
  border-color: var(--accent);
  background: rgba(0,113,227,0.04);
  color: var(--accent);
}
.kb-stat-card {
  transition: all 0.2s ease;
}
.kb-stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.kb-folder-card {
  transition: all 0.2s ease;
}
.kb-folder-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.kb-recent-item {
  transition: all 0.2s ease;
}
.kb-recent-item:hover {
  border-color: var(--accent);
}
html[data-theme="dark"] .kb-scholar-hero {
  background: linear-gradient(180deg, rgba(0,113,227,0.06) 0%, transparent 100%);
}
html[data-theme="dark"] .kb-stat-card:hover,
html[data-theme="dark"] .kb-folder-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ── Project Stage Pills ────────────────────── */
.stage-pill {
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.stage-pill:hover:not(.bg-\[var\(--accent\)\]) {
  border-color: var(--accent);
}

/* ── Modeling Module ───────────────────────── */
.modeling-workbench {
  height: calc(100vh - 104px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--bg-secondary);
  overflow: hidden;
}
.modeling-workbench-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 15px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}
.modeling-experiment-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.modeling-experiment-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: #111827;
  color: #fff;
}
.modeling-experiment-mark svg { width: 21px; height: 21px; }
.modeling-breadcrumb {
  margin-bottom: 3px;
  color: var(--text-tertiary);
  font-family: 'Consolas', monospace;
  font-size: 9px;
}
.modeling-experiment-identity h2 {
  overflow: hidden;
  font-size: 18px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.experiment-state {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--border);
  font-size: 9px;
  font-weight: 600;
}
.experiment-state.completed {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
  background: color-mix(in srgb, var(--success) 8%, transparent);
  color: var(--success);
}
.experiment-state.running {
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border));
  background: color-mix(in srgb, var(--warning) 8%, transparent);
  color: var(--warning);
}
.experiment-state.draft { color: var(--text-secondary); }
.modeling-experiment-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 10px;
}
.modeling-experiment-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}
.modeling-experiment-meta svg { width: 11px; height: 11px; }
.modeling-workbench-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modeling-mode-control {
  height: 30px;
  display: flex;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}
.modeling-mode-control button {
  min-width: 70px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.modeling-mode-control button.active {
  background: #111827;
  color: #fff;
}
.modeling-workbench-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  overflow-x: auto;
}
.modeling-workbench-tab {
  min-width: max-content;
  height: 43px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 13px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  transition: color .15s ease, border-color .15s ease;
}
.modeling-workbench-tab:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.modeling-workbench-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.modeling-workbench-tab svg { width: 14px; height: 14px; }
.modeling-workbench-main {
  overflow: auto;
}
.modeling-workbench-main > .modeling-content {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
}
.modeling-page-eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-family: 'Consolas', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
}
.run-composer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-bottom: 16px;
}
.run-strategy-panel,
.run-summary-panel,
.run-section {
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.run-strategy-panel,
.run-summary-panel { padding: 18px; }
.run-section { margin-bottom: 16px; }
.run-section-body { padding: 16px 18px 18px; }
.run-panel-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 13px;
}
.run-section > .run-panel-title {
  padding: 15px 18px 13px;
  border-bottom: 1px solid var(--border);
}
.run-panel-title > span {
  width: 24px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: #111827;
  color: #fff;
  font-family: 'Consolas', monospace;
  font-size: 9px;
}
.run-panel-title b {
  display: block;
  font-size: 12px;
}
.run-panel-title small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 10px;
}
.run-strategy-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.run-strategy-option {
  min-width: 0;
  min-height: 152px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-content: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.run-strategy-option:hover:not(.locked) { border-color: var(--accent); }
.run-strategy-option.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg-primary));
}
.run-strategy-option.locked {
  cursor: not-allowed;
  opacity: .48;
}
.run-strategy-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.run-strategy-option.active .run-strategy-icon {
  background: var(--accent);
  color: #fff;
}
.run-strategy-icon svg { width: 16px; height: 16px; }
.run-strategy-code {
  display: block;
  color: var(--accent);
  font-family: 'Consolas', monospace;
  font-size: 8px;
  font-weight: 700;
}
.run-strategy-option b {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}
.run-strategy-option small {
  display: block;
  min-height: 44px;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 1.55;
}
.run-strategy-option em {
  display: block;
  margin-top: 7px;
  color: var(--text-tertiary);
  font-size: 8px;
  font-style: normal;
}
.run-strategy-radio {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 50%;
}
.run-strategy-option.active .run-strategy-radio {
  border: 3px solid var(--accent);
}
.run-strategy-lock { width: 13px; height: 13px; color: var(--text-tertiary); }
.run-summary-list > div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
}
.run-summary-list dt { color: var(--text-secondary); }
.run-summary-list dd {
  overflow: hidden;
  font-weight: 600;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-safety-note {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  background: color-mix(in srgb, var(--success) 7%, transparent);
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 1.5;
}
.run-safety-note svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--success);
}
.run-result-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.run-result-tabs button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
}
.run-result-tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.run-metric-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.run-metric-cell {
  min-width: 0;
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 13px 14px;
  border-right: 1px solid var(--border);
}
.run-metric-cell:last-child { border-right: 0; }

.modeling-subnav {
  width: 212px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.modeling-subnav-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.modeling-subnav-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.modeling-subnav-footer {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.modeling-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.modeling-nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.modeling-nav-item.active {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
  font-weight: 600;
}
.modeling-nav-item.active i {
  color: var(--accent);
}

.modeling-main {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}
.modeling-content {
  padding: 28px 32px;
  max-width: 1200px;
}
.modeling-page-header {
  margin-bottom: 24px;
}

/* ── Modeling Dashboard ────────────────────── */
.modeling-dashboard {
  max-width: 1320px;
}
.modeling-command-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--bg-primary);
}
.modeling-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.modeling-status-dot.success { background: var(--success); }
.modeling-status-dot.running {
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 15%, transparent);
}
.modeling-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  background: var(--bg-primary);
  margin-bottom: 20px;
}
.modeling-kpi {
  min-width: 0;
  min-height: 88px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-right: 1px solid var(--border);
}
.modeling-kpi:last-child { border-right: 0; }
.modeling-kpi-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}
.modeling-kpi-icon.green {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}
.modeling-kpi-icon.amber {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
}
.modeling-kpi-icon.cyan {
  background: rgba(8, 145, 178, 0.1);
  color: #0891b2;
}
.modeling-kpi-icon svg { width: 18px; height: 18px; }
.modeling-kpi-value {
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text-primary);
}
.modeling-kpi-label {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}
.modeling-kpi-meta {
  align-self: end;
  padding-bottom: 2px;
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.modeling-workflow-panel,
.modeling-focus-panel {
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.modeling-workflow-panel { padding: 20px; }
.modeling-focus-panel { padding: 18px; }
.modeling-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.modeling-section-head.compact { margin-bottom: 12px; }
.modeling-section-head h3 {
  font-size: 14px;
  font-weight: 700;
}
.modeling-section-head p {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-secondary);
}
.modeling-workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.modeling-workflow-item {
  min-width: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 24px 34px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
.modeling-workflow-item:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.modeling-workflow-item.current {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.modeling-workflow-index {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
}
.modeling-workflow-item.completed .modeling-workflow-index {
  background: var(--success);
  color: #fff;
}
.modeling-workflow-index svg { width: 12px; height: 12px; }
.modeling-workflow-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.modeling-workflow-item.current .modeling-workflow-icon {
  background: var(--accent);
  color: #fff;
}
.modeling-workflow-icon svg { width: 16px; height: 16px; }
.modeling-workflow-item b {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modeling-workflow-item small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-tertiary);
}
.modeling-workflow-arrow {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}
.modeling-side-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modeling-status-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.modeling-status-list > div:last-child { border-bottom: 0; }
.modeling-status-list span { color: var(--text-secondary); }
.modeling-status-list b {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modeling-alert-line {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  color: var(--text-secondary);
  font-size: 11px;
}
.modeling-alert-line svg {
  width: 15px;
  height: 15px;
  color: var(--warning);
}
.modeling-activity-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.modeling-activity-bar p {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
}
.modeling-data-workspace {
  padding: 0;
  overflow: hidden;
}
.modeling-data-workspace > .flex:first-child {
  padding: 18px 20px 0;
}
.modeling-data-toolbar {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 150px 130px auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.modeling-search-box {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.modeling-search-box:focus-within { border-color: var(--accent); }
.modeling-search-box svg {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}
.modeling-search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 11px;
}
.modeling-data-summary {
  justify-self: end;
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.modeling-sheet-table {
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}
.modeling-sheet-table th {
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border);
  font-size: 11px;
  white-space: nowrap;
}
.modeling-sheet-table td {
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.modeling-sheet-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.modeling-sheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 10px;
}
.modeling-sheet-footer span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.modeling-sheet-footer svg { width: 13px; height: 13px; }
.modeling-context-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}
.modeling-context-strip > div {
  min-width: 0;
  padding: 11px 14px;
  border-right: 1px solid var(--border);
}
.modeling-context-strip > div:last-child { border-right: 0; }
.modeling-context-strip span {
  display: block;
  font-size: 9px;
  color: var(--text-tertiary);
}
.modeling-context-strip b {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Modeling Steps (flow visual) ──────────── */
.modeling-steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 12px 0;
}
.modeling-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}
.modeling-step-num {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.modeling-step-arrow {
  display: flex;
  align-items: center;
  padding: 0 4px;
  color: var(--text-tertiary);
  margin-bottom: 18px;
}

/* ── Intensity Cards ───────────────────────── */
.intensity-card {
  transition: all 0.2s ease;
}
.intensity-card:hover {
  transform: translateY(-1px);
}

/* ── Algorithm Chips ───────────────────────── */
.algo-chip-label { cursor: pointer; }
.algo-cb:checked + .algo-chip {
  background: rgba(0,113,227,0.08);
  border-color: var(--accent);
  color: var(--accent);
}
.algo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: all 0.15s ease;
  user-select: none;
}
.algo-chip:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

/* ── Predict Fields / Model Select ─────────── */
.model-select-card {
  transition: all 0.2s ease;
}
.model-select-card:hover {
  border-color: var(--accent);
}

/* ── Impact Tier Buttons ───────────────────── */
.impact-tier-btn {
  transition: all 0.15s ease;
}

/* ── Pipeline ──────────────────────────────── */
.pipeline-module-lib {
  padding: 12px 8px;
}
.pipeline-lib-item {
  transition: all 0.15s ease;
  user-select: none;
}
.pipeline-lib-item:hover {
  background: rgba(0,113,227,0.08);
}
.pipeline-lib-item:active {
  transform: scale(0.96);
}

.pipeline-node {
  transition: transform 0.15s ease;
}
.pipeline-node:hover {
  transform: scale(1.03);
  z-index: 5;
}
.pipeline-node-card {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}
.pipeline-node-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.pipeline-node-card.ring-2 {
  border-color: var(--accent);
}

/* ── Notebook Code Area ────────────────────── */
.notebook-code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Field Chips (sample config) ───────────── */
.field-chip {
  transition: all 0.15s ease;
}
.field-chip:hover {
  transform: scale(1.04);
}

/* ── Report Card ───────────────────────────── */
.report-card {
  transition: all 0.2s ease;
}
.report-card:hover {
  border-color: var(--accent);
}

/* ── Data Source Card ──────────────────────── */
.data-source-card.selected {
  border-color: var(--accent);
  background: rgba(0,113,227,0.03);
}

/* ── Modeling Dark Mode ────────────────────── */
html[data-theme="dark"] .modeling-nav-item.active {
  background: rgba(0,113,227,0.14);
}
html[data-theme="dark"] .algo-cb:checked + .algo-chip {
  background: rgba(0,113,227,0.14);
}
html[data-theme="dark"] .pipeline-node-card {
  background: var(--bg-secondary);
}
html[data-theme="dark"] .modeling-step-num {
  color: #fff;
}

@media (max-width: 1050px) {
  .run-composer-layout { grid-template-columns: 1fr; }
  .run-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .run-metric-cell { border-bottom: 1px solid var(--border); }
  .modeling-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modeling-kpi:nth-child(2) { border-right: 0; }
  .modeling-kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .modeling-data-toolbar { grid-template-columns: minmax(180px, 1fr) 140px 120px auto auto; }
  .modeling-data-summary { grid-column: 1 / -1; justify-self: start; }
  .modeling-context-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modeling-context-strip > div:nth-child(2) { border-right: 0; }
  .modeling-context-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .modeling-workbench-header {
    min-height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }
  .modeling-workbench-actions { width: 100%; flex-wrap: wrap; }
  .modeling-mode-control { flex: 1; }
  .modeling-mode-control button { flex: 1; min-width: 0; }
  .modeling-experiment-meta { flex-wrap: wrap; gap: 6px 12px; }
  .modeling-workbench-tabs { padding: 0 8px; }
  .run-strategy-list { grid-template-columns: 1fr; }
  .run-strategy-option { min-height: auto; }
  .run-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modeling-content { padding: 20px 16px; }
  .modeling-command-bar,
  .modeling-activity-bar { align-items: flex-start; flex-direction: column; }
  .modeling-kpi-strip,
  .modeling-workflow-grid { grid-template-columns: 1fr; }
  .modeling-kpi {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .modeling-kpi:last-child { border-bottom: 0; }
  .modeling-data-toolbar { grid-template-columns: 1fr 1fr; }
  .modeling-search-box,
  .modeling-data-summary { grid-column: 1 / -1; }
  .modeling-context-strip { grid-template-columns: 1fr; }
  .modeling-context-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .modeling-context-strip > div:last-child { border-bottom: 0; }
}

/* ── Optimization Module ──────────────────── */
.opt-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* Stepper */
.opt-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 0 28px;
}
.opt-step-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 10px;
  transition: background 0.15s ease;
  color: var(--text-tertiary);
  font-size: 13px;
}
.opt-step-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.opt-step-btn.active {
  color: var(--accent);
}
.opt-step-btn.active .opt-step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.opt-step-btn.done {
  color: var(--text-secondary);
}
.opt-step-btn.done .opt-step-circle {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.opt-step-circle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-secondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.opt-step-label {
  font-weight: 500;
  white-space: nowrap;
}
.opt-step-line {
  width: 48px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  border-radius: 1px;
}

/* Step Content */
.opt-step-content {
  min-height: 400px;
}
.opt-step-card {
  animation: opt-fade-in 0.2s ease;
}
/* Suppress step-card animation on inline re-renders */
#app-content[data-entrance-done] .opt-step-card {
  animation: none;
}
@keyframes opt-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.opt-step-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.opt-step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Empty hint */
.opt-empty-hint {
  text-align: center;
  padding: 32px 0;
}

/* Source dropdown */
.opt-source-dropdown {
  max-width: 480px;
}

/* Variables layout */
.opt-variables-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: 320px;
}
.opt-var-pool {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--bg-tertiary);
}
.opt-var-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 380px;
  overflow-y: auto;
}
.opt-var-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}
.opt-var-item:hover {
  border-color: var(--accent);
  background: rgba(0,113,227,0.03);
}
.opt-var-configured {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.opt-var-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.opt-var-empty {
  padding: 16px 0;
  text-align: center;
}
.opt-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.opt-var-row:last-child { border-bottom: none; }

.opt-var-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.opt-var-remove:hover {
  background: rgba(255,59,48,0.12);
  color: var(--danger);
}
.opt-var-name {
  font-size: 13px;
  font-weight: 500;
  min-width: 80px;
}
.opt-var-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.opt-range-input {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  font-family: 'SF Mono', 'JetBrains Mono', 'Consolas', monospace;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}
.opt-range-input:focus {
  border-color: var(--accent);
}
.opt-obj-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.opt-obj-select:focus {
  border-color: var(--accent);
}
.opt-var-badge {
  flex-shrink: 0;
}

/* Summary box */
.opt-summary-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.opt-summary-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.opt-summary-row:last-child { border-bottom: none; }
.opt-summary-row > span:first-child {
  width: 100px;
  flex-shrink: 0;
}

/* Results info */
.opt-result-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(0,113,227,0.04);
  border: 1px solid rgba(0,113,227,0.12);
}

/* Y column styling */
.opt-y-col-header {
  background: rgba(245,158,11,0.06);
}
.opt-y-cell {
  background: rgba(245,158,11,0.03);
  padding: 4px;
}
.opt-y-input {
  width: 100%;
  min-width: 80px;
  padding: 4px 8px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}
.opt-y-input:focus {
  border-color: var(--accent);
  border-style: solid;
}
.opt-y-input::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Optimization dark mode */
html[data-theme="dark"] .opt-step-circle {
  background: var(--bg-tertiary);
}
html[data-theme="dark"] .opt-step-btn.active .opt-step-circle {
  background: var(--accent);
}
html[data-theme="dark"] .opt-var-pool {
  background: var(--bg-secondary);
}
html[data-theme="dark"] .opt-var-item {
  background: var(--bg-tertiary);
}
html[data-theme="dark"] .opt-y-cell {
  background: rgba(245,158,11,0.05);
}
html[data-theme="dark"] .opt-y-col-header {
  background: rgba(245,158,11,0.08);
}

/* Responsive */
@media (max-width: 768px) {
  .opt-container {
    padding: 16px;
  }
  .opt-variables-layout {
    grid-template-columns: 1fr;
  }
  .opt-stepper {
    flex-wrap: wrap;
    gap: 4px;
    padding-bottom: 20px;
  }
  .opt-step-line {
    width: 20px;
  }
  .opt-step-label {
    display: none;
  }
  .opt-step-btn.active .opt-step-label {
    display: inline;
  }
}

/* ── Admin Module ───────────────────────── */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px;
}
.admin-page-header {
  margin-bottom: 20px;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  margin-bottom: 24px;
  width: fit-content;
}
.admin-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}
.admin-tab:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.admin-tab.active {
  background: var(--bg-primary);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Dept permission matrix */
.admin-dept-table th {
  vertical-align: middle;
}
.admin-dept-table td {
  vertical-align: middle;
  padding: 6px 8px;
}
.admin-dept-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Module toggle cards */
.module-toggle-card {
  transition: all 0.15s ease;
}
.module-toggle-card:hover {
  border-color: var(--accent);
  background: rgba(0,113,227,0.03);
}
.module-toggle-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Admin dark mode */
html[data-theme="dark"] .admin-tabs {
  background: var(--bg-secondary);
}
html[data-theme="dark"] .admin-tab.active {
  background: var(--bg-tertiary);
}

/* Admin responsive */
@media (max-width: 768px) {
  .admin-container {
    padding: 16px;
  }
  .admin-tabs {
    flex-wrap: wrap;
    width: 100%;
  }
  .admin-dept-table {
    font-size: 11px;
  }
}

/* ── Sheet Tree Bar (hierarchical table relations) ── */
.sheet-tree-bar {
  min-height: 38px;
}
.sheet-tree-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px 6px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}
.sheet-tree-item:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.sheet-tree-item.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sheet-tree-indent {
  display: inline-flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}
.sheet-tree-line {
  display: inline-block;
  width: 1px;
  height: 100%;
  min-height: 20px;
  background: var(--border);
  position: absolute;
  left: 4px;
  top: -8px;
}
.sheet-tree-branch {
  display: inline-block;
  width: 10px;
  height: 1px;
  background: var(--border);
  position: absolute;
  left: 4px;
  top: 50%;
}
.sheet-tree-item:first-child .sheet-tree-line,
.sheet-tree-item[data-depth="0"] .sheet-tree-line {
  /* No line if first/root */
}
.sheet-tree-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  color: var(--text-tertiary);
}
.sheet-tree-chevron:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
}
.sheet-tree-chevron.collapsed {
  transform: rotate(-90deg);
}
.sheet-tree-chevron-empty {
  width: 16px;
  flex-shrink: 0;
}
.sheet-tree-label {
  line-height: 1.2;
}
.sheet-tree-item.active .sheet-tree-line,
.sheet-tree-item.active .sheet-tree-branch {
  background: rgba(255,255,255,0.4);
}
.sheet-tree-item.active .sheet-tree-chevron {
  color: rgba(255,255,255,0.8);
}
.sheet-tree-item.active .sheet-tree-chevron:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* Dark mode */
html[data-theme="dark"] .sheet-tree-item {
  background: var(--bg-tertiary);
  border-color: var(--border);
}
html[data-theme="dark"] .sheet-tree-item:hover {
  background: var(--bg-secondary);
}
html[data-theme="dark"] .sheet-tree-line,
html[data-theme="dark"] .sheet-tree-branch {
  background: var(--border);
}
html[data-theme="dark"] .sheet-tree-chevron:hover {
  background: rgba(255,255,255,0.08);
}

/* ═══════════════════════════════════════════════
   TRANSITION ANIMATION SYSTEM
   Apple-style fluid motion · UI/UX Pro Max §7
   Duration: 150–300ms · Transform/opacity only
   Ease-out for enter · Ease-in for exit
   ═══════════════════════════════════════════════ */

/* ── Global animation tokens ──────────────── */
:root {
  --ease-spring: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
}

/* ── Page content entrance ────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

/* Entrance animation — only on first render (before data-entrance-done is set) */
#app-content:not([data-entrance-done]) > * {
  animation: fadeInUp 180ms var(--ease-out) both;
}

/* ── Staggered entrance for cards (first render only) ─── */
#app-content:not([data-entrance-done]) .app-card,
#app-content:not([data-entrance-done]) .quick-card,
#app-content:not([data-entrance-done]) .module-card {
  animation: fadeInUp 180ms var(--ease-out) both;
}
#app-content:not([data-entrance-done]) .app-card:nth-child(1) { animation-delay: 0ms; }
#app-content:not([data-entrance-done]) .app-card:nth-child(2) { animation-delay: 30ms; }
#app-content:not([data-entrance-done]) .app-card:nth-child(3) { animation-delay: 60ms; }
#app-content:not([data-entrance-done]) .app-card:nth-child(4),
#app-content:not([data-entrance-done]) .app-card:nth-child(5),
#app-content:not([data-entrance-done]) .app-card:nth-child(6),
#app-content:not([data-entrance-done]) .app-card:nth-child(7),
#app-content:not([data-entrance-done]) .app-card:nth-child(8) { animation-delay: 80ms; }

/* Inline updates (re-renders): no entrance animation, just a subtle opacity snap */
#app-content[data-entrance-done] .app-card,
#app-content[data-entrance-done] .quick-card,
#app-content[data-entrance-done] .module-card,
#app-content[data-entrance-done] > * {
  animation: none;
}

/* ── Card hover lift ──────────────────────── */
.app-card, .app-card-hover {
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.app-card-hover:hover,
a.app-card:hover,
.app-card[onclick]:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.08);
  border-color: var(--accent);
}

/* ── Quick-action & Module cards ──────────── */
.quick-card, .module-card {
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
.quick-card:hover, .module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}
.quick-card:active, .module-card:active {
  transform: scale(0.97);
  transition: transform 60ms var(--ease-out);
}

/* ── Button press feedback ────────────────── */
button:not([disabled]),
.btn-primary, .btn-secondary, .btn-ghost,
.llm-tab, .action-btn {
  transition: transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
button:not([disabled]):active,
.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.96);
  transition: transform 60ms var(--ease-out);
}

/* ── Sidebar transitions ──────────────────── */
.app-sidebar {
  transition: width var(--duration-slow) var(--ease-out);
}
.app-main {
  transition: margin-left var(--duration-slow) var(--ease-out);
}
.app-sidebar .nav-item,
.app-sidebar .nav-section {
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}
.app-sidebar.collapsed .nav-item span,
.app-sidebar.collapsed .nav-section span {
  opacity: 0;
}

/* ── Modal backdrop + panel ───────────────── */
.modal-backdrop {
  animation: modalBackdropIn var(--duration-normal) var(--ease-out) both;
}
@keyframes modalBackdropIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; backdrop-filter: blur(4px); }
}
.modal-panel {
  animation: modalPanelIn var(--duration-slow) var(--ease-spring) both;
}
@keyframes modalPanelIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Toast notification slide ─────────────── */
@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.92); }
}
#toast-container .toast {
  animation: toastSlideUp var(--duration-slow) var(--ease-spring) both;
}
#toast-container .toast.toast-out {
  animation: toastSlideOut 180ms var(--ease-in) both;
}

/* ── Table row hover ──────────────────────── */
.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}
.data-table tbody tr:hover {
  background: rgba(0,113,227,0.03);
}

/* ── Optimization task management table ──── */
.opt-task-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.opt-task-table {
  width: 100%;
  min-width: 1080px;
  table-layout: fixed;
}
.opt-task-table th,
.opt-task-table td,
.opt-task-table td > * {
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  vertical-align: middle;
}
.opt-task-table th,
.opt-task-table td {
  padding: 10px;
}
.opt-task-table th:nth-child(1),
.opt-task-table td:nth-child(1) { width: 135px; }
.opt-task-table th:nth-child(2),
.opt-task-table td:nth-child(2) { width: 170px; }
.opt-task-table th:nth-child(3),
.opt-task-table td:nth-child(3) { width: 125px; }
.opt-task-table th:nth-child(4),
.opt-task-table td:nth-child(4) { width: 105px; }
.opt-task-table th:nth-child(5),
.opt-task-table td:nth-child(5) { width: 175px; }
.opt-task-table th:nth-child(6),
.opt-task-table td:nth-child(6) { width: 80px; }
.opt-task-table th:nth-child(7),
.opt-task-table td:nth-child(7) { width: 60px; }
.opt-task-table th:nth-child(8),
.opt-task-table td:nth-child(8) { width: 80px; }
.opt-task-table th:nth-child(9),
.opt-task-table td:nth-child(9) { width: 150px; }
.opt-task-cell-clip {
  overflow: hidden;
  text-overflow: ellipsis;
}
.opt-task-table .badge {
  min-width: max-content;
  flex-shrink: 0;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
}
.opt-task-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}
.opt-task-actions button {
  min-width: max-content;
  white-space: nowrap;
}

/* ── Tab content crossfade ────────────────── */
.llm-tab, .admin-tab {
  transition: all var(--duration-fast) var(--ease-out);
}

/* ── Input focus glow ─────────────────────── */
.form-input, .llm-input, textarea.form-input,
select.form-input {
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.form-input:focus, .llm-input:focus {
  box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

/* ── Progress bar pulse ───────────────────── */
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.progress-bar-fill {
  transition: width var(--duration-slow) var(--ease-out);
}
.progress-bar-fill.indeterminate {
  animation: progressPulse 1.5s ease-in-out infinite;
}

/* ── Skeleton loading shimmer ─────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-tertiary) 25%,
    var(--bg-secondary) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

/* ── Badge / tag entrance ─────────────────── */
.badge, .tag-chip, .kb-tag-chip {
  transition: all var(--duration-fast) var(--ease-out);
}
.kb-tag-chip:hover {
  transform: translateY(-1px);
}

/* ── Sidebar nav item hover ───────────────── */
.app-sidebar .nav-item {
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.app-sidebar .nav-item:hover {
  transform: translateX(2px);
}

/* ── Reduced motion ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .app-content > * { animation: none; }
  .app-card { animation: none; }
  .modal-backdrop { animation: none; }
  .modal-panel { animation: none; }
  #toast-container .toast { animation: none; }
}

/* ── Knowledge page hero entrance ─────────── */
.kb-scholar-hero {
  animation: fadeIn var(--duration-slow) var(--ease-out) both;
}
.kb-stat-card {
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.kb-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

/* ── LLM sidebar chat rows ────────────────── */
.llm-chat-row, .project-chat-row {
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

/* ── Dropdown menu animation ──────────────── */
[id$="-menu"]:not(.hidden),
.llm-chat-actions {
  animation: fadeInScale 150ms var(--ease-out) both;
}
