@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

@font-face {
    font-family: 'STCForward';
    src: url('fonts/STCForward-Regular.ttf') format('truetype');
    font-weight: 400;
    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);
}

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;
}
.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: 1;
}

.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: 1.5rem;
    display: flex;
    justify-content: center;
}

/* 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;
    }
    #toggle-lang {
        display: none !important;
    }
    .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;
    }
    .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;
    }
    #toggle-lang {
        display: none !important;
    }
    .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;
    }
    .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;
    }
    #rc-channels-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    #rc-status-chart-wrapper {
        width: 280px;
        height: 280px;
    }
    #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;
}

/* RTL Support for Arabic Regulation Names */
[dir="rtl"] .reg-pill-name {
    text-align: right;
    padding-right: 0;
    padding-left: 10px;
}

.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, 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;
    }
    body:not(.executive-mode) .summary-widgets {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    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-dot-orbit {
    from { transform: rotate(0deg)   translateX(var(--orbit-r, 30px)); }
    to   { transform: rotate(360deg) translateX(var(--orbit-r, 30px)); }
}
@keyframes export-icon-spin {
    to { transform: rotate(360deg); }
}
@keyframes export-btn-glow {
    0%, 100% { box-shadow: 0 0 6px  2px rgba(79,0,140,.30), inset 0 0 0 1px rgba(79,0,140,.3); }
    50%       { box-shadow: 0 0 22px 8px rgba(79,0,140,.60), inset 0 0 0 1px rgba(124,58,237,.6); }
}

/* Host wrapper keeps buttons in flow while dots orbit absolutely */
.export-aura-host {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Each orbiting dot */
.export-aura-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    top: calc(50% - 3.5px);
    left: calc(50% - 3.5px);
    pointer-events: none;
    z-index: 10;
}
.export-aura-dot:nth-child(1) {
    background: #4F008C;
    box-shadow: 0 0 8px 3px rgba(79,0,140,.85);
    animation: export-dot-orbit 1.5s linear infinite;
}
.export-aura-dot:nth-child(2) {
    background: #7C3AED;
    box-shadow: 0 0 8px 3px rgba(124,58,237,.85);
    animation: export-dot-orbit 1.5s linear infinite calc(-1.5s / 3);
}
.export-aura-dot:nth-child(3) {
    background: #C4B5FD;
    box-shadow: 0 0 8px 3px rgba(196,181,253,.9);
    animation: export-dot-orbit 1.5s linear infinite calc(-1.5s * 2 / 3);
}

/* Button state while exporting */
.btn.btn-exporting {
    pointer-events: none;
    animation: export-btn-glow 1.5s ease-in-out infinite;
    position: relative;
    z-index: 1;
}
.btn.btn-exporting i {
    display: inline-block;
    animation: export-icon-spin 0.9s linear infinite;
}
