@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

:root {
  /* SLM portal — fixed blue accent */
  --bg: #f3f5f7;
  --bg-soft: #eef1f4;
  --surface: #ffffff;
  --surface2: #f4f6f8;
  --surface-hover: #e8ecf0;
  --tint: hsl(214 100% 97%);
  --tint-sidebar: #ffffff;
  --border: #e6eaee;
  --border-light: #94a3b8;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --accent: hsl(221 83% 53%);
  --accent-hover: hsl(221 83% 43%);
  --accent-soft: hsl(214 95% 93%);
  --accent-glow: hsl(221 83% 53% / 0.22);
  --accent-ring: hsl(213 97% 87%);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.1), 0 4px 6px -4px rgb(15 23 42 / 0.08);
  --header-h: 64px;
  --sidebar-w: 240px;
  --sidebar-w-expanded: 240px;
  --sidebar-w-collapsed: 72px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── App shell (DashboardLayout pattern) ─── */
.portal-shell {
  display: flex;
  min-height: 100vh;
}

.portal-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: var(--sidebar-w);
  height: 100vh;
  border-right: 1px solid var(--border);
  background: var(--surface);
  box-shadow: none;
  transition: transform var(--transition), width var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
  background: transparent;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
}

.sidebar-brand-link:hover { color: inherit; }

.sidebar-brand-text {
  display: inline;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  width: 100%;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.sidebar-link span { display: inline; }

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.sidebar-link.nav-active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
  box-shadow: none;
}

.sidebar-link.nav-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 24px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
  transform: translateY(-50%);
}

.sidebar-link.nav-active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
  width: 100%;
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.sidebar-link-muted:hover { color: var(--error); background: var(--error-soft); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
}

.portal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  background: var(--bg);
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-h);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-soft);
  border-color: var(--accent-ring);
  transform: none;
  box-shadow: none;
}

.topbar-heading { min-width: 0; flex: 0 1 auto; max-width: 14rem; }

.topbar-heading h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.3;
  color: var(--text);
}

.topbar-heading p {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
  line-height: 1.4;
  display: none;
}

@media (min-width: 1280px) {
  .topbar-heading { max-width: 18rem; }
  .topbar-heading p { display: block; }
}

.topbar-search {
  flex: 1;
  position: relative;
  min-width: 0;
  max-width: 36rem;
  margin: 0 auto;
}

.topbar-search-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--bg-soft);
}

.topbar-search-inner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
}

.topbar-search input[type="search"] {
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  background-image: none;
  box-shadow: none;
  min-height: auto;
  font-size: 0.875rem;
}

.topbar-search input[type="search"]:hover,
.topbar-search input[type="search"]:focus {
  border: none;
  box-shadow: none;
  background: transparent;
}

.topbar-search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  z-index: 230;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.topbar-search-item {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.topbar-search-item:hover,
.topbar-search-item:focus {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.topbar-search-empty {
  margin: 0;
  padding: 0.6rem 0.75rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  text-decoration: none;
}

.topbar-icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.topbar-icon-btn svg {
  width: 20px;
  height: 20px;
}

.topbar-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.topbar-crumb {
  color: var(--muted);
  text-decoration: none;
}

a.topbar-crumb:hover {
  color: var(--accent);
}

.topbar-crumb.current {
  color: var(--text-secondary);
  font-weight: 700;
}

.topbar-crumb-sep {
  color: #cbd5e1;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}

.topbar-quick {
  display: none !important;
}

.topbar-quick-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.topbar-quick-btn:hover {
  color: var(--accent-hover);
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}

.topbar-user {
  position: relative;
}

.topbar-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  min-height: 42px;
  padding: 0.2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font-weight: 600;
}

.topbar-user-btn:hover {
  border-color: transparent;
  background: var(--bg-soft);
  transform: none;
  box-shadow: none;
}

.topbar-user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, white), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  box-shadow: 0 0 0 2px var(--surface);
}

.topbar-user-meta {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  max-width: 11rem;
}

.topbar-user-name {
  font-size: 0.8rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.topbar-user-plan {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-hover);
}

.topbar-user-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 220;
  width: min(280px, calc(100vw - 2rem));
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.topbar-user-menu-head {
  padding: 0.75rem 0.85rem 0.85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}

.topbar-user-org {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.topbar-user-email {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
  word-break: break-all;
}

.topbar-user-trial {
  margin-top: 0.55rem;
  display: inline-flex;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.7rem;
  font-weight: 700;
}

.topbar-user-item {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: none;
  min-height: auto;
}

.topbar-user-item:hover {
  background: var(--bg-soft);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.topbar-user-logout {
  color: var(--error);
}

.topbar-user-logout:hover {
  background: var(--error-soft);
  color: var(--error);
}

.sidebar-plan-badge {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: var(--space-2);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--accent-hover);
}

.sidebar-plan-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.sidebar-plan-days {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-plan-badge.is-urgent {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
  color: #b45309;
}

.sidebar-plan-badge.is-expired {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--muted);
}

@media (min-width: 900px) {
  .topbar-user-meta { display: flex; }
}

/* ─── Auth split layout (AuthLayout pattern) ─── */
.portal-auth-page {
  background: linear-gradient(160deg, var(--tint) 0%, var(--bg) 42%, var(--surface) 100%);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1fr;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  text-decoration: none;
  color: var(--text);
  width: fit-content;
}

.auth-logo span {
  font-size: 1.2rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.04em;
}

.auth-form-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.auth-hero {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background:
    radial-gradient(circle at 20% 20%, rgba(16, 183, 127, 0.2), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(45, 212, 191, 0.16), transparent 40%),
    linear-gradient(135deg, var(--tint) 0%, #f0fdf9 40%, var(--bg-soft) 100%);
  text-align: center;
}

.auth-hero h2 {
  font-size: 1.85rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.045em;
  margin-bottom: var(--space-4);
  max-width: 24ch;
  color: var(--text);
}

.auth-hero p {
  color: var(--muted);
  font-size: 1rem;
  max-width: 36ch;
  line-height: 1.6;
}

.auth-page-title {
  font-size: 1.6rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.04em;
  margin-bottom: var(--space-2);
}

.auth-page-subtitle {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-bottom: var(--space-6);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace;
  font-size: 0.85em;
  background: var(--surface2);
  padding: 0.15em 0.45em;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ─── Header ─── */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-8);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: white;
  box-shadow: 0 8px 20px var(--accent-glow);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.portal-header h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.portal-header p {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
  line-height: 1.4;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.portal-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  transition: color var(--transition), background var(--transition);
}

.portal-nav a:hover { color: var(--text); background: var(--surface2); }

.portal-nav a.nav-active {
  color: var(--text);
  background: var(--surface2);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border-light);
}

.portal-nav a[data-nav-logout] { margin-left: 2px; }
.portal-nav a[data-nav-logout]:hover {
  color: var(--error);
  background: var(--error-soft);
}

/* ─── Layout ─── */
.portal-main {
  flex: 1;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: var(--space-6) var(--space-6) 80px;
}

/* Full-bleed content pages (Models, Training, etc.). Dashboard stays constrained via .lumen-dashboard */
.portal-main-wide {
  max-width: none;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.page-intro { margin-bottom: var(--space-1); }

.page-intro h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
  line-height: 1.25;
}

.page-intro p {
  color: var(--muted);
  font-size: 0.9375rem;
  max-width: 56ch;
  line-height: 1.55;
}

/* ─── Cards ─── */
.card,
.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card + .card,
.portal-card + .portal-card,
.page-stack > .card { margin-bottom: 0; }

.card:hover,
.portal-card:hover {
  border-color: var(--accent-ring);
  box-shadow: 0 12px 28px rgba(16, 183, 127, 0.08);
}

.card h2:not(.section-title) {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
}

.section-title {
  font-size: 0.6875rem;
  margin-bottom: var(--space-4);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

.section-header-row .section-title {
  margin-bottom: 0;
}

/* ─── Forms ─── */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: var(--space-4) 0 var(--space-2);
}

label:first-child,
.form-field:first-child label { margin-top: 0; }

input,
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder,
textarea::placeholder { color: var(--muted); }

input:hover,
textarea:hover,
select:hover { border-color: #cbd5e1; }

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

input[type="search"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  padding-left: 36px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; cursor: pointer; }

/* ─── Buttons ─── */
button,
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  transition: opacity var(--transition), background var(--transition), border-color var(--transition), transform 0.12s ease, box-shadow var(--transition);
  box-shadow: 0 8px 18px var(--accent-glow);
  line-height: 1.4;
}

button:hover:not(:disabled),
.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px var(--accent-glow);
}

button.secondary,
.btn.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

button.secondary:hover:not(:disabled),
.btn.secondary:hover {
  border-color: var(--accent-ring);
  background: var(--bg);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

button.btn-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: var(--error);
  margin-top: 0;
  box-shadow: none;
}

button.btn-danger:hover:not(:disabled) {
  background: var(--error-soft);
  box-shadow: none;
  transform: translateY(-1px);
}

button.btn-delete {
  background: var(--surface2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--error);
  margin-top: 0;
  font-weight: 600;
  box-shadow: none;
}

button.btn-delete:hover:not(:disabled) {
  background: var(--error-soft);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* GPU On stays full accent blue like other primary buttons (even when disabled) */
button.gpu-power-on,
button.gpu-power-on:disabled {
  opacity: 1;
  background: var(--accent);
  color: white;
}

button.gpu-power-on:disabled {
  cursor: not-allowed;
}

button.gpu-power-on:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* Segmented ON / OFF toggle (same square control) */
.gpu-power-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: var(--space-2);
  background: var(--surface-hover);
}

.gpu-power-toggle .gpu-power-seg {
  margin: 0;
  min-width: 72px;
  min-height: 40px;
  padding: 8px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: none;
  opacity: 1;
}

.gpu-power-toggle .gpu-power-seg + .gpu-power-seg {
  border-left: 1px solid var(--border);
}

.gpu-power-toggle .gpu-power-seg.is-active {
  background: var(--accent);
  color: #fff;
}

.gpu-power-toggle .gpu-power-seg:hover:not(:disabled):not(.is-active) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.gpu-power-toggle .gpu-power-seg:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.gpu-power-toggle .gpu-power-seg.is-active:disabled {
  background: var(--accent);
  color: #fff;
  opacity: 1;
}

button:focus-visible,
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted { color: var(--muted); font-size: 0.875rem; }

.text-error {
  color: var(--error) !important;
  font-size: 0.8125rem;
}

.error-box {
  color: #b91c1c;
  background: var(--error-soft);
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-top: var(--space-4);
  font-size: 0.875rem;
  line-height: 1.5;
}

.info-box {
  color: var(--muted);
  background: var(--tint);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
}

.hidden { display: none !important; }

/* ─── Auth ─── */
.portal-auth-main { max-width: none; padding-top: 0; }

.auth-card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  background: var(--surface);
  border-radius: var(--radius-xl);
}

.auth-card:hover {
  border-color: var(--accent-ring);
  box-shadow: 0 20px 40px rgba(16, 183, 127, 0.08);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.auth-card { height: 100%; }

.auth-card h2.auth-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--space-2);
  text-transform: none;
}

.auth-card .card-desc {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: var(--space-2);
  line-height: 1.5;
}

.auth-card-single {
  max-width: 420px;
  margin: var(--space-6) auto 0;
}

.auth-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.auth-footer-btn { margin-top: 0; width: 100%; text-align: center; }

/* ─── Dataset / job rows ─── */
.dataset-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-5);
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.dataset-row:first-child { padding-top: var(--space-1); }
.dataset-row:last-child { border-bottom: none; padding-bottom: var(--space-1); }

.dataset-row h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}

.dataset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.pill.ready,
.pill.status-completed {
  border-color: rgba(22, 163, 74, 0.35);
  color: #15803d;
  background: var(--success-soft);
}

.pill.status-running,
.pill.status-pending,
.pill.status-merging {
  border-color: rgba(16, 183, 127, 0.3);
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.pill.status-failed,
.pill.status-cancelled {
  border-color: rgba(220, 38, 38, 0.3);
  color: #b91c1c;
  background: var(--error-soft);
}

.dataset-row .actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  margin-top: 0;
  align-items: center;
}

.dataset-row .actions button { margin-top: 0; }

.empty-state {
  text-align: center;
  padding: 48px var(--space-4);
  color: var(--muted);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-xl);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  opacity: 0.7;
}

.empty-state p { font-size: 0.9rem; line-height: 1.55; }

/* ─── Loading ─── */
.loading-dots::after {
  content: "";
  animation: loadingDots 1.2s steps(4, end) infinite;
}

@keyframes loadingDots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

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

/* ─── Modals ─── */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}

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

.preview-modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: min(1100px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.preview-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.preview-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}

.preview-toolbar {
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-soft);
}

.preview-toolbar input { flex: 1; min-width: 180px; margin: 0; }

.view-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.view-tab {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  margin: 0;
  box-shadow: none;
}

.view-tab:hover {
  color: var(--text);
  background: var(--surface2);
  transform: none;
  box-shadow: none;
}

.view-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.preview-body {
  overflow-y: auto;
  padding: var(--space-4) var(--space-6) var(--space-6);
  flex: 1;
}

.preview-summary {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
  color: var(--muted);
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.6;
}

.preview-summary strong { color: var(--text); }

.sample-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: border-color var(--transition);
}

.sample-card:hover { border-color: var(--border-light); }

.sample-card h4 {
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  font-weight: 600;
}

.sample-field { margin-bottom: var(--space-3); }
.sample-field:last-child { margin-bottom: 0; }

.sample-label {
  font-size: 0.6875rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.sample-text {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: var(--text-secondary);
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.chat-bubble.user {
  background: var(--tint);
  border-left: 3px solid var(--accent);
}

.chat-bubble.assistant {
  background: var(--success-soft);
  border-left: 3px solid var(--success);
}

.chat-role {
  font-size: 0.625rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-1);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.preview-json {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  color: var(--text-secondary);
}

.edit-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
}

.edit-json {
  width: 100%;
  min-height: 420px;
  flex: 1;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
}

.edit-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--bg-soft);
}

.edit-footer button { margin-top: 0; }

.preview-empty {
  text-align: center;
  padding: 48px var(--space-4);
  color: var(--muted);
}

.close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  font-size: 1.125rem;
  line-height: 1;
  margin: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
  min-width: 32px;
  min-height: 32px;
}

.close-btn:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface2);
  transform: none;
  box-shadow: none;
}

/* ─── Train page ─── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

.form-field label { margin-top: 0; }

#startTrainBtn { margin-top: var(--space-5); }

.progress-bar-wrap {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: var(--space-4) 0 var(--space-3);
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-meta {
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#progressCard {
  border-color: rgba(79, 70, 229, 0.25);
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.06), var(--shadow-md);
}

#chatCard {
  border-color: rgba(22, 163, 74, 0.2);
}

.chat-messages {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.chat-input-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  resize: vertical;
  min-height: 130px;
}

.chat-input-row button {
  margin-top: 0;
  flex-shrink: 0;
}

.agent-id-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 13px;
}

.agent-id-row code {
  font-size: 12px;
  word-break: break-all;
}

.usage-code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}

.btn-copy {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
  margin-top: 0;
}


.actions-row button { margin-top: 0; }

/* ─── Dashboard / pipeline ─── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.step-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.step-pill.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.step-pill.done {
  color: var(--success);
  background: var(--success-soft);
}

.step-pill.fail {
  color: var(--error);
  background: var(--error-soft);
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-xl);
  padding: 48px var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 12px 28px var(--accent-glow);
}

.dropzone input { display: none; }

.dropzone strong { color: var(--accent); font-weight: 600; }

.dropzone .filename {
  margin-top: var(--space-3);
  color: var(--accent);
  font-weight: 500;
  font-size: 0.875rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  margin-top: var(--space-4);
  font-size: 0.875rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.running {
  background: var(--warning);
  animation: pulse 1.2s ease-in-out infinite;
}

.dot.done { background: var(--success); }
.dot.fail { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.summary-box,
.text-out {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.6;
  color: var(--text-secondary);
}

.rec-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  background: var(--bg-soft);
}

.rec-card:hover {
  border-color: var(--border-light);
  background: var(--surface2);
}

.rec-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.rec-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}

.rec-card p {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.rec-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: var(--space-2);
}

.tabs {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  margin: 0;
  box-shadow: none;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface2);
  transform: none;
  box-shadow: none;
}

.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.meta-item {
  background: var(--bg-soft);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.meta-item span {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
}

.meta-item strong {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* TDG status badges */
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status.queued, .status.processing { background: var(--accent-soft); color: var(--accent-hover); }
.status.awaiting { background: var(--warning-soft); color: var(--warning); }
.status.done { background: var(--success-soft); color: #15803d; }
.status.failed { background: var(--error-soft); color: #b91c1c; }

.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.actions button { width: auto; margin-top: 0; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Responsive ─── */
@media (min-width: 1024px) {
  .auth-shell { grid-template-columns: 1fr 1fr; }
  .auth-hero { display: flex; }
  .auth-panel { padding: var(--space-8) var(--space-12); }
}

@media (max-width: 1023px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-open .portal-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .portal-content { margin-left: 0; }

  .sidebar-toggle { display: inline-flex; }

  .topbar-heading { max-width: 40%; }
  .topbar-heading p { display: none; }
}

@media (max-width: 768px) {
  .portal-header { padding: var(--space-3) var(--space-4); }
  .portal-topbar { padding: var(--space-3) var(--space-4); }
  .portal-main { padding: var(--space-5) var(--space-4) 64px; }
  .auth-grid { grid-template-columns: 1fr; }
  .portal-nav { width: 100%; justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .pipeline { justify-content: center; }
}

@media (max-width: 640px) {
  .dataset-row { flex-direction: column; }
  .dataset-row .actions { width: 100%; }
  .dataset-row .actions button { flex: 1; }
  .preview-toolbar { flex-direction: column; align-items: stretch; }
  .view-tabs { justify-content: center; }
  .chat-input-row { flex-direction: column; align-items: stretch; }
  .chat-input-row button { width: 100%; }
  .topbar-heading { display: none; }
  .topbar-user-meta { display: none !important; }
}

/* Impersonation banner */
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 500;
  background: hsl(38 92% 50%);
  color: hsl(222 47% 11%);
  border-bottom: 2px solid hsl(38 92% 40%);
}
.impersonation-banner-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
  font-size: 14px;
}
.impersonation-banner-inner button { margin-left: auto; }

/* Agent detail */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.detail-tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}
.detail-tab {
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
  margin-bottom: -1px;
}
.detail-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.form-field-full { grid-column: 1 / -1; }
@media (max-width: 768px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* Admin */
.admin-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.admin-tab {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  margin-top: 0;
  min-height: auto;
  box-shadow: none;
}
.admin-tab:hover:not(.active) {
  background: var(--surface-hover);
  border-color: var(--border-light);
  color: var(--text);
}
.admin-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.admin-panel.hidden { display: none; }
.inline-form {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: var(--space-4);
}
.inline-form .form-field { flex: 1; min-width: 160px; }
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--tint);
}
.sidebar-link.hidden { display: none; }

/* ─── Agent detail page ─── */
.agent-detail { display: flex; flex-direction: column; gap: var(--space-5); }

.agent-detail-hero {
  padding: var(--space-5) var(--space-6);
}

.agent-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: var(--space-4);
  transition: color var(--transition);
}

.agent-back-link:hover { color: var(--accent); }

.agent-detail-hero-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.agent-detail-hero-text h2 {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: var(--space-3);
}

.agent-detail-subline {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: var(--space-2);
  line-height: 1.5;
}

.agent-detail-hero .actions-row {
  margin-top: 0;
  flex-shrink: 0;
}

.detail-tabs-sticky {
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: var(--bg);
  padding: var(--space-2) 0;
  margin-bottom: 0;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.detail-panel.hidden { display: none; }

.form-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.form-section-desc {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: calc(var(--space-4) * -1) 0 var(--space-4);
  line-height: 1.5;
}

.meta-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.meta-info-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.meta-info-item span {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.meta-info-item .meta-info-value {
  font-size: 0.875rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.meta-info-item .agent-id-row {
  margin-top: 0;
  font-size: 0.8125rem;
}

.agent-detail-save-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.agent-detail-save-row button { margin-top: 0; }

.feedback-success {
  color: #15803d;
  background: var(--success-soft);
  border: 1px solid rgba(22, 163, 74, 0.25);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.train-progress-block {
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.train-progress-block.hidden { display: none; }

.versions-section {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.chat-panel-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chat-api-panel {
  padding: var(--space-4);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.chat-api-panel.hidden { display: none; }

.chat-api-panel .usage-code { margin-bottom: var(--space-3); }

.detail-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.detail-tab:hover:not(.active) {
  color: var(--text);
  background: var(--surface2);
}

@media (max-width: 640px) {
  .agent-detail-hero-main { flex-direction: column; }
  .agent-detail-hero .actions-row { width: 100%; }
  .agent-detail-hero .actions-row button { flex: 1; }
}

/* Dashboard stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-grid-compact { margin-bottom: 0; }
.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, var(--tint) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: var(--space-2);
  font-weight: 600;
}
.stat-value {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.2;
  color: var(--text);
}
.stat-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--space-2);
}
.service-ok { color: var(--success, #16a34a); }
.service-degraded { color: #ca8a04; }
.service-down { color: var(--danger, #dc2626); }

/* ─── Toasts & confirm dialogs ─── */
.portal-toast-stack {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.portal-toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: auto;
}

.portal-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.portal-toast-success {
  border-color: rgba(22, 163, 74, 0.35);
  background: var(--success-soft);
  color: #15803d;
}

.portal-toast-error {
  border-color: rgba(220, 38, 38, 0.35);
  background: var(--error-soft);
  color: #b91c1c;
}

.portal-toast-info {
  border-color: rgba(79, 70, 229, 0.25);
  background: var(--accent-soft);
  color: var(--text-secondary);
}

.portal-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.18s ease;
}

.portal-confirm-overlay.hidden { display: none !important; }

.portal-confirm-modal {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.portal-confirm-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}

.portal-confirm-message {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.55;
  margin-bottom: var(--space-5);
  white-space: pre-wrap;
}

.portal-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.portal-confirm-actions button { margin-top: 0; }

/* ─── Dashboard use-case cards ─── */
.usecase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.usecase-card-title {
  margin: 0 0 var(--space-3);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.03em;
  color: var(--text);
  text-transform: none;
}

.usecase-card[data-key="xapi"] .usecase-card-title {
  color: #1d4ed8;
}

.usecase-card[data-key="prompt-injection"] .usecase-card-title {
  color: #b45309;
}

.usecase-card[data-key="trading"] .usecase-card-title {
  color: #047857;
}

.usecase-card[data-key="other"] .usecase-card-title {
  color: #0e7490;
}

.usecase-card-desc {
  margin-bottom: var(--space-3);
  min-height: 2.6em;
}

.usecase-card-meta {
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
}

.usecase-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.usecase-banner.hidden {
  display: none !important;
}

.usecase-banner-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-hover);
}

.usecase-banner-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: #1d4ed8;
}

.usecase-banner[data-key="xapi"] {
  border-left-color: #1d4ed8;
  background: #dbeafe;
}
.usecase-banner[data-key="xapi"] .usecase-banner-label { color: #1e40af; }
.usecase-banner[data-key="xapi"] .usecase-banner-title { color: #1d4ed8; }

.usecase-banner[data-key="prompt-injection"] {
  border-left-color: #b45309;
  background: #ffedd5;
}
.usecase-banner[data-key="prompt-injection"] .usecase-banner-label { color: #9a3412; }
.usecase-banner[data-key="prompt-injection"] .usecase-banner-title { color: #b45309; }

.usecase-banner[data-key="trading"] {
  border-left-color: #047857;
  background: #d1fae5;
}
.usecase-banner[data-key="trading"] .usecase-banner-label { color: #065f46; }
.usecase-banner[data-key="trading"] .usecase-banner-title { color: #047857; }

.usecase-banner[data-key="other"] {
  border-left-color: #0e7490;
  background: #cffafe;
}
.usecase-banner[data-key="other"] .usecase-banner-label { color: #155e75; }
.usecase-banner[data-key="other"] .usecase-banner-title { color: #0e7490; }

@media (max-width: 720px) {
  .usecase-grid { grid-template-columns: 1fr; }
}

/* ─── Dashboard pipeline (Phase 2) ─── */
.pipeline-sticky-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  margin-bottom: var(--space-5);
  padding: var(--space-2) 0 var(--space-3);
  background: linear-gradient(var(--bg) 70%, transparent);
}

.pipeline-track {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  padding: var(--space-2) var(--space-3);
  scrollbar-width: thin;
}

.pipeline-step {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.pipeline-connector {
  width: 20px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  transition: background var(--transition);
}

.pipeline-connector.done { background: var(--success); }
.pipeline-connector.active { background: var(--accent); }

.step-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: all var(--transition);
  white-space: nowrap;
  border: none;
  background: transparent;
  cursor: default;
  font-family: inherit;
  margin: 0;
  box-shadow: none;
  min-height: auto;
}

.step-pill.clickable {
  cursor: pointer;
}

.step-pill.clickable:hover:not(.active) {
  color: var(--text);
  background: var(--surface2);
}

.step-pill.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.step-pill.done {
  color: var(--success);
  background: var(--success-soft);
}

.step-pill.fail {
  color: var(--error);
  background: var(--error-soft);
}

.pipeline-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: var(--space-2);
  padding: 0 var(--space-1);
  font-size: 0.8125rem;
  color: var(--muted);
}

.pipeline-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.topbar-gpu {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.25rem 0.35rem 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.topbar-gpu-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.topbar-gpu .pill {
  margin: 0;
}

.topbar-gpu .gpu-power-toggle {
  margin-top: 0;
  border-radius: 999px;
}

.topbar-gpu .gpu-power-toggle .gpu-power-seg {
  min-width: 44px;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.7rem;
}

.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-1) 0;
  border-top: 1px solid var(--border);
}

.step-nav-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  text-align: center;
  flex: 1;
}

.step-nav button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.results-cta-row #btnCreateAgent {
  margin-top: 0;
}

@media (max-width: 700px) {
  .topbar-gpu-label { display: none; }
}

.gpu-power-msg {
  margin: var(--space-3) 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.advanced-settings {
  margin-top: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  overflow: hidden;
}

.advanced-settings summary {
  padding: var(--space-3) var(--space-4);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.advanced-settings summary::-webkit-details-marker { display: none; }

.advanced-settings summary::after {
  content: "▸";
  float: right;
  transition: transform var(--transition);
}

.advanced-settings[open] summary::after { transform: rotate(90deg); }

.advanced-settings-body {
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}

/* ─── Collapsible form sections ─── */
.form-collapse {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.form-collapse:last-of-type { margin-bottom: var(--space-5); }

.form-collapse-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.form-collapse-summary::-webkit-details-marker { display: none; }

.form-collapse-summary::after {
  content: "▸";
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform var(--transition);
}

.form-collapse[open] .form-collapse-summary::after { transform: rotate(90deg); }

.form-collapse-body {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.form-collapse-body .form-grid,
.form-collapse-body .form-grid-2 {
  margin-bottom: 0;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: var(--space-1);
  line-height: 1.4;
  font-weight: 400;
}

/* ─── Chat polish ─── */
.chat-panel-inner {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: min(72vh, 640px);
}

.chat-thread {
  flex: 1;
  min-height: 240px;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.chat-composer {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.chat-composer textarea {
  flex: 1;
  resize: vertical;
  min-height: 52px;
  max-height: 160px;
  margin: 0;
}

.chat-composer button {
  margin-top: 0;
  flex-shrink: 0;
}

.chat-message {
  max-width: 88%;
  align-self: flex-start;
}

.chat-message-user {
  align-self: flex-end;
}

.chat-message-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.chat-message-user .chat-message-head {
  flex-direction: row-reverse;
}

.chat-message-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-message-user .chat-message-avatar {
  background: var(--accent-soft);
  color: var(--accent);
}

.chat-message-assistant .chat-message-avatar {
  background: var(--success-soft);
  color: #15803d;
}

.chat-message-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.chat-copy-btn {
  margin-left: auto;
  padding: 2px 8px !important;
  font-size: 0.6875rem !important;
  min-height: auto !important;
}

.chat-message-user .chat-copy-btn { display: none; }

.chat-message-body {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message-user .chat-message-body {
  background: var(--accent-soft);
  border: 1px solid rgba(79, 70, 229, 0.15);
  border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-message-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-message-error .chat-message-body {
  border-color: rgba(220, 38, 38, 0.25);
  background: var(--error-soft);
  color: #b91c1c;
}

.typing-dots::after {
  content: "";
  animation: loadingDots 1.2s steps(4, end) infinite;
}

@media (max-width: 768px) {
  .portal-toast-stack {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }

  .chat-message { max-width: 95%; }

  .chat-composer { flex-direction: column; align-items: stretch; }
  .chat-composer button { width: 100%; }
}

/* ─── Phase 3: lists, cards, skeletons ─── */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.list-toolbar input[type="search"],
.list-toolbar select {
  margin: 0;
  width: auto;
  min-width: 180px;
  flex: 1;
}

.list-toolbar select {
  flex: 0 1 200px;
  padding-right: 28px;
}

.list-toolbar-count {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

button.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #10b77f);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.agent-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.agent-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.agent-card:hover {
  border-color: var(--accent-ring);
  box-shadow: 0 16px 32px rgba(16, 183, 127, 0.08);
  transform: translateY(-2px);
}

.agent-card-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.agent-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9375rem;
  flex-shrink: 0;
  box-shadow: 0 8px 18px var(--accent-glow);
}

.agent-card-head-text {
  flex: 1;
  min-width: 0;
}

.agent-card-head-text h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
  line-height: 1.3;
}

.agent-card-head-text h3 a {
  color: var(--text);
  text-decoration: none;
}

.agent-card-head-text h3 a:hover { color: var(--accent); }

.agent-card-sub {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.agent-card-status {
  flex-shrink: 0;
}

.agent-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.agent-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.agent-card-actions button {
  margin-top: 0;
  flex: 1;
  min-width: 72px;
  padding: 8px 12px;
  min-height: 36px;
  font-size: 0.8125rem;
}

.agent-card-actions button.primary-action {
  flex: 1.4;
}

.dataset-list-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: var(--space-1);
}

/* Skeleton loaders */
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface-hover) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}

.skeleton-line {
  height: 12px;
  margin-bottom: var(--space-2);
}

.skeleton-line.lg { height: 18px; width: 70%; }
.skeleton-line.md { height: 12px; width: 90%; }
.skeleton-line.sm { height: 10px; width: 55%; }

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.skeleton-pill-row {
  height: 24px;
  width: 60%;
  border-radius: 999px;
}

.skeleton-btn-row {
  height: 36px;
  width: 100%;
  border-radius: var(--radius-md);
}

.skeleton-row .skeleton-row-main { flex: 1; min-width: 0; }

.skeleton-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.skeleton-block {
  border-radius: var(--radius-lg);
  min-height: 80px;
}

.skeleton-block.hero { min-height: 120px; }
.skeleton-block.tabs { min-height: 44px; max-width: 420px; }
.skeleton-block.panel { min-height: 200px; }

.skeleton-row td { padding-top: var(--space-3); padding-bottom: var(--space-3); }

/* Agent detail tabs (Phase 3) */
.detail-tabs-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: var(--bg);
  padding: var(--space-2) 0 var(--space-3);
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.detail-tabs-bar .detail-tabs {
  margin-bottom: 0;
  border-bottom: none;
  gap: var(--space-1);
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.detail-tabs-bar .detail-tab {
  margin-bottom: 0;
  border-bottom: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  white-space: nowrap;
}

.detail-tabs-bar .detail-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.detail-tabs-bar .detail-tab .tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.tab-badge-training {
  background: var(--warning-soft);
  color: #b45309;
}

.tab-badge-ready {
  background: var(--success-soft);
  color: #15803d;
}

.tab-badge-muted {
  background: var(--surface2);
  color: var(--muted);
}

.data-table tr.version-active {
  background: var(--success-soft);
}

.data-table tr.version-active td:first-child {
  font-weight: 600;
  color: #15803d;
}

.data-table tr.version-active td {
  border-bottom-color: rgba(22, 163, 74, 0.2);
}

.list-empty-filter {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--muted);
  font-size: 0.9375rem;
}

@media (max-width: 640px) {
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .list-toolbar-count { margin-left: 0; }
  .agent-card-grid { grid-template-columns: 1fr; }
  .detail-tabs-bar .detail-tabs { width: 100%; }
}

.analytics-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.usage-chart { margin-top: var(--space-4); min-height: 160px; }
.usage-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.usage-bar-col { flex: 1; display: flex; align-items: flex-end; min-width: 0; }
.usage-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.usage-empty { padding: var(--space-8) 0; text-align: center; }

.analytics-fw { padding-top: var(--space-2); }
.analytics-fw .fw-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.analytics-fw .fw-tab {
  background: none;
  border: 0;
  padding: 8px 0 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  box-shadow: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.analytics-fw .fw-tab:hover { color: var(--text); background: none; transform: none; }
.analytics-fw .fw-tab.active {
  color: #6d28d9;
  border-bottom-color: #6d28d9;
  background: none;
}
.analytics-fw .fw-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.analytics-fw .fw-pills { display: flex; gap: 4px; }
.analytics-fw .fw-pill {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 5px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: 8px;
}
.analytics-fw .fw-pill:hover { background: var(--bg-soft); color: var(--text); transform: none; }
.analytics-fw .fw-pill.active {
  background: #e8e8ee;
  color: var(--text);
}
.analytics-fw .fw-controls-right { display: flex; align-items: center; gap: 8px; }
.analytics-fw .fw-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0 8px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}
.analytics-fw .fw-range select {
  border: 0;
  background: transparent;
  font-size: 0.8125rem;
  padding: 7px 4px 7px 0;
  color: inherit;
  box-shadow: none;
}
.analytics-fw .fw-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  box-shadow: none;
}
.analytics-fw .fw-icon-btn:hover { background: var(--bg-soft); transform: none; }
.analytics-fw .fw-banner {
  font-size: 0.8125rem;
  color: #5b21b6;
  background: #f3e8ff;
  border: 1px solid #ead9ff;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.analytics-fw .fw-chart-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px 12px;
}
.analytics-fw .fw-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.analytics-fw .fw-chart-title {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0 0 4px;
}
.analytics-fw .fw-chart-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.analytics-fw .fw-chart-total { text-align: right; }
.analytics-fw .fw-chart-total-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.analytics-fw .fw-chart-total strong {
  font-size: 1.35rem;
  font-weight: 700;
}
.analytics-fw .fw-chart-body { min-height: 220px; position: relative; }
.analytics-fw .fw-empty {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}
.analytics-fw .fw-learn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  background: #fff;
}
.analytics-fw .fw-learn:hover { background: var(--bg-soft); color: var(--text); }
.analytics-fw .fw-plot { padding: 12px 0 4px; }
.analytics-fw .usage-bars { height: 180px; }
.analytics-fw .usage-bar { background: #7c3aed; opacity: 0.85; }
.analytics-fw .fw-keys {
  margin-top: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}
.analytics-fw .fw-keys-title { font-size: 0.95rem; margin: 0 0 12px; }
.analytics-fw .fw-keys-form { display: flex; gap: 8px; margin-bottom: 12px; max-width: 360px; }
.analytics-fw .fw-keys-form input {
  flex: 1;
  padding: 7px 10px;
  font-size: 0.8125rem;
}
.analytics-fw .fw-keys-form button {
  padding: 7px 12px;
  font-size: 0.8125rem;
}

/* Training wizard */
.train-wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.train-wizard .card-desc {
  margin-top: -0.35rem;
  margin-bottom: var(--space-2);
}

.train-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.train-step.is-done .train-step-badge {
  background: var(--success);
}

.train-step-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
  box-shadow: none;
  min-height: auto;
}

.train-step-header.is-locked {
  cursor: default;
  opacity: 0.72;
}

.train-step-header:not(.is-locked):hover {
  background: var(--surface2);
}

.train-step-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}

.train-step-title {
  font-weight: 700;
  font-size: 0.9375rem;
}

.train-step-summary {
  margin-left: auto;
  font-size: 0.8125rem;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-step-chevron {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--transition);
  margin-left: var(--space-1);
}

.train-step.is-open .train-step-chevron {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.train-step-body {
  display: none;
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}

.train-step.is-open .train-step-body {
  display: block;
}

.train-step-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.train-step-actions-split {
  justify-content: space-between;
}

.train-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.train-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  background: var(--surface2);
}

.train-mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.train-mode-option input {
  margin: 0;
}

.train-upload-help {
  margin-top: var(--space-2);
  line-height: 1.5;
}

.train-upload-help a {
  margin-left: 0.35rem;
}

.train-settings-subtitle {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.train-settings-divider {
  padding-top: var(--space-2);
  margin-top: var(--space-1);
  border-top: 1px solid var(--border);
}

.field-error {
  color: var(--error);
  font-size: 0.8125rem;
  margin-top: var(--space-2);
}

select.input-error,
input.input-error {
  border-color: var(--error);
}

/* ─── Models library list ─── */
.model-lib-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.model-lib-hint {
  margin: 0;
  max-width: 36ch;
  text-align: right;
}

.model-lib-list {
  display: flex;
  flex-direction: column;
}

.model-lib-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: center;
  padding: 1rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.model-lib-row:last-child {
  border-bottom: none;
  padding-bottom: 0.25rem;
}

.model-lib-row:first-child {
  padding-top: 0.25rem;
}

.model-lib-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  background: #fff;
  display: grid;
  place-items: center;
  padding: 0.35rem;
}

.model-lib-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.model-lib-logo.qwen {
  background: #f5f3ff;
  padding: 0.3rem;
}

.model-lib-logo.smollm {
  background: #fff8df;
  padding: 0.2rem;
}

.model-lib-logo.mobilellm {
  background: #eef5ff;
  padding: 0.45rem 0.35rem;
}

.model-lib-logo.gemma {
  background: #fff;
  padding: 0.4rem;
}

.model-lib-logo.deepseek {
  background: #eef9ff;
  padding: 0.55rem 0.35rem;
}

.model-lib-logo.default {
  background: var(--accent-soft);
}

.model-lib-fallback {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-hover);
}

.model-lib-main {
  min-width: 0;
}

.model-lib-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.model-lib-title-row h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.model-lib-meta {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
}

.model-lib-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.model-lib-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.7rem;
  font-weight: 700;
}

.model-lib-tag.soft {
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

@media (max-width: 700px) {
  .model-lib-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .model-lib-side {
    grid-column: 2;
    justify-content: flex-start;
  }

  .model-lib-hint {
    text-align: left;
  }
}

.agent-lib-list .model-lib-row {
  align-items: center;
}

.agent-lib-desc {
  margin: 0.4rem 0 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.45;
  max-width: 72ch;
}

.agent-lib-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  max-width: 22rem;
}

.agent-lib-actions button {
  margin-top: 0;
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  box-shadow: none;
}

.agent-lib-actions button.primary-action {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
}

.agent-lib-actions button.primary-action:hover {
  background: var(--accent-hover);
  transform: none;
}

.model-lib-title-row h3 a {
  color: inherit;
  text-decoration: none;
}

.model-lib-title-row h3 a:hover {
  color: var(--accent-hover);
}

@media (max-width: 900px) {
  .agent-lib-actions {
    max-width: none;
    justify-content: flex-start;
  }
}

.sidebar-link:focus-visible,
.topbar-icon-btn:focus-visible,
.topbar-search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Lumen dashboard (Template 3) ─── */
.lumen-dash-wrap {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - var(--header-h));
}

.lumen-dash-main {
  flex: 1;
  min-width: 0;
}

.lumen-dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  max-width: 64rem; /* match Template 3 max-w-5xl */
  margin-left: auto;
  margin-right: auto;
}

.lumen-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.lumen-metric {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0;
  min-height: auto;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.lumen-metric:hover {
  transform: none;
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.lumen-metric.is-active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 28px var(--accent-glow);
}

.lumen-metric-label {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.lumen-metric.is-active .lumen-metric-label {
  color: rgba(255, 255, 255, 0.82);
}

.lumen-metric-value {
  margin: 0.75rem 0 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.lumen-metric-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.lumen-metric.is-active .lumen-metric-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.lumen-metric-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.lumen-chart-card,
.lumen-table-card {
  padding: 0;
  overflow: hidden;
}

.lumen-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5) 0;
}

.lumen-card-head-border {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.lumen-card-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lumen-card-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-hover);
  text-decoration: none;
}

.lumen-card-link:hover { text-decoration: underline; }

.lumen-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.lumen-sort select {
  width: auto;
  min-height: auto;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg);
}

.lumen-area-chart {
  position: relative;
  height: 240px;
  padding: var(--space-3) var(--space-4) var(--space-5);
  cursor: crosshair;
}

.lumen-area-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.lumen-chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 7.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.lumen-chart-tooltip[hidden] { display: none; }

.lumen-chart-tooltip strong {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
}

.lumen-chart-tooltip span {
  font-size: 0.75rem;
  color: var(--muted);
}

.lumen-chart-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}

.lumen-table-scroll { overflow-x: auto; }

.lumen-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.lumen-table th {
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.lumen-table td {
  padding: 0.95rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.lumen-table-name {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.lumen-table-name:hover { color: var(--accent-hover); }

.lumen-status {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}

.lumen-usecases .lumen-card-head {
  padding: 0;
  margin-bottom: var(--space-2);
  align-items: flex-end;
}

.lumen-usecases .lumen-card-head p {
  margin: 0;
  font-size: 0.8125rem;
}

.lumen-dash-aside {
  display: none;
  width: 288px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: var(--space-5);
  gap: var(--space-6);
  flex-direction: column;
}

.lumen-aside-card h2 {
  margin: 0 0 var(--space-4);
  font-size: 0.875rem;
  font-weight: 700;
}

.lumen-donut-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}

.lumen-donut {
  width: 100%;
  height: 100%;
  display: block;
}

.lumen-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.lumen-donut-center strong {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lumen-donut-center span {
  font-size: 0.625rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lumen-legend {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lumen-legend li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.lumen-legend-bar {
  width: 4px;
  height: 1.75rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.lumen-legend-name {
  flex: 1;
  color: var(--muted);
}

.lumen-legend strong {
  font-weight: 700;
  color: var(--text);
}

.lumen-activity {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lumen-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition), color var(--transition);
}

.lumen-activity-item:hover,
.lumen-activity-item.is-active {
  background: var(--accent);
  color: #fff;
}

.lumen-activity-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  flex-shrink: 0;
}

.lumen-activity-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.lumen-activity-copy strong {
  font-size: 0.875rem;
  font-weight: 700;
}

.lumen-activity-copy span {
  font-size: 0.75rem;
  color: var(--muted);
}

.lumen-activity-item:hover .lumen-activity-copy span,
.lumen-activity-item.is-active .lumen-activity-copy span {
  color: rgba(255, 255, 255, 0.8);
}

@media (min-width: 1200px) {
  .lumen-dash-aside {
    display: flex;
  }

  .lumen-dash-main.portal-main {
    max-width: none;
    padding-right: var(--space-5);
  }

  .lumen-dash-main .lumen-dashboard {
    margin-left: auto;
    margin-right: auto;
  }
}

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

@media (max-width: 640px) {
  .lumen-metric-value { font-size: 1.65rem; }
  .lumen-area-chart { height: 200px; }
}


