/* AppShell + primitive component styles */

/* ---------- AppShell ---------- */
.shell {
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100vh;
  /* dvh = dynamic viewport — supersedes 100vh on browsers that recalc
     for the URL bar / soft keyboard. Falls back gracefully where unsupported. */
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}
.sidebar {
  background: linear-gradient(180deg, hsl(var(--sidebar-bg-from)) 0%, hsl(var(--sidebar-bg-to)) 100%);
  color: hsl(var(--sidebar-fg));
  border-right: 1px solid hsl(var(--sidebar-border));
  width: 232px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 200ms ease;
}
.sidebar[data-collapsed="true"] { width: 56px; }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid hsl(var(--sidebar-border));
  height: 52px;
}
.sidebar-brand-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar-brand-text .name {
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
}
.sidebar-brand-text .product {
  font-size: 10px;
  color: hsl(var(--sidebar-fg-muted));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.sidebar[data-collapsed="true"] .sidebar-brand-text { display: none; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--sidebar-group));
  padding: 4px 8px;
  margin-top: 4px;
}
.sidebar[data-collapsed="true"] .nav-group-label { display: none; }
.nav { flex: 1; overflow-y: auto; padding: 0 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: hsl(var(--sidebar-fg-muted));
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: hsl(var(--sidebar-hover-bg)); color: hsl(var(--sidebar-fg)); }
.nav-item[data-active="true"] {
  background: hsl(var(--sidebar-active-bg) / 0.18);
  color: hsl(var(--sidebar-fg));
}
.nav-item[data-active="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: hsl(var(--sidebar-active-bg));
  border-radius: 2px;
}
.nav-item .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item[data-active="true"] .nav-icon { opacity: 1; }
.sidebar[data-collapsed="true"] .nav-item span:not(.nav-icon-wrap) { display: none; }
.sidebar[data-collapsed="true"] .nav-item { justify-content: center; padding: 6px; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid hsl(var(--sidebar-border));
  margin-top: auto;
}
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-user:hover { background: hsl(var(--sidebar-hover-bg)); }
.avatar {
  width: 24px; height: 24px; border-radius: 999px;
  background: hsl(var(--accent));
  display: grid; place-items: center;
  color: hsl(var(--accent-foreground));
  font-weight: 700; font-size: 10px;
  flex-shrink: 0;
}
.sidebar-user .meta { display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; }
.sidebar-user .meta .name { font-size: 11px; font-weight: 600; color: hsl(var(--sidebar-fg)); }
.sidebar-user .meta .role { font-size: 10px; color: hsl(var(--sidebar-fg-muted)); }
.sidebar[data-collapsed="true"] .sidebar-user .meta { display: none; }

/* ---------- Topbar ---------- */
/* ``min-height: 0`` is the classic flexbox unlock — without it the
   .page child can't shrink below its content height and the .shell's
   100vh constraint produces a non-scrollable page. */
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.topbar {
  height: 52px;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); min-width: 0; }
.breadcrumbs .crumb { cursor: pointer; padding: 2px 4px; border-radius: var(--radius-sm); white-space: nowrap; }
.breadcrumbs .crumb:hover { background: hsl(var(--muted)); }
.breadcrumbs .crumb-current { color: hsl(var(--foreground)); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
}
.icon-btn:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: hsl(var(--muted-foreground));
  flex: 1; min-width: 0;
}
.breadcrumb .crumb { cursor: pointer; padding: 2px 4px; border-radius: var(--radius-sm); white-space: nowrap; }
.breadcrumb .crumb:hover { background: hsl(var(--muted)); }
.breadcrumb .crumb.current { color: hsl(var(--foreground)); font-weight: 600; }
.breadcrumb .sep { opacity: 0.5; }

.env-banner {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.env-banner[data-env="non-prod"] {
  background: hsl(var(--warning-soft));
  color: hsl(var(--warning));
  border: 1px solid hsl(var(--warning) / 0.3);
}
.env-banner[data-env="prod"] {
  background: hsl(var(--destructive-soft));
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.3);
}
.env-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.delphi-launcher {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, hsl(var(--delphi-from) / 0.12), hsl(var(--delphi-to) / 0.12));
  color: hsl(var(--delphi-ink));
  border: 1px solid hsl(var(--delphi-from) / 0.3);
}
.delphi-launcher:hover { background: linear-gradient(135deg, hsl(var(--delphi-from) / 0.2), hsl(var(--delphi-to) / 0.2)); }

/* ---------- Page surface ---------- */
.page {
  flex: 1 1 0;
  /* Combined with .main-col { min-height: 0 } this is what makes the
     page scroll instead of inflating the parent. Both lines are needed. */
  min-height: 0;
  overflow: auto;
  background: hsl(var(--background));
  position: relative;
}
.page-inner {
  padding: 16px 20px 32px;
  max-width: 1640px;
  margin: 0 auto;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid hsl(var(--border));
}
.page-header .title-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-header .title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.page-header .subtitle { font-size: 12px; color: hsl(var(--muted-foreground)); }
.page-header .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--input-h);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border-strong));
}
.btn:hover { background: hsl(var(--muted)); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-accent {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border-color: hsl(var(--accent));
}
.btn-accent:hover { background: hsl(var(--accent) / 0.9); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: hsl(var(--muted-foreground));
}
.btn-ghost:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.btn-destructive {
  background: hsl(var(--destructive));
  color: white;
  border-color: hsl(var(--destructive));
}
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }
.btn-sm { height: 24px; padding: 0 8px; font-size: 11px; }
.btn-lg { height: 32px; padding: 0 14px; }
.btn .lucide { width: 13px; height: 13px; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.pill[data-tone="open"] { background: hsl(var(--status-open) / 0.12); color: hsl(var(--status-open)); border-color: hsl(var(--status-open) / 0.3); }
.pill[data-tone="new"] { background: hsl(var(--status-new) / 0.12); color: hsl(var(--status-new)); border-color: hsl(var(--status-new) / 0.3); }
.pill[data-tone="recommended"] { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); border-color: hsl(var(--primary) / 0.3); }
.pill[data-tone="surviving"] { background: hsl(var(--success-soft)); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.pill[data-tone="rejected"] { background: hsl(var(--destructive-soft)); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.3); }
.pill[data-tone="drafting"] { background: hsl(var(--warning-soft)); color: hsl(var(--warning)); border-color: hsl(var(--warning) / 0.3); }
.pill[data-tone="complete"] { background: hsl(var(--success-soft)); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.pill[data-tone="muted"] { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }
.pill[data-tone="info"] { background: hsl(var(--info-soft)); color: hsl(var(--info)); border-color: hsl(var(--info) / 0.3); }
.pill[data-tone="delphi"] {
  background: linear-gradient(135deg, hsl(var(--delphi-from) / 0.12), hsl(var(--delphi-to) / 0.12));
  color: hsl(var(--delphi-ink));
  border-color: hsl(var(--delphi-from) / 0.3);
}
.pill[data-size="sm"] { font-size: 9px; padding: 0 6px; }
.pill[data-size="lg"] { font-size: 11px; padding: 2px 10px; }

/* ---------- Card ---------- */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  gap: 10px;
}
.card-header .title { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-header .actions { display: flex; gap: 6px; align-items: center; }
.card-body { padding: 12px; }
.card-body.no-pad { padding: 0; }

/* ---------- KPI tile ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.kpi {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 100ms ease;
  position: relative;
}
.kpi:hover { border-color: hsl(var(--border-strong)); }
.kpi[data-active="true"] {
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 2px hsl(var(--accent) / 0.15);
}
.kpi .label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: hsl(var(--muted-foreground)); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 6px; letter-spacing: -0.01em; }
.kpi .delta { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.kpi .delta[data-trend="up"] { color: hsl(var(--success)); }
.kpi .delta[data-trend="down"] { color: hsl(var(--destructive)); }

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  padding: 8px 10px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.table td {
  padding: 7px 10px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
  height: var(--row-h);
}
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: hsl(var(--muted) / 0.6); }
.table tbody tr[data-selected="true"] td { background: hsl(var(--accent) / 0.08); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .id { font-family: var(--font-mono); font-size: 11px; color: hsl(var(--muted-foreground)); }
.table-wrap { max-height: 100%; overflow: auto; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid hsl(var(--border));
}
.tab {
  padding: 8px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
  position: relative;
}
.tab:hover { color: hsl(var(--foreground)); }
.tab[data-active="true"] {
  color: hsl(var(--primary));
  border-bottom-color: hsl(var(--primary));
  font-weight: 600;
}

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  width: 100%;
  height: var(--input-h);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 12px;
  outline: none;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 2px hsl(var(--accent) / 0.2);
}
.textarea { height: auto; padding: 6px 10px; resize: vertical; min-height: 60px; line-height: 1.5; }
.field-label {
  font-size: 11px; font-weight: 500; color: hsl(var(--foreground));
  display: flex; align-items: center; gap: 4px; margin-bottom: 4px;
}
.field-help { font-size: 10px; color: hsl(var(--muted-foreground)); margin-top: 4px; font-style: italic; }
.field { display: flex; flex-direction: column; }
.required { color: hsl(var(--destructive)); }

/* Segmented control */
.segmented {
  display: inline-flex;
  background: hsl(var(--muted));
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.segmented button[data-active="true"] {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px hsl(var(--foreground) / 0.06);
  font-weight: 600;
}
.segmented button:hover:not([data-active="true"]) { color: hsl(var(--foreground)); }

/* Checkbox/Radio bare */
.checkbox-row, .radio-row {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px;
}
.checkbox-row input, .radio-row input { margin: 0; accent-color: hsl(var(--accent)); }

/* ---------- Stage stepper ---------- */
.stepper {
  display: flex;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.stepper .step {
  flex: 1;
  padding: 10px 14px;
  position: relative;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  border-right: 1px solid hsl(var(--border));
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}
.stepper .step:last-child { border-right: none; }
.stepper .step .num {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.stepper .step .step-label { display: flex; flex-direction: column; line-height: 1.2; }
.stepper .step .step-label .name { font-weight: 600; color: hsl(var(--foreground)); }
.stepper .step .step-label .meta { font-size: 10px; }
.stepper .step[data-state="complete"] .num { background: hsl(var(--success)); color: white; }
.stepper .step[data-state="active"] {
  background: hsl(var(--primary) / 0.06);
}
.stepper .step[data-state="active"] .num { background: hsl(var(--primary)); color: white; }
.stepper .step[data-state="active"]::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px; background: hsl(var(--primary));
}
.stepper .step[data-state="locked"] {
  cursor: not-allowed;
  background: hsl(var(--muted) / 0.4);
}
.stepper .step[data-state="locked"] .name { color: hsl(var(--muted-foreground)); }

/* ---------- Object detail header strip ---------- */
.detail-strip {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.detail-strip .left { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.detail-strip .meta-row { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; }
.detail-strip .meta { display: flex; flex-direction: column; gap: 2px; }
.detail-strip .meta .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: hsl(var(--muted-foreground)); font-weight: 600; }
.detail-strip .meta .value { font-size: 12px; font-weight: 500; }
.detail-strip .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: hsl(215 30% 15% / 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  animation: fadeIn 120ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 460px;
  max-width: 100vw;
  background: hsl(var(--card));
  border-left: 1px solid hsl(var(--border));
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px hsl(215 30% 15% / 0.1);
  animation: slideIn 180ms ease;
}
.drawer.wide { width: 580px; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-header .title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid hsl(var(--border));
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ---------- Filter strip ---------- */
.filter-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: hsl(var(--accent-soft));
  color: hsl(var(--accent));
  border: 1px solid hsl(var(--accent) / 0.3);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.filter-chip .x { cursor: pointer; opacity: 0.7; display: inline-flex; }
.filter-chip .x:hover { opacity: 1; }
.search-box {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--input-h);
  padding: 0 10px;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
  min-width: 240px;
}
.search-box input {
  border: none; outline: none; background: transparent;
  flex: 1; height: 100%;
  font-size: 12px;
}

/* ---------- Delphi card ---------- */
.delphi-card {
  background: linear-gradient(135deg, hsl(var(--delphi-from) / 0.04), hsl(var(--delphi-to) / 0.04));
  border: 1px solid hsl(var(--delphi-from) / 0.25);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.delphi-card .delphi-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.delphi-card .delphi-head .title { font-weight: 600; font-size: 12px; color: hsl(var(--delphi-ink)); }
.sparkle-btn {
  height: 28px;
  width: auto;
  padding: 0 10px;
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, hsl(var(--delphi-from)), hsl(var(--delphi-to)));
  color: white;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.sparkle-btn:hover { transform: scale(1.03); }
.sparkle-btn.sm { height: 22px; padding: 0 7px; font-size: 10.5px; }
.sparkle-btn.sm svg { width: 10px; height: 10px; }

/* ---------- Misc ---------- */
.advisory-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 6px;
  background: hsl(var(--warning-soft));
  color: hsl(var(--warning));
  border: 1px dashed hsl(var(--warning) / 0.4);
  border-radius: 3px;
}
.locked-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: hsl(215 30% 15%);
  color: white;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 50;
}
.stepper .step[data-state="locked"]:hover .locked-tooltip { opacity: 1; }

.placeholder {
  border: 1px dashed hsl(var(--border-strong));
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.3);
}
.placeholder .ico { display: grid; place-items: center; margin-bottom: 8px; }

/* Phase progress bar */
.phase-progress {
  display: flex; flex-direction: column; gap: 8px;
}
.phase-progress .row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.phase-progress .bar {
  height: 4px; background: hsl(var(--muted)); border-radius: 999px; overflow: hidden;
}
.phase-progress .bar > div {
  height: 100%; background: hsl(var(--accent)); transition: width 200ms ease;
}
.phase-progress .phases { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; }
.phase-progress .phases .ph { display: inline-flex; align-items: center; gap: 6px; color: hsl(var(--muted-foreground)); }
.phase-progress .phases .ph[data-state="done"] { color: hsl(var(--success)); }
.phase-progress .phases .ph[data-state="active"] { color: hsl(var(--primary)); font-weight: 600; }

/* ---------- Skeleton / ErrorState / EmptyState ---------- */
.skeleton {
  display: inline-block;
  background: linear-gradient(
    90deg,
    hsl(var(--muted) / 0.45) 0%,
    hsl(var(--muted) / 0.75) 50%,
    hsl(var(--muted) / 0.45) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.error-state {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid hsl(var(--destructive) / 0.4);
  background: hsl(var(--destructive) / 0.06);
  border-radius: var(--radius-sm);
}
.error-state.compact { padding: 8px 10px; gap: 8px; font-size: 11px; }
.error-state-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: hsl(var(--destructive) / 0.18);
  color: hsl(var(--destructive));
}
.error-state-body { min-width: 0; }
.error-state-title { font-weight: 600; font-size: 12.5px; color: hsl(var(--foreground)); }
.error-state-detail {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  margin-top: 2px;
  word-break: break-word;
  white-space: pre-wrap;
}
.error-state-class { font-size: 10.5px; color: hsl(var(--muted-foreground)); margin-top: 4px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 24px 16px;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--muted) / 0.25);
  text-align: center;
}
.empty-state-title { font-weight: 600; font-size: 13px; }
.empty-state-hint { max-width: 380px; line-height: 1.5; }

/* ---------- Login screen ----------
   Rendered by auth.jsx when no user is signed in. Uses the same
   design tokens as the rest of the app so the login lives on the
   same background as the workbench. All login-specific class names
   are prefixed `.login-*` (or scoped inside `.login-card`) to avoid
   colliding with existing form primitives. */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  background: hsl(var(--background));
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow:
    0 12px 32px hsl(215 30% 8% / 0.16),
    0 4px 10px hsl(215 30% 8% / 0.08);
  padding: 28px;
  display: flex; flex-direction: column;
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.login-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
}
.login-brand-text .brand-name {
  font-size: 15px; font-weight: 700;
  letter-spacing: 0.01em;
  color: hsl(var(--foreground));
  line-height: 1.1;
}
.login-brand-text .brand-sub {
  font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground));
  font-family: var(--font-mono);
  margin-top: 2px;
}
.login-hint {
  font-size: 12.5px; line-height: 1.55;
  color: hsl(var(--muted-foreground));
  margin: 4px 0 18px;
}
.login-card .field-label { margin-bottom: 6px; }
.login-input {
  height: 34px;
  padding: 8px 10px;
  font-size: 13px;
}
.login-error {
  font-size: 11.5px;
  color: hsl(var(--destructive));
  background: hsl(var(--destructive-soft));
  border: 1px solid hsl(var(--destructive) / 0.30);
  border-radius: var(--radius);
  padding: 7px 10px;
  display: flex; align-items: center; gap: 6px;
}
.login-foot {
  margin-top: 14px;
  font-size: 11px; text-align: center;
  color: hsl(var(--muted-foreground));
}
.login-foot b { color: hsl(var(--foreground)); font-weight: 600; }

/* ---------- Sign-out button in sidebar user card ---------- */
.user-card { position: relative; }
.user-logout {
  margin-left: auto;
  width: 24px; height: 24px;
  color: hsl(var(--sidebar-fg-muted));
  opacity: 0.7;
  transition: opacity 120ms ease, background 120ms ease;
}
.user-logout:hover {
  opacity: 1;
  background: hsl(var(--sidebar-hover-bg));
  color: hsl(var(--sidebar-fg));
}
.sidebar[data-collapsed="true"] .user-logout { display: none; }
