:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e8eaef;
  --muted: #9aa3b5;
  --accent: #6c8cff;
  --accent2: #8b5cf6;
  --danger: #ef4444;
  --success: #22c55e;
  --sidebar-w: 260px;
  --radius: 10px;
  --focus-ring: 0 0 0 3px rgba(108, 140, 255, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #1e2540 0%, var(--bg) 60%);
}

.auth-legal {
  width: 100%;
  max-width: 420px;
  margin-top: 8px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 8px; }
.auth-card .sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
}
.auth-tabs button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-color: transparent;
}
.human-challenge-code {
  display: inline-block;
  padding: 10px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.35rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.form-group input {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 8px;
}
.btn:focus-visible,
.nav-item:focus-visible,
.account-nav-item:focus-visible,
.oauth-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.header-actions .btn-secondary { margin-top: 0; }
.oauth-row { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.oauth-btn:hover { background: var(--surface2); }
.divider { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 12px 0; }
.checkbox-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.85rem; color: var(--muted); margin-bottom: 16px; }
.alert { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 0.9rem; }
.alert-error { background: rgba(239,68,68,.15); color: #fca5a5; }
.alert-info { background: rgba(108,140,255,.15); color: #a5b4fc; }
.hidden { display: none !important; }

/* Portal layout */
.portal { display: flex; min-height: 100vh; }
.enterprise-account-page {
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
}
.enterprise-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 16px;
  flex-wrap: wrap;
}
.enterprise-page-header h1 { font-size: 1.5rem; margin: 8px 0 4px; }
.enterprise-page-header .sub { margin: 0; }
.back-link { font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--accent); }
.header-actions { display: flex; gap: 10px; align-items: center; }
.account-hub-full {
  flex: 1;
  padding: 24px 32px 48px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-height: calc(100vh - 120px);
}
.account-content-full {
  min-height: 520px;
}
.card-static { cursor: default; }
.card-static:hover { border-color: var(--border); }
.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.input-dark {
  flex: 1;
  min-width: 160px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.key-reveal-box {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.key-reveal-box code {
  display: block;
  word-break: break-all;
  margin: 8px 0;
  font-size: 0.9rem;
}
.code-block {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  overflow-x: auto;
  color: var(--muted);
}
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 12px; }
.library-build-status,
.library-upload-status { margin: 8px 0 12px; min-height: 1.25em; white-space: pre-wrap; }
.library-pii-option { display: block; margin: 4px 0 8px; font-size: 0.85rem; cursor: pointer; }
.library-pii-option input { margin-right: 6px; }
.library-build-status-active { color: var(--text, #e8eaed); font-weight: 500; }
.library-ingest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.library-ingest-card { padding: 14px 16px; }
.library-ingest-title { margin: 0 0 6px; font-size: 0.95rem; font-weight: 600; }
.library-ingest-hint { margin: 0 0 10px; font-size: 0.8rem; }
.library-source-card { padding: 16px; margin-bottom: 16px; }
.library-source-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.library-source-form {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .library-source-form { grid-template-columns: 1fr 1fr; }
}
.library-source-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted, #9aa0a6);
  margin-bottom: 4px;
}
.library-source-field-wide { grid-column: span 1; }
.library-source-field-full { grid-column: 1 / -1; }
.library-source-path-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.library-source-path-row .input-dark { flex: 1 1 auto; min-width: 0; }
.library-source-path-row .btn.hidden { display: none; }
.library-source-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.library-source-type-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  cursor: pointer;
}
.library-source-url-only.hidden,
.library-source-folder-only.hidden { display: none !important; }
.library-source-max-pages {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.library-source-max-pages .input-dark {
  width: 72px;
  padding: 4px 8px;
}
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}
.library-field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.library-file-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.library-file-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}
.library-browse-network {
  padding: 10px 14px 0;
  border-bottom: 1px solid var(--border);
}
.library-browse-network-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 10px;
}
.library-browse-network-row .input-dark { flex: 1 1 auto; min-width: 0; }
.library-browse-stats {
  padding: 6px 14px;
  font-size: 0.76rem;
  border-bottom: 1px solid var(--border);
}
.library-browse-item-network .browse-icon { color: var(--accent, #6ea8fe); }
.library-bulk-card { padding: 16px; margin-bottom: 16px; }
.library-bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
.library-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.library-schedule-form {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.library-schedule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 10px 0;
  font-size: 0.82rem;
}
.library-schedule-row select { min-width: 140px; }
.library-schedule-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.library-schedule-status { margin-top: 8px; white-space: pre-wrap; font-size: 0.78rem; }
.library-source-select-cell { flex: 0 0 auto; padding-top: 2px; }
.library-source-row { align-items: flex-start; }
.library-browse-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.library-browse-modal.hidden { display: none !important; }
.library-browse-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.library-browse-panel {
  position: relative;
  width: min(560px, 96vw);
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.library-browse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.library-browse-head h4 { margin: 0; font-size: 0.95rem; }
.library-browse-path {
  padding: 8px 14px;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.library-browse-list {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px;
  min-height: 200px;
  max-height: 360px;
}
.library-browse-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.88rem;
}
.library-browse-item:hover { background: rgba(255, 255, 255, 0.06); }
.library-browse-item .browse-icon { opacity: 0.7; }
.library-browse-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.library-sources-list { margin-top: 8px; }
.library-source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border, #3c4043);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface2, #1e2128);
}
.library-source-meta { flex: 1 1 200px; min-width: 0; }
.library-source-meta strong { display: block; font-size: 0.88rem; }
.library-source-meta code {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
  margin-top: 2px;
}
.library-source-stats { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.library-scan-result { margin-top: 10px; white-space: pre-wrap; font-size: 0.82rem; }
.library-build-row { margin-bottom: 4px; }
.section-heading { margin: 24px 0 10px; font-size: 0.95rem; font-weight: 600; }
.brand-logo { max-height: 28px; max-width: 180px; vertical-align: middle; object-fit: contain; }
.brand-logo.hidden { display: none !important; }
.brand-lockup { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.brand-lockup.has-logo [data-brand="product"] { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.auth-brand-lockup { text-align: center; align-items: center; margin-bottom: 4px; }
.auth-brand-lockup .auth-logo { max-height: 56px; max-width: 220px; margin: 0 auto 12px; }
.auth-brand-lockup h1 { margin: 0; }
.auth-brand-lockup.has-logo .auth-headline-fallback {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.auth-brand-lockup .auth-logo {
  max-height: 120px;
  max-width: min(360px, 92vw);
  width: auto;
  height: auto;
}
.enterprise-header-brand { flex-direction: row; align-items: flex-start; gap: 16px; }
.enterprise-header-brand .header-logo { max-height: 44px; max-width: 160px; margin-top: 4px; }
.sidebar-brand img.brand-logo { display: block; }
.sidebar-brand.brand-lockup.has-logo .brand-logo { max-height: 36px; max-width: 200px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex-shrink: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  z-index: 20;
}

.portal-sidebar-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--header-h, 64px);
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.portal-sidebar-head .sidebar-brand {
  flex: 1;
  min-width: 0;
  padding: 0;
  margin: 0;
  border-bottom: none;
}

.portal-sidebar-collapse-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 1.125rem;
  line-height: 1;
}

.portal-sidebar-collapse-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.portal-sidebar-scroll {
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.portal-sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.portal-sidebar-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 999px;
}

.portal-sidebar-nav {
  padding: 8px 8px 16px;
}

.nav-group {
  margin-bottom: 4px;
}

.nav-group-platform {
  padding-bottom: 4px;
}

.sidebar-brand {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
}

.portal .sidebar-brand.brand-lockup {
  gap: 4px;
}

.portal .sidebar-brand.brand-lockup.has-logo .brand-logo {
  max-height: 32px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.9rem;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.3;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item-link {
  color: var(--muted);
}

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

.nav-item.active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface2));
  color: var(--accent, var(--text));
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-section {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 14px 12px 6px;
  font-weight: 700;
}

.nav-group:first-child .nav-section {
  padding-top: 8px;
}

.history-list {
  padding: 0 4px 8px;
  max-height: 168px;
  overflow-y: auto;
}

.history-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
}
.history-item-title { display: block; overflow: hidden; text-overflow: ellipsis; }
.history-item:hover { background: var(--surface2); color: var(--text); }
.history-item.selected {
  background: var(--accent-muted, rgba(108, 140, 255, 0.12));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.history-item-meta { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.history-list--full { max-height: none; padding: 0; }
.history-panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.history-panel-head .hint { flex: 1; min-width: 200px; margin: 0; font-size: 0.88rem; color: var(--muted); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

.portal-panel-intro { margin-bottom: 20px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.portal-panel-intro code { font-size: 0.82rem; }
.portal-field-label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 8px; }
.research-textarea {
  width: 100%;
  min-height: 88px;
  max-height: 200px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  resize: vertical;
  margin-bottom: 12px;
  font-family: inherit;
  line-height: 1.5;
}
.research-options { margin-bottom: 14px; }
.research-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.research-status { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 0.88rem; color: var(--muted); }
.research-output { white-space: pre-wrap; line-height: 1.55; }
.research-sources { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-size: 0.82rem; }
.research-sources h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.research-sources ul { margin: 0; padding-left: 18px; color: var(--muted); }

.upgrade-status-banner {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 20px;
}
.upgrade-status-banner strong { color: var(--text); }
.upgrade-checkout-box {
  margin-top: 20px;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.upgrade-actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.upgrade-usage-block {
  margin-bottom: 20px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.upgrade-usage-block h4 { margin: 0 0 8px; font-size: 0.95rem; }
.upgrade-usage-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.upgrade-usage-kpi {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.upgrade-usage-kpi .label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}
.upgrade-compare-wrap { margin-bottom: 8px; }
.upgrade-compare-wrap h4 { margin: 0 0 10px; font-size: 0.95rem; }
.upgrade-compare-table td, .upgrade-compare-table th { font-size: 0.82rem; }
.upgrade-compare-table tr.selected td { background: rgba(108, 140, 255, 0.08); }
.upgrade-metering-note { margin-top: 10px; font-size: 0.78rem; }
.plan-card-tokens {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 6px 0 8px;
}
.upgrade-plan-detail {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.upgrade-plan-detail h4 { margin: 0 0 12px; font-size: 0.9rem; }
.upgrade-detail-dl { margin: 0; }
.upgrade-detail-dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.upgrade-detail-dl div:last-child { border-bottom: none; }
.upgrade-detail-dl dt { color: var(--muted); margin: 0; }
.upgrade-detail-dl dd { margin: 0; font-weight: 600; text-align: right; }

.alert-warn { background: rgba(245, 158, 11, 0.12); color: #fcd34d; }

.portal-sidebar-footer,
.sidebar-footer {
  grid-row: 3;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 12px 10px 14px;
  position: relative;
  background: var(--surface);
  z-index: 3;
}

.portal-sidebar-profile-pin {
  margin-top: 0;
}

.portal-sidebar-footer--elevated {
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.22);
}

.portal-sidebar-user-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  text-align: left;
}

.portal-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.portal-user-plan {
  font-size: 0.75rem;
  color: var(--muted);
}

.portal-signout-btn {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius);
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: var(--surface2);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.user-menu-btn:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.user-dropdown {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 4px;
  display: none;
  z-index: 100;
}
.user-dropdown.open { display: block; }
.user-dropdown button, .user-dropdown a {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.user-dropdown button:hover { background: var(--bg); }
.user-dropdown .danger { color: var(--danger); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-sidebar-expand-btn {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
}

.portal-sidebar-expand-btn:hover {
  border-color: var(--accent);
}

.portal-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.portal-theme-toggle:hover {
  border-color: var(--accent);
  background: var(--bg);
}

.portal-theme-toggle .theme-icon {
  display: block;
}

.main-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.main-header h2 { font-size: 1.25rem; }
.main-body {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.panel { display: none; }
.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Panels with bottom composer (New chat, Deep research) fill main column */
.main-body > .panel.active:not(#panel-chat):not(#panel-research) {
  display: block;
  overflow-y: auto;
  padding: 24px;
}

.chat-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px clamp(16px, 3vw, 28px) 16px;
}

.chat-empty-hint {
  margin: 0;
  padding: 32px 20px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface2) 50%, transparent);
}

.chat-messages:has(.prompt-turn) .chat-empty-hint,
.chat-messages:has(.chat-response:not(.hidden)) .chat-empty-hint,
.research-messages:has(.prompt-turn) .research-empty-hint,
.research-messages:has(.research-output:not(.hidden)) .research-empty-hint,
.research-messages:has(.research-status:not(.hidden)) .research-empty-hint {
  display: none;
}

.prompt-turns {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.prompt-turn {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prompt-turn-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.prompt-turn-ask {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.prompt-turn-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
}

.prompt-turn-attachments {
  margin-top: 8px;
}

.prompt-turn-response .chat-response,
.prompt-turn-response .research-output {
  margin: 0;
}

.research-intro {
  display: none;
}

.portal-unified-composer {
  flex: 0 0 auto;
  padding: 12px clamp(16px, 3vw, 28px) 16px;
}

.portal-composer-route {
  padding: 0 0 8px;
}

.portal-auto-route-badge {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent, #6c8cff);
  line-height: 1.35;
}

.portal-auto-route-badge.portal-auto-route-badge-idle {
  color: var(--muted);
  font-weight: 500;
}

.portal-composer-box {
  position: relative;
}

.portal-unified-composer .portal-composer-box .chat-prompt-input,
.portal-unified-composer .portal-composer-box textarea {
  height: 96px;
  min-height: 88px;
  max-height: 120px;
  resize: none;
  margin-bottom: 0;
  padding: 12px 56px 12px 14px;
  box-sizing: border-box;
}

.portal-send-inline {
  position: absolute;
  right: 10px;
  bottom: 10px;
  margin: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 2;
}

.portal-send-inline .portal-send-logo {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: contain;
  pointer-events: none;
}

.portal-composer-advanced {
  display: none !important;
}

.chat-layout.portal-has-response .chat-messages,
.research-layout.portal-has-response .research-messages {
  flex: 1 1 auto;
  min-height: 0;
}

.research-messages .research-status {
  margin-top: 0;
  margin-bottom: 12px;
}

.research-messages .research-output {
  margin-top: 0;
  margin-bottom: 12px;
}

.research-messages .research-sources {
  margin-top: 0;
}

.research-composer .research-actions {
  justify-content: flex-end;
  gap: 10px;
}

.research-composer .research-actions .btn {
  min-width: 120px;
}

.chat-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  padding: 16px clamp(16px, 3vw, 28px) 20px;
}

.chat-composer-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.chat-prompt-input,
.chat-area textarea {
  width: 100%;
  min-height: 88px;
  max-height: 200px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  margin-bottom: 12px;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.chat-prompt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.chat-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.chat-opt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
}

.chat-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-opt-select {
  margin-left: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
}

.chat-scope-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  opacity: 0.9;
}

.chat-composer-actions {
  display: flex;
  justify-content: flex-end;
}

.chat-composer-actions .btn-primary {
  min-width: 120px;
  padding: 10px 28px;
}

.chat-response {
  margin-top: 0;
  padding: 16px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  white-space: pre-wrap;
}

.chat-response.chat-response-formatted {
  white-space: normal;
}
.chat-response-formatted .chat-md h1 { font-size: 1.35rem; margin: 0 0 12px; }
.chat-response-formatted .chat-md h2 { font-size: 1.15rem; margin: 18px 0 8px; color: var(--text); }
.chat-response-formatted .chat-md h3 { font-size: 1rem; margin: 14px 0 6px; }
.chat-response-formatted .chat-md table.chat-md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 16px;
  font-size: 0.9rem;
}
.chat-response-formatted .chat-md table.chat-md-table td,
.chat-response-formatted .chat-md table.chat-md-table th {
  border: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: top;
}
.chat-response-formatted .chat-md-table {
  width: max-content;
  min-width: 100%;
}
.chat-response-formatted .chat-md-table th {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-weight: 700;
}
.chat-table-shell {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.chat-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.chat-table-meta {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}
.chat-table-expand-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chat-table-scroll {
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-table-shell.is-expanded .chat-table-scroll {
  max-height: min(68vh, 560px);
}
.chat-response-rich-only .chat-view-pane-rich-only {
  width: 100%;
}
.chat-response-formatted .chat-md blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 0.9rem;
}
.chat-response-formatted .chat-md pre {
  overflow-x: auto;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.85rem;
}
.chat-response-rich .chat-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.chat-response-rich .chat-view-tab {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
.chat-response-rich .chat-view-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.chat-response-rich .chat-view-pane.hidden { display: none; }
.chat-response-formatted .chat-md-list {
  margin: 8px 0 12px;
  padding-left: 1.25rem;
}
.chat-response-formatted .chat-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.chat-code-block {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.chat-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--border) 40%, var(--surface));
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}
.chat-code-lang {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.chat-code-copy {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
}
.chat-code-copy:hover { border-color: var(--accent); }
.chat-code-block pre.code-block {
  margin: 0;
  border: none;
  border-radius: 0;
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
}
.chat-html-preview.assist-preview {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 200px;
  background: #fff;
}
.chat-html-preview.assist-preview iframe {
  width: 100%;
  min-height: 240px;
  border: 0;
  display: block;
  background: #fff;
}
.chat-html-source {
  margin-top: 10px;
  font-size: 0.85rem;
}
.chat-html-source summary {
  cursor: pointer;
  color: var(--muted);
  margin-bottom: 8px;
}
.chat-code-assist-intro {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.chat-view-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card-app {
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card-app:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.card-app-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 12px;
}
.card-app-governance .card-app-icon { background: linear-gradient(135deg, rgba(139,92,246,.25), rgba(108,140,255,.2)); }
.card-app-audit .card-app-icon { background: linear-gradient(135deg, rgba(6,182,212,.2), rgba(34,197,94,.15)); }
.card-app-legacy .card-app-icon { background: linear-gradient(135deg, rgba(245,158,11,.2), rgba(249,115,22,.15)); }
.card h3 { font-size: 1rem; margin-bottom: 8px; }
.card p { font-size: 0.85rem; color: var(--muted); }

.dashboard-user-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 24px;
  max-width: 420px;
}

.dashboard-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.85rem;
}

.dashboard-user-plan {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.nav-item-rich {
  align-items: flex-start;
  padding-top: 8px;
  padding-bottom: 8px;
  min-height: 44px;
}

.nav-item-rich .nav-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.nav-item-rich .nav-desc {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
}

a.nav-item-link {
  text-decoration: none;
  color: inherit;
}

.dashboard-overview-stats {
  margin: 16px 0 20px;
}

body.portal-embed-mode .sidebar,
body.portal-embed-mode .portal-sidebar-head,
body.portal-embed-mode .portal-sidebar-footer,
body.portal-embed-mode .main-header {
  display: none !important;
}

body.portal-embed-mode .portal.page-shell {
  display: block;
}

body.portal-embed-mode .main {
  min-height: 100vh;
  min-height: 100dvh;
}

body.portal-embed-mode .main-body {
  padding: 12px 16px 20px;
}

body.portal-embed-mode .main-body > .panel {
  display: none;
}

body.portal-embed-mode .main-body > .panel.active {
  display: block;
}

.dashboard-section {
  margin-bottom: 28px;
}

.dashboard-section-title {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.dashboard-grid .card-dash {
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}

a.card-dash-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.settings-grid { max-width: 640px; }
.settings-section { margin-bottom: 28px; }
.settings-section h3 { margin-bottom: 12px; font-size: 1rem; }
.plan-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(108,140,255,.2);
  color: var(--accent);
}
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data-table th, table.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.data-table th { color: var(--muted); font-weight: 600; }

.account-hub {
  display: flex;
  gap: 24px;
  min-height: 480px;
  align-items: flex-start;
}
.account-nav {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.account-nav-item {
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}
.account-nav-item:hover { background: var(--surface2); color: var(--text); }
.account-nav-item.active {
  background: rgba(108,140,255,.15);
  color: var(--accent);
  font-weight: 600;
}
.account-content {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.account-pane h3 { margin-bottom: 8px; font-size: 1.15rem; }
.account-pane .sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stat-card {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-card .value { font-size: 1.5rem; font-weight: 700; }
.stat-card .label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.integration-list { list-style: none; margin: 16px 0; }
.integration-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.badge-on { color: var(--success); font-size: 0.8rem; font-weight: 600; }
.badge-off { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 900px) {
  .account-hub { flex-direction: column; }
  .account-nav { width: 100%; flex-direction: row; flex-wrap: wrap; }
}

.onboarding-card { max-width: 780px; }
.onboarding-progress { margin: 16px 0 20px; }
.onboarding-progress ol {
  display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0;
}
.onboarding-progress li {
  font-size: 0.72rem; font-weight: 600; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.onboarding-progress li.active { border-color: var(--accent); color: var(--text); background: var(--accent-muted, rgba(108,140,255,.08)); }
.onboarding-progress li.done { color: var(--success, #16a34a); border-color: var(--success, #16a34a); }
.onboarding-step-title { font-size: 1.15rem; margin: 0 0 12px; }
.onboarding-lead { color: var(--text-secondary, var(--muted)); margin-bottom: 16px; line-height: 1.55; }
.onboarding-value-list { margin: 0 0 16px; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
.onboarding-value-list li { margin-bottom: 8px; }
.onboarding-step-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row-2 { grid-template-columns: 1fr; } }
.plan-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent); margin-bottom: 6px;
}
.plan-compliance { font-size: 0.72rem; color: var(--muted); margin-top: 8px; padding-left: 16px; }
.plan-compliance li { margin-bottom: 3px; }
.checkout-features { margin: 12px 0; padding-left: 20px; color: var(--muted); font-size: 0.88rem; }
.onboarding-done { text-align: center; }
.onboarding-done-icon { font-size: 2rem; margin-bottom: 12px; }
.onboarding-checklist { text-align: left; max-width: 420px; margin: 20px auto; padding: 16px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); }
.onboarding-checklist h3 { margin: 0 0 10px; font-size: 0.95rem; }
.onboarding-checklist ol { margin: 0; padding-left: 20px; font-size: 0.88rem; color: var(--muted); }
.onboarding-ide-box { text-align: left; max-width: 520px; margin: 20px auto; padding: 16px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); }
.onboarding-cmd-pre { margin-top: 12px; font-size: 0.75rem; overflow: auto; padding: 8px; background: #0d0f12; border-radius: 6px; }
.alert-success { background: rgba(22, 163, 74, 0.12); border-color: var(--success, #16a34a); color: var(--text); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.plan-card {
  text-align: left;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
}
.plan-card:hover { border-color: var(--accent); }
.plan-card.selected { border-color: var(--accent); background: rgba(108,140,255,.08); }
.plan-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.plan-price { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.plan-tagline { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.plan-card ul { font-size: 0.78rem; color: var(--muted); padding-left: 16px; margin: 0; }
.plan-card li { margin-bottom: 4px; }
.app-plan-badge {
  display: inline-block; font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 6px; padding: 2px 8px; border-radius: 4px;
}
.app-plan-ok { color: var(--success, #16a34a); background: rgba(22,163,74,.1); }
.app-plan-locked { color: var(--warning, #d97706); background: rgba(217,119,6,.12); }
.card-app-locked { opacity: 0.72; }
.card-app-locked:hover { border-color: var(--border); cursor: pointer; }

/* Light theme tokens & polish: static/css/theme-light.css (via enterprise.css) */
html[data-theme="light"] .meta-pill.live { color: #15803d; border-color: rgba(21, 128, 61, 0.35); }
html[data-theme="light"] .val-chip.pass,
html[data-theme="light"] .check-row.pass { color: #166534; }
html[data-theme="light"] .val-chip.gap,
html[data-theme="light"] .check-row.gap { color: #b91c1c; }

/* ── Shared dashboard / page shell ── */
.page-shell {
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(108, 140, 255, 0.1), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(139, 92, 246, 0.07), transparent 50%),
    var(--bg);
}
/* Portal sidebar collapse */
body.portal-sidebar-collapsed {
  --sidebar-w: 56px;
}

body.portal-sidebar-collapsed .portal-sidebar-scroll,
body.portal-sidebar-collapsed .sidebar-brand-text,
body.portal-sidebar-collapsed .nav-section,
body.portal-sidebar-collapsed .history-list,
body.portal-sidebar-collapsed .portal-user-text {
  display: none;
}

body.portal-sidebar-collapsed .portal-signout-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  font-size: 0;
  line-height: 36px;
  align-self: center;
}

body.portal-sidebar-collapsed .portal-signout-btn::after {
  content: "⎋";
  font-size: 1rem;
}

body.portal-sidebar-collapsed .portal-sidebar-head {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px 6px;
  gap: 6px;
}

body.portal-sidebar-collapsed .sidebar-brand {
  padding: 0;
  text-align: center;
  width: 100%;
}

body.portal-sidebar-collapsed .sidebar-brand .brand-logo {
  margin: 0 auto;
}

body.portal-sidebar-collapsed .nav-item {
  font-size: 0;
  justify-content: center;
  padding: 10px 8px;
  gap: 0;
}

body.portal-sidebar-collapsed .nav-icon {
  font-size: 1rem;
  display: flex;
  margin: 0 auto;
}

body.portal-sidebar-collapsed .portal-sidebar-user-row {
  flex-direction: row;
  justify-content: center;
  gap: 6px;
  align-items: center;
}

body.portal-sidebar-collapsed .user-menu-btn {
  justify-content: center;
  padding: 8px;
}

body.portal-sidebar-collapsed .portal-collapse-icon {
  transform: rotate(180deg);
  display: inline-block;
}

body.portal-sidebar-collapsed .portal-sidebar-footer {
  padding: 8px 6px;
}

body.portal-sidebar-collapsed .nav-label {
  display: none;
}


.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.meta-pill.live {
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}
.meta-pill.live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: livePulse 2s ease infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.sticky-subnav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 6px;
  padding: 12px 0;
  margin-bottom: 24px;
  background: rgba(15, 17, 23, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.sticky-subnav::-webkit-scrollbar { display: none; }

.subnav-link {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.subnav-link:hover { color: var(--text); background: var(--surface2); }
.subnav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.subnav-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-head h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.section-head p { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.section-score { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.metric-card {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--surface);
  transition: transform 0.15s, box-shadow 0.15s;
}
.metric-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.metric-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.metric-card-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; line-height: 1.35; }
.metric-card-value { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.metric-hint { margin-top: 8px; font-size: 0.68rem; }

.metric-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface2);
  overflow: hidden;
}
.metric-fill {
  height: 100%;
  border-radius: 3px;
  width: 0;
  transition: width 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.filter-pills { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-pill.active {
  background: rgba(108, 140, 255, 0.15);
  border-color: rgba(108, 140, 255, 0.4);
  color: var(--accent);
}
.filter-pill:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  overflow: hidden;
}

.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
}
.status-chip.ok { border-color: rgba(34, 197, 94, 0.35); color: #86efac; }
.status-chip.warn { border-color: rgba(245, 158, 11, 0.35); color: #fcd34d; }
.status-chip.bad { border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }

.skeleton-grid { display: grid; gap: 16px; }
.skeleton-block {
  border-radius: 16px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.sk-hero { height: 280px; }
.sk-row { height: 120px; }
.sk-panel { height: 320px; }

.dash-animate { animation: fadeSlideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.d1 { animation-delay: 0.05s; }
.d2 { animation-delay: 0.1s; }
.d3 { animation-delay: 0.15s; }
.d4 { animation-delay: 0.2s; }

.ring-progress { transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1); }

.code-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.78rem;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  line-height: 1.5;
}

.archive-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.archive-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.archive-row:hover { border-color: var(--accent); background: var(--surface2); }
.archive-row.active { border-color: var(--accent); background: rgba(108, 140, 255, 0.08); }
.archive-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.archive-row-name { font-weight: 600; font-size: 0.85rem; }
.archive-row-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.archive-row-badge { font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface2); }

.activity-bar-row { margin-bottom: 10px; }
.activity-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.activity-bar-head span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

.page-body-padded {
  padding: 0 32px 64px;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

.spending-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.spending-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.spending-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}
.spending-plan-name {
  font-size: 1.35rem;
  font-weight: 700;
}
.spending-plan-price {
  font-size: 1.1rem;
  color: var(--muted);
  margin-top: 4px;
}
.spending-reset {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}
.spending-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.spending-blurb {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 12px 0 0;
}
.spending-total-pct {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}
.spending-summary {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 4px 0 16px;
}
.spending-meter { margin-bottom: 12px; }
.spending-meter-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.spending-meter-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.spending-meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.spending-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  margin-bottom: 8px;
}
.spending-muted {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 8px;
}
.spending-status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.spending-status-badge.off {
  background: var(--surface2);
  color: var(--muted);
}
.spending-status-badge.on {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.spending-limit-row label:first-child {
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}
.spending-limit-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.spending-limit-inputs input[type="number"] {
  width: 120px;
  padding: 8px 10px;
}
.spending-unlimited {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.spending-save-msg { font-size: 0.85rem; margin-top: 8px; }
.spending-save-msg.ok { color: #22c55e; }
.spending-save-msg.err { color: #ef4444; }

.billing-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.included-usage-block { margin-top: 8px; }
.included-usage-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 4px;
}
.included-usage-period {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 12px;
}
.included-usage-table { margin-top: 0; }
tr.invoice-head td { font-weight: 600; border-top: 1px solid var(--border); }
tr.invoice-line td {
  font-size: 0.85rem;
  color: var(--muted);
  padding-top: 4px;
  padding-bottom: 4px;
}

@media (max-width: 640px) {
  .page-body-padded { padding: 0 16px 48px; }
}

.portal-workflow-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  padding: 0 4px;
}
.portal-chip-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 4px;
}
.portal-chip {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  color: inherit;
  cursor: pointer;
}
.portal-chip:hover {
  border-color: var(--accent, #2563eb);
  color: var(--accent, #2563eb);
}
.portal-composer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 6px 0 4px;
  padding: 0 4px;
}
.portal-meta-label {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.portal-meta-label select {
  min-width: 140px;
}
