/* ─────────────────────────────────────────────────────────────
   Minerva — Application styles
   ───────────────────────────────────────────────────────────── */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ds-bg);
  font-family: var(--ds-font-body);
  color: var(--ds-ink-900);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
}

/* ─── App layout ──────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--ds-surface);
  border-right: 1px solid var(--ds-border);
  display: flex;
  flex-direction: column;
  transition: width var(--ds-dur-base) var(--ds-ease-standard);
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-label { display: none !important; }
.sidebar.collapsed #sidebar-projects-items,
.sidebar.collapsed #sidebar-history-items { display: none !important; }

.sidebar-header {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar.collapsed .sidebar-header { padding: 0; justify-content: center; }

.sidebar-logo {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  height: 32px;
  width: auto;
  display: block;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-new-btn {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--ds-border);
  border-bottom: 1px solid var(--ds-border);
  margin-bottom: 8px;
}
.sidebar.collapsed .sidebar-new-btn {
  padding: 8px 4px;
  display: flex;
  justify-content: center;
}
.sidebar.collapsed #new-sim-btn {
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  border-radius: 50%;
}
.sidebar.collapsed #new-sim-btn svg {
  width: 20px !important;
  height: 20px !important;
}

.sidebar-section-label {
  padding: 12px 24px 8px;
  font-family: var(--ds-font-meta);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ds-ink-300);
  text-transform: uppercase;
  white-space: nowrap;
}

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

.sidebar-section { margin-bottom: 8px; }
#sidebar-projects-list { margin-top: -4px; }
#admin-items { margin-top: -4px; }

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  user-select: none;
}
.section-toggle:hover { background: var(--ds-surface-2); }
.sidebar.collapsed .section-toggle {
  justify-content: center;
  padding: 0;
  height: 40px;
  border-radius: 10px;
}

.section-chevron {
  color: var(--ds-ink-300);
  transition: transform var(--ds-dur-base);
}
.section-chevron.rotated { transform: rotate(-90deg); }

.section-icon { display: none; }
.sidebar.collapsed .section-icon { display: flex; }

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  height: 32px;
  width: 100%;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  transition: background var(--ds-dur-fast);
}
.history-item:hover { background: var(--ds-surface-2); }
.sidebar.collapsed .history-item { padding: 0; justify-content: center; }

.history-item-name {
  flex: 1;
  font-size: 12px;
  color: var(--ds-ink-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-menu-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ds-ink-300);
  opacity: 0;
  transition: opacity var(--ds-dur-fast), background var(--ds-dur-fast), color var(--ds-dur-fast);
}
.history-item:hover .history-item-menu-btn { opacity: 1; }
.history-item-menu-btn:hover { background: var(--ds-surface-3); color: var(--ds-ink-600); }

.sim-context-menu { padding: 4px 0; }
.sim-context-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font: 400 13px/18px var(--ds-font-body);
  color: var(--ds-ink-700);
  cursor: pointer;
  transition: background var(--ds-dur-fast);
  user-select: none;
}
.sim-context-option:hover { background: var(--ds-surface-2); }
.sim-context-delete:hover { background: var(--ds-status-error-bg); color: var(--ds-status-error-fg); }
.sidebar-hint {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ds-ink-300);
  font-style: italic;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ds-ink-300);
  font-family: var(--ds-font-meta);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--ds-dur-fast);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover  { background: var(--ds-surface-2); }
.nav-item.active { background: var(--ds-indigo-50); color: var(--ds-indigo-600); font-weight: 600; }
.sidebar.collapsed .nav-item { padding: 0; justify-content: center; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item .new-btn-icon { display: flex; }
.nav-item-new { color: var(--ds-indigo-600); font-size: 13px; }
.nav-item-new:hover { background: var(--ds-indigo-50); }
.new-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ds-indigo-600);
  color: #fff;
}

.nav-group-label {
  padding: 4px 12px 2px;
  font-family: var(--ds-font-meta);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ds-ink-300);
  text-transform: uppercase;
  margin-top: 8px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--ds-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sidebar.collapsed .sidebar-footer { justify-content: center; }
.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-name { font-size: 13px; font-weight: 600; color: var(--ds-ink-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role { font-size: 12px; color: var(--ds-ink-400); white-space: nowrap; }

.sidebar-toggle-btn {
  position: absolute;
  top: 28px;
  right: -12px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--ds-border);
  background: var(--ds-surface);
  border-radius: 50%;
  color: var(--ds-ink-500);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  z-index: 10;
}

/* ─── Main content area ───────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}


.page-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--ds-space-8) var(--ds-space-8);
}

/* ─── Page views ──────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ─── Empty state ─────────────────────────────────────────────── */
.empty-state {
  max-width: 560px;
  margin: 80px auto 0;
  text-align: center;
}
.empty-state-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 28px;
  border-radius: 50%;
  background: var(--ds-indigo-50);
  border: 1px solid var(--ds-indigo-100);
  display: grid;
  place-items: center;
  color: var(--ds-indigo-600);
}
.empty-state h1 {
  font: 700 32px/1.15 var(--ds-font-display);
  letter-spacing: -0.01em;
  color: var(--ds-ink-900);
  margin: 0 0 12px;
}
.empty-state p {
  font: 400 16px/1.5 var(--ds-font-body);
  color: var(--ds-ink-400);
  margin: 0 auto 32px;
  max-width: 420px;
}
.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.sidebar-admin {
  padding: 8px 12px;
  border-top: 1px solid var(--ds-border);
  flex-shrink: 0;
}
.sidebar.collapsed .sidebar-admin { padding: 8px 4px; border-top: none; }

.admin-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  user-select: none;
}
.admin-toggle:hover { background: var(--ds-surface-2); }
.sidebar.collapsed .admin-toggle { justify-content: center; padding: 4px 0; }
.admin-chevron { color: var(--ds-ink-300); }
.admin-chevron.rotated { transform: rotate(-90deg); }

/* ─── Project list (sidebar) ──────────────────────────────────── */
.project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  height: 36px;
  border-radius: 8px;
  font-family: var(--ds-font-body);
  font-size: 13px;
  font-weight: 400;
  color: var(--ds-ink-600);
  cursor: pointer;
  transition: background var(--ds-dur-fast);
  text-decoration: none;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
}
.project-item:hover  { background: var(--ds-surface-2); }
.project-item.active { background: var(--ds-indigo-50); color: var(--ds-indigo-700); font-weight: 600; }
.project-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-item-menu-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ds-ink-300);
  opacity: 0;
  transition: opacity var(--ds-dur-fast), background var(--ds-dur-fast), color var(--ds-dur-fast);
}
.project-item:hover .project-item-menu-btn { opacity: 1; }
.project-item-menu-btn:hover { background: var(--ds-surface-3); color: var(--ds-ink-600); }

/* ─── Project cards (grid view) ──────────────────────────────── */
.project-card {
  position: relative;
  cursor: pointer;
  transition: box-shadow var(--ds-dur-fast);
}
.project-card:hover { box-shadow: 0 4px 12px rgba(3,15,43,0.08); }
.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.project-card-name {
  font: 700 15px/20px var(--ds-font-display);
  color: var(--ds-ink-900);
  flex: 1;
}
.project-card-menu-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ds-ink-300);
  opacity: 0;
  transition: opacity var(--ds-dur-fast), background var(--ds-dur-fast), color var(--ds-dur-fast);
}
.project-card:hover .project-card-menu-btn { opacity: 1; }
.project-card-menu-btn:hover { background: var(--ds-surface-3); color: var(--ds-ink-600); }

/* ─── Reference filters ───────────────────────────────────────── */
.ref-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ref-search-wrap {
  min-width: 360px;
  flex: 0 0 auto;
  padding: 6px 12px;
}
.ref-search-wrap input { min-width: 0; }
.ref-highlight {
  background: var(--ds-indigo-100);
  color: var(--ds-indigo-800);
  border-radius: 2px;
  padding: 0 1px;
}


/* Generic has-filter state for any btn-field in a filter bar */
.btn-field { gap: 6px; border-color: var(--ds-indigo-100); color: var(--ds-ink-600); }
.btn-field.has-filter { border-color: var(--ds-indigo-500); color: var(--ds-indigo-600); }

/* Date inputs in filter panels */
.proj-date-input-wrap { padding: 6px 10px; gap: var(--ds-space-2); }
.proj-date-input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font: 400 13px/20px var(--ds-font-body);
  color: var(--ds-ink-900);
  min-width: 0;
  cursor: pointer;
}
.proj-date-input::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
  filter: invert(30%) sepia(60%) saturate(400%) hue-rotate(210deg);
}

.ref-cat-wrap { position: relative; flex-shrink: 0; }
.ref-cat-btn { gap: 6px; border-color: var(--ds-indigo-100); color: var(--ds-ink-600); }
.ref-cat-btn.has-filter { border-color: var(--ds-indigo-500); color: var(--ds-indigo-600); }
.ref-cat-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  padding: 4px 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ref-cat-panel.hidden { display: none; }

.ref-cat-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-700);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--ds-border);
  transition: background var(--ds-dur-fast);
}
.ref-cat-option:last-of-type { border-bottom: none; }
.ref-cat-option:hover { background: var(--ds-surface-2); }

.ref-cat-cb { display: none; }
.cat-count {
  font: var(--ds-type-xs);
  color: var(--ds-ink-300);
  margin-left: 4px;
}
.cat-check {
  margin-left: auto;
  color: var(--ds-indigo-500);
  font-size: 13px;
  font-weight: 700;
  visibility: hidden;
  flex-shrink: 0;
}
.ref-cat-option input[type="checkbox"]:checked ~ .cat-check { visibility: visible; }

.ref-cat-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--ds-border);
}

.ref-prodtime-wrap { position: relative; flex-shrink: 0; }
.ref-prodtime-btn { gap: 6px; border-color: var(--ds-indigo-100); color: var(--ds-ink-600); }
.ref-prodtime-btn.has-filter { border-color: var(--ds-indigo-500); color: var(--ds-indigo-600); }

.ref-export-wrap { position: relative; flex-shrink: 0; }
.ref-export-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 4px 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ref-export-panel.hidden { display: none; }
.ref-export-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-700);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--ds-border);
  transition: background var(--ds-dur-fast);
}
.ref-export-option:last-child { border-bottom: none; }
.ref-export-option:hover { background: var(--ds-surface-2); }

.ref-disp-wrap { position: relative; flex-shrink: 0; }
.ref-disp-btn { gap: 6px; border-color: var(--ds-indigo-100); color: var(--ds-ink-600); }
.ref-disp-btn.has-filter { border-color: var(--ds-indigo-500); color: var(--ds-indigo-600); }
.ref-disp-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  padding: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.ref-disp-panel.hidden { display: none; }

.ref-prodtime-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  padding: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.ref-prodtime-panel.hidden { display: none; }

.range-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ds-border);
}
.range-group-label {
  font: 600 13px/18px var(--ds-font-body);
  color: var(--ds-ink-700);
}

.dual-range-wrap {
  position: relative;
  height: 20px;
}
.dual-range-track {
  position: absolute;
  left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 4px;
  background: var(--ds-indigo-100);
  border-radius: 2px;
}
.dual-range-fill {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  height: 4px;
  background: var(--ds-indigo-500);
  border-radius: 2px;
}
.dual-range-wrap input[type=range] {
  position: absolute;
  width: 100%;
  top: 50%; transform: translateY(-50%);
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  outline: none;
}
.dual-range-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ds-surface);
  border: 2px solid var(--ds-indigo-500);
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 1px 3px rgba(85,100,218,.2);
}
.dual-range-wrap input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ds-surface);
  border: 2px solid var(--ds-indigo-500);
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 1px 3px rgba(85,100,218,.2);
}

.range-values {
  font: 400 12px/16px var(--ds-font-body);
  color: var(--ds-ink-400);
  display: flex;
  gap: 4px;
}

.range-panel-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px;
}

/* ─── Table ───────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font: var(--ds-type-sm);
}
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font: 600 12px/16px var(--ds-font-meta);
  color: var(--ds-ink-300);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--ds-indigo-100);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-indigo-100);
  color: var(--ds-ink-700);
  font-size: 14px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--ds-indigo-50); }
.data-table td { vertical-align: middle; }
.data-table .col-desc-cell { max-width: 0; }
.data-table .col-desc-cell > div {
  font-size: 13px;
  color: var(--ds-ink-400);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 18px;
}

.desc-tooltip {
  position: fixed;
  z-index: 400;
  max-width: 380px;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-sm);
  box-shadow: var(--ds-shadow-panel);
  padding: 10px 12px;
  font: 400 13px/18px var(--ds-font-body);
  color: var(--ds-ink-700);
  pointer-events: none;
  white-space: normal;
  word-break: break-word;
}
.desc-tooltip.hidden { display: none; }
.data-table .col-desc-header { width: 100%; min-width: 180px; }
.data-table .col-num { white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
.col-unit {
  font-size: 11px;
  color: var(--ds-ink-300);
  font-weight: 400;
  margin-left: 3px;
}
.row-action-btn {
  padding: 0;
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--ds-ink-300);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--ds-dur-fast), color var(--ds-dur-fast);
}
.row-action-btn:hover  { background: var(--ds-surface-2); color: var(--ds-ink-600); }
.row-delete-btn:hover  { background: var(--ds-status-error-bg); color: var(--ds-status-error-fg); }
/* Alias kept for any external references */
.ref-action-btn { padding:0;width:28px;height:28px;border-radius:6px;border:none;background:transparent;color:var(--ds-ink-300);display:inline-flex;align-items:center;justify-content:center;cursor:pointer; }
.ref-action-btn:hover { background:var(--ds-surface-2);color:var(--ds-ink-600); }
.ref-delete-btn:hover  { background:var(--ds-status-error-bg);color:var(--ds-status-error-fg); }
.data-table-wrap {
  background: var(--ds-surface);
  border: 1px solid var(--ds-indigo-100);
  border-radius: var(--ds-radius-md);
  overflow: hidden;
  max-width: 100%;
}

#view-references .data-table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

#view-references .data-table {
  min-width: 1040px;
}

/* ─── Badge / status chip ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--ds-radius-pill);
  font: 700 11px/22px var(--ds-font-body);
  letter-spacing: 0.02em;
  background: var(--ds-surface-2);
  color: var(--ds-ink-500);
}
.badge-indigo  { background: var(--ds-indigo-50);       color: var(--ds-indigo-700); }
.badge-success { background: #E6F5EE;                   color: var(--ds-status-success-fg); }
.badge-warn    { background: #FFF3E8;                   color: var(--ds-status-warn-fg); }
.badge-error   { background: var(--ds-status-error-bg); color: var(--ds-status-error-fg); }
.badge-coral   { background: #FDF1EE;                   color: var(--ds-accent-coral); }
.badge-slate   { background: var(--ds-surface-3);       color: var(--ds-ink-600); }

/* ─── Page tabs ───────────────────────────────────────────────── */
.page-tabs {
  display: flex;
  border-bottom: 1px solid var(--ds-border);
  margin-bottom: 20px;
  gap: 0;
}
.page-tab {
  padding: 0 2px;
  margin-right: 24px;
  height: 38px;
  display: flex;
  align-items: center;
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-400);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--ds-dur-base), border-color var(--ds-dur-base);
  white-space: nowrap;
}
.page-tab:hover { color: var(--ds-ink-900); }
.page-tab.active {
  color: var(--ds-indigo-600);
  border-bottom-color: var(--ds-indigo-500);
  font-weight: 600;
}

/* ─── "+ New" sidebar dropdown ────────────────────────────────── */
.new-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font: 400 13px/18px var(--ds-font-body);
  color: var(--ds-ink-900);
  border-radius: 6px;
  margin: 0 4px;
  transition: background var(--ds-dur-base);
}
.new-dropdown-item:hover { background: var(--ds-indigo-50); }

/* ─── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--ds-space-6);
  gap: var(--ds-space-4);
}
.page-header h1 {
  font: 700 24px/32px var(--ds-font-display);
  color: var(--ds-ink-900);
  margin: 0 0 4px;
  letter-spacing: var(--ds-tracking-tight);
}
.page-header p {
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-400);
  margin: 0;
}
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ─── Side panel (product detail drawer) ─────────────────────── */
.side-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(3, 15, 43, 0.18);
}
.side-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 82%;
  background: var(--ds-surface);
  border-left: 1px solid var(--ds-border);
  box-shadow: -4px 0 32px rgba(3, 15, 43, 0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sidePanelIn 0.22s var(--ds-ease-standard);
}
@keyframes sidePanelIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.side-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ds-indigo-100);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.side-panel-body {
  flex: 1;
  overflow-y: auto;
}
.side-panel-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--ds-border);
}
.side-panel-section:last-child { border-bottom: none; }
.side-panel-detail-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--ds-border);
}
.side-panel-detail-row:last-child { border-bottom: none; }
.side-panel-detail-label {
  width: 90px;
  flex-shrink: 0;
  font: 600 10px/14px var(--ds-font-meta);
  color: var(--ds-ink-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}
.side-panel-detail-value {
  flex: 1;
  font: 400 13px/18px var(--ds-font-body);
  color: var(--ds-ink-800);
  word-break: break-word;
}
.side-panel-detail-value .input-wrap { align-items: flex-start; padding: 3px 8px; }
.side-panel-detail-value .input-wrap textarea {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font: 400 13px/1.5 var(--ds-font-body);
  color: var(--ds-ink-900);
  resize: vertical;
  min-height: 60px;
  width: 100%;
}

/* ─── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 15, 43, 0.35);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--ds-surface);
  border-radius: var(--ds-radius-lg);
  border: 1px solid var(--ds-indigo-100);
  box-shadow: var(--ds-shadow-panel);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--ds-indigo-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title {
  font: 700 16px/24px var(--ds-font-display);
  color: var(--ds-ink-900);
  margin: 0;
}
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ds-indigo-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ds-ink-400);
}
.modal-close:hover { background: var(--ds-surface-2); color: var(--ds-ink-900); }

/* ─── Permissions table ───────────────────────────────────────── */
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-toggle { cursor: pointer; user-select: none; }
.perm-toggle input[type="checkbox"] { display: none; }
.perm-toggle .badge { opacity: 0.2; transition: opacity 0.1s; }
.perm-toggle input[type="checkbox"]:checked + .badge { opacity: 1; }

/* ─── Password eye toggle ─────────────────────────────────────── */
.pw-eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ds-ink-300);
  padding: 0;
  display: flex;
  align-items: center;
}
.pw-eye-btn:hover { color: var(--ds-ink-600); }

/* ─── Form ────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--ds-space-4); }
.form-label {
  display: block;
  font: 600 12px/16px var(--ds-font-meta);
  color: var(--ds-ink-400);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-input {
  width: 100%;
  background: var(--ds-surface);
  border: 1px solid var(--ds-indigo-100);
  border-radius: var(--ds-radius-sm);
  padding: 8px 12px;
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-900);
  outline: none;
  transition: border-color var(--ds-dur-fast), box-shadow var(--ds-dur-fast);
}
.form-input:focus {
  border-color: var(--ds-indigo-500);
  box-shadow: var(--ds-shadow-press);
}
.form-input::placeholder { color: var(--ds-ink-300); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ─── Markdown preview ────────────────────────────────────────── */
.md-preview {
  height: 240px;
  min-height: 120px;
  padding: 12px 14px;
  background: var(--ds-surface-2, #F5F6F8);
  border: 1px solid var(--ds-indigo-100);
  border-radius: var(--ds-radius-sm);
  font: 400 13px/1.7 var(--ds-font-body);
  color: var(--ds-ink-900);
  overflow-y: auto;
  resize: vertical;
}
.md-preview h1,.md-preview h2,.md-preview h3 { font-weight:700; margin:1em 0 .4em; color:var(--ds-ink-900); }
.md-preview h1 { font-size:18px; }
.md-preview h2 { font-size:15px; }
.md-preview h3 { font-size:13px; }
.md-preview p  { margin:.5em 0; }
.md-preview ul,.md-preview ol { margin:.4em 0; padding-left:20px; }
.md-preview li { margin:.2em 0; }
.md-preview code { background:var(--ds-indigo-50);border:1px solid var(--ds-indigo-100);border-radius:4px;padding:1px 5px;font-size:12px;font-family:monospace; }
.md-preview pre  { background:var(--ds-indigo-50);border:1px solid var(--ds-indigo-100);border-radius:var(--ds-radius-sm);padding:10px 12px;overflow-x:auto; }
.md-preview pre code { background:none;border:none;padding:0; }
.md-preview hr   { border:none;border-top:1px solid var(--ds-border);margin:1em 0; }
.md-preview strong { font-weight:700; }

/* ─── Divider ─────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--ds-indigo-100);
  margin: var(--ds-space-6) 0;
}

/* ─── Wizard dropdown options ─────────────────────────────────── */
.wiz-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-700);
  cursor: pointer;
  border-bottom: 1px solid var(--ds-border);
  transition: background var(--ds-dur-fast);
  user-select: none;
}
.wiz-dropdown-option:last-child { border-bottom: none; }
.wiz-dropdown-option:hover { background: var(--ds-surface-2); }
.wiz-dropdown-option.selected { color: var(--ds-indigo-600); font-weight: 600; }
.wiz-dropdown-option.create-option { color: var(--ds-indigo-600); }

/* ─── Field validation error ──────────────────────────────────── */
.field-error {
  font: 400 12px/16px var(--ds-font-body);
  color: var(--ds-status-error-fg);
  margin-top: 4px;
}

/* ─── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: 380px;
}
.toast {
  background: var(--ds-surface);
  border: 1px solid var(--ds-indigo-100);
  border-radius: var(--ds-radius-sm);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  box-shadow: var(--ds-shadow-toaster);
  animation: toast-in var(--ds-dur-base) var(--ds-ease-standard);
}
.toast.toast-success { border-color: var(--ds-status-success-fg); }
.toast.toast-error   { border-color: var(--ds-status-error-fg); background: var(--ds-status-error-bg); }
.toast.toast-warn    { border-color: var(--ds-status-warn-fg); }
.toast-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ds-indigo-500);
  color: #fff;
  display: grid;
  place-items: center;
  font: 700 10px/1 var(--ds-font-body);
  flex-shrink: 0;
  margin-top: 2px;
}
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ds-ink-400);
  font-size: 16px;
  line-height: 1;
  padding: 0 0 0 8px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ds-indigo-100);
  border-top-color: var(--ds-indigo-500);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--ds-space-2); }
.gap-3 { gap: var(--ds-space-3); }
.gap-4 { gap: var(--ds-space-4); }
.mt-4  { margin-top: var(--ds-space-4); }
.mt-6  { margin-top: var(--ds-space-6); }
.text-sm { font: var(--ds-type-sm); }
.text-xs { font: var(--ds-type-xs); }
.text-muted { color: var(--ds-ink-400); }

/* ── Windows stroke compensation ─────────────────────────────── */
/* Skia rasterisation renders strokes heavier than macOS CoreText;
   Light (300) compensates to approximate the Mac visual weight.  */
.win body { font-weight: 300; }

/* ─── Simulation detail — grouped table (3 card-sections) ─────── */
/* Each group renders like a .data-table-wrap card (white bg, indigo-100 border,
   radius-md corners) while rows stay height-aligned across groups.           */
#sim-detail-table { border-collapse: separate; border-spacing: 0; }

/* Reset: neutralise data-table's collapse borders without !important so that
   the sd-* class borders (higher specificity via #id) can take over.         */
#sim-detail-table th,
#sim-detail-table td { border: none; }

/* Spacer columns — canvas background, no border, invisible */
#sim-detail-table .sd-sp { padding: 0; background: var(--ds-bg); }

/* Group cells — white card base + row separator on the bottom */
#sim-detail-table .sd-g  { background: var(--ds-surface); border-bottom: 1px solid var(--ds-indigo-100); }
/* Top border only on header row */
#sim-detail-table thead .sd-g { border-top: 1px solid var(--ds-indigo-100); }
/* Left / right card edges */
#sim-detail-table .sd-gl { border-left:  1px solid var(--ds-indigo-100); }
#sim-detail-table .sd-gr { border-right: 1px solid var(--ds-indigo-100); }

/* AI group (Match / Prod. Time) — same card look, grey background */
#sim-detail-table .sd-ai { background: var(--ds-bg); }

/* Top corners — thead */
#sim-detail-table thead .sd-gl { border-top-left-radius:  var(--ds-radius-md); }
#sim-detail-table thead .sd-gr { border-top-right-radius: var(--ds-radius-md); }

/* Bottom corners — default: last tbody row */
#sim-detail-table tbody tr:last-child .sd-gl { border-bottom-left-radius:  var(--ds-radius-md); }
#sim-detail-table tbody tr:last-child .sd-gr { border-bottom-right-radius: var(--ds-radius-md); }

/* When tfoot is present: last tbody row loses its separator + radius
   (the tfoot row takes over the card bottom)                                  */
#sim-detail-table:has(tfoot tr) tbody tr:last-child .sd-g  { border-bottom: none; }
#sim-detail-table:has(tfoot tr) tbody tr:last-child .sd-gl { border-bottom-left-radius:  0; }
#sim-detail-table:has(tfoot tr) tbody tr:last-child .sd-gr { border-bottom-right-radius: 0; }

/* Bottom corners — tfoot row */
#sim-detail-table tfoot .sd-gl { border-bottom-left-radius:  var(--ds-radius-md); }
#sim-detail-table tfoot .sd-gr { border-bottom-right-radius: var(--ds-radius-md); }

/* Hover — tbody only; spacers stay on canvas colour */
#sim-detail-table tbody tr:hover .sd-g  { background: var(--ds-indigo-50); }
#sim-detail-table tbody tr:hover .sd-sp { background: var(--ds-bg); }

/* ── Move-to-project modal — allow dropdown to overflow card ── */
#move-sim-modal .modal,
#move-sim-modal .modal-body { overflow: visible; }

/* ── Move-to-project dropdown options ─────────────────────── */
.move-proj-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font: 400 14px/20px var(--ds-font-body);
  color: var(--ds-ink-900);
  border-bottom: 1px solid var(--ds-border);
  transition: background 0.1s;
}
.move-proj-option:last-child { border-bottom: none; }
.move-proj-option:hover      { background: var(--ds-indigo-50); }
.move-proj-active            { background: var(--ds-indigo-50); color: var(--ds-indigo-600); font-weight: 600; }
.move-proj-option > *        { pointer-events: none; }
