/*
 * tenant-shell.css — TPR-1 shell styles
 *
 * Owns: app-shell layout, SidebarNav, TopBar, shared primitives
 * (Breadcrumbs, Tabs, BulkActionBar, EmptyState), CommandPalette.
 * Responsive rules: <=1024px auto-collapse; <=640px off-canvas drawer.
 */

:root {
    --sidebar-width-expanded: 240px;
    --sidebar-width-collapsed: 64px;
    --topbar-height: 56px;
    /* --shell-surface and --shell-border are now defined in design-system.css
       [data-theme="dark"] and [data-theme="light"] blocks so theme switching
       picks them up automatically. The values below are safe fallbacks for any
       context where data-theme has not yet been stamped on <html>. */
    --shell-surface: rgba(21, 18, 46, 0.98);
    --shell-border: rgba(196, 154, 60, 0.18);
}

/* ── App shell layout ───────────────────────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--color-navy, #15122E);
}

#app-sidebar-slot {
    flex: 0 0 var(--sidebar-width-expanded);
    max-width: var(--sidebar-width-expanded);
    min-width: 0;
    transition: flex-basis 0.18s ease, max-width 0.18s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 60;
}

#app-sidebar-slot.sidebar--collapsed {
    flex-basis: var(--sidebar-width-collapsed);
    max-width: var(--sidebar-width-collapsed);
}

#app-shell-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#app-topbar-slot {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-height);
}

#app-main-slot {
    flex: 1 1 auto;
    min-width: 0;
    outline: none;
}

#app-footer-slot { flex: 0 0 auto; }

/* ── PWNOTIF-2: Password expiry banner ──────────────────────────── */
/*
 * Sits in #app-shell-main between #app-topbar-slot and #app-main-slot.
 * Empty when no expiry state is active (zero height, no layout impact).
 */
#pw-expiry-banner {
    flex: 0 0 auto;
}

.pw-expiry-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    font-size: var(--text-sm, 0.875rem);
    line-height: 1.5;
}

.pw-expiry-banner--warn {
    background: var(--color-amber-glow, rgba(196,154,60,0.18));
    border-block-end: 1px solid var(--color-amber, #C49A3C);
    color: var(--color-amber, #C49A3C);
}

.pw-expiry-banner--danger {
    background: rgba(220, 38, 38, 0.12);
    border-block-end: 1px solid var(--color-red, #dc2626);
    color: var(--color-red, #dc2626);
}

.pw-expiry-banner__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.pw-expiry-banner__text {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.pw-expiry-banner__link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pw-expiry-banner__link:hover,
.pw-expiry-banner__link:focus-visible {
    opacity: 0.85;
}

.pw-expiry-banner__dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    margin-inline-start: auto;
}

.pw-expiry-banner__dismiss:hover,
.pw-expiry-banner__dismiss:focus-visible {
    opacity: 1;
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Light theme overrides */
[data-theme="light"] .pw-expiry-banner--warn {
    background: rgba(180, 83, 9, 0.08);
    border-block-end-color: var(--color-amber, #B45309);
    color: var(--color-amber, #B45309);
}

[data-theme="light"] .pw-expiry-banner--danger {
    background: rgba(220, 38, 38, 0.08);
    border-block-end-color: var(--color-red, #dc2626);
    color: var(--color-red, #dc2626);
}

/* ── SidebarNav ─────────────────────────────────────────────────── */

.sidebar-nav {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--shell-surface);
    border-right: 1px solid var(--shell-border);
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--shell-border);
    gap: 8px;
    height: var(--topbar-height);
}

.sidebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-primary, #fff);
    font-family: var(--font-serif);
    font-weight: 700;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand__wrap {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1;
}

.sidebar-brand__text {
    font-size: 22px;
    line-height: 1;
}

.sidebar-brand__hindi {
    font-family: var(--font-devanagari, 'Noto Serif Devanagari', serif);
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--color-gold, #C49A3C);
    opacity: 0.95;
}

.sidebar-brand__mark {
    display: none;
    font-size: 22px;
}

.sidebar-nav.sidebar--collapsed .sidebar-brand__wrap { display: none; }
.sidebar-nav.sidebar--collapsed .sidebar-brand__mark { display: inline; }

.sidebar-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary, #C5C8E5);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}
.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #fff);
    outline: none;
}
.sidebar-nav.sidebar--collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 8px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-category {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #8A8BB0);
    padding: 8px 12px 4px;
    font-weight: 600;
}
.sidebar-nav.sidebar--collapsed .sidebar-category {
    visibility: hidden;
    height: 6px;
    padding: 0;
}
.sidebar-category--link {
    display: block;
    text-decoration: none;
    cursor: pointer;
    color: var(--text-muted, #8A8BB0);
    border-radius: 4px;
    transition: color 0.15s;
}
.sidebar-category--link:hover {
    color: var(--text-primary, #E2E4F0);
}
.sidebar-category--link.sidebar-category--active {
    color: var(--accent, #7C6EF5);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    min-height: 44px;
    border-radius: 8px;
    color: var(--text-secondary, #C5C8E5);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sidebar-item:hover,
.sidebar-item:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #fff);
    outline: none;
}
.sidebar-item--active {
    background: rgba(0, 180, 162, 0.12);
    color: var(--color-teal, #00B4A2);
}
.sidebar-item__icon {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    opacity: 0.95;
}
.sidebar-item__label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-nav.sidebar--collapsed .sidebar-item { justify-content: center; padding: 10px 8px; }
.sidebar-nav.sidebar--collapsed .sidebar-item__label { display: none; }

/* Tooltip via title attribute on collapsed state relies on browser default. */

/* ── TopBar ─────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: var(--topbar-height);
    background: var(--shell-surface);
    border-bottom: 1px solid var(--shell-border);
    backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-center {
    flex: 1 1 auto;
    min-width: 0;
}

.topbar-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary, #C5C8E5);
    cursor: pointer;
}
.topbar-hamburger:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary, #fff); }

.topbar-iconbtn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    height: 44px;
    min-width: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary, #C5C8E5);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.topbar-iconbtn:hover,
.topbar-iconbtn:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #fff);
    outline: none;
}
.topbar-kbd {
    font-family: var(--font-body);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted, #8A8BB0);
}

.topbar-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--color-red, #E53935);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
}

.topbar-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #fff;
}

.topbar-profile { position: relative; }

.topbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-teal, #00B4A2);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.topbar-avatar:hover,
.topbar-avatar:focus-visible {
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 0 3px rgba(0, 180, 162, 0.3);
    outline: none;
}

.topbar-profile-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--color-navy-mid, #1B1840);
    border: 1px solid var(--shell-border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
    display: none;
    z-index: 200;
}
.topbar-profile-menu--open { display: block; }

.topbar-profile-link {
    display: flex;
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    background: transparent;
    border: none;
    text-align: left;
    text-decoration: none;
    color: var(--text-primary, #fff);
    font-size: 13px;
    cursor: pointer;
}
.topbar-profile-link:hover,
.topbar-profile-link:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}
.topbar-profile-link--admin {
    color: var(--color-amber, #C49A3C);
}
.topbar-profile-link--danger {
    color: var(--color-red, #E53935);
}
.topbar-profile-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--shell-border);
}

/* Profile header inside the dropdown — was inline styles, now token-backed classes */
.topbar-profile-header {
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--shell-border);
}
.topbar-profile-header__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-profile-header__sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.topbar-profile-header__tags {
    margin-top: 6px;
}

/* ── Shared page wrappers (mirror .team-page / .team-main) ─────── */
/* Use on every tenant-portal page so breadcrumb + header + body   */
/* share the same centered column, horizontal padding, and width.  */

.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background: var(--bg-primary);
}

.page-main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

.page-shell > .breadcrumbs,
.page-shell > [id$="-bc"],
.page-shell > [id$="Breadcrumbs"] {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-5) var(--space-6) 0;
}

@media (max-width: 768px) {
    .page-main { padding: var(--space-4); }
    .page-shell > .breadcrumbs,
    .page-shell > [id$="-bc"],
    .page-shell > [id$="Breadcrumbs"] { padding: var(--space-3) var(--space-4) 0; }
}

/* ── Shared data-table (used by Projects, Settings, Billing, ── */
/* Invitations, GrantRequests, UserSessions, ModuleDetail, etc.) */

/* MR-017: wrap every .data-table in this to enable horizontal scroll on mobile */
.data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    overflow: hidden;
}
.data-table thead th {
    text-align: left;
    padding: 12px 14px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #8A8BB0);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--surface-border);
}
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-primary, #fff);
    vertical-align: middle;
    overflow-wrap: break-word;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ── Form primitives (shared by tenant pages) ────────────────────── */
.form-control,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface-card, #1B1840);
    border: 1px solid var(--surface-border-mid, rgba(196,154,60,0.22));
    border-radius: 8px;
    color: var(--text-primary, #EDE8DB);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    outline: none;
    box-sizing: border-box;
}
.form-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 32px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted, rgba(237,232,219,0.6)) 50%),
                      linear-gradient(135deg, var(--text-muted, rgba(237,232,219,0.6)) 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.form-control:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--accent-gold, rgba(196,154,60,0.55));
}
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-gold, #C49A3C);
    box-shadow: 0 0 0 3px rgba(196,154,60,0.18);
    background: var(--surface-card-hover, #201D4A);
}
.form-control:disabled,
.form-select:disabled,
.form-textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.form-control::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted, rgba(237,232,219,0.38));
}
.form-select option {
    background: var(--surface-card, #1B1840);
    color: var(--text-primary, #EDE8DB);
}
.form-control--sm,
.form-select--sm {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
}
.form-select--sm {
    padding-right: 28px;
    background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
}

/* Projects-specific bits (no dedicated CSS file) */
.proj-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}
.proj-filters .form-select { max-width: 200px; }
.proj-name { font-weight: 600; color: var(--text-primary, #fff); }
.proj-code { font-size: 11px; color: var(--text-muted, #8A8BB0); margin-top: 2px; }
.proj-row:hover td { background: rgba(196, 154, 60, 0.05); }

.proj-toast {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: 1000;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: var(--text-sm);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}
.proj-toast--visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.proj-toast--success { border-color: rgba(16, 185, 129, 0.4); }
.proj-toast--error   { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }

.proj-form .form-section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-gold, #C49A3C);
    margin-bottom: 12px;
}
.proj-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}
.proj-form .form-group { margin-bottom: 12px; }
.proj-form .form-label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: 6px; }
.proj-form .form-hint  { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.proj-form .form-error { color: #fca5a5; font-size: var(--text-sm); }
.proj-form .req        { color: #fca5a5; }
.proj-form .form-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 768px) {
    .proj-form .form-row { grid-template-columns: 1fr; } /* MR-015: extended from 640px */
}

/* ── Breadcrumbs ────────────────────────────────────────────────── */

.breadcrumbs__list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0;
    margin: 0;
    list-style: none;
    font-size: 13px;
    color: var(--text-muted, #8A8BB0);
}
.breadcrumbs__item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.breadcrumbs__link {
    color: var(--text-secondary, #C5C8E5);
    text-decoration: none;
}
.breadcrumbs__link:hover { color: var(--color-teal, #00B4A2); }
.breadcrumbs__item--current { color: var(--text-primary, #fff); }
.breadcrumbs__sep {
    opacity: 0.5;
    margin: 0 2px;
}

/* ── Tabs ───────────────────────────────────────────────────────── */

.tabs { display: flex; flex-direction: column; gap: 16px; }
.tabs__list {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--shell-border);
    padding: 0 4px;
}
.tabs__tab {
    background: transparent;
    border: none;
    padding: 8px 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary, #C5C8E5);
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tabs__tab:hover,
.tabs__tab:focus-visible {
    color: var(--text-primary, #fff);
    background: rgba(255, 255, 255, 0.04);
    outline: none;
}
.tabs__tab--active {
    color: var(--color-teal, #00B4A2);
    border-color: var(--color-teal, #00B4A2);
}
.tabs__panel { padding: 4px; }

/* ── BulkActionBar ──────────────────────────────────────────────── */

.bulk-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--color-navy-mid, #1B1840);
    border: 1px solid var(--shell-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    margin: 16px;
}
.bulk-bar__count { color: var(--text-primary, #fff); font-size: 13px; }
.bulk-bar__actions { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.bulk-bar__btn {
    padding: 6px 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    background: rgba(0, 180, 162, 0.15);
    border: 1px solid rgba(0, 180, 162, 0.35);
    color: var(--color-teal, #00B4A2);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.bulk-bar__btn:hover:not(:disabled) { background: rgba(0, 180, 162, 0.25); }
.bulk-bar__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.bulk-bar__btn--danger {
    background: rgba(229, 57, 53, 0.1);
    border-color: rgba(229, 57, 53, 0.35);
    color: var(--color-red, #E53935);
}
.bulk-bar__btn--danger:hover:not(:disabled) { background: rgba(229, 57, 53, 0.2); }
.bulk-bar__clear {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--shell-border);
    color: var(--text-secondary, #C5C8E5);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.bulk-bar__clear:hover { background: rgba(255, 255, 255, 0.05); }

/* ── EmptyState ─────────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #C5C8E5);
}
.empty-state__icon {
    opacity: 0.55;
    color: var(--color-teal, #00B4A2);
}
.empty-state__headline {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}
.empty-state__subtext {
    font-size: 13px;
    max-width: 420px;
    color: var(--text-muted, #8A8BB0);
}
.empty-state__cta { margin-top: 12px; }

/* ── CommandPalette (⌘K) ────────────────────────────────────────── */

.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
    z-index: 1000;
}
.cmdk-panel {
    width: 560px;
    max-width: 90vw;
    background: var(--color-navy-mid, #1B1840);
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.cmdk-input {
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--shell-border);
    color: var(--text-primary, #fff);
    font-size: 15px;
    outline: none;
}
.cmdk-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    max-height: 50vh;
    overflow-y: auto;
}
.cmdk-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary, #C5C8E5);
}
.cmdk-item--active {
    background: rgba(0, 180, 162, 0.15);
    color: var(--color-teal, #00B4A2);
}
.cmdk-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cmdk-item__label { font-size: 14px; font-weight: 500; }
.cmdk-item__route { font-size: 11px; color: var(--text-muted, #8A8BB0); overflow: hidden; text-overflow: ellipsis; }
.cmdk-item__hint { font-size: 11px; color: var(--text-muted, #8A8BB0); flex-shrink: 0; }
.cmdk-empty { padding: 14px; color: var(--text-muted, #8A8BB0); text-align: center; }
.cmdk-footer {
    display: flex;
    gap: 14px;
    padding: 8px 14px;
    border-top: 1px solid var(--shell-border);
    font-size: 11px;
    color: var(--text-muted, #8A8BB0);
}

/* ── Responsive breakpoints ─────────────────────────────────────── */

/* Tablet: auto-collapse sidebar below 1024px */
@media (max-width: 1024px) {
    #app-sidebar-slot {
        flex-basis: var(--sidebar-width-collapsed);
        max-width: var(--sidebar-width-collapsed);
    }
    /* Honour explicit user preference: the JS toggles .sidebar--collapsed
       on the slot element; desktop override was the default above. */
}

/* Mobile: off-canvas drawer below 768px (MR-004: extended from 640px to cover tablet portrait) */
@media (max-width: 768px) {
    .topbar-hamburger { display: inline-flex; }

    #app-sidebar-slot {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        flex-basis: var(--sidebar-width-expanded);
        max-width: var(--sidebar-width-expanded);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 6px 0 24px rgba(0, 0, 0, 0.4);
    }
    #app-sidebar-slot.sidebar--mobile-open {
        transform: translateX(0);
    }
    #app-shell-main { margin-left: 0; }
    .sidebar-item__label { display: inline; }   /* drawer shows labels */
    #app-sidebar-slot .sidebar-category { visibility: visible; height: auto; padding: 8px 12px 4px; }
    #app-sidebar-slot .sidebar-brand__text { display: inline; }

    .topbar-kbd { display: none; }

    /* MR-127: topbar-right overflow prevention — at 375px the right side can exceed
       viewport width when tenant switcher renders. Strategy:
       1. Reduce gap between topbar-right icons from 8px → 4px.
       2. Suppress switcher name text (icon-only mode, ~44px wide).
       3. Hide non-critical help icon (accessible via FAQ page in sidebar).
       Max width math: switcher(44) + search(44) + theme(44) + bell(44) + avatar(44)
       + 4 gaps(4px each) = 220 + 16 = 236px — fits within 375−44(hamburger)−24(padding) = 307px. */
    .topbar-right {
        flex-shrink: 0;
        gap: 4px;
    }
    /* Hide non-critical help button to prevent topbar overflow at 375px */
    #topbarHelpBtn {
        display: none;
    }
    /* Hide tenant-switcher name text on mobile — avatar initial still shows */
    .ts-drop-name {
        display: none;
    }
    .ts-drop-caret {
        display: none;
    }
    /* Tighten the tenant switcher button to icon-only size */
    .ts-drop-btn {
        padding: 6px;
        max-width: 44px;
        min-width: 32px;
        gap: 0;
    }
}

/* ── TPR-3 — Module Registry visuals ───────────────────────────────────── */

/* Locked-sidebar item — entitlement absent but user has minSidebarPermission. */
.sidebar-item--locked {
    opacity: 0.55;
    cursor: pointer;
    position: relative;
}
.sidebar-item--locked:hover,
.sidebar-item--locked:focus-visible {
    opacity: 0.85;
    background: rgba(255, 255, 255, 0.03);
}
.sidebar-item__lock {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.85;
}

/* Module health status dot — pending / ready / broken tri-state. */
.sidebar-item__health {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    gap: 4px;
}
.sidebar-item__health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
}
.sidebar-item__health-dot--pending {
    background: #f59e0b;
    animation: vakio-pulse 1.6s ease-in-out infinite;
}
.sidebar-item__health-dot--ready  { background: #10b981; }
.sidebar-item__health-dot--broken { background: #ef4444; }
.sidebar-nav.sidebar--collapsed .sidebar-item__health-label,
.sidebar-nav.sidebar--collapsed .sidebar-item__lock { display: none; }

/* ZME-6 — Hierarchy health count badge on static nav items */
.sidebar-item__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    margin-left: auto;
    flex-shrink: 0;
}
.sidebar-nav.sidebar--collapsed .sidebar-item__badge { display: none; }

@keyframes vakio-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* Compliance Hub page — card grid. */
.compliance-hub {
    padding: 24px 32px 48px;
    max-width: 1200px;
    margin: 0 auto;
}
.compliance-hub__header {
    margin-bottom: 24px;
}
.compliance-hub__title {
    margin: 0 0 6px 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #f3f4f6);
}
.compliance-hub__subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary, #9ca3af);
    max-width: 640px;
}
.compliance-hub__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.compliance-card {
    display: flex;
    flex-direction: row;
    border-radius: 10px;
    background: var(--surface-1, #121a2a);
    border: 1px solid var(--surface-border, #1f2937);
    color: var(--text-primary, #f3f4f6);
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
    min-height: 160px;
    overflow: hidden;
}
.compliance-card:hover,
.compliance-card:focus-within {
    transform: translateY(-1px);
    border-color: var(--accent, #00b4a2);
    background: var(--surface-2, #16203a);
}
/* Left: main clickable area */
.compliance-card__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 16px 16px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}
.compliance-card__main:hover .compliance-card__cta,
.compliance-card__main:focus-visible .compliance-card__cta {
    text-decoration: underline;
}
.compliance-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.compliance-card__icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--accent, #00b4a2);
}
.compliance-card__label {
    font-size: 15px;
    font-weight: 700;
}
.compliance-card__copy {
    font-size: 12px;
    color: var(--text-secondary, #9ca3af);
    margin-top: 2px;
}
.compliance-card__cta {
    font-size: 12px;
    color: var(--accent, #00b4a2);
    margin-top: auto;
}
.compliance-card__health {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary, #9ca3af);
}
.compliance-card__health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.25);
}
.compliance-card__health-dot--pending {
    background: #f59e0b;
    animation: vakio-pulse 1.6s ease-in-out infinite;
}
.compliance-card__health-dot--ready  { background: #10b981; }
.compliance-card__health-dot--broken { background: #ef4444; }
/* Right: quick-access nav links */
.compliance-card__nav {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 14px 16px 14px 14px;
    border-left: 1px solid var(--surface-border, #1f2937);
    min-width: 148px;
}
.compliance-card__nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary, #9ca3af);
    text-decoration: none;
    transition: color 0.12s, background 0.12s;
    white-space: nowrap;
}
.compliance-card__nav-link:hover,
.compliance-card__nav-link:focus-visible {
    color: var(--accent, #00b4a2);
    background: rgba(0, 180, 162, 0.07);
}
.compliance-card__nav-icon svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* TPR-3 module activation modal — reuses tenant-shell tokens. */
.tpr3-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 20, 0.72);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9100;
}
.tpr3-modal {
    width: min(480px, 92vw);
    background: var(--surface-1, #121a2a);
    border: 1px solid var(--surface-border, #1f2937);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}
.tpr3-modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--surface-border, #1f2937);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tpr3-modal__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #f3f4f6);
}
.tpr3-modal__close {
    background: transparent;
    color: var(--text-secondary, #9ca3af);
    border: 1px solid transparent;
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.tpr3-modal__close:hover {
    color: var(--text-primary, #f3f4f6);
    border-color: var(--accent, #00b4a2);
}
.tpr3-modal__body {
    padding: 18px 20px 8px;
    color: var(--text-primary, #f3f4f6);
    font-size: 13px;
    line-height: 1.55;
    overflow-y: auto;
}
.tpr3-modal__body .tpr3-modal__reason-label {
    display: block;
    margin: 12px 0 6px;
    font-size: 12px;
    color: var(--text-secondary, #9ca3af);
}
.tpr3-modal__body textarea {
    width: 100%;
    min-height: 88px;
    padding: 10px 12px;
    background: var(--surface-2, #16203a);
    color: var(--text-primary, #f3f4f6);
    border: 1px solid var(--surface-border, #1f2937);
    border-radius: 6px;
    resize: vertical;
    font: inherit;
}
.tpr3-modal__footer {
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--surface-border, #1f2937);
}
.tpr3-modal__btn {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary, #f3f4f6);
}
.tpr3-modal__btn--ghost:hover {
    border-color: var(--surface-border, #1f2937);
}
.tpr3-modal__btn--primary {
    background: var(--accent, #00b4a2);
    color: #0b1220;
}
.tpr3-modal__btn--primary:hover {
    filter: brightness(1.08);
}

/* Sidebar sub-item — indented under a module parent (TPR-3). */
.sidebar-subitems {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 18px;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    margin: 2px 0 4px 12px;
}
.sidebar-subitem {
    padding: 6px 10px !important;
    font-size: 12px !important;
    opacity: 0.86;
}
.sidebar-subitem .sidebar-item__icon {
    width: 14px;
    height: 14px;
}
.sidebar-nav.sidebar--collapsed .sidebar-subitems { display: none; }

/* MOD-ACT-1.6: HRO compliance theme groups within the Compliance accordion */
.sidebar-theme-group {
    margin: 6px 0 2px;
}
.sidebar-theme-group__label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
    padding: 6px 12px 3px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-theme-group__items {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
/* HRO module items: slightly more indent than top-level compliance items */
.sidebar-hro-item {
    padding-left: 20px !important;
    font-size: 12.5px !important;
}
.sidebar-hro-item .sidebar-item__icon {
    width: 14px;
    height: 14px;
    opacity: 0.8;
}
/* Hide theme groups in collapsed mode (same as subitems) */
.sidebar-nav.sidebar--collapsed .sidebar-theme-group { display: none; }

/* "+ Add Compliance Module" footer entry */
.sidebar-item--add-module {
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 8px !important;
    color: #60a5fa !important;
    font-size: 12px !important;
    opacity: 0.85;
}
.sidebar-item--add-module:hover,
.sidebar-item--add-module:focus-visible {
    opacity: 1;
    background: rgba(96, 165, 250, 0.1) !important;
}
.sidebar-item--add-module .sidebar-item__icon {
    width: 14px;
    height: 14px;
    color: #60a5fa;
}
.sidebar-nav.sidebar--collapsed .sidebar-item--add-module { display: none; }

/* ════════════════════════════════════════════════════════════════════════════
   Tenant-portal admin primitives
   ────────────────────────────────────────────────────────────────────────────
   Tenant-admin pages (Settings, Departments, Permission Groups, Billing,
   Invitations, Grant Requests, etc.) inherit the admin-portal form/button/
   modal visual language but the full admin.css is intentionally NOT linked
   from index.html (its html,body reset would override the tenant surface
   background and font-size). The primitives below are the minimal surface
   those pages depend on, mirrored from admin.css §Buttons/Form controls/Modal.
   ════════════════════════════════════════════════════════════════════════════ */

:root {
    --adm-bg-elevated:    #222d42;
    --adm-bg-card:        #1a2236;
    --adm-bg-card-hover:  #1f2a3f;
    --adm-border:         rgba(255, 255, 255, 0.07);
    --adm-border-mid:     rgba(255, 255, 255, 0.12);
    --adm-teal:           #00b4a2;
    --adm-teal-glow:      rgba(0, 180, 162, 0.12);
    --adm-gold:           #c49a3c;
    --adm-gold-glow:      rgba(196, 154, 60, 0.15);
    --adm-green:          #10b981;
    --adm-green-glow:     rgba(16, 185, 129, 0.12);
    --adm-amber:          #f59e0b;
    --adm-amber-glow:     rgba(245, 158, 11, 0.12);
    --adm-red:            #ef4444;
    --adm-red-glow:       rgba(239, 68, 68, 0.12);
    --adm-purple:         #8b5cf6;
    --adm-purple-glow:    rgba(139, 92, 246, 0.12);
    --adm-text-primary:   #f0f4ff;
    --adm-text-secondary: #94a3b8;
    --adm-text-muted:     #64748b;
    --adm-radius-sm:      6px;
    --adm-radius-md:      10px;
    --adm-radius-lg:      14px;
    --adm-shadow:         0 4px 24px rgba(0, 0, 0, 0.4);
    --adm-transition:     0.18s ease;
    --adm-font:           'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* DocumentViewer (KB-15.7) tokens — tenant-side dark variants.
       Without these the shared document-viewer.css falls through to its
       hardcoded light-theme defaults (#f8fafc, #fef2f2, etc.), which
       produced a white-on-white viewer panel inside the navy tenant shell. */
    --adm-bg-base:        #0a0e1a;
    --adm-surface:        #1f2a3f;
    --adm-border-light:   rgba(255, 255, 255, 0.05);
    --adm-error-bg:       rgba(239, 68, 68, 0.10);
    --adm-error-border:   rgba(239, 68, 68, 0.35);
    --adm-error-text:     #fca5a5;
}

/* ── Buttons ─────────────────────────────────────────────── */
.adm-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--adm-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--adm-transition);
    border: none;
    white-space: nowrap;
}

.adm-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.adm-btn-primary {
    background: var(--adm-teal);
    color: #0a0e1a;
}
.adm-btn-primary:hover:not(:disabled) {
    background: #00c8b4;
    box-shadow: 0 0 16px rgba(0, 180, 162, 0.35);
}

.adm-btn-secondary {
    background: var(--adm-bg-elevated);
    color: var(--adm-text-primary);
    border: 1px solid var(--adm-border-mid);
}
.adm-btn-secondary:hover:not(:disabled) {
    background: var(--adm-bg-card-hover);
    border-color: var(--adm-teal);
}

.adm-btn-danger {
    background: var(--adm-red-glow);
    color: var(--adm-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.adm-btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); }

.adm-btn-warning {
    background: var(--adm-amber-glow);
    color: var(--adm-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.adm-btn-warning:hover:not(:disabled) { background: rgba(245, 158, 11, 0.2); }

.adm-btn-ghost {
    background: transparent;
    color: var(--adm-text-secondary);
}
.adm-btn-ghost:hover:not(:disabled) {
    color: var(--adm-text-primary);
    background: var(--adm-bg-elevated);
}

.adm-btn-success {
    background: var(--adm-green);
    border: 1px solid var(--adm-green);
    color: white;
}
.adm-btn-success:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
}

.adm-btn-sm   { padding: 5px 10px; font-size: 12px; }
.adm-btn-icon { padding: 7px; }

/* ── Form controls ───────────────────────────────────────── */
.adm-form-group { margin-bottom: 18px; }

.adm-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--adm-text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}

.adm-input,
.adm-select,
.adm-textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--adm-bg-elevated);
    border: 1px solid var(--adm-border-mid);
    border-radius: var(--adm-radius-sm);
    color: var(--adm-text-primary);
    font-size: 13px;
    font-family: var(--adm-font);
    transition: border-color var(--adm-transition), box-shadow var(--adm-transition);
    outline: none;
    box-sizing: border-box;
}

.adm-input:focus,
.adm-select:focus,
.adm-textarea:focus {
    border-color: var(--adm-teal);
    box-shadow: 0 0 0 3px rgba(0, 180, 162, 0.12);
}

.adm-select   { cursor: pointer; }
.adm-textarea { resize: vertical; min-height: 80px; }
.adm-input::placeholder { color: var(--adm-text-muted); }

.adm-form-error {
    font-size: 12px;
    color: var(--adm-red);
    margin-top: 5px;
}

.adm-form-hint {
    font-size: 11px;
    color: var(--adm-text-muted);
    margin-top: 5px;
}

.adm-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Badges ──────────────────────────────────────────────── */
.adm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.adm-badge--neutral { background: var(--adm-bg-elevated); color: var(--adm-text-secondary); border: 1px solid var(--adm-border-mid); }
.adm-badge--success { background: var(--adm-green-glow);  color: var(--adm-green);  }
.adm-badge--warning { background: var(--adm-amber-glow);  color: var(--adm-amber);  }
.adm-badge--deleted { background: var(--adm-red-glow);    color: var(--adm-red);    }

/* ── Modal primitives (adm-modal-backdrop pattern — Rule 10 in .ai/context.md) ── */
.adm-modal-backdrop,
.adm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.adm-modal-backdrop[hidden],
.adm-modal-overlay[hidden] { display: none; }

.adm-modal {
    background: var(--adm-bg-card);
    border: 1px solid var(--adm-border-mid);
    border-radius: var(--adm-radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    box-shadow: var(--adm-shadow);
}

.adm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--adm-border);
}

.adm-modal-title { font-size: 16px; font-weight: 700; color: var(--adm-text-primary); }
.adm-modal-body  { padding: 20px 24px; overflow-y: auto; flex: 1; }

.adm-modal-close {
    background: transparent;
    border: 1px solid var(--adm-border-mid);
    border-radius: var(--adm-radius-sm);
    color: var(--adm-text-secondary);
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--adm-transition);
}
.adm-modal-close:hover {
    color: var(--adm-text-primary);
    border-color: var(--adm-teal);
}

.adm-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--adm-border);
}

/* BEM-style section header used inside modals + detail panels */
.adm-modal__section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--adm-text-muted);
    margin-bottom: 8px;
}

/* ── Stats grid (used by tenant-portal pages e.g. HrisSyncPage) ──────────── */
.adm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.adm-stat-card {
    background: var(--adm-bg-card);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius-md);
    padding: 20px;
    transition: border-color var(--adm-transition);
    overflow-wrap: break-word;
}
.adm-stat-card:hover { border-color: var(--adm-border-mid); }
.adm-stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--adm-text-muted);
    margin-bottom: 10px;
}
.adm-stat-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
    overflow-wrap: break-word;
}
.adm-stat-sub { font-size: 12px; color: var(--adm-text-muted); margin-top: 6px; }
.adm-stat-card.teal   .adm-stat-value { color: var(--adm-teal); }
.adm-stat-card.gold   .adm-stat-value { color: var(--adm-gold); }
.adm-stat-card.green  .adm-stat-value { color: var(--adm-green); }
.adm-stat-card.amber  .adm-stat-value { color: var(--adm-amber); }
.adm-stat-card.red    .adm-stat-value { color: var(--adm-red); }
.adm-stat-card.purple .adm-stat-value { color: var(--adm-purple); }

/* ── Key-value grid ───────────────────────────────────────────────────────── */
.adm-card.adm-kv-grid { overflow: hidden; padding: 0; }
.adm-kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
}
.adm-kv {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 14px 20px;
    border-right: 1px solid var(--adm-border);
    border-bottom: 1px solid var(--adm-border);
}
.adm-kv:last-child { border-right: none; }
.adm-kv > span:first-child {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--adm-text-muted);
    white-space: nowrap;
}
.adm-kv > strong,
.adm-kv > span:not(:first-child) {
    font-size: 13px;
    font-weight: 600;
    color: var(--adm-text-primary);
}

/* ── Empty / loading states ───────────────────────────────────────────────── */
.adm-empty-icon  { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.adm-empty-title { font-size: 15px; font-weight: 600; color: var(--adm-text-secondary); }
.adm-empty-sub   { font-size: 13px; margin-top: 4px; }

/* ── Inline form error ────────────────────────────────────────────────────── */
.adm-form-err { color: var(--color-error, #EF4444); margin-top: 4px; font-size: 12px; }

/* ── Sprint MR-1 Mobile Responsiveness Fixes ────────────────────────────── */

/* MR-003: Prevent iOS Safari auto-zoom on input focus (requires 16px minimum) */
@media (max-width: 768px) {
    .form-control,
    .form-select,
    .form-textarea {
        font-size: 16px;
    }
    .adm-input,
    .adm-select,
    .adm-textarea,
    .adm-input--sm,
    .adm-select--sm {
        font-size: 16px;
    }
    .form-control--sm,
    .form-select--sm {
        font-size: 16px;
    }
    .cmdk-input {
        font-size: 16px;
    }
}

/* MR-012: compliance-card flex-direction column on mobile */
@media (max-width: 768px) {
    .compliance-card {
        flex-direction: column;
    }
    .compliance-card__nav {
        min-width: auto;
        border-left: none;
        border-top: 1px solid var(--border-subtle, #e5e7eb);
        padding-top: 12px;
    }
}

/* MR-014: adm-form-grid single column on mobile */
@media (max-width: 768px) {
    .adm-form-grid {
        grid-template-columns: 1fr;
    }
}

/* Sprint MR-2 Mobile Responsiveness Fixes ──────────────────────────────────── */

/* MR-025: profile menu must stay below off-canvas sidebar (z-60) on mobile */
@media (max-width: 768px) {
    .topbar-profile-menu { z-index: 55; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Accordion Sidebar Sections
   ══════════════════════════════════════════════════════════════════════════════ */

/* Accordion group trigger (the clickable category header) */
.sidebar-accordion-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 12px;
    min-height: 44px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted, #8A8BB0);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.sidebar-accordion-trigger:hover,
.sidebar-accordion-trigger:focus-visible {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary, #C5C8E5);
    outline: none;
}
.sidebar-accordion-trigger .sidebar-item__icon {
    flex-shrink: 0;
    opacity: 0.55;
    transition: opacity 0.15s;
}
.sidebar-accordion-trigger:hover .sidebar-item__icon { opacity: 0.85; }

.sidebar-accordion-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-accordion-chevron {
    flex-shrink: 0;
    opacity: 0.45;
    transition: transform 0.22s ease, opacity 0.15s;
    margin-left: auto;
}
.sidebar-section--open .sidebar-accordion-chevron {
    transform: rotate(180deg);
    opacity: 0.7;
}

/* Accordion body — CSS grid trick for smooth height animation */
.sidebar-accordion-body {
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    transition: grid-template-rows 0.22s ease;
}
.sidebar-section--open .sidebar-accordion-body {
    grid-template-rows: 1fr;
}
.sidebar-accordion-inner {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 0 4px;
}

/* Active-group indicator — teal accent on trigger when group has the active route */
.sidebar-section--has-active .sidebar-accordion-trigger {
    color: var(--color-teal, #00B4A2);
}
.sidebar-section--has-active .sidebar-accordion-trigger .sidebar-item__icon {
    opacity: 0.9;
}

/* ── Collapsed (icon-only) mode — accordion behaviour ──────────────────────── */

/* Trigger becomes a square icon button — shows category representative icon only */
.sidebar-nav.sidebar--collapsed .sidebar-accordion-trigger {
    justify-content: center;
    padding: 10px 8px;
    gap: 0;
}
.sidebar-nav.sidebar--collapsed .sidebar-accordion-label { display: none; }
.sidebar-nav.sidebar--collapsed .sidebar-accordion-chevron { display: none; }

/* Body hidden in collapsed mode — flyout takes over */
.sidebar-nav.sidebar--collapsed .sidebar-accordion-body { display: none !important; }

/* Category icon is the sole visual anchor — make it more prominent */
.sidebar-nav.sidebar--collapsed .sidebar-accordion-trigger .sidebar-item__icon {
    opacity: 0.75;
    width: 20px;
    height: 20px;
}
.sidebar-nav.sidebar--collapsed .sidebar-accordion-trigger:hover .sidebar-item__icon,
.sidebar-nav.sidebar--collapsed .sidebar-accordion-trigger:focus-visible .sidebar-item__icon {
    opacity: 1;
}

/* Active-group glow ring in collapsed mode */
.sidebar-nav.sidebar--collapsed .sidebar-section--has-active .sidebar-accordion-trigger {
    background: rgba(0, 180, 162, 0.12);
    border-radius: 10px;
}
.sidebar-nav.sidebar--collapsed .sidebar-section--has-active .sidebar-accordion-trigger .sidebar-item__icon {
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(0, 180, 162, 0.55));
}

/* ── Accordion visual hierarchy — items indented beneath their group header ── */

/* Left accent bar on the trigger — visible when the group is open */
.sidebar-section--accordion.sidebar-section--open .sidebar-accordion-trigger::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--color-teal, #00B4A2);
    border-radius: 0 2px 2px 0;
    opacity: 0.45;
}

/* Items inside accordion body — indented to show they are children of the trigger */
.sidebar-accordion-inner .sidebar-item {
    padding-left: 28px;
}

/* Don't indent in collapsed (icon-only) mode — items show as centred icons */
.sidebar-nav.sidebar--collapsed .sidebar-accordion-inner .sidebar-item {
    padding-left: 8px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Collapsed-mode Group Flyout
   Appears to the right of the 64 px sidebar when hovering a group trigger icon.
   Gives every item in that group its label — full discoverability without expanding.
   ══════════════════════════════════════════════════════════════════════════════ */

.sidebar-collapsed-flyout {
    display: none;
    position: fixed;
    z-index: 500;
    min-width: 200px;
    max-width: 256px;
    background: rgba(21, 18, 46, 0.97);
    border: 1px solid rgba(196, 154, 60, 0.18);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 6px 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04);
    backdrop-filter: blur(12px);
    /* Gentle slide-in from the left */
    animation: flyout-in 0.15s ease;
}
@keyframes flyout-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.sidebar-collapsed-flyout__header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--color-gold, #C49A3C);
    padding: 5px 10px 6px;
    border-bottom: 1px solid rgba(196, 154, 60, 0.14);
    margin-bottom: 4px;
}

.sidebar-collapsed-flyout__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--text-secondary, #C5C8E5);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
}
.sidebar-collapsed-flyout__item:hover,
.sidebar-collapsed-flyout__item:focus-visible {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary, #fff);
    outline: none;
}
.sidebar-collapsed-flyout__item--active {
    background: rgba(0, 180, 162, 0.13);
    color: var(--color-teal, #00B4A2);
}
.sidebar-collapsed-flyout__item--active:hover {
    background: rgba(0, 180, 162, 0.2);
}
.sidebar-collapsed-flyout__item--locked {
    opacity: 0.55;
}
.sidebar-collapsed-flyout__item .sidebar-item__icon {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    opacity: 0.8;
}
.sidebar-collapsed-flyout__item--active .sidebar-item__icon { opacity: 1; }

/* Suppress flyout entirely in mobile drawer mode — labels are already visible */
@media (max-width: 768px) {
    .sidebar-collapsed-flyout { display: none !important; }
}

/* MR-5: adm-btn-sm — enforce 44px minimum tap target on mobile/tablet (WCAG 2.5.5) */
@media (max-width: 768px) {
    .adm-btn-sm {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* MR-5: adm-btn base — all .adm-btn variants must meet 44×44px tap target (WCAG 2.5.5) */
@media (max-width: 768px) {
    .adm-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* MR-5: shell text elements below 12px minimum — sidebar labels, topbar chips, and status
   badges must all be ≥ 12px on mobile/tablet (WCAG 1.4.4 minimum font size) */
@media (max-width: 768px) {
    .sidebar-accordion-trigger,
    .sidebar-accordion-label,
    .sidebar-item__badge,
    .sidebar-theme-group__label,
    .sidebar-brand__hindi {
        font-size: 12px;
    }
    /* Topbar notification badge/dot text must be readable (WCAG 1.4.4) */
    .topbar-badge,
    .topbar-dot,
    .topbar-kbd {
        font-size: 12px;
    }
    /* adm-badge status chips used across all admin pages */
    .adm-badge {
        font-size: 12px;
    }
    /* adm-label detail field headers used on audit/admin pages */
    .adm-label {
        font-size: 12px;
    }
}

/* MR-5: breadcrumbs__link — anchor tap target ≥ 44×44px on mobile (WCAG 2.5.5) */
@media (max-width: 768px) {
    .breadcrumbs__link {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        padding: 0 2px;
    }
    .breadcrumbs__item {
        align-items: center;
    }
}

/* MR-046: tabs__list overflow on mobile — Settings page has 6+ tabs that cannot fit in 375px.
   Enable horizontal scroll so all tabs remain accessible without layout breakage.
   .tabs gets overflow-x:hidden to prevent the list from expanding document scrollWidth;
   the inner .tabs__list still has overflow-x:auto so tabs scroll within that container. */
@media (max-width: 768px) {
    .tabs {
        overflow-x: hidden;           /* bound the widget — prevents document scrollWidth expansion */
    }
    .tabs__list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;        /* Firefox: hide decorative scrollbar */
        padding-bottom: 1px;          /* prevent border-bottom clipping during scroll */
    }
    .tabs__list::-webkit-scrollbar {
        display: none;                /* WebKit: hide decorative scrollbar */
    }
    .tabs__tab {
        flex-shrink: 0;               /* prevent tabs from compressing below min-content width */
    }
}

/* ── Theme toggle button (TopBar) ───────────────────────────────── */

.topbar-theme-btn {
    /* Inherits .topbar-iconbtn layout; only override the icon sizing */
    padding: 6px 10px;
    min-width: 40px;
}

.topbar-theme-icon {
    font-size: 15px;
    line-height: 1;
    display: inline-block;
}

/* In dark mode the sun icon (☀) is shown — click will switch to light */
[data-theme="dark"] .topbar-theme-btn {
    color: var(--color-amber, #C49A3C);
}

/* In light mode the moon icon (🌙) is shown — click will switch to dark */
[data-theme="light"] .topbar-theme-btn {
    color: var(--color-teal, #007A6E);
}

/* ── Light-theme shell overrides ────────────────────────────────── */
/* Surfaces that use rgba(255,255,255,...) in dark mode need to flip  */
/* to rgba(0,0,0,...) on light background for sufficient contrast.    */

[data-theme="light"] .topbar-iconbtn {
    background: rgba(45, 42, 110, 0.05);
    border-color: rgba(45, 42, 110, 0.10);
}
[data-theme="light"] .topbar-iconbtn:hover,
[data-theme="light"] .topbar-iconbtn:focus-visible {
    background: rgba(45, 42, 110, 0.10);
}
[data-theme="light"] .topbar-hamburger:hover {
    background: rgba(45, 42, 110, 0.08);
}
[data-theme="light"] .topbar-kbd {
    background: rgba(45, 42, 110, 0.07);
}
[data-theme="light"] .topbar-profile-menu {
    background: #FFFFFF;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
}
[data-theme="light"] .topbar-profile-link:hover,
[data-theme="light"] .topbar-profile-link:focus-visible {
    background: rgba(45, 42, 110, 0.05);
}
[data-theme="light"] .sidebar-nav {
    background: #FFFFFF;
    border-right: 1px solid var(--shell-border);
}
[data-theme="light"] .sidebar-item:hover,
[data-theme="light"] .sidebar-item:focus-visible {
    background: rgba(45, 42, 110, 0.06);
}
[data-theme="light"] .sidebar-item--active {
    background: rgba(0, 122, 110, 0.10);
}
[data-theme="light"] .sidebar-collapse-btn:hover,
[data-theme="light"] .sidebar-collapse-btn:focus-visible {
    background: rgba(45, 42, 110, 0.07);
}
[data-theme="light"] .data-table thead th {
    background: rgba(45, 42, 110, 0.03);
}
[data-theme="light"] .data-table tbody tr:hover td {
    background: rgba(45, 42, 110, 0.03);
}
[data-theme="light"] .tabs__tab:hover,
[data-theme="light"] .tabs__tab:focus-visible {
    background: rgba(45, 42, 110, 0.05);
}
[data-theme="light"] .cmdk-overlay {
    background: rgba(26, 22, 40, 0.4);
}
[data-theme="light"] .cmdk-panel {
    background: #FFFFFF;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}
[data-theme="light"] .cmdk-item--active {
    background: rgba(0, 122, 110, 0.10);
}
[data-theme="light"] .bulk-bar {
    background: #FFFFFF;
}
[data-theme="light"] .sidebar-subitems {
    border-left-color: rgba(45, 42, 110, 0.12);
}
[data-theme="light"] .sidebar-theme-group__label {
    color: rgba(26, 22, 40, 0.4);
}
[data-theme="light"] .sidebar-item--add-module {
    border-top-color: rgba(45, 42, 110, 0.10);
}
[data-theme="light"] .sidebar-collapsed-flyout__item:hover,
[data-theme="light"] .sidebar-collapsed-flyout__item:focus-visible {
    background: rgba(45, 42, 110, 0.06);
}
[data-theme="light"] .compliance-card {
    background: #FFFFFF;
    border-color: rgba(0,0,0,0.08);
    box-shadow: var(--shadow-card);
}
[data-theme="light"] .compliance-card:hover,
[data-theme="light"] .compliance-card:focus-within {
    border-color: var(--color-teal);
    background: #F7F8FA;
}
[data-theme="light"] .tpr3-modal {
    background: #FFFFFF;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}
[data-theme="light"] .tpr3-modal__body textarea {
    background: #F0F2F5;
}
/* adm-* token overrides for light theme (tenant-admin pages)
   Updated to cool-grey palette — warm-beige values removed. */
[data-theme="light"] {
    --adm-bg-elevated:    #E2E8F0;
    --adm-bg-card:        #FFFFFF;
    --adm-bg-card-hover:  #F7F8FA;
    --adm-bg-base:        #F0F2F5;
    --adm-surface:        #E8ECF0;
    --adm-border:         rgba(0,0,0,0.08);
    --adm-border-mid:     rgba(0,0,0,0.14);
    --adm-border-light:   rgba(0,0,0,0.05);
    --adm-teal:           #00897B;
    --adm-teal-hover:     #00695C;
    --adm-teal-glow:      rgba(0,137,123,0.15);
    /* Button CTA tokens — indigo separates actions from teal status indicators */
    --adm-btn-primary-bg:    #0D9488;
    --adm-btn-primary-hover: #0F766E;
    --adm-text-primary:   #111827;
    --adm-text-secondary: #374151;
    --adm-text-muted:     #6B7280;
    --adm-shadow:         0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
    /* --surface-base is used by inline-styled pages as a card/input background alias. */
    --surface-base:       #FFFFFF;
    /* --bg-primary is consumed by .page-shell and .team-page */
    --bg-primary:         #F0F2F5;
}

/* ── Light theme: adm-btn-* (hyphen) overrides ───────────────────────────────
   Brand indigo for primary CTA; teal stays for badges/indicators/status only. */
[data-theme="light"] .adm-btn-primary {
    background: var(--adm-btn-primary-bg) !important;
    color: #EFF6FF !important;
    border-color: transparent !important;
    box-shadow: 0 2px 8px rgba(45,42,110,0.20) !important;
}
[data-theme="light"] .adm-btn-primary:hover:not(:disabled) {
    background: var(--adm-btn-primary-hover) !important;
    color: #EFF6FF !important;
    box-shadow: 0 4px 16px rgba(45,42,110,0.28) !important;
}
[data-theme="light"] .adm-btn-secondary {
    background: #FFFFFF;
    color: #111827;
    border-color: rgba(0,0,0,0.20);
}
[data-theme="light"] .adm-btn-secondary:hover:not(:disabled) {
    background: #F7F8FA;
    border-color: #0D9488;
    color: #0D9488;
}
[data-theme="light"] .adm-btn-ghost {
    color: #374151;
}
[data-theme="light"] .adm-btn-ghost:hover:not(:disabled) {
    color: #111827;
    background: rgba(0, 0, 0, 0.06);
}

/* ── Light theme: adm-btn--* (BEM) overrides ─────────────────────────────────
   Brand teal for all primary CTAs; overrides auditor.css glassy teal and any
   other sheet that sets .adm-btn--primary to teal in light mode. */
[data-theme="light"] .adm-btn--primary,
[data-theme="light"] .adm-btn.adm-btn--primary,
[data-theme="light"] .adm-btn-primary {
    background: #0D9488 !important;
    color: #EFF6FF !important;
    border-color: transparent !important;
    box-shadow: 0 2px 8px rgba(13,148,136,0.22) !important;
}
[data-theme="light"] .adm-btn--primary:hover:not(:disabled),
[data-theme="light"] .adm-btn.adm-btn--primary:hover:not(:disabled),
[data-theme="light"] .adm-btn-primary:hover:not(:disabled) {
    background: #0F766E !important;
    color: #EFF6FF !important;
    box-shadow: 0 4px 16px rgba(13,148,136,0.28) !important;
}
[data-theme="light"] .adm-btn--secondary,
[data-theme="light"] .adm-btn.adm-btn--secondary {
    background: #FFFFFF;
    border-color: rgba(0,0,0,0.20);
    color: #111827;
}
[data-theme="light"] .adm-btn--secondary:hover:not(:disabled),
[data-theme="light"] .adm-btn.adm-btn--secondary:hover:not(:disabled) {
    background: #F7F8FA;
    border-color: #0D9488;
    color: #0D9488;
}
[data-theme="light"] .adm-btn--ghost,
[data-theme="light"] .adm-btn.adm-btn--ghost {
    background: transparent;
    border-color: rgba(0,0,0,0.16);
    color: #374151;
}
[data-theme="light"] .adm-btn--ghost:hover:not(:disabled),
[data-theme="light"] .adm-btn.adm-btn--ghost:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.06);
    color: #111827;
}

/* ── App-shell background — light theme ─────────────────────────────────────
   .app-shell uses var(--color-navy) which resolves to #2D2A6E (deep indigo) in
   light mode — still dark. Override to surface-bg so the area between sidebar
   and page content is the warm off-white. */
[data-theme="light"] .app-shell {
    background: var(--surface-bg);
}

/* ── Sidebar header area — light theme ──────────────────────────────────────
   .sidebar-header has no explicit background; it inherits .sidebar-nav which is
   now white. Ensure the border uses the light token. */
[data-theme="light"] .sidebar-header {
    border-bottom-color: var(--shell-border);
}

/* ── Sidebar accordion trigger — light theme ─────────────────────────────── */
[data-theme="light"] .sidebar-accordion-trigger:hover,
[data-theme="light"] .sidebar-accordion-trigger:focus-visible {
    background: rgba(45, 42, 110, 0.05);
    color: var(--text-secondary);
}

/* ── Sidebar brand text — light theme ────────────────────────────────────── */
[data-theme="light"] .sidebar-brand {
    color: var(--text-primary);
}

/* ── Collapsed flyout panel — light theme ────────────────────────────────── */
[data-theme="light"] .sidebar-collapsed-flyout {
    background: #FFFFFF;
    border-color: var(--shell-border);
    box-shadow: 6px 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(45, 42, 110, 0.06);
}
[data-theme="light"] .sidebar-collapsed-flyout__header {
    border-bottom-color: rgba(45, 42, 110, 0.10);
}

/* ── TopBar profile menu — already overridden above; guard secondary vars ── */

/* ── Page shell — light theme ───────────────────────────────────────────────
   .page-shell uses var(--bg-primary) which is undefined in design-system.css.
   Now that --bg-primary is defined in the [data-theme="light"] block above,
   this rule is a belt-and-suspenders explicit override. */
[data-theme="light"] .page-shell {
    background: var(--surface-bg);
}

/* ── Main slot — light theme ────────────────────────────────────────────────
   Belt-and-suspenders: #app-main-slot is transparent by default; the .app-shell
   override above handles the background. This ensures any child wrapper that
   doesn't use .page-shell also gets the right base. */
[data-theme="light"] #app-main-slot {
    background: var(--surface-bg);
}

/* ── Inline-styled action buttons (ESI/compliance pages) — light theme ──────
   Pages that use _btnStyle('secondary') fall back to background:#1A1840 when
   --surface-base is not defined. Now that --surface-base is defined in the
   [data-theme="light"] custom-property block above, inline elements that
   reference var(--surface-base) will resolve to #FFFFFF in light mode. */

/* ── Bulk bar — light theme (already present above) ── */

/* ── TopBar — light theme ───────────────────────────────────────────────────
   .topbar uses var(--shell-surface) which resolves to #FFFFFF in light mode,
   but backdrop-filter: blur(12px) on the base rule composites the dark navy
   app-shell background through, making the bar appear smoky/dark.
   !important beats any inline style; backdrop-filter:none removes the blur. */
[data-theme="light"] .topbar {
    background: #FFFFFF !important;
    border-bottom: 1px solid rgba(0,0,0,0.10) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    color: #111827 !important;
}

/* Topbar brand text and icon buttons — dark on white */
[data-theme="light"] .topbar-brand,
[data-theme="light"] .topnav-brand {
    color: #1A1628;
}

/* topbar-iconbtn already overridden above at line 1971; re-state colour explicitly */
[data-theme="light"] .topbar-iconbtn {
    color: #374151;
}
[data-theme="light"] .topbar-iconbtn:hover,
[data-theme="light"] .topbar-iconbtn:focus-visible {
    color: #111827;
    background: rgba(26,22,40,0.06);
}

/* Hamburger — same dark-on-white treatment */
[data-theme="light"] .topbar-hamburger {
    color: #374151;
}
[data-theme="light"] .topbar-hamburger:hover {
    background: rgba(26,22,40,0.06);
    color: #111827;
}

/* Keyboard shortcut chip */
[data-theme="light"] .topbar-kbd {
    background: rgba(0,0,0,0.06);
    color: #6B7280;
}

/* Light theme: subtle card separation — replaces the heavy border pass */
[data-theme="light"] .card,
[data-theme="light"] .stat-card,
[data-theme="light"] .panel,
[data-theme="light"] .summary-card,
[data-theme="light"] .detail-card {
    border: 1px solid rgba(0,0,0,0.07);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

/* ── Site Footer — light theme ──────────────────────────────────────────────
   .site-footer inherits the dark navy --shell-surface in dark mode.
   In light mode override to white with a hairline top border.
   No backdrop-filter on .site-footer in the base rule, so none to disable. */
[data-theme="light"] .site-footer {
    background: #FFFFFF !important;
    border-top: 1px solid rgba(0,0,0,0.10) !important;
    color: #374151 !important;
}
[data-theme="light"] .site-footer-copy {
    color: #374151 !important;
}
[data-theme="light"] .footer-legal-btn {
    color: #374151 !important;
    border-color: rgba(0,0,0,0.20) !important;
}
[data-theme="light"] .footer-legal-btn:hover,
[data-theme="light"] .footer-legal-btn:focus-visible {
    color: #111827 !important;
    border-color: rgba(0,0,0,0.40) !important;
}
[data-theme="light"] .site-footer-links a {
    color: #374151 !important;
    border-color: rgba(0,0,0,0.20) !important;
}
[data-theme="light"] .site-footer-links a:hover,
[data-theme="light"] .site-footer-links a:focus-visible {
    color: #111827 !important;
    border-color: rgba(0,0,0,0.40) !important;
}
[data-theme="light"] .site-footer-conf {
    color: #B45309 !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   adm-* primitives — tenant-portal supplement
   Classes defined in admin.css that are also needed by tenant-portal pages
   (e.g. LearnerSegmentAdminPage, SettingsPage sub-tabs) but are NOT loaded via
   admin.css in the tenant shell. All colours use the adm-* CSS custom properties
   already declared earlier in this file so dark/light theming is automatic.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Outline button variant ──────────────────────────────────────────────── */
.adm-btn-outline {
    background: transparent;
    color: var(--adm-text-secondary);
    border: 1px solid var(--adm-border-mid);
}
.adm-btn-outline:hover:not(:disabled) {
    border-color: var(--adm-teal);
    color: var(--adm-teal);
}

[data-theme="light"] .adm-btn-outline {
    color: #374151;
    border-color: rgba(0, 0, 0, 0.20);
}
[data-theme="light"] .adm-btn-outline:hover:not(:disabled) {
    border-color: #0D9488;
    color: #0D9488;
}

/* ── Compact select (standalone — does NOT set width:100%) ───────────────── */
/* Use for filter dropdowns and in-table selects where full-width is wrong.   */
.adm-select-sm {
    display: inline-block;
    padding: 5px 10px;
    font-size: 12px;
    min-width: 120px;
    background: var(--adm-bg-elevated);
    border: 1px solid var(--adm-border-mid);
    border-radius: var(--adm-radius-sm);
    color: var(--adm-text-primary);
    font-family: var(--adm-font, inherit);
    cursor: pointer;
    outline: none;
    transition: border-color var(--adm-transition), box-shadow var(--adm-transition);
    box-sizing: border-box;
}
.adm-select-sm:focus {
    border-color: var(--adm-teal);
    box-shadow: 0 0 0 3px rgba(0, 180, 162, 0.12);
}

[data-theme="light"] .adm-select-sm {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.18);
    color: #111827;
}
[data-theme="light"] .adm-select-sm:focus {
    border-color: #0D9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

/* ── Compact input variant ──────────────────────────────────────────────── */
.adm-input-sm {
    padding: 6px 10px;
    font-size: 12px;
    background: var(--adm-bg-elevated);
    border: 1px solid var(--adm-border-mid);
    border-radius: var(--adm-radius-sm);
    color: var(--adm-text-primary);
    font-family: var(--adm-font, inherit);
    outline: none;
    transition: border-color var(--adm-transition), box-shadow var(--adm-transition);
    box-sizing: border-box;
}
.adm-input-sm:focus {
    border-color: var(--adm-teal);
    box-shadow: 0 0 0 3px rgba(0, 180, 162, 0.12);
}
.adm-input-sm::placeholder { color: var(--adm-text-muted); }

[data-theme="light"] .adm-input-sm {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.18);
    color: #111827;
}
[data-theme="light"] .adm-input-sm:focus {
    border-color: #0D9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

/* ── Alert / banner variants ────────────────────────────────────────────── */
.adm-alert {
    padding: 12px 16px;
    border-radius: var(--adm-radius-sm);
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid transparent;
}
.adm-alert-error {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.30);
    color: var(--adm-red, #ef4444);
}
.adm-alert-warn {
    background: rgba(234, 179, 8, 0.08);
    border-color: rgba(234, 179, 8, 0.25);
    color: #fde68a;
}
.adm-alert-info {
    background: rgba(0, 180, 162, 0.08);
    border-color: rgba(0, 180, 162, 0.25);
    color: var(--adm-teal, #00b4a2);
}
.adm-alert-success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: var(--adm-green, #10b981);
}

[data-theme="light"] .adm-alert-error {
    background: rgba(239, 68, 68, 0.06);
    color: #b91c1c;
}
[data-theme="light"] .adm-alert-warn {
    background: rgba(180, 83, 9, 0.06);
    border-color: rgba(180, 83, 9, 0.25);
    color: #92400e;
}
[data-theme="light"] .adm-alert-info {
    background: rgba(0, 137, 123, 0.07);
    border-color: rgba(0, 137, 123, 0.25);
    color: #00695c;
}
[data-theme="light"] .adm-alert-success {
    background: rgba(5, 150, 105, 0.07);
    border-color: rgba(5, 150, 105, 0.25);
    color: #065f46;
}

/* ── Spinner (loading indicator) ────────────────────────────────────────── */
@keyframes adm-spin { to { transform: rotate(360deg); } }

.adm-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--adm-border-mid, rgba(255,255,255,0.12));
    border-top-color: var(--adm-teal, #00b4a2);
    border-radius: 50%;
    animation: adm-spin 0.7s linear infinite;
    flex-shrink: 0;
}
.adm-spinner-lg { width: 36px; height: 36px; border-width: 3px; }

/* ── Search bar wrapper + input ─────────────────────────────────────────── */
.adm-search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0;
}
.adm-search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--adm-text-muted);
    pointer-events: none;
    flex-shrink: 0;
}
.adm-search-input {
    padding: 7px 12px 7px 32px;
    background: var(--adm-bg-elevated);
    border: 1px solid var(--adm-border-mid);
    border-radius: var(--adm-radius-sm);
    color: var(--adm-text-primary);
    font-size: 13px;
    font-family: var(--adm-font, inherit);
    outline: none;
    min-width: 220px;
    transition: border-color var(--adm-transition), box-shadow var(--adm-transition);
    box-sizing: border-box;
}
.adm-search-input:focus {
    border-color: var(--adm-teal);
    box-shadow: 0 0 0 3px rgba(0, 180, 162, 0.12);
}
.adm-search-input::placeholder { color: var(--adm-text-muted); }

[data-theme="light"] .adm-search-input {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.18);
    color: #111827;
}
[data-theme="light"] .adm-search-input:focus {
    border-color: #0D9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

/* ── Mobile: iOS auto-zoom prevention for new compact inputs ─────────────── */
@media (max-width: 768px) {
    .adm-select-sm,
    .adm-input-sm,
    .adm-search-input {
        font-size: 16px;
    }
    /* MR-212: .adm-select-sm's own padding (5px 10px) + 12px base font
       resolves to ~35px effective height at every viewport — confirmed live
       on the Stalled Joiners filter bar (LearningReportsLandingPage, #/reports),
       9px short of the 44px touch-target minimum (Rule 1). min-height only
       (no display:inline-flex) — mirrors the established .ttp-filter-select
       precedent (MR-186, learning-admin.css) for <select> elements; native
       selects already vertically center their content without flex. Scoped
       to .adm-select-sm only (not .adm-input-sm/.adm-search-input, unused by
       the pages in this audit's scope). */
    .adm-select-sm {
        min-height: 44px;
    }
}
