/*
 * Force LIGHT theme for the admin portal.
 *
 * The FODS design system was authored as a dark-first palette (see
 * ui/fods/tokens.css, ui/fods/themes/dark.css). Several admin pages had
 * hand-rolled inline styles that used FODS dark tokens (e.g. var(--fods-color-bg))
 * or hardcoded dark hex values, making them visually inconsistent with the
 * canonical admin/payments.php look.
 *
 * To match payments.php on every admin page, we (1) remap every FODS colour
 * token to its light admin-token equivalent under body.admin-shell and (2)
 * undo the html-level color-scheme:dark from fods/themes/dark.css.
 */
html.admin-shell-root {
    color-scheme: light !important;
}

body.admin-shell .portal-attention-strip,
body.admin-shell .admin-page-header__main,
body.admin-shell .cc-page-header-left {
    display: none !important;
}

body.admin-shell .admin-page-header:not(:has(.admin-page-header__actions > *)),
body.admin-shell .cc-page-header:not(:has(.cc-page-header-right > *)) {
    display: none !important;
}

body.admin-shell {
    --admin-page-max-width: 1400px;
    --admin-page-gutter: 30px;
    --admin-page-gutter-compact: 14px;

    /* FODS surfaces -> light admin surfaces */
    --fods-color-bg-deep: #f0f4f8;
    --fods-color-bg: #f8fafc;
    --fods-color-bg-elevated: #ffffff;
    --fods-color-surface: #ffffff;
    --fods-color-surface-hover: #f1f5f9;
    --fods-color-border: #e2e8f0;
    --fods-color-border-strong: #cbd5e1;

    /* FODS text -> dark text on light bg */
    --fods-color-text: #1e293b;
    --fods-color-text-muted: #475569;
    --fods-color-text-subtle: #64748b;

    /* FODS accent stays brand-aligned but switches to admin-violet for
       readability against light surfaces */
    --fods-color-accent: #8b5cf6;
    --fods-color-accent-muted: #7c3aed;
    --fods-color-accent-soft: rgba(139, 92, 246, 0.12);

    /* Light-friendly elevation */
    --fods-shadow-1: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
    --fods-shadow-2: 0 4px 12px rgba(15, 23, 42, 0.08), 0 16px 40px rgba(15, 23, 42, 0.10);
}

/*
 * Defensive override: a few admin pages embed inline style="background:#0f172a;color:#e8edf4;…"
 * directly on <input>/<select> elements (e.g. staff-permissions.php). Inline styles without
 * !important are still beaten by !important in a stylesheet, so we use attribute selectors
 * to remap those literal dark hex values to the light admin tokens.
 */
body.admin-shell [style*="#0f172a"],
body.admin-shell [style*="#121a23"],
body.admin-shell [style*="#141b22"],
body.admin-shell [style*="#1a222b"],
body.admin-shell [style*="#1f2833"] {
    background: var(--admin-card-bg, #ffffff) !important;
    color: var(--admin-text, #1e293b) !important;
}

body.admin-shell [style*="#e8edf4"] {
    color: var(--admin-text, #1e293b) !important;
}

body.admin-shell [style*="#cbd5e1"],
body.admin-shell [style*="#CBD5E1"],
body.admin-shell [style*="#94a3b8"],
body.admin-shell [style*="#94A3B8"],
body.admin-shell [style*="#9aa8b8"],
body.admin-shell [style*="#9AA8B8"],
body.admin-shell [style*="color:#cbd5e1"],
body.admin-shell [style*="color: #cbd5e1"],
body.admin-shell [style*="color:#94a3b8"],
body.admin-shell [style*="color: #94a3b8"] {
    color: var(--admin-text-muted, #475569) !important;
}

body.admin-shell [style*="#2a3544"],
body.admin-shell [style*="#3d4f63"] {
    border-color: var(--admin-border, #e2e8f0) !important;
}

/* Shared layout for root admin pages — use with <body class="admin-shell"> */
body.admin-shell {
    font-family: var(--admin-font);
    background: var(--admin-body-bg);
    margin: 0;
    padding: 0;
    overflow-x: visible;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    color: var(--admin-text);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

body.admin-shell * {
    box-sizing: border-box;
}

body.admin-shell .container {
    max-width: var(--admin-page-max-width);
    width: 100%;
    margin: 0 auto;
    padding: var(--admin-page-gutter);
    box-sizing: border-box;
}

@media (max-width: 1280px) {
    body.admin-shell .container {
        padding: 20px var(--admin-page-gutter-compact);
    }
}

body.admin-shell #main-content {
    flex: 1 0 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    outline: none;
}

/*
 * Unified admin page rail.
 *
 * Command Center pages use `.cc-container`:
 *   max-width: 1600px; width: 100%; margin: 0 auto; padding: 30px;
 *
 * Legacy admin pages vary widely: most use `<main id="main-content"
 * class="container">`, while some add inline max-widths (960px/1100px/etc.) or
 * wrapper classes like `.audit-wrap`, `.mc-wrap`, `.ep-wrap`. Those narrower
 * wrappers create the ugly left/right gutter jump when moving between admin
 * pages. Keep all admin main content on the same rail as Command Center.
 */
body.admin-shell #main-content:not(.login-card) {
    max-width: var(--admin-page-max-width) !important;
    margin-right: auto !important;
    margin-left: auto !important;
    padding-right: var(--admin-page-gutter) !important;
    padding-left: var(--admin-page-gutter) !important;
    box-sizing: border-box;
}

body.admin-shell #main-content.container:not(.login-card) {
    padding: var(--admin-page-gutter) !important;
}

body.admin-shell > .container:not(#main-content) {
    max-width: var(--admin-page-max-width) !important;
    margin-right: auto !important;
    margin-left: auto !important;
    box-sizing: border-box;
}

@media (max-width: 1280px) {
    body.admin-shell #main-content:not(.login-card) {
        padding-right: var(--admin-page-gutter-compact) !important;
        padding-left: var(--admin-page-gutter-compact) !important;
    }

    body.admin-shell #main-content.container:not(.login-card) {
        padding: 20px var(--admin-page-gutter-compact) !important;
    }
}

/*
 * Unified page header row.
 *
 * The canonical reference is admin/payments.php which uses UiPageHeader::render
 * (emits <header class="fods-page-header">). Many legacy admin pages use one of:
 *   - <div class="page-header admin-page-header">
 *   - <div class="admin-page-header">
 *   - <div class="page-header">
 * with inline <style> blocks that set their own font-sizes / margins.
 *
 * To guarantee EVERY admin page renders the same visual look as payments.php,
 * we use a high-specificity selector (body.admin-shell.fods-flagship + class +
 * !important on key typographic rules) so legacy inline styles are overridden.
 *
 * This is purely visual: no HTML structure changes are required.
 */
body.admin-shell .page-header,
body.admin-shell .page-header.admin-page-header,
body.admin-shell .admin-page-header,
body.admin-shell .fods-page-header {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--admin-space-4, 16px);
    margin: 0 0 var(--admin-space-6, 24px) !important;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

body.admin-shell .page-header > *:not(.header-actions):not(.admin-page-header__actions):not(.fods-page-header__actions),
body.admin-shell .admin-page-header__main,
body.admin-shell .fods-page-header__titles {
    flex: 1 1 240px;
    min-width: 0;
}

body.admin-shell .admin-page-header__actions,
body.admin-shell .page-header .header-actions,
body.admin-shell .admin-page-header .header-actions,
body.admin-shell .fods-page-header__actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

body.admin-shell .page-header h1,
body.admin-shell .admin-page-header h1,
body.admin-shell .fods-page-header__title {
    color: var(--admin-page-title) !important;
    font-size: var(--admin-text-2xl, 1.5rem) !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    font-weight: 650 !important;
    letter-spacing: -0.01em !important;
}

body.admin-shell .page-header .page-subtitle,
body.admin-shell .page-subtitle,
body.admin-shell .admin-page-header .page-subtitle,
body.admin-shell .fods-page-header__subtitle {
    margin: 6px 0 0 !important;
    color: var(--admin-text-muted) !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
}

/* Quick stats */
body.admin-shell .quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

body.admin-shell .qs-card {
    background: var(--admin-card-bg);
    padding: 20px;
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow-card);
    border-left: 4px solid var(--admin-primary);
    transition: transform 0.2s;
}

body.admin-shell .qs-card:hover {
    transform: translateY(-2px);
}

body.admin-shell .qs-card.accent-purple {
    border-left-color: var(--admin-primary-end);
}

body.admin-shell .qs-card.accent-green {
    border-left-color: var(--admin-green);
}

body.admin-shell .qs-card.accent-amber {
    border-left-color: var(--admin-amber);
}

body.admin-shell .qs-label {
    color: var(--admin-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

body.admin-shell .qs-value {
    color: var(--admin-page-title);
    font-size: 28px;
    font-weight: 800;
}

/* Content cards */
body.admin-shell .content-card {
    background: var(--admin-card-bg);
    border-radius: 14px;
    box-shadow: var(--admin-shadow-card);
    margin-bottom: 24px;
    overflow: hidden;
}

body.admin-shell .content-card-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--admin-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

body.admin-shell .content-card-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--admin-page-title);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

body.admin-shell .content-card-body {
    padding: 24px 28px;
}

/* Tables (shared) */
body.admin-shell .admin-table-wrap {
    overflow-x: auto;
    border-radius: var(--admin-radius-sm);
    border: 1px solid var(--admin-border);
    background: var(--admin-card-bg);
}

body.admin-shell table.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

body.admin-shell table.admin-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--admin-border-light);
    color: var(--admin-text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--admin-border);
}

body.admin-shell table.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--admin-border-light);
    color: var(--admin-text);
}

body.admin-shell table.admin-table tr:hover td {
    background: rgba(102, 126, 234, 0.04);
}

body.admin-shell .crm-tpl-list-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.65rem;
}

body.admin-shell .crm-tpl-list-delete-form {
    display: inline-block;
    margin: 0;
}

body.admin-shell[data-density="compact"] table.admin-table th,
body.admin-shell[data-density="compact"] table.admin-table td {
    padding: 8px 12px;
    font-size: 13px;
}

body.admin-shell[data-density="compact"] .content-card-body,
body.admin-shell[data-density="compact"] .content-card-header {
    padding: 16px 20px;
}

body.admin-shell[data-density="compact"] .qs-card {
    padding: 14px 16px;
}

/* Buttons */
body.admin-shell .admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--admin-radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

body.admin-shell .admin-btn-primary {
    background: var(--admin-gradient);
    color: #fff;
    box-shadow: var(--admin-shadow-purple);
}

body.admin-shell a.admin-btn {
    text-decoration: none;
}

body.admin-shell a.admin-btn-primary {
    color: #fff;
}

body.admin-shell .admin-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

body.admin-shell .admin-btn-secondary {
    background: var(--admin-border);
    color: var(--admin-text-secondary);
}

body.admin-shell .admin-btn-secondary:hover {
    background: #cbd5e1;
}

body.admin-shell .admin-btn-secondary.is-active,
body.admin-shell a.admin-btn-secondary.is-active {
    background: var(--admin-gradient);
    color: #fff;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.25);
}

body.admin-shell .admin-btn-secondary.is-active:hover,
body.admin-shell a.admin-btn-secondary.is-active:hover {
    color: #fff;
    background: var(--admin-gradient);
}

body.admin-shell .admin-btn:disabled,
body.admin-shell .admin-btn.admin-btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    pointer-events: none;
}

/* Empty state */
body.admin-shell .admin-empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--admin-text-light);
}

body.admin-shell .admin-empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.85;
}

body.admin-shell .admin-empty-state h3 {
    color: var(--admin-text-muted);
    font-size: 18px;
    margin-bottom: 8px;
}

body.admin-shell .admin-empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* Legacy class names used on existing pages */
body.admin-shell .empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--admin-text-light);
}

body.admin-shell .empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

body.admin-shell .empty-state h3 {
    color: var(--admin-text-muted);
    font-size: 18px;
    margin-bottom: 8px;
}

body.admin-shell .empty-state p {
    font-size: 14px;
}

/* Form controls */
body.admin-shell .admin-input,
body.admin-shell .admin-select {
    padding: 10px 14px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--admin-text);
    background: var(--admin-card-bg);
}

body.admin-shell .admin-input:focus,
body.admin-shell .admin-select:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

@media (max-width: 768px) {
    body.admin-shell .container {
        padding: 15px;
    }

    body.admin-shell .page-header h1,
    body.admin-shell .admin-page-header h1,
    body.admin-shell .fods-page-header__title {
        font-size: 20px !important;
    }

    body.admin-shell .page-header,
    body.admin-shell .admin-page-header,
    body.admin-shell .fods-page-header {
        align-items: flex-start;
    }

    body.admin-shell .quick-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    body.admin-shell .qs-card {
        padding: 14px;
    }

    body.admin-shell .qs-value {
        font-size: 22px;
    }

    body.admin-shell .content-card-header {
        padding: 16px 18px;
    }

    body.admin-shell .content-card-body {
        padding: 16px 18px;
    }
}

@media (max-width: 480px) {
    body.admin-shell .quick-stats {
        grid-template-columns: 1fr 1fr;
    }
}

/* Typography rhythm (modern scale) */
body.admin-shell h2 {
    font-size: var(--admin-text-lg);
    font-weight: 700;
    color: var(--admin-page-title);
    letter-spacing: -0.02em;
    line-height: 1.25;
}

body.admin-shell h3 {
    font-size: var(--admin-text-md);
    font-weight: 600;
    color: var(--admin-page-title);
    line-height: 1.3;
}

body.admin-shell .admin-breadcrumb + .page-header,
body.admin-shell .admin-breadcrumb + .admin-page-header {
    margin-top: 0;
}

/* Unified buttons (common .btn classes across legacy pages) */
body.admin-shell .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--admin-space-2, 8px);
    padding: var(--admin-space-2, 8px) var(--admin-space-4, 16px);
    font-family: var(--admin-font);
    font-size: var(--admin-text-sm);
    font-weight: 600;
    line-height: 1.25;
    border-radius: var(--admin-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: filter var(--admin-duration-fast) var(--admin-ease),
        box-shadow var(--admin-duration-fast) var(--admin-ease),
        transform var(--admin-duration-fast) var(--admin-ease);
}

body.admin-shell .btn:focus-visible {
    outline: 2px solid var(--admin-primary);
    outline-offset: 2px;
}

body.admin-shell .btn-primary {
    background: var(--admin-gradient);
    color: #fff;
    box-shadow: var(--admin-shadow-purple);
}

body.admin-shell .btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

body.admin-shell .btn-secondary {
    background: var(--admin-card-bg);
    color: var(--admin-text-secondary);
    border-color: var(--admin-border);
}

body.admin-shell .btn-secondary:hover {
    background: var(--admin-border-light);
    border-color: var(--admin-text-light);
}

body.admin-shell .btn-success {
    background: var(--admin-green);
    color: #fff;
}

body.admin-shell .btn-success:hover {
    filter: brightness(1.05);
}

body.admin-shell .btn-danger {
    background: var(--admin-red);
    color: #fff;
}

body.admin-shell .btn-danger:hover {
    filter: brightness(1.05);
}

body.admin-shell .btn-sm {
    padding: var(--admin-space-1, 4px) var(--admin-space-3, 12px);
    font-size: var(--admin-text-xs);
}

/* Form controls in shell pages */
body.admin-shell .form-group label,
body.admin-shell label.form-label {
    font-size: var(--admin-text-sm);
    font-weight: 600;
    color: var(--admin-text-secondary);
}

body.admin-shell .form-group input[type="text"],
body.admin-shell .form-group input[type="email"],
body.admin-shell .form-group input[type="password"],
body.admin-shell .form-group input[type="number"],
body.admin-shell .form-group input[type="search"],
body.admin-shell .form-group input[type="date"],
body.admin-shell .form-group select,
body.admin-shell .form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: var(--admin-space-2, 8px) var(--admin-space-3, 12px);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-xs);
    font-size: var(--admin-text-base);
    font-family: var(--admin-font);
    color: var(--admin-text);
    background: var(--admin-card-bg);
    transition: border-color var(--admin-duration-fast) var(--admin-ease),
        box-shadow var(--admin-duration-fast) var(--admin-ease);
}

body.admin-shell .form-group input:focus,
body.admin-shell .form-group select:focus,
body.admin-shell .form-group textarea:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Focus visibility (keyboard) */
body.admin-shell :focus-visible {
    outline: 2px solid var(--admin-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    body.admin-shell *,
    body.admin-shell *::before,
    body.admin-shell *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .admin-toast,
    .admin-skeleton {
        animation: none !important;
    }
}

/* CRM admin subpages */
body.admin-shell .crm-toolbar {
    width: fit-content;
    max-width: 100%;
    margin: 0 0 18px;
    padding: 6px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    background: #f8fafc;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
body.admin-shell .crm-toolbar a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--admin-text-secondary, #334155);
    text-decoration: none;
    line-height: 1.2;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
body.admin-shell .crm-toolbar a:hover {
    color: var(--admin-primary, #667eea);
    text-decoration: none;
    background: rgba(102, 126, 234, 0.08);
}
body.admin-shell .crm-toolbar a.is-active,
body.admin-shell .crm-toolbar a[aria-current='page'] {
    color: #fff;
    background: var(--admin-gradient);
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.25);
}
body.admin-shell .crm-flash--ok {
    color: var(--admin-green);
    margin: 0 0 14px;
    font-weight: 600;
}
body.admin-shell .crm-flash--err {
    color: #b91c1c;
    margin: 0 0 14px;
    font-weight: 600;
}
body.admin-shell .crm-form-inline {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
body.admin-shell fieldset.crm-fieldset {
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-sm);
    padding: 16px 20px;
    margin: 0 0 18px;
    background: var(--admin-card-bg);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
body.admin-shell fieldset.crm-fieldset legend {
    padding: 0 8px;
    font-weight: 700;
    color: var(--admin-text-secondary);
}

/* CRM forms: vertical rhythm */
body.admin-shell .crm-form-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

body.admin-shell .crm-field-row {
    margin: 0;
}

body.admin-shell .crm-field-row label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--admin-text-secondary);
    margin-bottom: 6px;
}

body.admin-shell .crm-field-row .admin-input,
body.admin-shell .crm-field-row .admin-select,
body.admin-shell .crm-field-row textarea.admin-input {
    margin-top: 0;
}

body.admin-shell .crm-field-row > input.admin-input:not([class*='admin-input--max']) {
    width: 100%;
    max-width: 42rem;
}

body.admin-shell .crm-field-row > select.admin-select {
    max-width: min(100%, 42rem);
}

body.admin-shell .crm-form-actions {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

body.admin-shell .crm-callout {
    padding: 12px 16px;
    border-radius: var(--admin-radius-sm);
    border: 1px solid var(--admin-border);
    background: rgba(102, 126, 234, 0.06);
    color: var(--admin-text);
    font-size: 14px;
    margin: 0 0 16px;
    line-height: 1.5;
}

body.admin-shell .crm-callout--info {
    border-color: rgba(3, 105, 161, 0.35);
    background: rgba(3, 105, 161, 0.08);
}

body.admin-shell .crm-footer-nav {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--admin-border-light);
    font-size: 14px;
}

body.admin-shell .crm-footer-nav a {
    font-weight: 600;
    color: var(--admin-primary);
    text-decoration: none;
}

body.admin-shell .crm-footer-nav a:hover {
    text-decoration: underline;
}

/* Textareas match inputs */
body.admin-shell textarea.admin-input,
body.admin-shell textarea.admin-textarea {
    padding: 10px 14px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--admin-text);
    background: var(--admin-card-bg);
    width: 100%;
    max-width: 42rem;
    resize: vertical;
    line-height: 1.45;
}

body.admin-shell textarea.admin-input--code,
body.admin-shell textarea.admin-textarea--code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    max-width: none;
}

body.admin-shell textarea.admin-input:focus,
body.admin-shell textarea.admin-textarea:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

body.admin-shell .admin-input--max-lg {
    max-width: 36rem;
}

body.admin-shell .admin-input--max-md {
    max-width: 28rem;
}

body.admin-shell .admin-input--max-sm {
    max-width: 20rem;
}

/* Dense data tables (samples, event lists) */
body.admin-shell table.admin-table.admin-table--dense th,
body.admin-shell table.admin-table.admin-table--dense td {
    padding: 8px 12px;
    font-size: 12px;
}

/* Key–value summary tables */
body.admin-shell table.admin-table.admin-table--kv th {
    width: 11rem;
    max-width: 38%;
    vertical-align: top;
    font-weight: 600;
    color: var(--admin-text-secondary);
    background: var(--admin-border-light);
}

body.admin-shell table.admin-table.admin-table--kv td {
    word-break: break-word;
}

/* HTML email preview sandbox */
body.admin-shell .crm-preview-frame {
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-sm);
    padding: 16px;
    background: #fff;
    color: #111;
    margin-top: 12px;
    overflow-x: auto;
}

/* JSON / debug blocks */
body.admin-shell .crm-json-block {
    white-space: pre-wrap;
    font-size: 12px;
    line-height: 1.45;
    padding: 12px 14px;
    border-radius: var(--admin-radius-sm);
    border: 1px solid var(--admin-border);
    background: var(--admin-border-light);
    color: var(--admin-text);
    margin: 0 0 16px;
    overflow-x: auto;
}

body.admin-shell .crm-muted,
body.admin-shell p.muted {
    color: var(--admin-text-muted);
    font-size: 14px;
}

body.admin-shell .crm-back-link {
    display: inline-block;
    margin-bottom: 16px;
    font-weight: 600;
}

body.admin-shell .crm-back-link a {
    color: var(--admin-primary);
    text-decoration: none;
}

body.admin-shell .crm-back-link a:hover {
    text-decoration: underline;
}

/* CRM lifecycle / variant badges */
body.admin-shell .crm-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.4;
    vertical-align: middle;
    margin: 0 4px 2px 0;
    border: 1px solid transparent;
}
body.admin-shell .crm-badge--active {
    background: rgba(22, 163, 74, 0.15);
    color: #15803d;
    border-color: rgba(22, 163, 74, 0.35);
}
body.admin-shell .crm-badge--paused {
    background: rgba(234, 179, 8, 0.2);
    color: #a16207;
    border-color: rgba(202, 138, 4, 0.45);
}
body.admin-shell .crm-badge--stop-enroll {
    background: rgba(249, 115, 22, 0.15);
    color: #c2410c;
    border-color: rgba(249, 115, 22, 0.35);
}
body.admin-shell .crm-badge--seed-pending {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.3);
}
body.admin-shell .crm-badge--seed-sent {
    background: rgba(99, 102, 241, 0.12);
    color: #4338ca;
    border-color: rgba(99, 102, 241, 0.35);
}
body.admin-shell .crm-badge--rollout {
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
    border-color: rgba(14, 165, 233, 0.35);
}
body.admin-shell .crm-badge--completed {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
    border-color: rgba(34, 197, 94, 0.35);
}
body.admin-shell .crm-badge--exited {
    background: rgba(100, 116, 139, 0.18);
    color: #475569;
    border-color: rgba(100, 116, 139, 0.35);
}
body.admin-shell .crm-badge--muted {
    background: rgba(148, 163, 184, 0.2);
    color: #64748b;
    border-color: rgba(148, 163, 184, 0.35);
}
body.admin-shell .crm-badge--variant {
    background: rgba(102, 126, 234, 0.12);
    color: #4338ca;
    border-color: rgba(102, 126, 234, 0.35);
}
body.admin-shell .crm-badge--holdout {
    background: rgba(180, 83, 9, 0.12);
    color: #9a3412;
    border-color: rgba(180, 83, 9, 0.35);
}
body.admin-shell .crm-badge--gr-alert {
    background: rgba(234, 179, 8, 0.2);
    color: #854d0e;
    border-color: rgba(202, 138, 4, 0.45);
}
body.admin-shell .crm-badge--gr-pause {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.35);
}
body.admin-shell .crm-badge--gr-stop {
    background: rgba(127, 29, 29, 0.12);
    color: #7f1d1d;
    border-color: rgba(127, 29, 29, 0.3);
}

body.admin-shell .crm-breadcrumb {
    font-size: 14px;
    font-weight: 600;
    color: var(--admin-text-secondary);
}
body.admin-shell .crm-breadcrumb a {
    color: var(--admin-primary);
    text-decoration: none;
}
body.admin-shell .crm-breadcrumb a:hover {
    text-decoration: underline;
}

body.admin-shell .crm-readiness {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}
body.admin-shell .crm-readiness li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.45;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius-sm);
    padding: 8px 10px;
    background: var(--admin-card-bg);
}
body.admin-shell .crm-readiness__state {
    flex-shrink: 0;
    font-weight: 800;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}
body.admin-shell .crm-readiness__state--ok {
    background: rgba(22, 163, 74, 0.15);
    color: #15803d;
}
body.admin-shell .crm-readiness__state--warn {
    background: rgba(234, 179, 8, 0.25);
    color: #92400e;
}
body.admin-shell .crm-readiness__state--off {
    background: rgba(148, 163, 184, 0.25);
    color: #475569;
}

body.admin-shell .crm-toolbar a.crm-toolbar__legacy {
    color: var(--admin-text-secondary, #334155);
    font-weight: 600;
}
body.admin-shell .crm-toolbar a.crm-toolbar__legacy.is-active,
body.admin-shell .crm-toolbar a.crm-toolbar__legacy[aria-current='page'] {
    color: #fff;
    font-weight: 700;
}
body.admin-shell .crm-nav-legacy-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.35);
    color: #475569;
    vertical-align: middle;
}

body.admin-shell .crm-rollup-trust--ok {
    color: #15803d;
    font-weight: 700;
}
body.admin-shell .crm-rollup-trust--warn {
    color: #b45309;
    font-weight: 700;
}

body.admin-shell tr.crm-row-test-fail td {
    background: rgba(254, 226, 226, 0.45);
}

body.admin-shell .crm-dash-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
    font-size: 13px;
}
body.admin-shell .crm-dash-shortcuts a {
    font-weight: 600;
    color: var(--admin-primary);
    text-decoration: none;
}
body.admin-shell .crm-dash-shortcuts a:hover {
    text-decoration: underline;
}

body.admin-shell .exec-readonly-watermark {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 9999;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px dashed rgba(139, 0, 0, 0.35);
    background: rgba(139, 0, 0, 0.08);
    color: #7c1d1d;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

/* Phase 8 polish: motion + accessibility utilities */
body.admin-shell .polish-fade-up {
    animation: polishFadeUp 240ms ease-out both;
}

@keyframes polishFadeUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

html.admin-shell-root body.admin-shell :focus-visible {
    outline: 2px solid var(--fods-color-accent, #d4a853);
    outline-offset: 2px;
    border-radius: 4px;
}

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

body.admin-shell .portal-attention-strip {
    margin: 0 0 22px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    padding: 18px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
    align-items: center;
    justify-content: space-between;
}
body.admin-shell .portal-attention-strip.is-active {
    border-color: rgba(245, 158, 11, 0.4);
    background: linear-gradient(135deg, #fffbeb 0%, #f8fafc 100%);
}
body.admin-shell .portal-attention-strip__lead {
    min-width: 250px;
    flex: 1 1 340px;
}
body.admin-shell .portal-attention-strip__eyebrow {
    margin: 0 0 4px;
    font-size: 11px;
    color: var(--admin-text-muted);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
body.admin-shell .portal-attention-strip__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
body.admin-shell .portal-attention-strip__title {
    margin: 0;
    font-size: 18px;
    color: var(--admin-page-title);
    font-weight: 800;
}
body.admin-shell .portal-attention-strip__total {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #92400e;
    background: rgba(245, 158, 11, 0.2);
}
body.admin-shell .portal-attention-strip.is-clear .portal-attention-strip__total {
    color: #166534;
    background: rgba(22, 163, 74, 0.15);
}
body.admin-shell .portal-attention-strip__subtitle {
    margin: 5px 0 0;
    font-size: 13px;
    color: var(--admin-text-secondary);
    line-height: 1.45;
}
body.admin-shell .portal-attention-strip__chips {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 10px;
    min-width: min(420px, 100%);
    flex: 1 1 420px;
}
body.admin-shell .portal-attention-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 10px;
    border: 1px solid var(--admin-border);
    background: #fff;
    text-decoration: none;
    padding: 10px 12px;
    color: var(--admin-page-title);
    transition: border-color 0.2s ease, transform 0.2s ease;
}
body.admin-shell .portal-attention-chip:hover {
    transform: translateY(-1px);
}
body.admin-shell .portal-attention-chip--tasks:hover {
    border-color: #3b82f6;
}
body.admin-shell .portal-attention-chip--approvals:hover {
    border-color: #8b5cf6;
}
body.admin-shell .portal-attention-chip--notifications:hover {
    border-color: #0ea5e9;
}
body.admin-shell .portal-attention-chip__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--admin-text-muted);
}
body.admin-shell .portal-attention-chip__count {
    font-size: 20px;
    font-weight: 800;
    color: var(--admin-page-title);
}

/*
 * Readability guardrails for light admin surfaces.
 *
 * Several legacy tabs/buttons were authored for the older dark UI and still
 * use pale slate text (#cbd5e1/#94a3b8) or low-opacity text on the new light
 * backgrounds. Keep inactive items visibly readable while preserving the
 * purple active state.
 */
body.admin-shell .hub-tabs a:not(.active),
body.admin-shell .cc-hub-tab:not(.cc-hub-tab--active),
body.admin-shell .crm-hub-tab:not(.crm-hub-tab--active):not([aria-current='page']):not([aria-selected='true']),
body.admin-shell .admin-btn-secondary:not(.is-active),
body.admin-shell .cc-btn-secondary,
body.admin-shell .crm-toolbar a:not(.is-active):not([aria-current='page']),
body.admin-shell .dash-tabs__btn:not(.is-active) {
    color: var(--admin-text-secondary, #334155) !important;
}

body.admin-shell .hub-tabs a:not(.active):hover,
body.admin-shell .cc-hub-tab:not(.cc-hub-tab--active):hover,
body.admin-shell .crm-hub-tab:not(.crm-hub-tab--active):not([aria-current='page']):not([aria-selected='true']):hover,
body.admin-shell .admin-btn-secondary:not(.is-active):hover,
body.admin-shell .cc-btn-secondary:hover,
body.admin-shell .crm-toolbar a:not(.is-active):not([aria-current='page']):hover,
body.admin-shell .dash-tabs__btn:not(.is-active):hover {
    color: var(--admin-primary, #667eea) !important;
}

body.admin-shell .hub-tabs a.active,
body.admin-shell .crm-hub-tab--active,
body.admin-shell .crm-hub-tab[aria-current='page'],
body.admin-shell .crm-hub-tab[aria-selected='true'],
body.admin-shell .admin-btn-secondary.is-active,
body.admin-shell .dash-tabs__btn.is-active {
    color: #fff !important;
}

body.admin-shell .cc-hub-tab--active {
    color: var(--cc-primary, var(--admin-primary, #667eea)) !important;
}

body.admin-shell .cc-page-subtitle,
body.admin-shell .page-subtitle,
body.admin-shell .admin-page-header .page-subtitle,
body.admin-shell .fods-page-header__subtitle,
body.admin-shell .crm-muted,
body.admin-shell .rbac-muted,
body.admin-shell .help-text,
body.admin-shell small,
body.admin-shell .text-muted {
    color: var(--admin-text-muted, #475569) !important;
}

body.admin-shell .cc-status-pill,
body.admin-shell .cc-status-badge,
body.admin-shell .badge,
body.admin-shell .status-badge,
body.admin-shell .admin-badge,
body.admin-shell .crm-confidence,
body.admin-shell .crm-kpi__label,
body.admin-shell .ie-kpi__label,
body.admin-shell .crm-form-section__title,
body.admin-shell .ie-section__title {
    color: var(--admin-text-secondary, #334155);
}

body.admin-shell [style*="opacity:.5"],
body.admin-shell [style*="opacity: .5"],
body.admin-shell [style*="opacity:0.5"],
body.admin-shell [style*="opacity: 0.5"],
body.admin-shell [style*="opacity:.6"],
body.admin-shell [style*="opacity: .6"],
body.admin-shell [style*="opacity:0.6"],
body.admin-shell [style*="opacity: 0.6"],
body.admin-shell [style*="opacity:.65"],
body.admin-shell [style*="opacity: .65"],
body.admin-shell [style*="opacity:0.65"],
body.admin-shell [style*="opacity: 0.65"] {
    opacity: 0.9 !important;
}

@media (max-width: 900px) {
    body.admin-shell .portal-attention-strip__chips {
        grid-template-columns: 1fr;
        min-width: 0;
    }
}
/* ── Hide browser scrollbar (keep scrolling functional) ── */
html, body {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
}
