/* ============================================================
   assets/css/style.css  –  CertVault Corporate Design System
   Theme: Modern Corporate  – blue, grey, white, clean & professional
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Variables ---- */
:root {
    /* Corporate blues */
    --primary: #1a56db;
    --primary-dark: #1245b3;
    --primary-light: #e8f0fe;
    --primary-glow: rgba(26, 86, 219, 0.15);

    /* Neutrals */
    --bg: #f4f6fb;
    --bg-alt: #eef1f7;
    --surface: #ffffff;
    --surface-alt: #f8faff;
    --border: #dde3ef;
    --border-strong: #c3cfe0;

    /* Text */
    --text: #1a2236;
    --text-sub: #3d4f6e;
    --text-muted: #6b7fa5;

    /* Status */
    --success: #0c9b6a;
    --success-bg: #e8f8f2;
    --danger: #d9363e;
    --danger-bg: #fdf1f2;
    --warning: #d97706;
    --warning-bg: #fef9ec;
    --info: #0e74cc;
    --info-bg: #e8f4fd;

    /* Sidebar */
    --sidebar-bg: #0f1e3d;
    --sidebar-text: #b0bfd8;
    --sidebar-active: #1a56db;
    --sidebar-hover: rgba(255, 255, 255, 0.07);

    /* Dimensions */
    --navbar-h: 0px; /* Top bar removed */
    --mobile-header-h: 60px;
    --sidebar-w: 240px; /* More compact */
    --bottomnav-h: 64px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.07);
    --shadow: 0 4px 16px rgba(26, 86, 219, 0.10);
    --shadow-lg: 0 8px 32px rgba(26, 86, 219, 0.15);
    --transition: 0.2s ease;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scroll */
    width: 100%;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

* {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ============================================================
   Mobile Header (only vsible on small screens)
   ============================================================ */
.mobile-only-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: var(--mobile-header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--primary);
}

.mobile-brand i {
    font-size: 1.4rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    text-decoration: none;
}

.navbar-brand i {
    color: var(--primary);
    font-size: 1.4rem;
}

.brand-text {
    color: var(--primary);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-right: 12px;
    border-right: 1px solid var(--border);
    margin-right: 4px;
}

.nav-user i {
    color: var(--primary);
    font-size: 1.1rem;
}

.nav-role {
    font-size: 0.72rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.user-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    display: none;
}

.nav-link {
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-sub);
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link i {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link:hover i {
    color: var(--primary);
}

.nav-logout {
    color: var(--danger);
}

.nav-logout i {
    color: var(--danger);
}

.nav-logout:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Hamburger (mobile only) */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    cursor: pointer;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    transition: background var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

.hamburger:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-sub);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.2s ease;
    transform-origin: center;
}

.hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
    background: var(--primary);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
}

.hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
    background: var(--primary);
}

/* ============================================================
   Sidebar (Desktop Permanent, Mobile Drawer)
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

.sidebar-logo i {
    color: var(--primary);
    font-size: 1.5rem;
}

.sidebar-user {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(0,0,0,0.2);
    margin: 15px;
    border-radius: var(--radius);
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    font-size: 0.65rem;
    color: var(--primary-light);
    background: rgba(26, 86, 219, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
    margin-top: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-group {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 20px 10px 8px;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.side-link i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.side-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.side-link:hover i {
    color: var(--primary);
}

.side-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.side-link.active i {
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.logout-link {
    color: #ff6b6b;
}

.logout-link:hover {
    background: rgba(217, 54, 62, 0.1);
    color: #ff5252;
}

/* ============================================================
   Bottom Navigation Bar (Mobile)
   ============================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(26, 86, 219, 0.1);
    z-index: 250;
    padding: 0;
}

.bottom-nav-inner {
    display: flex;
    align-items: stretch;
    height: 100%;
    width: 100%;
    gap: 0;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    border-radius: 0;
    margin: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
    text-align: center;
    min-width: 0;
}

.bottom-nav-item span {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    padding: 0 4px;
}

.bottom-nav-item i {
    font-size: 1.15rem;
    line-height: 1;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    flex: 1;
    padding: 32px 40px;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-w)); /* Explicit width to prevent spill */
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

@media (min-width: 1440px) {
    .main-content {
        padding: 40px 60px;
    }
}

body:not(.has-sidebar) .main-content {
    margin-left: 0;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    text-align: center;
    padding: 18px 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ============================================================
   Auth Pages (login / register)
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: linear-gradient(135deg, #e8f0fe 0%, #f4f6fb 50%, #eef4ff 100%);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 32px; /* Adjusted for tighter feel like the image */
    width: 100%;
    max-width: 400px; /* More compact */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), 0 20px 48px rgba(0, 0, 0, 0.05);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .logo-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: #eef4ff; /* Light blue box */
    color: var(--primary);
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.auth-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.auth-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.72rem; /* Tighter labels */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #4b5563; /* grey-600 */
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid #e5e7eb; /* Subtle border */
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 90px;
}

.form-group select {
    cursor: pointer;
}

.form-group select option {
    background: var(--surface);
    color: var(--text);
}

/* Input with icon */
.input-icon-wrap {
    position: relative;
}

.input-icon-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.input-icon-wrap input {
    padding-left: 38px;
}

/* File drop zone */
.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
    background: var(--bg);
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.file-drop-icon {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 8px;
    display: block;
}

.file-drop-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-drop-name {
    font-size: 0.83rem;
    color: var(--primary);
    margin-top: 8px;
    font-weight: 600;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn i {
    font-size: 0.9rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #077a53;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #b52b32;
    color: #fff;
}

.btn-info {
    background: var(--info);
    color: #fff;
}

.btn-info:hover {
    background: #0a5fa3;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-sub);
    border: 1.5px solid var(--border);
}

.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #b05e04;
    color: #fff;
}

.btn-sm {
    padding: 6px 13px;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* ============================================================
   Cards & Panels
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    min-width: 0; /* Fix for horizontal scroll inside grid/flex items */
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    font-size: 1.1rem;
    color: var(--primary);
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* legacy .icon span support */
.card-title .icon {
    font-size: 1.1rem;
}

/* ---- Stats grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stats-grid > * {
    min-width: 0;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.green::before {
    background: var(--success);
}

.stat-card.red::before {
    background: var(--danger);
}

.stat-card.teal::before {
    background: #0891b2;
}

.stat-card.blue::before {
    background: var(--info);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.stat-card.green .stat-icon {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card.red .stat-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-card.teal .stat-icon {
    background: #e0f7fa;
    color: #0891b2;
}

.stat-card.blue .stat-icon {
    background: var(--info-bg);
    color: var(--info);
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.stat-card.green .stat-number {
    color: var(--success);
}

.stat-card.red .stat-number {
    color: var(--danger);
}

.stat-card.teal .stat-number {
    color: #0891b2;
}

.stat-card.blue .stat-number {
    color: var(--info);
}

.stat-label {
    font-size: 0.77rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-top: 4px;
}

/* ============================================================
   Table
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    background: var(--bg-alt);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg);
}

td {
    padding: 12px 16px;
    color: var(--text);
    vertical-align: middle;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-pending {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(12, 155, 106, 0.2);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(217, 54, 62, 0.2);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(14, 116, 204, 0.2);
}

/* ============================================================
   Alerts / Flash messages
   ============================================================ */
.alert {
    padding: 13px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.88rem;
    border-left: 4px solid currentColor;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert i {
    margin-top: 1px;
    flex-shrink: 0;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

/* ============================================================
   Search / Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 160px;
}

/* ============================================================
   Page heading
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i {
    font-size: 1.3rem;
    color: var(--primary);
    background: var(--primary-light);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-header .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 400;
}

/* ============================================================
   Certificate Preview Thumbnail
   ============================================================ */
.cert-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.cert-pdf-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--danger-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--danger);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 50, 0.5);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background var(--transition);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition);
    text-decoration: none;
}

.page-btn:hover,
.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============================================================
   Utility helpers
   ============================================================ */
.text-muted {
    color: var(--text-muted);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 16px;
}

.mt-8 {
    margin-top: 32px;
}

.mb-4 {
    margin-bottom: 16px;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 8px;
}

.align-center {
    align-items: center;
}

/* ============================================================
   Upload / Registration Form — sections
   ============================================================ */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.section-title i {
    font-size: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-row > * {
    min-width: 0;
}

/* ============================================================
   Layout Helpers
   ============================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-2 > * {
    min-width: 0;
}

.card-empty-state {
    padding: 56px 40px;
}

/* Document upload grid card */
.doc-upload-card {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: border-color var(--transition);
}

.doc-upload-card:hover {
    border-color: var(--primary);
}

.doc-upload-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.doc-upload-card input[type="file"] {
    font-size: 0.78rem;
    width: 100%;
    color: var(--text-sub);
}

/* Upload sidebar */
.upload-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
}

/* ============================================================
   Breadcrumbs
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb a {
    color: var(--primary);
}

.breadcrumb i {
    font-size: 0.65rem;
}

/* ============================================================
   Responsive — Tablet (max 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .main-content {
        padding: 24px 20px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================
   Responsive — Tablet & Mobile (max 768px)
   ============================================================ */
@media (max-width: 768px) {
    .mobile-only-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px 16px;
    }

    .hamburger {
        display: flex;
    }

    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(10, 20, 40, 0.5);
        z-index: 1050;
        backdrop-filter: blur(2px);
    }

    .mobile-sidebar-overlay.open {
        display: block;
    }

    /* --- Bottom nav shown on mobile --- */
    .bottom-nav {
        display: block;
    }

    /* --- Main content --- */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px 16px;
    }

    /* --- Stats grid --- */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    /* --- Forms & Inputs --- */
    .form-group input, 
    .form-group select, 
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* --- Modals --- */
    .modal {
        padding: 24px 16px 40px;
        border-radius: 24px 24px 0 0;
    }

    /* --- Auth --- */
    .auth-card {
        padding: 28px 20px;
    }

    .auth-wrapper {
        padding: 20px 14px;
    }

    /* --- Forms --- */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 11px 13px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .form-section {
        padding: 14px;
    }

    /* --- Filter bar --- */
    .filter-bar {
        flex-direction: column;
        gap: 10px;
    }

    .filter-bar .form-group {
        min-width: 100%;
        width: 100%;
        margin-bottom: 0;
        flex: none !important;
    }

    .filter-bar .form-group .btn {
        width: 100%;
        justify-content: center;
    }

    /* --- Layout grids --- */
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* --- Cards --- */
    .card {
        padding: 16px;
        border-radius: var(--radius);
    }

    .card-title {
        font-size: 0.95rem;
    }

    .card-empty-state {
        padding: 36px 18px;
    }

    /* --- Page header --- */
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 18px;
    }

    .page-header h2 {
        font-size: 1.2rem;
    }

    .page-header>a.btn,
    .page-header>button.btn {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .page-header>.flex {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .page-header>.flex .btn {
        width: 100%;
        justify-content: center;
    }

    /* --- Upload sidebar → full width --- */
    .upload-sidebar {
        width: 100% !important;
        border-radius: var(--radius);
    }

    /* --- Modal → bottom sheet --- */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        border-radius: 20px 20px 0 0;
        max-width: 100%;
        width: 100%;
        max-height: 88vh;
        overflow-y: auto;
        padding: 24px 18px 40px;
        animation: slideUpSheet 0.25s ease;
    }

    @keyframes slideUpSheet {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-header {
        margin-bottom: 14px;
    }

    /* --- Tables --- */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        width: 100%; /* Ensure it doesn't expand beyond its container */
    }

    .table-wrapper table {
        min-width: 520px;
        width: max-content;
    }

    thead th {
        padding: 10px 12px;
        font-size: 0.7rem;
    }

    td {
        padding: 10px 12px;
        font-size: 0.83rem;
    }

    /* --- Pagination --- */
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }

    .page-btn {
        padding: 6px 11px;
        font-size: 0.82rem;
    }

    /* --- Alerts --- */
    .alert {
        font-size: 0.85rem;
        padding: 11px 14px;
    }

    /* --- Flex rows --- */
    .flex.gap-2 {
        flex-wrap: wrap;
    }

    /* --- Site footer — keep above bottom nav --- */
    .site-footer {
        margin-bottom: var(--bottomnav-h);
    }
}

/* ============================================================
   Responsive — Small phones (max 480px)
   ============================================================ */
@media (max-width: 480px) {
    .navbar {
        padding: 0 12px;
        height: 58px;
    }

    :root {
        --navbar-h: 58px;
    }

    .main-content {
        padding: 12px 10px calc(var(--bottomnav-h) + 12px);
    }

    .page-header h2 {
        font-size: 1.05rem;
    }

    .page-header .subtitle {
        font-size: 0.77rem;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 14px 12px;
    }

    .stat-number {
        font-size: 1.7rem;
    }

    .stat-label {
        font-size: 0.68rem;
        letter-spacing: 0;
    }

    .stat-icon {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }

    /* Auth */
    .auth-card {
        padding: 22px 14px;
    }

    .auth-logo h1 {
        font-size: 1.3rem;
    }

    .auth-logo .logo-icon {
        width: 54px;
        height: 54px;
        font-size: 1.4rem;
    }

    /* Cards */
    .card {
        padding: 12px;
        border-radius: 10px;
    }

    .card-title {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    .card-empty-state {
        padding: 28px 12px;
    }

    /* Buttons */
    .btn {
        padding: 9px 14px;
        font-size: 0.83rem;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 0.76rem;
    }

    /* Modal */
    .modal {
        padding: 18px 14px 36px;
        border-radius: 16px 16px 0 0;
    }

    /* Tables */
    .table-wrapper table {
        min-width: 460px;
    }

    thead th {
        padding: 8px 10px;
        font-size: 0.68rem;
    }

    td {
        padding: 8px 10px;
        font-size: 0.79rem;
    }

    /* Filter */
    .filter-bar {
        gap: 8px;
    }

    /* Form inputs - always 16px prevent iOS zoom */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 11px 34px;
        font-size: 16px;
    }
}

/* ============================================================
   Charts & Dashboard Enhancements
   ============================================================ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-card .card-title {
    width: 100%;
    margin-bottom: 20px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.chart-container.wide {
    max-width: 100%;
    height: 240px;
}

@media (max-width: 768px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
}