/* NAVCDP Dashboard - Modern UI/UX Styles */

:root {
    /* NAVCDP Brand Colors */
    --navcdp-primary: #56ab2f; /* Green */
    --navcdp-primary-dark: #2d5016; /* Dark Green */
    --navcdp-primary-light: #a8e6cf; /* Light Green */
    --navcdp-secondary: #8b6914; /* Brown */
    --navcdp-accent: #ffc107; /* Yellow/Gold */
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-300: #ced4da;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --gray-800: #212529;
    --gray-900: #0d1117;
    
    /* Spacing */
    /* Sidebar dark theme */
    --sidebar-bg: #1a2b20;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.08);
    --sidebar-bg-active: rgba(255, 255, 255, 0.12);
    --sidebar-text: rgba(255, 255, 255, 0.72);
    --sidebar-text-active: #ffffff;
    --sidebar-width: 248px;
    --topbar-height: 64px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f4f5f7;
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   APP SHELL
   ============================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: #f4f5f7;
}

.app-main {
    flex: 1 1 0;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   TOP BAR
   ============================================ */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 1px 0 rgba(16, 24, 40, 0.04);
}

.app-topbar-start {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.app-topbar-toggle {
    width: 38px;
    height: 38px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--white);
    color: var(--gray-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.app-topbar-toggle:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.app-topbar-titles {
    min-width: 0;
}

.app-topbar-eyebrow {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gray-500);
    line-height: 1.2;
}

.app-topbar-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar-end {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(86, 171, 47, 0.1);
    color: var(--navcdp-primary-dark);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.3rem 0.45rem 0.3rem 0.35rem;
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    background: var(--white);
    color: inherit;
    transition: var(--transition-fast);
}

.app-user-trigger:hover,
.app-user-trigger:focus {
    background: var(--gray-50);
    border-color: var(--gray-300);
    box-shadow: none;
}

.app-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navcdp-primary), var(--navcdp-primary-dark));
    color: var(--white);
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-user-avatar--lg {
    width: 42px;
    height: 42px;
    font-size: 0.9rem;
}

.app-user-meta {
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}

.app-user-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--gray-900);
}

.app-user-role {
    font-size: 0.72rem;
    color: var(--gray-500);
}

.app-user-chevron {
    font-size: 0.65rem;
    color: var(--gray-400);
    margin-right: 0.15rem;
}

.app-user-dropdown {
    width: 260px;
    padding: 0.35rem;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.app-user-dropdown-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
}

.app-user-dropdown-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-900);
}

.app-user-dropdown-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.app-user-dropdown .dropdown-item {
    border-radius: 8px;
    font-size: 0.875rem;
    padding: 0.55rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.app-user-dropdown .dropdown-item i {
    width: 16px;
    text-align: center;
    opacity: 0.75;
}

/* ============================================
   FOOTER
   ============================================ */
.app-footer {
    margin-top: auto;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
    padding: 0.9rem 1.5rem;
}

.app-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    font-size: 0.78rem;
    color: var(--gray-500);
}

.app-footer-copy strong {
    color: var(--gray-700);
    font-weight: 600;
}

.app-footer-sep {
    margin: 0 0.35rem;
    opacity: 0.5;
}

.app-footer-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-footer-meta a {
    color: var(--navcdp-primary-dark);
    text-decoration: none;
    font-weight: 500;
}

.app-footer-meta a:hover {
    color: var(--navcdp-primary);
    text-decoration: underline;
}

/* Legacy navbar hidden */
.navbar { display: none !important; }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: none;
    overflow: hidden;
    z-index: 1040;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.1rem 1rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.sidebar-brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(86, 171, 47, 0.18);
    color: #a8e6cf;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.sidebar-brand-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-brand-sub {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.sidebar .nav { padding: 0.85rem 0.65rem; }

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.7rem 0.9rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-left: none;
    transition: var(--transition-fast);
    margin: 0.1rem 0;
    border-radius: 8px;
}

.sidebar .nav-link i {
    width: 20px;
    font-size: 0.95rem;
    margin-right: 10px;
    text-align: center;
    opacity: 0.85;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
    transform: none;
}

.sidebar .nav-link.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.sidebar .nav-link.active i { opacity: 1; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    padding: 1.35rem 1.5rem 1.5rem;
    min-height: 0;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1019;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Sidebar Header for Mobile */
.sidebar-header {
    display: none;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    align-items: center;
    justify-content: space-between;
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h5 {
    margin: 0;
    font-weight: 600;
    color: #fff;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
    }
    
    .sidebar {
        transform: translateX(-100%);
        z-index: 1020;
        width: 280px;
        max-width: 85vw;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-header {
        display: flex;
    }
    
    .app-main {
        margin-left: 0;
    }

    .main-content {
        padding: 1rem;
    }

    .app-topbar {
        padding: 0 1rem;
    }

    .app-topbar-title {
        font-size: 1rem;
    }

    .scope-badge {
        display: none;
    }
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.5rem;
}

/* ============================================
   STATISTICS CARDS
   ============================================ */
.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem 1.25rem;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, rgba(86, 171, 47, 0.1) 0%, transparent 100%);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card.success,
.stat-card.info,
.stat-card.warning,
.stat-card.danger {
    border-left: none;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.stat-card .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-card .stat-icon {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 1.5rem;
    opacity: 0.12;
    color: var(--navcdp-primary);
}

.stat-card .stat-value .skeleton {
    margin-bottom: 0;
}

.stat-card.is-loading {
    pointer-events: none;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: var(--transition-fast);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--navcdp-primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--navcdp-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline-primary {
    border: 2px solid var(--navcdp-primary);
    color: var(--navcdp-primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--navcdp-primary);
    color: var(--white);
}

/* ============================================
   SKELETON LOADERS
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--border-radius-sm);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 4px;
}

.skeleton-text:last-child {
    margin-bottom: 0;
}

.skeleton-title {
    height: 1.75rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.skeleton-table {
    width: 100%;
}

.skeleton-table-row {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.skeleton-table-cell {
    flex: 1;
    height: 1rem;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-badge {
    width: 80px;
    height: 24px;
    border-radius: 12px;
}

/* Table Skeleton */
.table-skeleton {
    display: table;
    width: 100%;
}

.table-skeleton .skeleton-row {
    display: table-row;
}

.table-skeleton .skeleton-cell {
    display: table-cell;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.skeleton-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    padding: 1rem;
    overflow: hidden;
}

.table-responsive.skeleton-container,
.table-loading-host {
    position: relative;
    min-height: 220px;
}

#countiesTable,
#countySaccosTable {
    min-width: 1280px;
}

.breadcrumb {
    font-size: 0.8125rem;
}

.breadcrumb-item a {
    color: var(--navcdp-primary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

/* ============================================
   FORMS
   ============================================ */
.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.form-control,
.form-select {
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    padding: 0.625rem 0.875rem;
    transition: var(--transition-fast);
    font-size: 0.9375rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--navcdp-primary);
    box-shadow: 0 0 0 3px rgba(86, 171, 47, 0.1);
    outline: none;
}

/* ============================================
   BREADCRUMBS
   ============================================ */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-item a {
    color: var(--navcdp-primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.breadcrumb-item a:hover {
    color: var(--navcdp-primary-dark);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--gray-600);
}

/* ============================================
   PAGE HEADERS
   ============================================ */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.page-header h2 i { color: var(--gray-500); font-size: 1.1rem; }

.page-header p { display: none; }

/* ============================================
   TABLES
   ============================================ */
.table {
    background: var(--white);
    margin-bottom: 0;
}

.table thead {
    background: transparent;
}

.table thead th {
    font-weight: 600;
    color: var(--gray-500);
    text-transform: none;
    font-size: 0.78rem;
    letter-spacing: 0;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--gray-800);
}

.table tbody tr:hover {
    background: #fafbfc;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

.table-link {
    font-weight: 600;
    color: var(--navcdp-primary-dark);
}

a.county-link {
    color: var(--navcdp-primary-dark);
    font-weight: 600;
    text-decoration: none;
}

a.county-link:hover {
    color: var(--navcdp-primary);
    text-decoration: none;
}

.dashboard-table-scroll {
    /* ~10 table rows visible before inner scroll */
    max-height: min(580px, calc(100vh - 220px));
    overflow: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.dashboard-table-scroll .table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    overflow: visible;
}

.dashboard-table-scroll table.dataTable thead > tr > th {
    position: sticky !important;
    top: 0;
    z-index: 3;
    background: var(--gray-50, #f8f9fa);
    box-shadow: 0 1px 0 var(--gray-200);
}

.dashboard-table-scroll thead th.col-county-sticky {
    z-index: 5;
    background: var(--gray-50, #f8f9fa);
    box-shadow: 1px 0 0 var(--gray-200), 0 1px 0 var(--gray-200);
}

#countiesTable th.col-county-sticky,
#countiesTable td.col-county-sticky,
#countySaccosTable th.col-county-sticky,
#countySaccosTable td.col-county-sticky {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--white);
    min-width: 140px;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.05);
}

#countiesTable thead th.col-county-sticky,
#countySaccosTable thead th.col-county-sticky {
    z-index: 5;
    background: var(--gray-50, #f8f9fa);
}

#countiesTable tbody tr:hover td.col-county-sticky,
#countySaccosTable tbody tr:hover td.col-county-sticky {
    background: var(--gray-50, #f8f9fa);
}

.btn-table-action {
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
}

.btn-table-action:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-200);
}

.badge {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--navcdp-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   UTILITIES
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   FILTER PANEL & DATA CARDS
   ============================================ */
.filter-panel {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.15rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem 1.25rem;
}

.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1rem;
    flex: 1;
}

.filter-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    margin-bottom: 0.3rem;
}

.filter-field--wide { min-width: 200px; flex: 1; }

.filter-panel--compact {
    padding: 0.8rem 1rem;
    gap: 0.65rem 0.85rem;
    flex-wrap: nowrap;
    align-items: flex-end;
}

.filter-panel--compact .filter-grid {
    flex-wrap: nowrap;
    gap: 0.6rem 0.75rem;
    align-items: flex-end;
    min-width: 0;
    flex: 1;
}

.filter-panel--compact .filter-field label {
    font-size: 0.62rem;
    margin-bottom: 0.22rem;
    letter-spacing: 0.03em;
}

.filter-panel--compact .filter-field .form-control,
.filter-panel--compact .filter-field .form-select {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
    min-height: 1.85rem;
    line-height: 1.4;
}

.filter-panel--compact .filter-field--search {
    flex: 0 1 160px;
    min-width: 110px;
    max-width: 180px;
}

.filter-panel--compact .filter-field--period {
    flex: 0 0 128px;
}

.filter-panel--compact .filter-field--select {
    flex: 0 0 auto;
    min-width: 100px;
    max-width: 130px;
}

.filter-panel--compact .filter-field--county {
    flex: 0 0 115px;
}

.filter-panel--compact .btn-filter-clear {
    font-size: 0.78rem;
    padding: 0.3rem 0.65rem;
    flex-shrink: 0;
    min-height: 1.85rem;
}

.navcdp-dt-footer .dataTables_length label,
.navcdp-dt-footer .dataTables_info {
    margin-bottom: 0;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.navcdp-dt-footer .dataTables_length select {
    font-size: 0.8rem;
    padding: 0.2rem 1.5rem 0.2rem 0.45rem;
    min-height: 1.75rem;
    margin: 0 0.35rem;
}

/* Pagination/footer sits below the scroll area (moved by navcdp-datatables.js) */
.data-card > .navcdp-dt-footer {
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}

@media (max-width: 991px) {
    .filter-panel--compact {
        flex-wrap: wrap;
    }
    .filter-panel--compact .filter-grid {
        flex-wrap: wrap;
    }
}

.btn-filter-clear {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    white-space: nowrap;
}

.btn-filter-clear:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

.data-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.data-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--gray-200);
}

.data-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.data-card-count {
    font-size: 0.78rem;
    color: var(--gray-500);
    font-weight: 500;
}

.data-card-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-export-csv {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--gray-300);
    background: #fff;
    color: var(--gray-700);
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-export-csv:hover {
    background: #f0f7eb;
    border-color: var(--navcdp-primary);
    color: var(--navcdp-primary-dark);
}

.data-card-hint {
    margin-top: 0.2rem;
    color: var(--gray-500);
    font-size: 0.75rem;
}

.county-detail-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
}

.county-detail-heading__main {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.county-detail-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid var(--gray-200);
    border-radius: 50%;
    color: var(--gray-700);
    background: var(--gray-50);
    text-decoration: none;
}

.county-detail-back:hover {
    color: var(--navcdp-primary-dark);
    border-color: var(--navcdp-primary);
    background: rgba(76, 175, 80, 0.08);
}

.county-detail-eyebrow {
    margin-bottom: 0.15rem;
    color: var(--gray-500);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.county-detail-heading h2 {
    margin: 0;
    color: var(--gray-900);
    font-size: 1.2rem;
    font-weight: 700;
}

.county-detail-heading p {
    margin: 0.2rem 0 0;
    color: var(--gray-500);
    font-size: 0.78rem;
}

.county-detail-period {
    flex: 0 0 auto;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-radius: 999px;
    background: rgba(76, 175, 80, 0.08);
    color: var(--navcdp-primary-dark);
    font-size: 0.76rem;
    font-weight: 700;
}

.entity-name-link {
    color: var(--navcdp-primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.entity-name-link:hover {
    color: var(--navcdp-primary);
    text-decoration: none;
}

/* Dashboard table cards use .data-card (not .card) — keep form/profile .card-body padding intact */

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.75rem;
    }
    
    .page-header h2 {
        font-size: 1.5rem;
    }
    
    .navbar-brand-text .brand-acronym {
        font-size: 1rem;
    }
    
    .navbar-brand-text .brand-full {
        font-size: 0.6rem;
    }
    
    .navbar-logo {
        height: 35px;
    }
    
    .navbar {
        padding: 0 1rem;
    }
    
    .navbar .dropdown-toggle {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }

    .county-detail-heading {
        align-items: flex-start;
    }

    .county-detail-heading p {
        display: none;
    }

    .county-detail-period {
        font-size: 0.7rem;
    }
    
    .sidebar .nav-link {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .sidebar .nav-link i {
        width: 20px;
        font-size: 1rem;
        margin-right: 10px;
    }
}

/* National reports page (dashboard-style) */
.reports-page {
    max-width: 100%;
}

.reports-report-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem;
    padding: 0 1rem 1rem;
}

.reports-control-card {
    padding: .75rem 1rem;
}

.reports-control-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .65rem .75rem;
}

.reports-control-bar .filter-field label {
    font-size: .72rem;
}

.reports-control-bar .filter-field--report {
    flex: 1 1 220px;
    min-width: 200px;
    max-width: 320px;
}

.reports-control-bar .filter-field--period-month {
    flex: 0 0 140px;
    min-width: 130px;
}

.reports-control-bar .filter-field--period-year {
    flex: 0 0 92px;
    min-width: 84px;
}

.reports-control-bar .filter-field--county {
    flex: 0 0 160px;
    min-width: 140px;
}

.reports-control-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
    padding-bottom: 1px;
}

.reports-page .reports-state {
    padding: 2rem 1rem;
}

.reports-report-type-field {
    min-width: min(100%, 320px);
    flex: 1 1 280px;
}

.reports-report-desc {
    font-size: .78rem;
    color: var(--gray-500);
    margin-top: .15rem;
}

.reports-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #66756d;
    background: #fff;
    border: 1px dashed #cfd9d3;
    border-radius: 12px;
}

.reports-state--error {
    color: #a63434;
    background: #fff7f7;
    border-color: #efc4c4;
}

.reports-page-header {
    padding-bottom: .25rem;
}

.reports-page-title {
    margin: 0 0 .35rem;
    font-size: 1.5rem;
    font-weight: 750;
    color: var(--gray-900);
}

.reports-page-subtitle {
    color: var(--gray-500);
    font-size: .9rem;
    max-width: 42rem;
}

.reports-scope-lock {
    height: 31px;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: 0 .7rem;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    background: var(--gray-50);
    color: var(--gray-600);
    font-size: .82rem;
}

.filter-panel--compact .filter-field--report {
    flex: 1 1 280px;
    min-width: 220px;
}

.filter-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.data-card-meta {
    color: var(--gray-500);
    font-size: .8rem;
    margin-top: .2rem;
}

.data-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
}

#reportKpiRow .stat-value {
    font-size: 1.2rem;
}

.analytics-chart-card .data-card-header { padding-bottom: 0; }
.analytics-chart-wrap { position: relative; height: 280px; padding: 0 1rem 1rem; }
.analytics-chart-wrap--short { height: 240px; }
.analytics-tile {
    padding: .85rem .9rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    height: 100%;
}
.analytics-tile span {
    display: block;
    color: var(--gray-500);
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.analytics-tile strong {
    display: block;
    margin-top: .35rem;
    font-size: 1.25rem;
    color: var(--gray-900);
}
.analytics-tile--warn strong { color: #9a5b00; }
.analytics-page .stat-delta {
    margin-top: .35rem;
    font-size: .72rem;
    font-weight: 600;
}
.reports-hub-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--gray-500);
    background: #fff;
    border: 1px dashed #cfd9d3;
    border-radius: 12px;
}
.reports-hub-state--error {
    color: #a63434;
    background: #fff7f7;
    border-color: #efc4c4;
}

@media (max-width: 768px) {
    .filter-panel--compact .filter-field--report {
        flex: 1 1 100%;
    }
    .reports-control-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }
    .reports-control-bar .filter-field--report,
    .reports-control-bar .filter-field--period-month,
    .reports-control-bar .filter-field--period-year,
    .reports-control-bar .filter-field--county {
        flex: 1 1 100%;
        max-width: none;
    }
    .data-card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .75rem;
    }
}

/* Legacy reports-hub (unused) */
.reports-hub { max-width: 100%; }
.reports-pack-grid { display: none; }

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}
