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

@font-face {
    font-family: 'STCForward';
    src: url('fonts/STCForward-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'STCForward';
    src: url('fonts/STCForward-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* STC Colors - Dark Mode Default */
    --stc-purple: #4F008C;
    --stc-coral: #FF375E;
    --stc-purple-dark: #2F005B;
    --stc-coral-light: #FF6D88;
    
    --bg-main: #140026;
    --bg-gradient: radial-gradient(circle at top right, #390066, #140026 50%), radial-gradient(circle at bottom left, #29004d, #140026 50%);
    --bg-secondary: rgba(43, 0, 77, 0.4);
    --bg-card: rgba(47, 0, 91, 0.4);
    
    --text-primary: #FFFFFF;
    --text-secondary: #D4B3FF;
    
    --primary: var(--stc-purple);
    --primary-hover: var(--stc-purple-dark);
    --primary-gradient: linear-gradient(135deg, var(--stc-purple), var(--stc-coral));
    
    --success: #00D2D3;
    --warning: #FFB800;
    --danger: var(--stc-coral);
    
    --danger-gradient: linear-gradient(135deg, #FF375E, #FF6D88);
    --success-gradient: linear-gradient(135deg, #00D2D3, #00A6A7);
    --warning-gradient: linear-gradient(135deg, #FFB800, #E6A600);
    
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.12);
    
    --shadow-md: 0 10px 40px -10px rgba(79, 0, 140, 0.5);
    --shadow-glow: 0 0 25px rgba(255, 55, 94, 0.4);
    
    --font-family: 'STCForward', 'Tajawal', sans-serif;
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    /* ── Design-scale tokens (Phase 2 Step 1) ──────────────────────────────
       Values chosen to MATCH the dominant existing inline values so later
       adoption is non-visual. Defined here only; not yet referenced. */
    --font-size-caption: 0.75rem;   /* small labels / hints */
    --font-size-label:   0.85rem;   /* field labels / table cells */
    --font-size-body:    0.95rem;   /* body copy */
    --font-size-base:    1rem;      /* default */
    --font-size-lg:      1.25rem;   /* sub-headings */
    --font-size-xl:      1.5rem;    /* headings */

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    --radius-sm:   6px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-pill: 9999px;
}

body.light-mode {
    --bg-main: #F4F6F9;
    --bg-gradient: radial-gradient(circle at top right, #F4F6F9, #FFFFFF 60%), radial-gradient(circle at bottom left, #FFEDF1, #F4F6F9 50%);
    --bg-secondary: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.85);
    
    --text-primary: #1A0D23;
    --text-secondary: #6A567D;
    
    --border-color: rgba(79, 0, 140, 0.08);
    --glass-border: rgba(255, 255, 255, 0.9);
    
    --shadow-md: 0 10px 40px -10px rgba(79, 0, 140, 0.12);
    --shadow-glow: 0 0 25px rgba(255, 55, 94, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    transition: var(--transition);
    overflow: hidden;
    height: 100vh;
    margin: 0;
    background-image: var(--bg-gradient);
    background-color: var(--bg-main);
    background-attachment: fixed;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
    transition: var(--transition);
    z-index: 10;
    height: 100%;
    overflow-y: auto;
}

/* Collapsed Sidebar State */
.sidebar.collapsed {
    width: 80px;
    padding: 2.5rem 0.75rem;
}
.sidebar.collapsed .sidebar-text {
    display: none;
}
.sidebar.collapsed .logo {
    display: none; /* Hide logo when collapsed to save space */
}
.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
}
.sidebar.collapsed #env-badge-row {
    padding-left: 0;
    padding-right: 0;
}
/* Lock scroll while passkey overlay is visible */
html.pk-locked,
body.pk-locked {
    overflow: hidden !important;
    /* Prevent iOS momentum scrolling showing content underneath */
    -webkit-overflow-scrolling: auto !important;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}
.sidebar.collapsed .export-section h3 {
    display: none;
}
.sidebar.collapsed .export-section .btn {
    justify-content: center;
    padding: 0.85rem;
}
.sidebar.collapsed .btn-outline i {
    margin: 0;
}

/* Floating Sidebar Toggle Action */
.sidebar-toggle-btn {
    position: absolute;
    left: calc(240px - 15px); /* Exactly at the 240px boundary between components */
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    z-index: 100;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-toggle-btn:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-50%) scale(1.1);
}
.sidebar-toggle-btn i {
    transition: transform 0.4s ease;
}
.sidebar.collapsed ~ .sidebar-toggle-btn {
    left: calc(80px - 15px); /* Tracks the sidebar seamlessly when collapsed */
}
/* Flip arrow gracefully when sidebar collapses */
.sidebar.collapsed ~ .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 3rem;
    text-shadow: 0px 4px 10px rgba(255, 55, 94, 0.3);
}

.logo i {
    font-size: 2.4rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item:hover {
    background-color: rgba(30, 144, 213, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

.export-section {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.export-section h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: 9999px; /* STC uses highly rounded action buttons */
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
    border: 1px solid rgba(255, 255, 94, 0.2);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 35px rgba(255, 55, 94, 0.6);
    transform: translateY(-2px);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
}
.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.theme-toggle {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.top-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Domain Navigation Pill */
.domain-segmented-nav {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 6px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.domain-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.domain-tab i {
    font-size: 1.1rem;
}

.domain-tab:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(128, 128, 128, 0.1);
}

.domain-tab.active {
    color: #ffffff;
    background: linear-gradient(135deg, #00D2D3, #0076FF);
    box-shadow: 0 0 15px rgba(0, 210, 211, 0.4), inset 0 1px 1px rgba(255,255,255,0.3);
    font-weight: 700;
}

/* Domain Views Animation */
.domain-view {
    display: none;
}
.domain-view.active {
    display: block !important;
    animation: fadeInDomain 0.4s ease-out forwards;
}
@keyframes fadeInDomain {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}

/* Glassmorphism Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--glass-border);
    border-radius: 28px; /* STC prefers very soft, rounded cards */
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(255, 55, 94, 0.4);
}

/* Uploader Section */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background-color: var(--bg-secondary);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

/* Widgets Grid */
.summary-widgets {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    padding-bottom: 0.5rem;
}

.summary-widgets .widget {
    flex: 1 1 0;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.widget-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.widget-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.widget-icon.primary { background: var(--primary-gradient); color: white; box-shadow: 0 8px 25px rgba(79, 0, 140, 0.4); }
.widget-icon.danger { background: var(--danger-gradient); color: white; box-shadow: 0 8px 25px rgba(255, 55, 94, 0.4); }
.widget-icon.success { background: var(--success-gradient); color: white; box-shadow: 0 8px 25px rgba(0, 210, 211, 0.4); }

.widget-info h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.widget-info p {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    display: flex;
    flex-direction: column;
}

.chart-container.full-width {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.canvas-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
    flex: 1;
}

/* Table Section */
.table-section {
    margin-bottom: 2rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.data-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
}

.search-box input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    border-radius: 9999px;
    color: var(--text-primary);
    font-family: inherit;
    width: 250px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 0, 140, 0.2);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 1rem 1.5rem;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    border-bottom: none;
    white-space: nowrap;
}

td {
    padding: 1rem 1.5rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

tbody tr {
    transition: background 0.2s ease, transform 0.2s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.badge.minor { background: var(--success-gradient); color: white; box-shadow: 0 2px 8px rgba(0, 210, 211, 0.3); border:none;}
.badge.moderate { background: var(--warning-gradient); color: white; box-shadow: 0 2px 8px rgba(255, 184, 0, 0.3); border:none;}
.badge.insignificant { background: var(--primary-gradient); color: white; box-shadow: 0 2px 8px rgba(79, 0, 140, 0.3); border:none;}
.badge.high { background: var(--danger-gradient); color: white; box-shadow: 0 2px 8px rgba(255, 55, 94, 0.3); border:none;}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1.5rem;
}

.page-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Filter Bar styles */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filter-bar:empty {
    display: none;
    margin-bottom: 0;
}

.filter-pill {
    background: var(--primary-gradient);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 10px rgba(79, 0, 140, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.filter-pill button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.8;
    transition: var(--transition);
}

.filter-pill button:hover {
    opacity: 1;
    transform: scale(1.1);
}

.filter-clear {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.filter-clear:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Utility */
.hidden {
    display: none !important;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 0, 20, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: flex !important; /* Retain flex but kill pointer events and opacity for transitions */
}

/* Modal Content */
.modal-content {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.95);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger-gradient);
    color: white;
}

/* Modal Grid & Fields */
.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input, .form-group textarea {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus, .form-group textarea:focus {
    border-color: rgba(255, 255, 94, 0.4);
    box-shadow: 0 0 15px rgba(255, 55, 94, 0.2);
}

.form-group input[readonly], .form-group textarea[readonly] {
    opacity: 0.9;
    cursor: default;
}

/* Print Utilities */
@media print {
    .sidebar, .top-header, .table-actions, .pagination, .upload-area, .filter-bar {
        display: none !important;
    }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    body { background: white; color: black; }
    .card { background: white !important; border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
    .widget-icon, .badge { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

@media (max-width: 1024px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
    .modal-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* Dense Chip Layout for Regulation Table */
#regulationTable {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    border: none;
    width: 100%;
}
#regulationTable thead {
    display: none;
}
#regulationTable tbody {
    display: contents; 
}
#regulationTable tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px; /* Can use rounded corners still, wrap expands vertically safely */
    padding: 6px 14px;
    margin: 2px;
    min-width: 0; /* Prevent grid blowout */
    transition: all 0.2s ease;
}
.light-mode #regulationTable tr {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
}
#regulationTable tr:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.light-mode #regulationTable tr:hover {
    background: rgba(0, 0, 0, 0.08);
}
#regulationTable td {
    border: none;
    padding: 0;
    max-width: initial;
    background: transparent;
}
#regulationTable td:first-child {
    font-weight: 500;
    margin-right: 12px;
    font-size: 0.85rem;
    white-space: normal;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}
#regulationTable td:last-child {
    background: var(--primary-color, #4F008C);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

/* Tablet & Mobile Devices */
@media (max-width: 1024px) {
    .sidebar-toggle-btn {
        display: none !important;
    }
    body {
        overflow: auto;
    }
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    .logo {
        margin-bottom: 0 !important;
    }
    .nav-menu {
        display: none;
    }
    .export-section {
        margin-top: 0 !important;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    .export-section h3 {
        display: none;
    }
    .export-section button {
        padding: 0.5rem;
        font-size: 1.25rem;
    }
    .export-section button .sidebar-text {
        display: none;
    }
    .theme-toggle {
        margin-top: 0 !important;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    .sidebar-header {
        width: auto;
        margin-right: auto;
        padding: 0.5rem 0 !important;
    }
    .main-content {
        padding: 1rem;
        height: auto;
        overflow: visible;
    }
    .top-header {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    .domain-segmented-nav {
        position: relative;
        left: auto;
        transform: none;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    .domain-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .top-header h1 {
        font-size: 1.5rem;
        width: 100%;
    }
    .table-header, .data-controls, .table-actions {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 1rem;
    }
    .table-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .search-box {
        width: 100%;
    }
    .search-box input {
        width: 100%;
    }
    .modal-grid {
        grid-template-columns: 1fr;
    }
    .card {
        padding: 1.25rem;
    }
    .pagination {
        flex-direction: column;
        gap: 1rem;
    }
    .chart-container h3, .widget-info h3 {
        font-size: 0.95rem;
    }
    #regulationTable {
        grid-template-columns: 1fr;
    }
}
/* Directional Bounce Animation */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px) translateX(20px);
    }
    60% {
        transform: translateY(-10px) translateX(10px);
    }
}

/* State Containers */
.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
}
#regulationTable thead {
    display: none;
}

/* Custom Modal Layout */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.custom-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.custom-modal.hidden {
    display: none;
}

.custom-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 1000;
}

.custom-modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    position: relative;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    margin-top: 8vh;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
}

.custom-modal.active .custom-modal-content {
    transform: translateY(0) scale(1);
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.custom-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: var(--danger);
}

/* Tree Graph Layout - iOS Redesign */
.org-tree {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    padding: 10px 0;
}

.org-tree ul {
    padding-top: 30px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    list-style-type: none;
    margin: 0;
    padding-left: 0;
}

.org-tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 30px 10px 0 10px;
    transition: all 0.5s;
}

/* Connecting lines */
.org-tree li::before, .org-tree li::after{
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #75b597; /* pale green connecting line */
    width: 50%;
    height: 30px;
}

.org-tree li::after{
    right: auto;
    left: 50%;
    border-left: 2px solid #75b597;
}

.org-tree li:only-child::after, .org-tree li:only-child::before {
    display: none;
}

.org-tree li:only-child{
    padding-top: 0;
}

.org-tree li:first-child::before, .org-tree li:last-child::after{
    border: 0 none;
}

.org-tree li:last-child::before{
    border-right: 2px solid #75b597;
    border-radius: 0 25px 0 0;
}

.org-tree li:first-child::after{
    border-radius: 25px 0 0 0;
}

.org-tree ul ul::before{
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #75b597;
    width: 0;
    height: 30px;
}

/* Base Node Styling override */
.tree-node {
    background: linear-gradient(145deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border: 1px solid var(--border-color);
    padding: 1rem 0.5rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    min-width: 170px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    gap: 8px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.tree-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--node-color, var(--accent));
}

.tree-node:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.tree-node h4 {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.tree-node .tree-count {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* Selected active node styling */
.tree-node.active-node {
    border: 3px solid var(--node-color, var(--primary));
    border-radius: 14px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}

.parent-node {
    padding: 1.5rem 1rem;
    min-width: 200px;
}

/* Dark Mode Fallbacks */
[data-theme="dark"] .tree-node {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
[data-theme="dark"] .giant-count,
[data-theme="dark"] .node-value .tree-count {
    color: var(--text-primary);
}
[data-theme="dark"] .active-node {
    border-color: #31a473;
}
[data-theme="dark"] .active-node .node-header h4 {
    color: #559ee5;
}

#regulationTable tbody {
    display: contents; 
}
#regulationTable tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px; /* Can use rounded corners still, wrap expands vertically safely */
    padding: 6px 14px;
    margin: 2px;
    min-width: 0; /* Prevent grid blowout */
    transition: all 0.2s ease;
}
.light-mode #regulationTable tr {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
}
#regulationTable tr:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.light-mode #regulationTable tr:hover {
    background: rgba(0, 0, 0, 0.08);
}
#regulationTable td {
    border: none;
    padding: 0;
    max-width: initial;
    background: transparent;
}
#regulationTable td:first-child {
    font-weight: 500;
    margin-right: 12px;
    font-size: 0.85rem;
    white-space: normal;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}
#regulationTable td:last-child {
    background: var(--primary-color, #4F008C);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

/* Tablet & Mobile Devices */
@media (max-width: 1024px) {
    .sidebar-toggle-btn {
        display: none !important;
    }
    body {
        overflow: auto;
    }
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    .logo {
        margin-bottom: 0 !important;
    }
    .nav-menu {
        display: none;
    }
    .export-section {
        margin-top: 0 !important;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    .export-section h3 {
        display: none;
    }
    .export-section button {
        padding: 0.5rem;
        font-size: 1.25rem;
    }
    .export-section button .sidebar-text {
        display: none;
    }
    .theme-toggle {
        margin-top: 0 !important;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    .sidebar-header {
        width: auto;
        margin-right: auto;
        padding: 0.5rem 0 !important;
    }
    .main-content {
        padding: 1rem;
        height: auto;
        overflow: visible;
    }
    .top-header {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    .domain-segmented-nav {
        position: relative;
        left: auto;
        transform: none;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    .domain-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .top-header h1 {
        font-size: 1.5rem;
        width: 100%;
    }
    .table-header, .data-controls, .table-actions {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 1rem;
    }
    .table-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .search-box {
        width: 100%;
    }
    .search-box input {
        width: 100%;
    }
    .modal-grid {
        grid-template-columns: 1fr;
    }
    .card {
        padding: 1.25rem;
    }
    .pagination {
        flex-direction: column;
        gap: 1rem;
    }
    .chart-container h3, .widget-info h3 {
        font-size: 0.95rem;
    }
    #regulationTable {
        grid-template-columns: 1fr;
    }
}
/* Directional Bounce Animation */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px) translateX(20px);
    }
    60% {
        transform: translateY(-10px) translateX(10px);
    }
}

/* State Containers */
.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
}
.empty-state-container.hidden {
    display: none !important;
}

/* Executive View Button Animated Boundaries */
button[onclick="toggleExecutiveMode()"] {
    position: relative;
    border: none !important;
}

button[onclick="toggleExecutiveMode()"]::after {
    content: '';
    position: absolute;
    top: -1px; left: -1px; right: -1px; bottom: -1px;
    border: 2px solid #00d2d3;
    background: transparent;
    border-radius: 9px;
    pointer-events: none;
    animation: borderSweep 4s linear infinite;
}

@keyframes borderSweep {
    0% { border-color: #00d2d3; box-shadow: 0 0 8px rgba(0, 210, 211, 0.4); }
    33% { border-color: #7a00ff; box-shadow: 0 0 8px rgba(122, 0, 255, 0.4); }
    66% { border-color: #ff375e; box-shadow: 0 0 8px rgba(255, 55, 94, 0.4); }
    100% { border-color: #00d2d3; box-shadow: 0 0 8px rgba(0, 210, 211, 0.4); }
}

/* Upload Highlight Animation for Domain Tabs */
@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 210, 211, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(0, 210, 211, 0);
        transform: scale(1.05);
        color: #fff;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 211, 0);
        transform: scale(1);
    }
}

.highlight-pulse {
    animation: highlightPulse 0.7s ease-in-out 3;
}

/* RC BU List Styles */
.rc-bu-card {
    height: 100%; /* Stretches to match the row's tallest card (the adjacent chart card) */
}

/* RC Map right-col desktop layout (values removed from inline styles to allow mobile overrides) */
@media (min-width: 769px) {
    .rc-right-card {
        min-height: 450px;
    }
    /* Compact donut-left/legend-right cards (Compliance Health + Risk Scoring) — scoped:
       CBU/EBU keep the 450px row behavior */
    .rc-compact-chart-card {
        min-height: 280px;
    }
    #rc-channels-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    #rc-status-chart-wrapper {
        width: 220px;
        height: 220px;
    }
    #rc-cbu-channel-chart-container,
    #rc-ebu-channel-chart-container {
        flex: 1;
        min-height: 350px;
    }
    .cst-chart-wrapper {
        height: 350px;
    }
}

.rc-bu-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.rc-bu-list-container::-webkit-scrollbar {
    width: 6px;
}

.rc-bu-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.rc-bu-list-container::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
}

.rc-bu-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem;
    background-color: transparent;
    border: none;
    transition: all 0.2s ease;
}

.rc-bu-list-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
    transform: none;
    box-shadow: none;
}

.rc-bu-list-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rc-bu-list-name i {
    color: var(--primary);
    font-size: 1.2rem;
    background: rgba(79, 0, 140, 0.1);
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.rc-bu-list-count {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 0;
    font-weight: 500;
    font-size: 0.95rem;
}

.rc-bu-see-all-btn {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    margin: 1rem auto 0;
    display: block;
    transition: all 0.2s ease;
}

.rc-bu-see-all-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Premium BU Card Styles */
.rc-bu-card {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 20px !important;
    padding: 1.5rem !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    color: #111827 !important;
}

[data-theme='dark'] .rc-bu-card {
    background: #1f2937 !important;
    border: 1px solid #374151 !important;
    color: #f3f4f6 !important;
}

.rc-bu-card h3 {
    font-size: 1.35rem !important;
    font-weight: 700 !important;
    margin-bottom: 0.15rem !important;
    color: inherit !important;
}

.rc-bu-subtitle {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.rc-bu-analysis-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: inherit;
}

.rc-bu-segmented-bar {
    display: flex;
    gap: 3px;
    height: 16px;
    margin-bottom: 0.75rem;
}

.rc-bu-segment {
    border-radius: 4px;
    height: 100%;
}

.rc-bu-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 2rem;
}

.rc-bu-legend-pill {
    padding: 4px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
}

.rc-bu-list-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: inherit;
}

.rc-bu-list-container {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.rc-bu-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0;
    border-bottom: 1px solid #f3f4f6;
}

[data-theme='dark'] .rc-bu-list-item {
    border-bottom: 1px solid #374151;
}

.rc-bu-list-item:last-child {
    border-bottom: none;
}

.rc-bu-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.rc-bu-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    font-size: 1.25rem;
}

[data-theme='dark'] .rc-bu-item-icon {
    background: #374151;
    border: 1px solid #4b5563;
}

.rc-bu-item-name {
    font-weight: 500;
    font-size: 1rem;
    color: inherit;
}

.rc-bu-item-value {
    font-weight: 600;
    font-size: 1rem;
    color: #6b7280;
}

.rc-bu-see-all-container {
    display: flex;
    justify-content: center;
    margin-top: auto;
    padding-top: 1rem;
}

.rc-bu-see-all-btn {
    background: #f3f4f6 !important;
    border: none !important;
    padding: 10px 32px !important;
    border-radius: 40px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #4b5563 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

[data-theme='dark'] .rc-bu-see-all-btn {
    background: #374151 !important;
    color: #d1d5db !important;
}

.rc-bu-see-all-btn:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
}

[data-theme='dark'] .rc-bu-see-all-btn:hover {
    background: #4b5563 !important;
    color: #ffffff !important;
}

/* Updated BU Bar Styles */
.rc-bu-segmented-bar {
    display: flex;
    height: 12px;
    margin-bottom: 0.75rem;
    border-radius: 4px;
    overflow: hidden;
}

.rc-bu-segment {
    height: 100%;
}

.rc-bu-bar-labels {
    display: flex;
    align-items: flex-end;
    margin-bottom: 8px;
    min-height: 30px;
}

.rc-bu-bar-label {
    line-height: 1.2;
}

.rc-bu-list-container {
    overflow: visible !important;
    height: auto !important;
}

/* 4 Column BU List */
.rc-bu-list-container {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.5rem 2.5rem !important;
    overflow: visible !important;
    height: auto !important;
    padding: 1rem 0 !important;
}

.rc-bu-list-item {
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
}

[data-theme='dark'] .rc-bu-list-item {
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}

.rc-bu-item-left {
    gap: 8px !important;
}

.rc-bu-item-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 1rem !important;
}

.rc-bu-item-name {
    font-size: 0.9rem !important;
}

.rc-bu-item-value {
    font-size: 0.9rem !important;
}

/* Regulation Pills Grid */
.regulation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 0.75rem;
    padding: 1rem 0;
}

.reg-pill-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 12px;
    padding: 10px 15px;
    border: 1px solid rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    cursor: pointer;
}

.light-mode .reg-pill-card {
    background: #f8f9fa;
}

.reg-pill-card:hover {
    background: #FFFFFF;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.reg-pill-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    padding-right: 10px;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    line-height: 1.4;
}

.reg-pill-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-top: 2px;
}

.reg-stat-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    color: white;
    min-width: 45px;
    text-align: center;
}

.reg-stat-badge.percentage {
    background: #FF375E; /* Default Red */
}

.reg-stat-badge.percentage.complete {
    background: #00C48C; /* Green for 100% */
}

.reg-stat-badge.count {
    background: #4F008C; /* Purple */
    min-width: 65px;
}

/* Adjust for smaller screens */
@media (max-width: 768px) {
    .regulation-grid {
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════════════════
   NATIVE MOBILE LAYOUT  ≤768px
   – Fixed top header + bottom tab bar (app-style navigation)
   – No horizontal overflow, no zooming required
   ════════════════════════════════════════════════════════ */

/* ── Mobile header (always in DOM, hidden on desktop) ── */
.mob-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 8000;
    box-shadow: 0 1px 8px rgba(0,0,0,0.09);
}
.mob-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mob-brand i {
    font-size: 1.35rem;
    color: var(--primary);
    flex-shrink: 0;
}
#mob-section-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.mob-actions { display: flex; gap: 0.3rem; }
.mob-action-btn {
    width: 34px; height: 34px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.mob-action-btn:hover { background: var(--primary-light); color: var(--primary); }

/* ── Mobile bottom nav (always in DOM, hidden on desktop) ── */
.mob-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    align-items: stretch;
    z-index: 8000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.mob-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.6rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.4rem 0.2rem;
    transition: color 0.2s;
    font-family: var(--font-family);
    letter-spacing: 0.01em;
}
.mob-nav-btn i {
    font-size: 1.45rem;
    transition: transform 0.2s;
}
.mob-nav-btn.active { color: var(--primary); }
.mob-nav-btn.active i { transform: scale(1.1); }
.mob-nav-btn:active { opacity: 0.65; }

/* ═══════════════════════════════════════════════════════
   Media query: activate native layout on phones
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Show native UI, hide desktop navigation */
    .mob-header     { display: flex !important; }
    .mob-bottom-nav { display: flex !important; }
    .sidebar        { display: none !important; }
    .top-header     { display: none !important; }

    /* Prevent ALL horizontal overflow */
    html, body { overflow-x: hidden; }
    .app-container  { overflow-x: hidden !important; max-width: 100vw; }
    .main-content   { overflow-x: hidden !important; }

    /* Remove default min-width on flex/grid items to prevent blowout */
    .app-container * { min-width: 0; }

    /* Main content: space for fixed header + bottom nav */
    .main-content {
        padding: 60px 0.75rem 74px !important;
        height: auto !important;
        overflow-y: auto;
    }

    /* Remove extra top margin on content divs (header already gives 60px) */
    body:not(.executive-mode) #true-landscape-content,
    body:not(.executive-mode) #app-content,
    body:not(.executive-mode) #annual-content,
    body:not(.executive-mode) #assurance-content {
        margin-top: 0.5rem !important;
    }

    /* ── Summary widgets: 2-column compact grid ── */
    body:not(.executive-mode) .summary-widgets {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
        padding: 0 !important;
    }
    body:not(.executive-mode) .summary-widgets .widget {
        flex: unset !important;
        gap: 0.5rem !important;
        min-width: 0 !important;
    }
    /* Hide flex row-break divs — they're flex-only and create phantom cells in grid */
    body:not(.executive-mode) .summary-widgets > div[style*="flex-basis: 100%"] {
        display: none !important;
    }
    /* Last widget spans both columns when total widget count is odd */
    body:not(.executive-mode) .summary-widgets > .widget.card:last-child:nth-child(even) {
        grid-column: 1 / -1;
    }
    body:not(.executive-mode) .widget-icon {
        width: 38px !important;
        height: 38px !important;
        border-radius: 10px !important;
        font-size: 1rem !important;
        flex-shrink: 0 !important;
    }
    body:not(.executive-mode) .widget-info p,
    body:not(.executive-mode) .widget-info .widget-value {
        font-size: 1.2rem !important;
        line-height: 1.15 !important;
    }
    body:not(.executive-mode) .widget-info h3,
    body:not(.executive-mode) .widget-info .widget-label {
        font-size: 0.65rem !important;
        margin-bottom: 0.1rem !important;
        letter-spacing: 0.01em !important;
    }

    /* ── Cards ── */
    .card { padding: 0.875rem !important; }

    /* ── Charts: single column, no overflow ── */
    .charts-section {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    .canvas-wrapper       { height: 220px !important; overflow: hidden !important; }
    .chart-container h3   { font-size: 0.875rem !important; margin-bottom: 0.625rem !important; }
    .chart-container      { padding: 0.875rem !important; }

    /* ── Tables: scroll within container, no page overflow ── */
    .table-container,
    .canvas-wrapper.table-responsive,
    #data-table-section .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100% !important;
    }

    /* ── Regulation chips: single column ── */
    #regulationTable { grid-template-columns: 1fr !important; }
    .regulation-grid { grid-template-columns: 1fr !important; }

    /* ── RC BU list: single column on mobile ── */
    .rc-bu-list-container {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        padding: 0.5rem 0 !important;
    }

    /* ── RC LandScape: single-column layout ── */
    #rc-charts-right-col {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    #rc-channels-row {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    .rc-right-card {
        min-height: 0;
    }
    #rc-status-chart-wrapper {
        width: 240px;
        height: 240px;
        margin: 0 auto;
    }
    #rc-cbu-channel-chart-container,
    #rc-ebu-channel-chart-container {
        height: 240px;
    }
    .rc-bu-card {
        height: auto;
    }

    /* ── CST Timeline: horizontally scrollable at fixed render width ── */
    #cst-timeline-card {
        overflow-x: auto !important;
    }
    .cst-chart-wrapper {
        width: 1100px !important;
        min-width: 1100px !important;
        height: 420px !important;
    }

    /* ── Upload drop zone: compact ── */
    #drop-zone { height: 35vh !important; }

    /* ── Modal: full screen on phones ── */
    .modal-content {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }
}

/* ── Extra-small phones (≤430px) ──────────────────────── */
@media (max-width: 430px) {
    .main-content { padding: 56px 0.5rem 70px !important; }

    body:not(.executive-mode) .summary-widgets { gap: 0.4rem !important; }
    body:not(.executive-mode) .widget-icon {
        width: 34px !important; height: 34px !important;
        font-size: 0.9rem !important;
    }
    body:not(.executive-mode) .widget-info p,
    body:not(.executive-mode) .widget-info .widget-value { font-size: 1.05rem !important; }

    .canvas-wrapper { height: 195px !important; }
    .card           { padding: 0.75rem !important; }
}

/* ── Export Generation Animation ──────────────────────────────────────── */
@keyframes export-icon-spin {
    to { transform: rotate(360deg); }
}
@keyframes export-rainbow-rotate {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Wrapper that provides the rainbow spinning border */
.export-rainbow-host {
    position: relative;
    display: inline-flex;
    border-radius: 9999px;
    padding: 2px;
    overflow: hidden;
    isolation: isolate;
}

/* Rotating conic gradient fills the 2px padding area */
.export-rainbow-host::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    transform: translate(-50%, -50%);
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(79,0,140,0.15) 60deg,
        rgba(79,0,140,0.5) 120deg,
        #4F008C 180deg,
        rgba(79,0,140,0.5) 240deg,
        rgba(79,0,140,0.15) 300deg,
        transparent 360deg
    );
    animation: export-rainbow-rotate 2s linear infinite;
    z-index: 0;
}

/* Button sits above the gradient, solid bg covers the center */
.btn.btn-exporting {
    position: relative;
    z-index: 1;
    pointer-events: none;
    background: var(--bg-main) !important;
    border-color: transparent !important;
    color: var(--text-primary) !important;
}
.btn.btn-exporting i {
    display: inline-block;
    animation: export-icon-spin 0.9s linear infinite;
}

/* ─── Schedule Modal ────────────────────────────────────────────────────────── */
.schedule-modal-content { max-width: 560px; width: 100%; }
.schedule-modal-body { padding: 1.25rem 1.75rem 1.5rem; overflow-y: auto; max-height: 78vh; }

.sch-form-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.sch-label-text {
    min-width: 120px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding-top: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sch-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.sch-input:focus { border-color: var(--primary); }
.sch-select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.sch-select:focus { border-color: var(--primary); }
.sch-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.35rem;
}
.sch-radio-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
}
.sch-tag-input {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: text;
    min-height: 38px;
    transition: border-color 0.2s;
}
.sch-tag-input:focus-within { border-color: var(--primary); }
.sch-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(79,0,140,0.15);
    color: var(--primary, #4F008C);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 600;
}
.sch-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 1px;
    opacity: 0.7;
}
.sch-tag-remove:hover { opacity: 1; }
.sch-tag-field {
    flex: 1;
    min-width: 160px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    padding: 2px 4px;
}
.sch-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.2rem;
}
.sch-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.25rem 0;
}
.sch-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.schedule-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    margin-bottom: 0.6rem;
    gap: 0.75rem;
}
.schedule-item-info { flex: 1; min-width: 0; }
.schedule-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.schedule-item-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.schedule-item-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}
.schedule-item-recipients {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.schedule-type-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}
.schedule-type-pdf  { background: rgba(79,0,140,0.15); color: #4F008C; }
.schedule-type-pptx { background: rgba(234,88,12,0.15); color: #c2410c; }
.schedule-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.schedule-delete-btn,
.schedule-edit-btn,
.schedule-run-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.schedule-delete-btn:hover { color: var(--danger, #ef4444); background: rgba(239,68,68,0.1); }
.schedule-edit-btn:hover   { color: #2563eb; background: rgba(37,99,235,0.1); }
.schedule-run-btn:hover    { color: #4F008C; background: rgba(79,0,140,0.1); }
.schedule-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.schedule-run-btn.sch-run-success { color: #16a34a; background: rgba(22,163,74,0.1); }
.schedule-run-btn.sch-run-error   { color: var(--danger, #ef4444); background: rgba(239,68,68,0.1); }
@keyframes sch-spin { to { transform: rotate(360deg); } }
.sch-spin { display: inline-block; animation: sch-spin 0.8s linear infinite; }

/* Inactivity warning banner */
#inactivity-warning {
    position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
    background: #1a0030; border: 1px solid rgba(255,55,94,0.5);
    border-radius: 12px; padding: 0.65rem 1.1rem;
    display: flex; align-items: center; gap: 0.8rem;
    z-index: 9999; box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    font-size: 0.83rem; color: #fff; white-space: nowrap;
}
#inactivity-warning button {
    height: 28px; padding: 0 0.9rem;
    background: linear-gradient(135deg,#4F008C,#7c3aed); color: #fff;
    border: none; border-radius: 9999px;
    font-family: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
body.light-mode #inactivity-warning { background: #fff; color: #1A0D23; border-color: rgba(255,55,94,0.4); box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
@media (max-width: 600px) { #inactivity-warning { left: 1rem; right: 1rem; transform: none; white-space: normal; } }

/* Tabs */
.sch-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
}
.sch-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s, border-color 0.2s;
}
.sch-tab.active {
    color: var(--primary, #4F008C);
    border-bottom-color: var(--primary, #4F008C);
}
.sch-tab:hover:not(.active) { color: var(--text-primary); }

/* Add-new button in header */
.sch-add-new-btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Form panel (collapsible) */
.sch-form-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem 0.25rem;
    margin-bottom: 1rem;
}

/* Last-run meta row under each schedule item */
.schedule-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
.sch-last-run {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}
.sch-status-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sch-status-success { background: rgba(22,163,74,0.15);  color: #15803d; }
.sch-status-error   { background: rgba(239,68,68,0.15);  color: #dc2626; }

/* Log items */
.sch-log-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-color);
}
.sch-log-item:last-child { border-bottom: none; }
.sch-log-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.sch-log-icon.log-created { background: rgba(79,0,140,0.12);  color: #4F008C; }
.sch-log-icon.log-updated { background: rgba(59,130,246,0.12); color: #2563eb; }
.sch-log-icon.log-deleted { background: rgba(239,68,68,0.12);  color: #dc2626; }
.sch-log-icon.log-success { background: rgba(22,163,74,0.12);  color: #15803d; }
.sch-log-icon.log-error   { background: rgba(239,68,68,0.12);  color: #dc2626; }
.sch-log-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.sch-log-action {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.sch-log-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sch-log-details {
    font-size: 0.78rem;
    color: var(--text-secondary);
    opacity: 0.85;
    word-break: break-word;
}
.sch-log-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 0.1rem;
}

/* ─── Passkey Gate ──────────────────────────────────────────────────────────── */
/* ============================================================
   ENTRY PASSKEY LOGIN — purple-led light redesign
   Drop-in from login-dropin.css. All IDs/handlers unchanged.
   #fn-pk-btn (findings.html Enter button) is grouped with
   #entry-passkey-btn so the findings login matches index.
   ============================================================ */
#entry-passkey-overlay {
    position: fixed; inset: 0;
    width: 100%; height: 100vh; height: 100dvh;
    z-index: 2147483646; /* one below the toast ceiling (#toast-container owns 2147483647) */
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; touch-action: none; overscroll-behavior: none;
    background:
        radial-gradient(95% 95% at 80% -8%, rgba(79,0,140,0.13), transparent 55%),
        radial-gradient(80% 80% at -8% 108%, rgba(79,0,140,0.08), transparent 55%),
        radial-gradient(60% 60% at 50% 120%, rgba(255,55,94,0.05), transparent 60%),
        linear-gradient(170deg, #fdfcff 0%, #f8f5ff 60%, #fbf8ff 100%);
}
#entry-passkey-overlay::before {
    content: ""; position: absolute; inset: -25%;
    background:
        radial-gradient(40% 40% at 32% 38%, rgba(79,0,140,0.10), transparent 70%),
        radial-gradient(30% 30% at 70% 62%, rgba(255,55,94,0.05), transparent 70%);
    filter: blur(32px);
    animation: pkDrift 26s ease-in-out infinite alternate;
    pointer-events: none;
}
@keyframes pkDrift {
    0%   { transform: translate(-4%,-3%) scale(1); }
    100% { transform: translate(5%,4%) scale(1.1); }
}
#entry-passkey-card {
    position: relative; z-index: 1;
    width: clamp(320px, 90vw, 380px);
    padding: 3rem 2.5rem 2.5rem;
    text-align: center;
    border-radius: 1.75rem;
    background: rgba(255,255,255,0.74);
    border: 1px solid rgba(255,255,255,0.9);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    box-shadow:
        0 24px 70px -24px rgba(79,0,140,0.26),
        0 6px 20px -10px rgba(79,0,140,0.12),
        inset 0 1px 0 rgba(255,255,255,0.95);
    animation: pkCardRise 0.9s cubic-bezier(0.16,1,0.3,1) both;
}
#entry-passkey-card::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px;
    background: linear-gradient(135deg, rgba(79,0,140,0.55), rgba(109,0,192,0.35) 50%, rgba(255,55,94,0.25) 85%, transparent);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    pointer-events: none;
}
@keyframes pkCardRise {
    from { opacity: 0; transform: translateY(28px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
#entry-passkey-card > * { animation: pkFadeUp 0.7s cubic-bezier(0.16,1,0.3,1) both; }
#entry-passkey-logo       { animation-delay: 0.15s; }
#entry-passkey-card h2    { animation-delay: 0.22s; }
#entry-passkey-card > p   { animation-delay: 0.29s; }
#entry-passkey-card .pk-input-row { animation-delay: 0.36s; }
#entry-passkey-card .req-link     { animation-delay: 0.43s; }
@keyframes pkFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
#entry-passkey-logo {
    width: 72px; height: 72px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.5rem; font-size: 2rem; color: #fff;
    background: linear-gradient(135deg, var(--stc-purple) 0%, var(--stc-purple) 45%, var(--stc-coral) 130%);
    box-shadow: 0 10px 28px -6px rgba(79,0,140,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
    position: relative;
}
#entry-passkey-logo::after {
    content: ""; position: absolute; inset: -6px; border-radius: 50%;
    background: linear-gradient(135deg, rgba(79,0,140,0.35), transparent 60%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude; padding: 1px;
}
#entry-passkey-card h2 {
    color: #1e0a3c; font-size: 1.7rem; font-weight: 700;
    letter-spacing: 0; margin: 0 0 0.4rem;
}
#entry-passkey-card > p {
    color: #6b5a85; font-size: 0.92rem; margin: 0 0 1.75rem; letter-spacing: 0.01em;
}
.pk-input-row { display: flex; gap: 0.6rem; }
.pk-input-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.pk-input-row input[type="password"],
.pk-input-row input[type="text"] {
    flex: 1; width: 100%;
    padding: 0.8rem 2.5rem 0.8rem 1rem;
    border-radius: 0.8rem;
    border: 1.5px solid rgba(79,0,140,0.22);
    background: rgba(255,255,255,0.72);
    color: #1e0a3c; font-size: 0.95rem; font-family: var(--font-family);
    outline: none;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
    box-shadow: 0 1px 4px rgba(79,0,140,0.05);
    -webkit-appearance: none; appearance: none;
}
.pk-input-row input[type="password"]::placeholder,
.pk-input-row input[type="text"]::placeholder { color: rgba(79,0,140,0.38); }
.pk-input-row input[type="password"]:focus,
.pk-input-row input[type="text"]:focus {
    border-color: rgba(79,0,140,0.6);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79,0,140,0.10), 0 4px 18px -6px rgba(79,0,140,0.3);
}
.pk-eye-btn {
    position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
    background: none !important; border: none !important; box-shadow: none !important;
    color: rgba(79,0,140,0.42); cursor: pointer; padding: 0.35rem; font-size: 1rem;
    transition: color 0.2s;
}
.pk-eye-btn:hover { color: rgba(79,0,140,0.8); }
#entry-passkey-btn,
#fn-pk-btn {
    padding: 0.8rem 1.4rem; border-radius: 0.8rem;
    background: linear-gradient(135deg, var(--stc-purple) 0%, var(--stc-purple) 55%, var(--stc-coral) 150%);
    color: #fff; border: none; font-size: 0.92rem; font-weight: 700; font-family: var(--font-family);
    cursor: pointer; white-space: nowrap; position: relative; overflow: hidden;
    box-shadow: 0 8px 22px -6px rgba(79,0,140,0.5);
    transition: transform 0.18s, box-shadow 0.25s;
}
#entry-passkey-btn::after,
#fn-pk-btn::after {
    content: ""; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    transition: left 0.5s;
}
#entry-passkey-btn:hover,
#fn-pk-btn:hover  { transform: translateY(-2px); box-shadow: 0 12px 30px -6px rgba(79,0,140,0.62); }
#entry-passkey-btn:hover::after,
#fn-pk-btn:hover::after { left: 100%; }
#entry-passkey-btn:active,
#fn-pk-btn:active { transform: translateY(0); }
.pk-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }
#entry-passkey-error,
#upload-passkey-error {
    display: none; color: #e11d48; font-size: 0.82rem; margin-top: 0.8rem;
}
#entry-passkey-overlay.shake #entry-passkey-card { animation: pkShake 0.4s; }
@keyframes pkShake {
    0%,100% { transform: translateX(0); }
    20%,60% { transform: translateX(-7px); }
    40%,80% { transform: translateX(7px); }
}
.req-link {
    margin-top: 1.5rem; background: none; border: none; cursor: pointer;
    color: #8a6daa; font-size: 0.83rem; font-family: var(--font-family);
    text-decoration: underline; text-underline-offset: 3px; transition: color 0.2s;
}
.req-link:hover { color: var(--stc-purple); }
@media (max-width: 768px) {
    #entry-passkey-card { padding: 2.5rem 1.75rem 2rem; }
    .pk-input-row { flex-direction: column; gap: 0.7rem; }
    .pk-input-row input[type="password"],
    .pk-input-row input[type="text"] { padding: 0.85rem 2.5rem 0.85rem 1rem; font-size: 1rem; }
    #entry-passkey-btn,
    #fn-pk-btn { width: 100%; padding: 0.85rem; }
}

/* Upload passkey modal uses shared .pk-input-row but on light bg */
#upload-passkey-modal .pk-input-row input[type="password"] {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
#upload-passkey-modal .pk-input-row input[type="password"]:focus {
    border-color: var(--primary);
}
#upload-passkey-modal .pk-input-row button {
    background: var(--primary);
}
#upload-passkey-modal .pk-input-row button:hover {
    background: var(--primary-dark, #3b0070);
}
#upload-passkey-modal .pk-input-wrap {
    position: relative;
    flex: 1;
    display: flex;
}
#upload-passkey-modal .pk-input-wrap input[type="password"],
#upload-passkey-modal .pk-input-wrap input[type="text"] {
    flex: 1;
    width: 100%;
    padding-right: 2.4rem;
}
#upload-passkey-modal .pk-eye-btn {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 1.05rem;
    color: #9ca3af;
    transition: color 0.15s;
}
#upload-passkey-modal .pk-eye-btn:hover { color: var(--text-primary); }

.assurance-row { transition: background-color 0.2s ease; }
.assurance-row:hover { background-color: rgba(0, 0, 0, 0.03); }

/* Risk Rating Distribution legend table */
.risk-legend-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.8rem;
}
.risk-legend-table tr { transition: background 0.15s; }
.risk-legend-table tr:hover { background: rgba(0,0,0,0.04); }
.risk-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}
.risk-legend-label {
    padding: 3px 6px;
    color: var(--text-primary);
    font-weight: 500;
    width: 100%;
}
.risk-legend-count {
    padding: 3px 6px;
    text-align: right;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}
.risk-legend-pct {
    padding: 3px 4px 3px 0;
    text-align: right;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
}

/* ── Temp Passkey duration buttons ── */
.tmp-dur-btn {
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tmp-dur-btn:hover { border-color: var(--primary); color: var(--primary); }
.tmp-dur-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.tmp-pk-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--border-color);
    gap: 0.75rem;
}
.tmp-pk-list-row:last-child { border-bottom: none; }
.tmp-pk-token-badge {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--primary);
    background: var(--primary-light, rgba(79,0,140,0.08));
    padding: 2px 8px;
    border-radius: 6px;
}

/* v64 */
/* ── Request Access duration buttons (reuse same pill style) ── */
.req-dur-btn {
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.req-dur-btn:hover  { border-color: var(--primary); color: var(--primary); }
.req-dur-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 600px) {
    #request-access-modal {
        align-items: flex-start;
        justify-content: center;
        padding: 0.75rem 0.5rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(10, 0, 20, 0.82) !important;
        transition: none !important;
    }
    #request-access-modal .modal-content {
        transition: none !important;
    }
    #request-access-modal .modal-content {
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
        padding: 1.25rem !important;
        margin: 0 !important;
        flex-shrink: 0;
        align-self: flex-start;
    }
}

/* ── Access request row ── */
.access-req-row {
    padding: 0.7rem 0;
    border-bottom: 1px dashed var(--border-color);
}
.access-req-row:last-child { border-bottom: none; }
.access-req-accept-form {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

/* ── CR Analysis UI ─────────────────────────────────────────────────────────── */

/* Choice panel */
.fn-cm-choice-wrap {
    margin-top: 1.2rem;
    padding: 1.1rem 1.2rem;
    background: rgba(124,58,237,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}
.fn-cm-choice-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.85rem;
}
.fn-cm-choice-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.fn-cm-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 0.9rem;
    border-radius: 10px;
    border: 1.5px solid var(--glass-border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    text-align: center;
    font-family: inherit;
}
.fn-cm-choice-btn:hover { border-color: #7c3aed; background: rgba(124,58,237,0.1); }
.fn-cm-choice-btn i { font-size: 1.6rem; color: #a78bfa; }
.fn-cm-choice-btn strong { font-size: 0.88rem; color: var(--text-primary); }
.fn-cm-choice-btn span { font-size: 0.74rem; color: var(--text-secondary); line-height: 1.4; }
.fn-cm-choice-btn.analyze { border-color: rgba(124,58,237,0.4); background: rgba(124,58,237,0.07); }
.fn-cm-choice-btn.analyze:hover { border-color: #7c3aed; background: rgba(124,58,237,0.15); }

/* Analysis form wrapper */
.fn-cm-analysis-wrap { margin-top: 0.75rem; }

/* Pre-filled read-only section */
.fn-cm-prefill-box {
    background: rgba(124,58,237,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}
.fn-cm-prefill-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #a78bfa;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.fn-cm-prefill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem 1rem;
}
.fn-cm-prefill-field { display: flex; flex-direction: column; gap: 0.15rem; }
.fn-cm-prefill-key { font-size: 0.68rem; color: var(--text-secondary); }
.fn-cm-prefill-val { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.fn-cm-prefill-desc {
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--glass-border);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Analysis input grid */
.fn-cm-analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
    margin-bottom: 0.9rem;
}
.fn-cm-analysis-group { display: flex; flex-direction: column; gap: 0.3rem; }
.fn-cm-analysis-group.full { grid-column: 1 / -1; }
.fn-cm-analysis-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.fn-cm-analysis-input {
    padding: 0.45rem 0.7rem;
    border-radius: 7px;
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}
.fn-cm-analysis-input:focus { outline: none; border-color: #7c3aed; }
.fn-cm-analysis-input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.fn-cm-analysis-textarea {
    resize: vertical;
    min-height: 72px;
}

/* Results panel */
.fn-cm-results-panel {
    background: rgba(124,58,237,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}
.fn-cm-results-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #a78bfa;
    margin-bottom: 0.6rem;
    margin-top: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.fn-cm-results-section-title:first-child { margin-top: 0; }
.fn-cm-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}
.fn-cm-metric { display: flex; flex-direction: column; gap: 0.12rem; }
.fn-cm-metric-key { font-size: 0.67rem; color: var(--text-secondary); }
.fn-cm-metric-val { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }

/* Compliance status pill */
.fn-cm-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.fn-cm-status-pill.on-track      { background: rgba(0,196,140,0.15);  color: #00c48c; border: 1px solid rgba(0,196,140,0.3); }
.fn-cm-status-pill.achievable    { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.fn-cm-status-pill.exceed        { background: rgba(255,55,94,0.13);  color: #FF375E; border: 1px solid rgba(255,55,94,0.25); }
.fn-cm-status-pill.conflict      { background: rgba(255,55,94,0.13);  color: #FF375E; border: 1px solid rgba(255,55,94,0.25); }
.fn-cm-status-pill.cant-achieve  { background: rgba(255,55,94,0.13);  color: #FF375E; border: 1px solid rgba(255,55,94,0.25); }

/* Validation checks */
.fn-cm-checks-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; margin-bottom: 0.4rem; }
.fn-cm-checks-table td { padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--glass-border); }
.fn-cm-checks-table tr:last-child td { border-bottom: none; }
.fn-cm-check-pass { color: #00c48c; font-weight: 700; }
.fn-cm-check-fail { color: #FF375E; font-weight: 700; }
.fn-cm-check-na   { color: var(--text-secondary); }

/* Alert banners */
.fn-cm-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 7px;
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
    line-height: 1.45;
}
.fn-cm-alert.warning { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.25); }
.fn-cm-alert.danger  { background: rgba(255,55,94,0.1);   color: #FF375E; border: 1px solid rgba(255,55,94,0.2); }

/* Scorecard bars */
.fn-cm-scorecard { display: flex; flex-direction: column; gap: 0.45rem; }
.fn-cm-score-row { display: flex; align-items: center; gap: 0.6rem; }
.fn-cm-score-label { font-size: 0.74rem; color: var(--text-secondary); width: 110px; flex-shrink: 0; }
.fn-cm-score-bar-wrap {
    flex: 1;
    height: 7px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}
.fn-cm-score-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
    transition: width 0.35s ease;
}
.fn-cm-score-pct { font-size: 0.72rem; font-weight: 700; color: var(--text-primary); width: 34px; text-align: right; flex-shrink: 0; }
.fn-cm-final-score {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--glass-border);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Analysis footer buttons */
.fn-cm-analysis-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.85rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 0.5rem;
    gap: 0.6rem;
}
.fn-cm-analysis-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.3rem;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.18s;
}
.fn-cm-analysis-submit-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.fn-cm-analysis-submit-btn:not(:disabled):hover { opacity: 0.88; }

/* Cancel warning overlay */
.fn-cm-cancel-warning {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}
.fn-cm-cancel-warning-box {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1.75rem 2rem;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
.fn-cm-cancel-warning-box i { font-size: 2.2rem; color: #f59e0b; display: block; margin-bottom: 0.65rem; }
.fn-cm-cancel-warning-box h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin: 0 0 0.45rem; }
.fn-cm-cancel-warning-box p { font-size: 0.82rem; color: var(--text-secondary); margin: 0 0 1.2rem; line-height: 1.5; }
.fn-cm-cancel-warning-btns { display: flex; gap: 0.6rem; justify-content: center; }

/* Analysis success panel */
.fn-cm-analysis-success {
    text-align: center;
    padding: 2rem 1rem;
}
.fn-cm-analysis-success i.success-icon { font-size: 3rem; color: #00c48c; display: block; margin-bottom: 0.75rem; }
.fn-cm-analysis-success h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin: 0 0 0.4rem; }
.fn-cm-analysis-success p { font-size: 0.84rem; color: var(--text-secondary); margin: 0 0 1.2rem; }
.fn-cm-analysis-success-btns { display: flex; gap: 0.65rem; justify-content: center; flex-wrap: wrap; }

/* Admin mode write-control gating */
body:not(.admin-mode) .admin-write { display: none !important; }
body.admin-mode .admin-read-msg { display: none !important; }

/* View analysis icon in log table */
.fn-cm-view-analysis-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(167,139,250,0.4);
    background: rgba(124,58,237,0.08);
    color: #a78bfa;
    cursor: pointer;
    font-size: 0.88rem;
    transition: background 0.15s, border-color 0.15s;
    margin-left: 2px;
    vertical-align: middle;
}
.fn-cm-view-analysis-btn:hover { background: rgba(124,58,237,0.2); border-color: #7c3aed; color: #fff; }

/* ============================================================================
 * UI KIT — shared primitives (toast, inline message, skeleton, empty state)
 * Paired with ui-kit.js. Uses existing theme vars with safe fallbacks.
 * ========================================================================== */

/* ── 1. Toast ────────────────────────────────────────────────────────────── */
.uik-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2147483647;            /* true ceiling — owns it exclusively */
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(92vw, 380px);
    pointer-events: none;          /* children re-enable for the × button */
}
.uik-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    background: var(--bg-card, rgba(47, 0, 91, 0.4));
    backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.12));
    border-left: 4px solid var(--uik-accent, #4F008C);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    color: var(--text-primary, #fff);
    font-family: var(--font-family, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.86rem;
    line-height: 1.35;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.uik-toast-in  { opacity: 1; transform: translateX(0); }
.uik-toast-out { opacity: 0; transform: translateX(120%); }
.uik-toast-icon { font-size: 1.2rem; flex-shrink: 0; color: var(--uik-accent, #4F008C); margin-top: 1px; }
.uik-toast-msg  { flex: 1; word-break: break-word; white-space: pre-wrap; }
.uik-toast-close {
    flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: var(--text-secondary, #D4B3FF); font-size: 0.95rem; padding: 2px;
    line-height: 1; border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.uik-toast-close:hover { color: var(--text-primary, #fff); background: rgba(255,255,255,0.1); }
.uik-toast-success { --uik-accent: var(--success, #00D2D3); }
.uik-toast-warning { --uik-accent: var(--warning, #FFB800); }
.uik-toast-error   { --uik-accent: var(--danger,  #FF375E); }
.uik-toast-info    { --uik-accent: var(--primary, #4F008C); }
body.light-mode .uik-toast { background: #ffffff; border-color: rgba(79,0,140,0.14); box-shadow: 0 10px 30px rgba(0,0,0,0.14); }

/* ── 2. Inline message ───────────────────────────────────────────────────── */
.uik-inline {
    display: flex; align-items: flex-start; gap: 0.55rem;
    padding: 0.6rem 0.75rem; border-radius: 10px;
    font-size: 0.82rem; line-height: 1.4;
    border: 1px solid var(--uik-accent, #FF375E);
    background: color-mix(in srgb, var(--uik-accent, #FF375E) 12%, transparent);
    color: var(--text-primary, #fff);
}
.uik-inline-icon { color: var(--uik-accent, #FF375E); font-size: 1.05rem; flex-shrink: 0; margin-top: 1px; }
.uik-inline-body { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.uik-inline-msg  { flex: 1 1 auto; }
.uik-inline-action {
    flex-shrink: 0; background: var(--uik-accent, #FF375E); color: #fff; border: none;
    padding: 0.3rem 0.7rem; border-radius: 7px; font-size: 0.78rem; font-weight: 700;
    cursor: pointer; font-family: var(--font-family, sans-serif); transition: opacity 0.15s;
}
.uik-inline-action:hover { opacity: 0.88; }
.uik-inline-close {
    flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: var(--text-secondary, #D4B3FF); font-size: 0.85rem; padding: 2px; line-height: 1;
}
.uik-inline-success { --uik-accent: var(--success, #00D2D3); }
.uik-inline-warning { --uik-accent: var(--warning, #FFB800); }
.uik-inline-error   { --uik-accent: var(--danger,  #FF375E); }
.uik-inline-info    { --uik-accent: var(--primary, #4F008C); }

/* ── 3. Skeleton (CSS-only shimmer) ──────────────────────────────────────── */
.uik-skel { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; }
.uik-skel-row  { display: flex; align-items: center; gap: 0.6rem; }
.uik-skel-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.9rem;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.12)); border-radius: 12px; }
.uik-skel-bar {
    height: 14px; border-radius: 6px; flex: 1;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.06) 25%,
        rgba(255,255,255,0.16) 37%,
        rgba(255,255,255,0.06) 63%);
    background-size: 400% 100%;
    animation: uik-shimmer 1.4s ease infinite;
}
body.light-mode .uik-skel-bar {
    background: linear-gradient(90deg,
        rgba(79,0,140,0.06) 25%,
        rgba(79,0,140,0.14) 37%,
        rgba(79,0,140,0.06) 63%);
    background-size: 400% 100%;
}
@keyframes uik-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .uik-skel-bar { animation: none; } }

/* ── 4. Empty state ──────────────────────────────────────────────────────── */
.uik-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 2.5rem 1.5rem; gap: 0.5rem;
}
.uik-empty-icon  { font-size: 2.6rem; color: var(--text-secondary, #D4B3FF); opacity: 0.4; }
.uik-empty-title { font-size: 0.98rem; font-weight: 700; color: var(--text-primary, #fff); }
.uik-empty-msg   { font-size: 0.84rem; color: var(--text-secondary, #D4B3FF); max-width: 340px; }
.uik-empty-hint  { font-size: 0.78rem; color: var(--text-secondary, #D4B3FF); opacity: 0.75; font-style: italic; margin-top: 0.25rem; }
.uik-empty-cta {
    margin-top: 0.5rem; background: var(--primary, #4F008C); color: #fff; border: none;
    padding: 0.55rem 1.1rem; border-radius: 9px; font-size: 0.85rem; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
    font-family: var(--font-family, sans-serif); transition: opacity 0.15s, transform 0.1s;
}
.uik-empty-cta:hover  { opacity: 0.9; }
.uik-empty-cta:active { transform: translateY(1px); }

@media (max-width: 640px) {
    .uik-toast-container { left: 0.75rem; right: 0.75rem; top: 0.75rem; max-width: none; }
    .uik-toast { transform: translateY(-120%); }
    .uik-toast-in  { transform: translateY(0); }
    .uik-toast-out { transform: translateY(-120%); }
}

/* ── 5. Confirm dialog (destructive/consequential actions) ───────────────── */
.uik-confirm-overlay {
    position: fixed; inset: 0; z-index: 2147483646;   /* below the toast ceiling */
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.18s ease;
}
.uik-confirm-overlay.uik-confirm-in { opacity: 1; }
.uik-confirm-box {
    background: var(--bg-card, #fff);
    backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.12));
    border-radius: 16px; padding: 1.5rem; max-width: 420px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    transform: translateY(8px); transition: transform 0.18s ease;
    font-family: var(--font-family, 'Plus Jakarta Sans', sans-serif);
}
.uik-confirm-overlay.uik-confirm-in .uik-confirm-box { transform: translateY(0); }
body.light-mode .uik-confirm-box { background: #fff; border-color: rgba(79,0,140,0.14); }
.uik-confirm-title {
    font-size: 1.02rem; font-weight: 800; display: flex; align-items: center; gap: 0.5rem;
    color: var(--text-primary, #fff); margin-bottom: 0.5rem;
}
.uik-confirm-title i { color: var(--warning, #FFB800); font-size: 1.15rem; }
.uik-confirm-box-danger .uik-confirm-title i { color: var(--danger, #FF375E); }
.uik-confirm-msg { font-size: 0.88rem; color: var(--text-secondary, #D4B3FF); line-height: 1.45; margin-bottom: 1.25rem; }
.uik-confirm-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.uik-confirm-cancel, .uik-confirm-ok {
    padding: 0.55rem 1.1rem; border-radius: 9px; font-size: 0.85rem; font-weight: 700;
    cursor: pointer; font-family: var(--font-family, sans-serif);
}
.uik-confirm-cancel { background: transparent; color: var(--text-primary, #fff); border: 1px solid var(--border-color, rgba(255,255,255,0.18)); }
.uik-confirm-cancel:hover:not(:disabled) { background: rgba(127,127,127,0.14); }
.uik-confirm-ok { background: var(--primary, #4F008C); color: #fff; border: 1px solid transparent; }
.uik-confirm-ok.uik-confirm-danger { background: var(--danger, #FF375E); }
.uik-confirm-ok:hover:not(:disabled) { opacity: 0.9; }
.uik-confirm-ok:disabled, .uik-confirm-cancel:disabled { opacity: 0.6; cursor: default; }
.uik-confirm-cancel:focus-visible, .uik-confirm-ok:focus-visible { outline: 2px solid var(--primary, #4F008C); outline-offset: 2px; }
.uik-spin { display: inline-block; animation: uik-spin-kf 0.8s linear infinite; }
@keyframes uik-spin-kf { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .uik-spin { animation: none; } .uik-confirm-overlay, .uik-confirm-box { transition: none; } }

/* Part D — Annual Plan Landscape active-filter chips */
.apl-filter-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 16px; font-size: 0.8rem; font-weight: 600;
    background: var(--primary-light, rgba(79,0,140,0.12)); color: var(--primary, #4F008C);
    border: 1px solid var(--primary, #4F008C);
}
.apl-filter-chip-x { cursor: pointer; font-size: 0.9rem; opacity: 0.8; }
.apl-filter-chip-x:hover { opacity: 1; }
.apl-filter-clear {
    background: none; border: none; cursor: pointer; font-size: 0.8rem; font-weight: 700;
    color: var(--danger, #FF375E); padding: 4px 8px; font-family: var(--font-family, sans-serif);
}
.apl-filter-clear:hover { text-decoration: underline; }


/* ── Keyboard focus ring (Phase 2 Step 3a) ─────────────────────────────────
   Visible focus ring for KEYBOARD users only. :focus-visible never matches a
   mouse click, so mouse users see no change (low regression risk). Drawn with
   box-shadow (not outline) so it COEXISTS with the existing element-scoped
   `outline:none` rules without removing them (those set `outline`, a different
   property). The transparent outline is a Windows High-Contrast / forced-colors
   fallback so the ring survives there too. */
:focus-visible {
    outline: 2px solid transparent;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.55);
}

/* ── Shared data-table treatment (Phase 2 Step 4-1) ────────────────────────
   ONE opt-in class for the uniform table polish: zebra + a default hover + a
   default sticky-header position, all from a single source. Tables opt in with
   class="uk-data-table" (and "uk-sortable" for click-to-sort, Step 2c).
   ⚠️ MUST stay opt-in — never a global tbody/table rule — because two tables
   (annual-requirements-table, regulationTable) are export-visible and would be
   swept into the frozen export silently.
   Per-table header styling, hover colour and scroll container stay table-
   specific; this class supplies the shared striping + sensible defaults that a
   table's own (higher-specificity) rules override where they already exist.
   Migrated from the Step-4a named-selector zebra — the 3 done tables now opt in
   via the class, so their appearance is unchanged. */
.uk-data-table tbody tr:nth-child(even) {
    background-color: rgba(124, 58, 237, 0.045);
}
.uk-data-table tbody tr:hover {
    background-color: rgba(79, 0, 140, 0.08);
}
.uk-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    /* Opaque header so a pinned sticky header never shows rows through, and so
       all data tables share the same header look as rc/fn/fn-cm. The 3 done
       tables set the same #4F008C via their own higher-specificity rules, so
       this is non-visual for them and uniform for newly-adopting tables. */
    background: #4F008C;
    color: #fff;
}
/* RC keeps its scoped hover (its only other hover was the low-specificity global) */
#rc-compliance-table tbody tr:hover {
    background-color: rgba(79, 0, 140, 0.10);
}

/* ── Sticky table headers (Phase 2 Step 4b) ────────────────────────────────
   The Findings table (.fn-table) and CR list (.fn-cm-log-table) already have
   sticky headers within their own overflow:auto scroll boxes. The RC table
   only had overflow-x on its container (an unconstrained sticky containing
   block → sticky would no-op), so give THAT container (scoped by id, not the
   global .table-container) a max-height scroll box and pin its header.
   Header cells already carry a solid #4F008C background (set inline by
   rc_table.js); z-index keeps them above the zebra-striped rows. */
#rc-table-scroll {
    max-height: 65vh;
    overflow-y: auto;
}
#rc-compliance-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}
