/* ============================================================
   CervixDx Platform — Design System
   Clinical-grade UI · IBM Plex Sans · MUST / Southwestern Uganda
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    /* Brand */
    --brand-start:      #4f63d2;
    --brand-end:        #6c3fc5;
    --brand-mid:        #5a52cc;
    --brand-gradient:   linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);

    /* Surfaces */
    --bg-page:          #f0f2f8;
    --bg-card:          #ffffff;
    --bg-subtle:        #f7f8fc;
    --bg-hover:         #eef0fb;

    /* Borders */
    --border:           #e2e6f0;
    --border-strong:    #c8cee0;

    /* Text */
    --text-primary:     #1a1f36;
    --text-secondary:   #4a5270;
    --text-muted:       #8892b0;
    --text-white:       #ffffff;

    /* Severity — Diagnosis colour system (Bethesda) */
    --sev-nilm:         #16a34a;   /* Normal / Benign — green */
    --sev-nilm-bg:      #dcfce7;
    --sev-lsil:         #ca8a04;   /* LSIL — amber */
    --sev-lsil-bg:      #fef9c3;
    --sev-hsil:         #ea580c;   /* HSIL — orange */
    --sev-hsil-bg:      #ffedd5;
    --sev-scc:          #dc2626;   /* Invasive / Carcinoma — red */
    --sev-scc-bg:       #fee2e2;
    --sev-uncertain:    #6b7280;   /* Uncertain */
    --sev-uncertain-bg: #f3f4f6;

    /* Status colours */
    --status-received:  #3b82f6;
    --status-processing:#8b5cf6;
    --status-ready:     #06b6d4;
    --status-analyzed:  #10b981;
    --status-reviewed:  #059669;
    --status-rejected:  #ef4444;

    /* Shadows */
    --shadow-sm:        0 1px 3px rgba(15,23,55,0.08), 0 1px 2px rgba(15,23,55,0.04);
    --shadow-md:        0 4px 12px rgba(15,23,55,0.10), 0 2px 6px rgba(15,23,55,0.06);
    --shadow-lg:        0 12px 32px rgba(15,23,55,0.12), 0 4px 12px rgba(15,23,55,0.08);
    --shadow-focus:     0 0 0 3px rgba(79,99,210,0.18);

    /* Radii */
    --radius-sm:        6px;
    --radius-md:        10px;
    --radius-lg:        14px;
    --radius-xl:        20px;
    --radius-pill:      999px;

    /* Transitions */
    --transition:       0.18s ease;
    --transition-slow:  0.3s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);
    min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────── */
.page-wrapper   { display: flex; flex-direction: column; min-height: 100vh; }
.main-content   { flex: 1; padding: 2rem 2.5rem; max-width: 1440px; margin: 0 auto; width: 100%; }
.container      { max-width: 1440px; margin: 0 auto; padding: 0 2rem; }
.content-wrapper{ width: 100%; }

/* ── Top Navigation ─────────────────────────────────────────── */
.top-nav {
    background: var(--brand-gradient);
    box-shadow: 0 2px 12px rgba(15,23,55,0.18);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    min-height: 64px;
    gap: 1rem;
}

/* Brand */
.nav-brand { flex-shrink: 0; }
.nav-brand a,
.nav-brand .brand-logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: white;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    padding: 0.75rem 0;
}
.nav-brand .brand-logo { cursor: default; }
.nav-brand i { font-size: 1.35rem; opacity: 0.92; }
.brand-name { color: rgba(255,255,255,0.95); }

/* Nav items */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.125rem;
    flex: 1;
    justify-content: center;
    align-items: center;
}

.nav-item { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.875rem;
    color: rgba(255,255,255,0.88);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,0.16);
    color: white;
    text-decoration: none;
}
.nav-link.active { background: rgba(255,255,255,0.2); }
.nav-link i { font-size: 0.95rem; opacity: 0.9; }

/* Dropdown */
.nav-item.dropdown { position: relative; }

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    min-width: 220px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 0.5rem;
    z-index: 1010;
    border: 1px solid var(--border);
    animation: dropIn 0.15s ease;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 993px) {
    .nav-item.dropdown:hover .dropdown-menu { display: block; }
}
.nav-item.dropdown.active .dropdown-menu { display: block !important; }

.dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary) !important;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.dropdown-menu li a:hover {
    background: var(--bg-hover) !important;
    color: var(--brand-start) !important;
    text-decoration: none;
}
.dropdown-menu li a i {
    width: 18px;
    text-align: center;
    color: var(--brand-start);
    font-size: 0.875rem;
}

/* Chevron */
.chevron-icon {
    font-size: 0.65rem;
    margin-left: 2px;
    transition: transform var(--transition);
    opacity: 0.8;
}
.nav-item.dropdown.active .chevron-icon { transform: rotate(180deg); }

/* Mobile toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: transform var(--transition);
    order: 3;
    z-index: 1002;
}
.mobile-menu-toggle:hover { transform: scale(1.1); }

/* ── User Dropdown ──────────────────────────────────────────── */
.nav-user {
    position: relative !important;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-slow);
    border: 1px solid rgba(255,255,255,0.18);
}
.user-info:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.35);
}
.user-info i.fa-user-circle { font-size: 1.5rem; color: white; }
.user-name { color: white; font-weight: 600; font-size: 0.875rem; }
.user-info .chevron-icon { color: rgba(255,255,255,0.8); }

.nav-user .user-dropdown {
    display: none;
    position: absolute !important;
    top: calc(100% + 10px) !important;
    right: 0 !important;
    left: auto !important;
    background: white !important;
    min-width: 220px !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0.5rem !important;
    z-index: 9999 !important;
    border: 1px solid var(--border);
    overflow: hidden;
}

.nav-user .user-dropdown.active {
    display: block !important;
    animation: dropIn 0.2s ease;
}

/* Gradient accent bar */
.user-dropdown::before {
    content: '';
    display: block;
    background: var(--brand-gradient);
    height: 3px;
    margin: -0.5rem -0.5rem 0.5rem;
}

.nav-user .user-dropdown a {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem !important;
    color: var(--text-primary) !important;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.nav-user .user-dropdown a:hover {
    background: var(--bg-hover) !important;
    color: var(--brand-start) !important;
    text-decoration: none;
}
.nav-user .user-dropdown a i {
    width: 18px;
    text-align: center;
    color: var(--brand-start);
    font-size: 1rem;
}
.nav-user .user-dropdown a.logout-link { color: #dc2626 !important; }
.nav-user .user-dropdown a.logout-link i { color: #dc2626 !important; }
.nav-user .user-dropdown a.logout-link:hover {
    background: #fee2e2 !important;
    color: #b91c1c !important;
}

/* Arrow caret */
.nav-user .user-dropdown::after {
    content: '';
    position: absolute;
    top: -7px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: white;
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--border);
}

.page-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin: 0 0 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.page-header h1 i {
    color: var(--brand-start);
    font-size: 1.375rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* ── Statistics Cards ───────────────────────────────────────── */
.stats-section,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.125rem;
    transition: transform var(--transition), box-shadow var(--transition);
    min-height: 100px;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    color: white;
    flex-shrink: 0;
}

.stat-content,
.stat-details { flex: 1; }

.stat-value,
.stat-card h3 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin: 0 0 0.25rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-label,
.stat-card p {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
    letter-spacing: 0.01em;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.card-body { padding: 1.5rem; }

/* Legacy .card with direct content (no card-body) */
.card > *:not(.card-header):not(.card-body) { padding: 0; }
.card:not(:has(.card-body)) { padding: 1.5rem; }

/* ── Hero Section ───────────────────────────────────────────── */
.hero-section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 1.75rem;
    position: relative;
    overflow: hidden;
}

/* Subtle top accent line */
.hero-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--brand-gradient);
}

.hero-section h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
}
.hero-section p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

/* ── Feature Cards (dashboard) ──────────────────────────────── */
.feature-card {
    padding: 1.375rem 1.5rem;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--brand-start);
    transition: box-shadow var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-md); }
.feature-card h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}
.feature-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.55;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

table thead,
.data-table thead {
    background: var(--bg-subtle);
    position: sticky;
    top: 0;
}

table th,
.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td,
.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
    vertical-align: middle;
}

table tbody tr,
.data-table tbody tr { transition: background var(--transition); }
table tbody tr:hover,
.data-table tbody tr:hover { background: var(--bg-hover); }
table tbody tr:last-child td,
.data-table tbody tr:last-child td { border-bottom: none; }

/* Action button group in table */
.table-actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: nowrap;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1.125rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.5;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn i { font-size: 0.875rem; }

.btn-primary   { background: var(--brand-start); color: white; border-color: var(--brand-start); }
.btn-primary:hover { background: #3d52c4; border-color: #3d52c4; }

.btn-secondary { background: #64748b; color: white; border-color: #64748b; }
.btn-secondary:hover { background: #475569; border-color: #475569; }

.btn-success   { background: #16a34a; color: white; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }

.btn-danger    { background: #dc2626; color: white; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.btn-warning   { background: #d97706; color: white; border-color: #d97706; }
.btn-warning:hover { background: #b45309; }

.btn-outline {
    background: white;
    color: var(--brand-start);
    border: 1.5px solid var(--brand-start);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-outline-danger {
    background: white;
    color: #dc2626;
    border: 1.5px solid #dc2626;
}
.btn-outline-danger:hover { background: #fee2e2; }

.btn-sm  { padding: 0.3125rem 0.75rem; font-size: 0.8125rem; }
.btn-lg  { padding: 0.75rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label,
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    padding: 0.5625rem 0.875rem;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-start);
    box-shadow: var(--shadow-focus);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%234a5270' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 10px;
    padding-right: 2.5rem;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Filters Section ────────────────────────────────────────── */
.filters-section {
    background: var(--bg-card);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.filters-form,
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.search-form .form-control { flex: 1; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}
.alert i { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }
.alert .close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.6;
    padding: 0;
    color: inherit;
    flex-shrink: 0;
}
.alert .close:hover { opacity: 1; }

.alert-success  { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.alert-danger   { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.alert-warning  { background: #fffbeb; border-color: #fcd34d; color: #b45309; }
.alert-info     { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.alert-dismissible { position: relative; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success  { background: #dcfce7; color: #15803d; }
.badge-warning  { background: #fef9c3; color: #854d0e; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-info     { background: #dbeafe; color: #1d4ed8; }
.badge-primary  { background: #ede9fe; color: #5b21b6; }
.badge-secondary{ background: #f1f5f9; color: #475569; }
.badge-dark     { background: #1e293b; color: white; }

/* Diagnosis severity badges */
.dx-nilm        { background: var(--sev-nilm-bg);      color: var(--sev-nilm); }
.dx-lsil        { background: var(--sev-lsil-bg);      color: var(--sev-lsil); }
.dx-hsil        { background: var(--sev-hsil-bg);      color: var(--sev-hsil); }
.dx-scc         { background: var(--sev-scc-bg);       color: var(--sev-scc); }
.dx-uncertain   { background: var(--sev-uncertain-bg); color: var(--sev-uncertain); }

/* Specimen status badges */
.status-received    { background: #dbeafe; color: #1d4ed8; }
.status-processing  { background: #ede9fe; color: #6d28d9; }
.status-ready       { background: #cffafe; color: #0e7490; }
.status-analyzed    { background: #d1fae5; color: #065f46; }
.status-reviewed    { background: #d1fae5; color: #064e3b; }
.status-rejected    { background: #fee2e2; color: #991b1b; }
.status-urgent      { background: #fee2e2; color: #991b1b; font-weight: 700; }
.status-high        { background: #ffedd5; color: #9a3412; }
.status-normal      { background: #f0fdf4; color: #166534; }

/* ── Lab Number / ID Pills ──────────────────────────────────── */
.lab-number,
.id-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.625rem;
    white-space: nowrap;
}

.patient-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    background: #f5f3ff;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
    border-radius: var(--radius-pill);
    padding: 0.25rem 0.75rem;
    white-space: nowrap;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-strong);
    margin: 1.5rem 0;
}
.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.4;
    margin-bottom: 1rem;
    display: block;
}
.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}
.pagination .btn {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.625rem;
    font-size: 0.875rem;
}
.pagination-ellipsis {
    padding: 0 0.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Images Grid ────────────────────────────────────────────── */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.image-card,
.labeled-image-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}
.image-card:hover,
.labeled-image-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.image-thumbnail,
.image-preview {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: #f1f3f9;
}
.image-thumbnail img,
.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.image-card:hover .image-preview img,
.labeled-image-card:hover .image-preview img { transform: scale(1.03); }

.image-info,
.card-content { padding: 1rem; }
.card-content p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.card-content p strong { color: var(--text-primary); font-weight: 600; }

.label-badge {
    position: absolute;
    top: 10px; left: 10px;
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    backdrop-filter: blur(4px);
}
.confidence-badge {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    backdrop-filter: blur(4px);
}
.quality-badge {
    position: absolute;
    bottom: 10px; right: 10px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}
.quality-high   { background: #16a34a; }
.quality-medium { background: #d97706; }
.quality-low    { background: #dc2626; }

/* ── Notes Box ──────────────────────────────────────────────── */
.notes-box {
    margin-top: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-strong);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ── Detail View — info rows ────────────────────────────────── */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    gap: 1rem;
}
.info-row:last-child { border-bottom: none; }
.info-row .info-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    min-width: 140px;
}
.info-row .info-value { color: var(--text-primary); }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 1.5rem;   font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: 0.9375rem;font-weight: 600; }
h5 { font-size: 0.875rem; font-weight: 600; }
h6 { font-size: 0.8125rem;font-weight: 600; }

h1,h2,h3,h4,h5,h6 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    line-height: 1.25;
}

p { margin-bottom: 0.875rem; }
a { color: var(--brand-start); text-decoration: none; transition: color var(--transition); }
a:hover { text-decoration: underline; }

code, .mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875em;
    background: var(--bg-subtle);
    padding: 0.125em 0.375em;
    border-radius: 4px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.main-footer {
    background: #0f172a;
    color: rgba(255,255,255,0.65);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    font-weight: 600;
}
.footer-brand i { color: var(--brand-start); }

.footer-links {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
}
.footer-links a {
    color: rgba(255,255,255,0.5);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color var(--transition);
}
.footer-links a:hover { color: rgba(255,255,255,0.9); text-decoration: none; }

.footer-copy {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.35);
}

/* ── Login Page ─────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    background: var(--bg-page);
}

.login-brand-panel {
    flex: 0 0 42%;
    background: var(--brand-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
}

/* Decorative circles */
.login-brand-panel::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    top: -100px; right: -100px;
}
.login-brand-panel::after {
    content: '';
    position: absolute;
    width: 280px; height: 280px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    bottom: -60px; left: -60px;
}

.login-brand-content { position: relative; z-index: 1; text-align: center; color: white; }
.login-brand-content i.fa-microscope {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    opacity: 0.92;
}
.login-brand-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}
.login-brand-content p {
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0;
}
.login-brand-content .must-logo {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.02em;
}

.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}

.login-form-box {
    width: 100%;
    max-width: 400px;
}

.login-form-box h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}
.login-form-box .login-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ── Utility ────────────────────────────────────────────────── */
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-muted    { color: var(--text-muted); }
.text-primary  { color: var(--brand-start); }
.text-success  { color: #16a34a; }
.text-danger   { color: #dc2626; }
.text-warning  { color: #d97706; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Section heading */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 992px) {
    .mobile-menu-toggle { display: block !important; }
    .nav-menu { display: none; }

    .nav-menu.active {
        display: flex !important;
        position: fixed;
        top: 64px; left: 0;
        width: 100%;
        height: calc(100vh - 64px);
        background: linear-gradient(180deg, var(--brand-start) 0%, var(--brand-end) 100%);
        flex-direction: column;
        padding: 1rem 0;
        overflow-y: auto;
        z-index: 999;
        gap: 0;
    }
    .nav-menu.active .nav-item { width: 100%; border-bottom: 1px solid rgba(255,255,255,0.08); }
    .nav-menu.active .nav-link { padding: 0.875rem 1.5rem; width: 100%; border-radius: 0; font-size: 0.95rem; }
    .nav-item.dropdown:hover .dropdown-menu { display: none !important; }
    .nav-menu.active .dropdown-menu {
        position: static;
        background: rgba(0,0,0,0.15);
        border: none; width: 100%;
        padding: 0; margin: 0; display: none;
        border-radius: 0; box-shadow: none;
    }
    .nav-menu.active .nav-item.dropdown.active .dropdown-menu { display: block !important; }
    .nav-menu.active .dropdown-menu li a {
        color: rgba(255,255,255,0.9) !important;
        padding: 0.75rem 2rem;
        border-radius: 0;
    }
    .nav-menu.active .dropdown-menu li a:hover {
        background: rgba(255,255,255,0.08) !important;
        color: white !important;
    }
    .nav-user { margin-left: 0.25rem; }
    .user-name { display: none; }
    .user-info { padding: 0.4rem 0.625rem; }

    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 1.375rem; }
    .header-actions { width: 100%; }
    .stats-section, .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .images-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .filters-form, .filter-form { grid-template-columns: 1fr; }
    .main-content { padding: 1.25rem 1rem; }

    .login-brand-panel { display: none; }
    .login-form-panel { padding: 2rem 1.25rem; }
}

@media (max-width: 768px) {
    html { font-size: 15px; }
    .stats-section, .stats-grid { grid-template-columns: 1fr 1fr; }
    .hero-section { padding: 2rem 1.25rem; }
    .hero-section h1 { font-size: 1.5rem; }
    table th, table td { padding: 0.625rem 0.75rem; }
    .table-actions { flex-wrap: wrap; }
    .info-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .info-row .info-label { min-width: unset; }
}

@media (max-width: 480px) {
    .stats-section, .stats-grid { grid-template-columns: 1fr; }
    .nav-brand .brand-name { display: none; }
    .stat-card { min-height: 80px; }
    .stat-value, .stat-card h3 { font-size: 1.5rem; }
    .btn { font-size: 0.8125rem; padding: 0.4375rem 0.875rem; }
    .images-grid { grid-template-columns: 1fr; }
}

