/* Admin portal, auth views, and shared CYDD chrome — uses cydd-tokens / themes */

body.portal-cydd-shell {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

/* ── Auth: full-width main (no sidebar offset) ── */
body.portal-cydd-auth {
  --sidebar-w: 0 !important;
}

body.portal-cydd-auth .topbar-logo {
  width: auto;
  min-width: 0;
}

body.portal-cydd-auth .topbar-right {
  width: auto;
  min-width: 0;
}

/* Auth routes: no workspace search, help shortcut, or activity history */
body.portal-cydd-auth .cydd-topbar-toolbar:not(.cydd-topbar-toolbar--account) {
  display: none;
}

/* Portal footer: one block in index.html for login, customer, and admin — align chrome with CYDD tokens */
body.portal-cydd-shell #portal-footer {
  flex-shrink: 0;
  border-top-color: var(--border);
  background: var(--bg-base);
}

body.portal-cydd-shell #portal-footer .footer-legal-list a {
  color: var(--text-primary);
}

body.portal-cydd-shell #portal-footer .footer-legal-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}

body.portal-cydd-shell #portal-footer .footer-copyright {
  color: var(--text-secondary);
}

body.portal-cydd-shell .topbar .menu {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

html[data-theme="dark"] body.portal-cydd-shell .topbar .menu {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

body.portal-cydd-shell .topbar .menu-item {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}

body.portal-cydd-shell .topbar .menu-item:hover,
body.portal-cydd-shell .topbar .menu-item:focus {
  background: var(--accent-glow);
  color: var(--accent);
}

body.portal-cydd-shell .topbar .menu-sep {
  background: var(--border);
}

/* ── Sidebars: sign out as button.nav-item ── */
#cydd-admin-sidebar button.nav-item,
#cydd-customer-sidebar button.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

#cydd-admin-sidebar button.nav-item--signout,
#cydd-customer-sidebar button.nav-item--signout {
  color: var(--text-secondary);
}

#cydd-admin-sidebar button.nav-item--signout:hover,
#cydd-customer-sidebar button.nav-item--signout:hover {
  color: var(--risk-high);
  background: var(--risk-high-bg);
}

/* ── Typography: admin & API headlines ── */
body.portal-cydd-shell .portal-headline {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--text-primary);
  margin: 0 0 var(--sp-6);
  font-size: var(--text-2xl);
  line-height: var(--lh-2xl);
}

body.portal-cydd-shell .portal-headline--admin {
  font-size: var(--text-2xl);
}

body.portal-cydd-shell #view-admin-api .page-header .message,
body.portal-cydd-shell .admin-overview-lead,
body.portal-cydd-shell .set-password-card .message {
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--lh-base);
}

/* ── Cards & inputs in admin / auth (CYDD surfaces) ── */
body.portal-cydd-shell #view-admin .card,
body.portal-cydd-shell #view-admin-api .card,
body.portal-cydd-shell .set-password-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
}

body.portal-cydd-shell #view-admin .card h2,
body.portal-cydd-shell #view-admin-api .card h2,
body.portal-cydd-shell .set-password-card h1 {
  font-family: var(--font-display);
  color: var(--text-primary);
}

body.portal-cydd-shell #view-admin .input,
body.portal-cydd-shell #view-admin-api .input,
body.portal-cydd-shell .set-password-card .input,
body.portal-cydd-shell #view-admin select.input,
body.portal-cydd-shell #view-admin-api select.input {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

body.portal-cydd-shell #view-admin .input-label,
body.portal-cydd-shell #view-admin-api .input-label,
body.portal-cydd-shell .set-password-card .input-label {
  color: var(--text-secondary);
  font-family: var(--font-ui);
}

body.portal-cydd-shell #view-admin .message,
body.portal-cydd-shell #view-admin-api .message,
body.portal-cydd-shell #view-admin .empty,
body.portal-cydd-shell #view-admin-api .empty {
  color: var(--text-secondary);
}

body.portal-cydd-shell #view-admin .hint,
body.portal-cydd-shell .set-password-card .hint {
  color: var(--text-muted);
}

body.portal-cydd-shell #view-admin .error,
body.portal-cydd-shell .set-password-card .error {
  color: var(--risk-high);
}

/* ── Admin layout inside .cydd-main ── */
body.admin-mode.portal-cydd-shell #main {
  padding: 0;
}

/* Pin Settings / Session to the bottom of the admin sidebar on desktop (shared rule hides flex-fill when expanded). */
#cydd-app-root:not(.cydd-sidebar-collapsed) #cydd-admin-sidebar .cydd-sidebar-flex-fill {
  display: block !important;
}

body.portal-cydd-shell #view-admin .admin-view-root,
body.portal-cydd-shell #view-admin-api .admin-view-root {
  gap: var(--sp-8);
  max-width: none;
}

body.portal-cydd-shell #view-admin .admin-view-root .page-header h1,
body.portal-cydd-shell #view-admin-api .admin-view-root .page-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: var(--lh-2xl);
  color: var(--text-primary);
}

body.portal-cydd-shell #view-admin .admin-view-root .page-header .message,
body.portal-cydd-shell #view-admin-api .admin-view-root .page-header .message {
  color: var(--text-secondary);
}

body.portal-cydd-shell #view-admin .admin-invite-card-title {
  font-family: var(--font-display);
  color: var(--text-primary);
}

body.portal-cydd-shell .admin-org-list-in-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

body.portal-cydd-shell .admin-stat-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

body.portal-cydd-shell .admin-stat-pill span {
  color: var(--text-secondary);
}

body.portal-cydd-shell .admin-org-subnav {
  border-bottom-color: var(--border);
}

body.portal-cydd-shell .admin-org-subnav__link {
  color: var(--text-secondary);
  font-family: var(--font-ui);
}

body.portal-cydd-shell .admin-org-subnav__link:hover {
  color: var(--text-primary);
}

body.portal-cydd-shell .admin-org-subnav__link--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

body.portal-cydd-shell .org-card {
  border-color: var(--border);
  background: var(--bg-surface);
}

body.portal-cydd-shell .org-card--selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

body.portal-cydd-shell .admin-org-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-bottom-color: var(--border);
}

body.portal-cydd-shell .admin-org-table td {
  border-bottom-color: var(--border);
  color: var(--text-primary);
}

body.portal-cydd-shell .admin-org-table-row:hover {
  background: var(--accent-glow);
}

body.portal-cydd-shell .admin-org-table-row--selected {
  background: var(--accent-glow);
  box-shadow: inset 3px 0 0 var(--accent);
}

body.portal-cydd-shell .admin-org-table__name-row .admin-org-enter-portal-btn {
  color: #fff;
  background: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 72%, #0f172a);
  box-shadow:
    0 2px 12px color-mix(in srgb, var(--accent) 42%, transparent),
    inset 0 1px 0 color-mix(in srgb, #fff 22%, transparent);
}

body.portal-cydd-shell .admin-org-table__name-row .admin-org-enter-portal-btn:hover {
  color: #fff;
  background: color-mix(in srgb, var(--accent) 82%, #0f172a);
  border-color: color-mix(in srgb, var(--accent) 65%, #0f172a);
  box-shadow:
    0 4px 16px color-mix(in srgb, var(--accent) 50%, transparent),
    inset 0 1px 0 color-mix(in srgb, #fff 26%, transparent);
}

body.portal-cydd-shell .admin-org-table__name-row .admin-org-enter-portal-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.portal-cydd-shell .admin-org-id-inline {
  color: var(--text-muted);
}

body.portal-cydd-shell #view-admin-api .api-docs-layout {
  gap: var(--sp-6);
  width: 100%;
  min-width: 0;
}

body.portal-cydd-shell .api-test-output {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Auth routes: stretch the shell between topbar and footer so the login card can centre
   vertically and horizontally at any viewport width (mobile / desktop / ultrawide). */
body.portal-cydd-auth #main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.portal-cydd-auth #cydd-app-root {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* Same top offset as signed-in routes: fixed topbar is out of normal flow. */
body.portal-cydd-auth .cydd-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  margin-top: var(--cydd-topbar-stack-h);
  padding: 0;
}

body.portal-cydd-auth .cydd-main > .view:not(.hidden) {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* ── Auth: centred card ── */
body.portal-cydd-shell .set-password-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  padding-top: var(--sp-6);
  padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--sp-4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--sp-4), env(safe-area-inset-right, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.portal-cydd-shell .set-password-card {
  width: 100%;
  max-width: 420px;
  padding: var(--sp-8);
}

/* Narrow viewports: auth card uses the main column height so the form stays in view (not a short strip at the bottom). */
@media (max-width: 720px) {
  body.portal-cydd-auth .cydd-main > .view:not(.hidden) .set-password-wrap {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding-top: max(var(--sp-4), env(safe-area-inset-top, 0px));
  }

  body.portal-cydd-auth .cydd-main > .view:not(.hidden) .set-password-card {
    max-width: none;
    flex: 1 1 auto;
    min-height: 0;
  }
}

/* Auth cards: Branz wordmark (dark on light card, light on dark theme) */
body.portal-cydd-shell .set-password-card .auth-card-logo-mark {
  display: flex;
  justify-content: center;
  margin: 0 0 var(--sp-5);
}

body.portal-cydd-shell .set-password-card .auth-card-logo-img {
  height: 28px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

body.portal-cydd-shell .set-password-card .auth-card-logo-img--dark {
  display: none;
}

html[data-theme="dark"] body.portal-cydd-shell .set-password-card .auth-card-logo-img--light {
  display: none;
}

html[data-theme="dark"] body.portal-cydd-shell .set-password-card .auth-card-logo-img--dark {
  display: block;
}

body.portal-cydd-shell .set-password-card .set-password-card-title--center {
  text-align: center;
}

/* ── Modals (global, CYDD-aligned when shell active) ── */
body.portal-cydd-shell .modal-overlay {
  background: rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] body.portal-cydd-shell .modal-overlay {
  background: rgba(0, 0, 0, 0.55);
}

body.portal-cydd-shell .modal-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

body.portal-cydd-shell .modal-title {
  font-family: var(--font-display);
  color: var(--text-primary);
}

body.portal-cydd-shell .modal-subtitle {
  color: var(--text-secondary);
  font-family: var(--font-ui);
}

body.portal-cydd-shell .modal-header {
  border-bottom-color: var(--border);
}

body.portal-cydd-shell .radio-option {
  border-color: var(--border);
  background: var(--bg-surface);
}

body.portal-cydd-shell .radio-option-title {
  color: var(--text-primary);
  font-family: var(--font-ui);
}

body.portal-cydd-shell .radio-option-hint {
  color: var(--text-muted);
}

/* ── Admin: destructive org reset (QA) ── */
.admin-org-reset-card {
  border-color: var(--risk-high);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--risk-high) 25%, transparent);
}

.admin-org-reset-confirm-hint {
  margin-top: var(--sp-2);
}

.admin-reset-code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.admin-org-reset-confirm-input {
  max-width: 22rem;
  margin-bottom: var(--sp-4);
}

.admin-org-reset-actions {
  margin-top: var(--sp-2);
}

.admin-org-reset-status {
  margin-top: var(--sp-4);
  color: var(--text-secondary);
}

/* ── Admin Overview: executive dashboard grouped columns ── */
.admin-exec-dashboard-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-6);
  width: 100%;
  min-width: 0;
  align-items: start;
}

@media (max-width: 1200px) {
  .admin-exec-dashboard-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .admin-exec-dashboard-columns {
    grid-template-columns: 1fr;
  }
}

.admin-exec-dash-column {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  padding: 0 0 0 var(--sp-4);
  border-left: 4px solid var(--admin-exec-col-accent, var(--accent));
}

.admin-exec-dash-column-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--lh-lg, 1.35);
  margin: 0;
  color: var(--text-primary);
}

.admin-exec-dash-column-title-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.admin-exec-dash-column--customers .admin-exec-dash-column-title-icon {
  background: var(--accent-glow);
  color: var(--accent);
}

.admin-exec-dash-column--finance .admin-exec-dash-column-title-icon {
  background: var(--risk-medium-bg);
  color: var(--risk-medium);
}

.admin-exec-dash-column--platform .admin-exec-dash-column-title-icon {
  background: var(--risk-critical-bg);
  color: var(--risk-critical);
}

.admin-exec-dash-column--delivery .admin-exec-dash-column-title-icon {
  background: var(--risk-low-bg);
  color: var(--risk-low);
}

/* Admin overview page header: title + lead link icon */
.admin-overview-page-title-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-1);
}

.admin-overview-page-title-row h1 {
  margin-bottom: 0;
}

.admin-overview-page-title-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-glow);
  color: var(--accent);
  flex-shrink: 0;
}

.admin-overview-lead-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.admin-overview-lead-link:hover {
  text-decoration: underline;
}

.admin-overview-lead-link-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.admin-exec-dash-column-lead {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: var(--lh-base, 1.5);
}

.admin-exec-dash-column--customers {
  --admin-exec-col-accent: var(--accent);
}

.admin-exec-dash-column--finance {
  --admin-exec-col-accent: var(--risk-medium);
}

.admin-exec-dash-column--platform {
  --admin-exec-col-accent: var(--risk-critical);
}

/* Distinct from finance column copy: stripe uses accent + medium blend where supported */
.admin-exec-dash-column--delivery {
  --admin-exec-col-accent: var(--accent);
}

@supports (color: color-mix(in srgb, white, black)) {
  .admin-exec-dash-column--delivery {
    --admin-exec-col-accent: color-mix(in srgb, var(--accent) 45%, var(--risk-medium) 55%);
  }
}

.admin-exec-dash-column-cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  min-width: 0;
}

/* One shared chroma per column: top accent, icon wells, metrics (ignores legacy per-card tone classes) */
.admin-exec-dash-column--customers .admin-exec-dash-card.kpi-card::after {
  background: linear-gradient(90deg, var(--accent), transparent);
}

.admin-exec-dash-column--customers .admin-exec-dash-card .kpi-icon {
  background: var(--accent-glow) !important;
  color: var(--accent) !important;
}

.admin-exec-dash-column--customers .admin-exec-dash-card .kpi-metric {
  color: var(--accent) !important;
}

.admin-exec-dash-column--finance .admin-exec-dash-card.kpi-card::after {
  background: linear-gradient(90deg, var(--risk-medium), transparent);
}

.admin-exec-dash-column--finance .admin-exec-dash-card .kpi-icon {
  background: var(--risk-medium-bg) !important;
  color: var(--risk-medium) !important;
}

.admin-exec-dash-column--finance .admin-exec-dash-card .kpi-metric {
  color: var(--risk-medium) !important;
}

.admin-exec-dash-column--platform .admin-exec-dash-card.kpi-card::after {
  background: linear-gradient(90deg, var(--risk-critical), transparent);
}

.admin-exec-dash-column--platform .admin-exec-dash-card .kpi-icon {
  background: var(--risk-critical-bg) !important;
  color: var(--risk-critical) !important;
}

.admin-exec-dash-column--platform .admin-exec-dash-card .kpi-metric {
  color: var(--risk-critical) !important;
}

.admin-exec-dash-column--delivery .admin-exec-dash-card.kpi-card::after {
  background: linear-gradient(90deg, var(--risk-low), transparent);
}

.admin-exec-dash-column--delivery .admin-exec-dash-card .kpi-icon {
  background: var(--risk-low-bg) !important;
  color: var(--risk-low) !important;
}

.admin-exec-dash-column--delivery .admin-exec-dash-card .kpi-metric {
  color: var(--risk-low) !important;
}

.admin-exec-dash-column--customers .admin-exec-dash-placeholder-pill {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: color-mix(in srgb, var(--accent-glow) 65%, var(--bg-elevated));
}

.admin-exec-dash-column--finance .admin-exec-dash-placeholder-pill {
  border-color: color-mix(in srgb, var(--risk-medium) 35%, var(--border));
  background: color-mix(in srgb, var(--risk-medium-bg) 55%, var(--bg-elevated));
}

.admin-exec-dash-column--platform .admin-exec-dash-placeholder-pill {
  border-color: color-mix(in srgb, var(--risk-critical) 30%, var(--border));
  background: color-mix(in srgb, var(--risk-critical-bg) 55%, var(--bg-elevated));
}

.admin-exec-dash-column--delivery .admin-exec-dash-placeholder-pill {
  border-color: color-mix(in srgb, var(--risk-low) 30%, var(--border));
  background: color-mix(in srgb, var(--risk-low-bg) 55%, var(--bg-elevated));
}

/* Overview executive tiles: gentle lift + column-tinted border on hover */
#admin-view-overview .admin-exec-dash-column-cards .admin-exec-dash-card.kpi-card {
  transition:
    transform var(--transition-hover, 200ms ease),
    box-shadow var(--transition-hover, 200ms ease),
    border-color var(--transition, 300ms ease),
    background-color var(--transition, 300ms ease);
}

#admin-view-overview .admin-exec-dash-column-cards .admin-exec-dash-card.kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

#admin-view-overview .admin-exec-dash-column--customers .admin-exec-dash-card.kpi-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

#admin-view-overview .admin-exec-dash-column--finance .admin-exec-dash-card.kpi-card:hover {
  border-color: color-mix(in srgb, var(--risk-medium) 45%, var(--border));
}

#admin-view-overview .admin-exec-dash-column--platform .admin-exec-dash-card.kpi-card:hover {
  border-color: color-mix(in srgb, var(--risk-critical) 40%, var(--border));
}

#admin-view-overview .admin-exec-dash-column--delivery .admin-exec-dash-card.kpi-card:hover {
  border-color: color-mix(in srgb, var(--risk-low) 40%, var(--border));
}

a.kpi-card.admin-exec-dash-card {
  text-decoration: none;
  color: inherit;
  display: block;
  cursor: pointer;
}

a.kpi-card.admin-exec-dash-card:focus {
  outline: none;
}

a.kpi-card.admin-exec-dash-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.admin-exec-dash-card .admin-exec-dash-placeholder-pill {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: var(--text-xs, 11px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  margin-bottom: var(--sp-3);
}

.admin-exec-dash-metric-sm {
  font-size: clamp(1.75rem, 4vw, 2rem) !important;
  margin-bottom: var(--sp-3) !important;
}

.admin-exec-dash-detail {
  margin-top: var(--sp-2);
  margin-bottom: 0;
  font-size: var(--text-sm);
  line-height: var(--lh-base, 1.5);
}

.admin-exec-dash-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
}

.admin-exec-dash-cta-icon {
  flex-shrink: 0;
  opacity: 0.95;
  transition: transform var(--transition-fast, 150ms ease);
}

.admin-exec-dash-column--customers a.kpi-card.admin-exec-dash-card .admin-exec-dash-cta {
  color: var(--accent);
}

.admin-exec-dash-column--finance a.kpi-card.admin-exec-dash-card .admin-exec-dash-cta {
  color: var(--risk-high);
}

.admin-exec-dash-column--platform a.kpi-card.admin-exec-dash-card .admin-exec-dash-cta {
  color: var(--risk-critical);
}

a.kpi-card.admin-exec-dash-card:hover .admin-exec-dash-cta {
  text-decoration: underline;
}

a.kpi-card.admin-exec-dash-card:hover .admin-exec-dash-cta-icon {
  transform: translateX(2px);
}

/* Primary contact (from org setup / enquiry) — admin Users card */
.admin-primary-contact-wrap {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated, var(--bg-base));
}

.admin-primary-contact-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}

.admin-primary-contact-meta {
  flex: 1;
  min-width: min(100%, 14rem);
}

.admin-primary-contact-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-1);
}

.admin-primary-contact-line {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: var(--lh-base, 1.5);
}

.admin-primary-contact-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
}

.admin-primary-invite-result {
  margin: 0;
  font-size: var(--text-sm);
  max-width: 22rem;
  text-align: right;
}

/* ── Admin engagement detail: snapshot, finance grid, future placeholders ── */
.admin-detail-dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: var(--sp-4) var(--sp-6);
  margin: var(--sp-4) 0 0;
}

.admin-detail-dl-grid dt {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-1);
}

.admin-detail-dl-grid dd {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-primary);
}

.admin-detail-dl-grid--compact dd {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.admin-detail-future-card .admin-detail-future-pill {
  margin-bottom: var(--sp-3);
}

.admin-financial-lead {
  margin-bottom: var(--sp-5);
}

.admin-financial-lead a {
  color: var(--accent);
  font-weight: 500;
}

.admin-financial-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-5);
  width: 100%;
  min-width: 0;
}

@media (max-width: 640px) {
  .admin-financial-card-grid {
    grid-template-columns: 1fr;
  }
}

.admin-fin-card--wide {
  grid-column: 1 / -1;
}

.admin-fin-checklist {
  margin: var(--sp-3) 0 0;
  padding-left: 1.25rem;
}

.admin-fin-checklist li {
  margin-bottom: var(--sp-2);
}

.admin-detail-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-5);
}

.admin-detail-future-card .admin-detail-notes-placeholder {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

.admin-detail-notes-placeholder {
  margin-top: var(--sp-3);
  resize: vertical;
  min-height: 4.5rem;
  opacity: 0.85;
  cursor: not-allowed;
}

/* Admin SOW form: use full card width (overrides legacy `.input { max-width: 320px }` from style.css). */
body.portal-cydd-shell .cydd-app .admin-sow-create .input,
body.portal-cydd-shell .cydd-app .admin-sow-create textarea.input,
body.portal-cydd-shell .cydd-app .admin-sow-create select.input {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

body.portal-cydd-shell .cydd-app .admin-sow-doc-view .admin-sow-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2, 0.5rem);
  align-items: center;
  margin-top: var(--sp-2, 0.5rem);
}

body.portal-cydd-shell .cydd-app .admin-sow-pdf-preview-wrap {
  margin-top: var(--sp-3, 0.75rem);
}

body.portal-cydd-shell .cydd-app .admin-sow-pdf-iframe {
  display: block;
  width: 100%;
  height: min(52vh, 36rem);
  min-height: 20rem;
  border: 0;
  border-radius: var(--radius-md, 8px);
  background: var(--bg-surface, #fff);
}

body.portal-cydd-shell .cydd-app .admin-sow-secondary-form {
  margin-top: var(--sp-5, 1.25rem);
  padding-top: var(--sp-4, 1rem);
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.1));
}

body.portal-cydd-shell .cydd-app .admin-sow-details-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary, inherit);
  list-style: none;
}

body.portal-cydd-shell .cydd-app .admin-sow-details-summary::-webkit-details-marker {
  display: none;
}

body.portal-cydd-shell .cydd-app .admin-sow-secondary-form[open] .admin-sow-details-summary {
  margin-bottom: var(--sp-3, 0.75rem);
}

/* Admin technology alerts: toolbar + column filters */
body.portal-cydd-shell .admin-tech-alerts-toolbar {
  align-items: flex-start;
  flex-wrap: wrap;
}

body.portal-cydd-shell .admin-tech-alerts-toolbar-hint {
  line-height: 1.45;
}

body.portal-cydd-shell .admin-tech-alerts-time-range {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 11rem;
}

body.portal-cydd-shell .admin-tech-alerts-time-range__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary, #555);
}

body.portal-cydd-shell .admin-tech-alerts-time-range__select {
  font-size: 0.8125rem;
  padding: 0.28rem 0.45rem;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.15));
  background: var(--bg-surface, #fff);
  color: inherit;
  max-width: 100%;
}

body.portal-cydd-shell #admin-view-technology-alerts .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;
}

body.portal-cydd-shell .admin-tech-alerts-table-filters th {
  font-weight: 400;
  vertical-align: top;
  padding: 0.35rem 0.45rem;
}

body.portal-cydd-shell .admin-tech-alerts-table-filters .input {
  width: 100%;
  min-width: 0;
  max-width: none;
  font-size: 0.8125rem;
  padding: 0.28rem 0.45rem;
  margin: 0;
}

body.portal-cydd-shell .admin-tech-alerts-filter-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Admin technology alerts: status badges (Open / Acknowledged / Resolved) */
body.portal-cydd-shell #admin-view-technology-alerts .badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.2;
}

body.portal-cydd-shell #admin-view-technology-alerts .badge--admin-alert-open {
  background: rgba(220, 53, 69, 0.12);
  color: #b02a37;
  border-color: rgba(220, 53, 69, 0.25);
}

body.portal-cydd-shell #admin-view-technology-alerts .badge--admin-alert-acknowledged {
  background: rgba(255, 193, 7, 0.22);
  color: #856404;
  border-color: rgba(255, 193, 7, 0.35);
}

body.portal-cydd-shell #admin-view-technology-alerts .badge--admin-alert-resolved {
  background: rgba(25, 135, 84, 0.14);
  color: #0f5132;
  border-color: rgba(25, 135, 84, 0.28);
}

/* Admin technology alerts: per-service summary cards */
body.portal-cydd-shell .admin-tech-alerts-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3, 0.75rem);
  margin-bottom: var(--sp-4, 1rem);
}

body.portal-cydd-shell .admin-tech-alerts-summary-card {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: var(--radius-md, 8px);
  padding: var(--sp-3, 0.75rem);
  background: var(--bg-surface, #fff);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary, inherit);
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary, #555);
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__count {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--bg-muted, rgba(0, 0, 0, 0.04));
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__count--open {
  background: rgba(220, 53, 69, 0.12);
  color: #b02a37;
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__count--ack {
  background: rgba(255, 193, 7, 0.18);
  color: #856404;
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__count--total {
  background: rgba(13, 110, 253, 0.12);
  color: #084298;
}

body.portal-cydd-shell .admin-tech-alerts-summary-card__lastseen {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
}

/* Admin technology alerts: error code bar chart */
body.portal-cydd-shell .admin-tech-alerts-chart-card {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: var(--radius-md, 8px);
  padding: var(--sp-3, 0.75rem) var(--sp-3, 0.75rem) var(--sp-2, 0.5rem);
  margin-bottom: var(--sp-4, 1rem);
  background: var(--bg-surface, #fff);
}

body.portal-cydd-shell .admin-tech-alerts-chart-card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3, 0.75rem);
  margin-bottom: 0.35rem;
}

body.portal-cydd-shell .admin-tech-alerts-chart-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart {
  overflow-x: auto;
  padding-bottom: 0.25rem;
  width: 100%;
  min-width: 0;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__plot {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  min-height: 11rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.25rem 0 0 2.25rem;
  position: relative;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__plot::before {
  content: 'Occurrences';
  position: absolute;
  left: 0;
  bottom: 2.1rem;
  font-size: 0.7rem;
  color: var(--text-muted, #888);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 8rem;
  line-height: 1.1;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__col {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
  padding: 0.25rem 0.2rem 0.15rem;
  border: 1px solid transparent;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__col:hover {
  background: var(--bg-muted, rgba(0, 0, 0, 0.04));
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__col:focus-visible {
  outline: 2px solid var(--clr-primary, #0d6efd);
  outline-offset: 2px;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__col--selected {
  border-color: var(--clr-primary, #0d6efd);
  background: rgba(13, 110, 253, 0.08);
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__bar-wrap {
  width: 100%;
  height: 7rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__bar {
  width: 78%;
  max-width: 100%;
  min-height: 4px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(13, 110, 253, 0.85), rgba(13, 110, 253, 0.45));
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__col--selected .admin-tech-alerts-error-code-chart__bar {
  background: linear-gradient(180deg, #0a58ca, #0d6efd);
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary, #555);
}

body.portal-cydd-shell .admin-tech-alerts-error-code-chart__label {
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
  color: var(--text-muted, #666);
  max-width: 100%;
}

body.portal-cydd-shell .admin-tech-alerts-status-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

body.portal-cydd-shell .admin-tech-alerts-status-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
}

body.portal-cydd-shell .admin-tech-alerts-status-label input {
  margin: 0;
}

/* Admin technology alerts: details drawer */
body.portal-cydd-shell .admin-tech-alert-drawer {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  justify-content: flex-end;
}

body.portal-cydd-shell .admin-tech-alert-drawer.hidden {
  display: none;
}

body.portal-cydd-shell .admin-tech-alert-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

body.portal-cydd-shell .admin-tech-alert-drawer__panel {
  position: relative;
  width: min(560px, 100vw);
  height: 100vh;
  background: var(--bg-surface, #fff);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.portal-cydd-shell .admin-tech-alert-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4, 1rem);
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.1));
}

body.portal-cydd-shell .admin-tech-alert-drawer__header h2 {
  margin: 0;
  font-size: 1.1rem;
}

body.portal-cydd-shell .admin-tech-alert-drawer__body {
  padding: var(--sp-4, 1rem);
  overflow-y: auto;
  flex: 1;
  font-size: 0.9rem;
}

body.portal-cydd-shell .admin-tech-alert-drawer__body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0 0 1rem 0;
}

body.portal-cydd-shell .admin-tech-alert-drawer__body dt {
  font-weight: 600;
  color: var(--text-secondary, #555);
}

body.portal-cydd-shell .admin-tech-alert-drawer__body dd {
  margin: 0;
  word-break: break-word;
}

body.portal-cydd-shell .admin-tech-alert-drawer__body pre {
  margin: 0;
  padding: 0.6rem;
  background: var(--bg-muted, rgba(0, 0, 0, 0.04));
  border-radius: var(--radius-sm, 4px);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 18rem;
  overflow: auto;
}

body.portal-cydd-shell .admin-tech-alert-http-pill {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

body.portal-cydd-shell .admin-tech-alert-http-pill--5xx {
  background: rgba(220, 53, 69, 0.15);
  color: #b02a37;
}

body.portal-cydd-shell .admin-tech-alert-http-pill--4xx {
  background: rgba(255, 193, 7, 0.2);
  color: #856404;
}

body.portal-cydd-shell .admin-tech-alert-http-pill--2xx,
body.portal-cydd-shell .admin-tech-alert-http-pill--3xx {
  background: rgba(25, 135, 84, 0.15);
  color: #0f5132;
}

/* Admin technology alerts: sortable headers, column filter popover, bulk bar */
body.portal-cydd-shell .admin-tech-alerts-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--bg-muted, rgba(0, 0, 0, 0.03));
}

body.portal-cydd-shell .admin-tech-alerts-bulk-count {
  font-size: 0.85rem;
  margin-right: 0.25rem;
  color: var(--text-secondary, #555);
}

body.portal-cydd-shell .admin-tech-alerts-table .admin-tech-alerts-th-select {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}

body.portal-cydd-shell .admin-tech-alerts-table .admin-tech-alerts-td-select {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}

body.portal-cydd-shell .admin-tech-alerts-table .admin-tech-alerts-th-actions {
  vertical-align: bottom;
  font-weight: 600;
  font-size: 0.85rem;
}

body.portal-cydd-shell .admin-tech-alerts-th-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
}

body.portal-cydd-shell .admin-tech-alerts-th-sort {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.2rem 0.25rem;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
  color: var(--text-primary, inherit);
}

body.portal-cydd-shell .admin-tech-alerts-th-sort:hover {
  background: var(--bg-muted, rgba(0, 0, 0, 0.05));
}

body.portal-cydd-shell .admin-tech-alerts-th-sort--active {
  color: var(--clr-primary, #0d6efd);
}

body.portal-cydd-shell .admin-tech-alerts-th-sort--active::after {
  content: ' \25B2';
  font-size: 0.65em;
  speak: never;
}

body.portal-cydd-shell .admin-tech-alerts-th-sort--active.admin-tech-alerts-th-sort--desc::after {
  content: ' \25BC';
}

body.portal-cydd-shell .admin-tech-alerts-th-filter {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.15rem 0.25rem;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--bg-surface, #fff);
  font-size: 0.75rem;
  line-height: 1.2;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  color: var(--text-secondary, #555);
}

body.portal-cydd-shell .admin-tech-alerts-th-filter:hover {
  border-color: var(--clr-primary, #0d6efd);
  color: var(--clr-primary, #0d6efd);
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover {
  position: fixed;
  z-index: 1200;
  min-width: 14rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  max-height: min(22rem, calc(100vh - 2rem));
  box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--bg-surface, #fff);
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__inner {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  padding: 0.65rem 0.75rem 0.5rem;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__title {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 600;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__options {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 3rem;
  max-height: 14rem;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: var(--radius-sm, 4px);
  padding: 0.35rem 0.45rem;
  margin-bottom: 0.35rem;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__row {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: 0.8rem;
  line-height: 1.25;
  margin-bottom: 0.35rem;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__row:last-child {
  margin-bottom: 0;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__row input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__row label {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  cursor: pointer;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

body.portal-cydd-shell .admin-tech-alerts-filter-popover__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

