:root {
    --bg-dark: #090d16;
    --sidebar-bg: #0d121f;
    --card-bg: rgba(22, 27, 34, 0.85);
    --card-border: #30363d;
    --accent: #388bfd;
    --accent-hover: #1f6feb;
    --accent-glow: rgba(56, 139, 253, 0.25);
    --success: #238636;
    --success-hover: #2ea043;
    --danger: #da3633;
    --danger-hover: #f85149;
    --text-primary: #e6edf3;
    --text-muted: #8b949e;
    --border-light: rgba(255, 255, 255, 0.08);
    --sidebar-width: 240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
    position: relative;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 140;
    backdrop-filter: blur(4px);
}

.sidebar-backdrop.active {
    display: block;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 150;
    transition: transform 0.25s ease;
}

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

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-badge {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #1f6feb, #238636);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

.brand-text h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sidebar-menu li a:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-menu li.active a {
    color: #ffffff;
    background-color: rgba(56, 139, 253, 0.15);
    border: 1px solid rgba(56, 139, 253, 0.3);
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-light);
    background-color: rgba(0, 0, 0, 0.15);
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-email {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    color: #f85149;
    background-color: rgba(248, 81, 73, 0.12);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.top-navbar {
    height: 56px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(13, 18, 31, 0.7);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
}

.page-title h1 {
    font-size: 1.15rem;
    font-weight: 700;
}

.content-body {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Card */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
}

/* Flash Alerts */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: rgba(35, 134, 54, 0.15);
    border: 1px solid rgba(35, 134, 54, 0.35);
    color: #3fb950;
}

.alert-error,
.alert-danger {
    background: rgba(218, 54, 51, 0.15);
    border: 1px solid rgba(218, 54, 51, 0.35);
    color: #f85149;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
}

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

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
    border-radius: 5px;
}

.btn-action {
    height: 30px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 6px;
    box-sizing: border-box;
    line-height: 1;
}

.btn-action-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-sizing: border-box;
    line-height: 1;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control,
.form-select {
    width: 100%;
    padding: 10px 12px;
    background: #0d1117;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: #e6edf3;
    font-size: 0.88rem;
    outline: none;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(56, 139, 253, 0.2);
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--card-border);
    border-radius: 10px;
    padding: 30px 16px;
    text-align: center;
    background: rgba(13, 17, 23, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(56, 139, 253, 0.05);
}

.dropzone-icon {
    color: var(--text-muted);
    margin-bottom: 8px;
}

.preview-container {
    margin-top: 12px;
    display: none;
}

.preview-img {
    max-width: 180px;
    max-height: 180px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    object-fit: cover;
}

/* Metrics Responsive Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.metric-card {
    background: rgba(13, 17, 23, 0.6);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.diag-card {
    grid-column: 1 / -1;
    text-align: left;
    padding: 12px 16px;
}

.diag-positive {
    border-left: 4px solid #da3633;
}

.diag-positive .diag-status {
    color: #f85149;
}

.diag-negative {
    border-left: 4px solid #238636;
}

.diag-negative .diag-status {
    color: #3fb950;
}

.diag-status {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 2px;
}

.metric-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #58a6ff;
}

/* 3-Panel Visual Layout */
.panel-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

/* 4-Panel Visual Layout */
.panel-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.panel-card {
    background: #0d1117;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.panel-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 0.2px;
}

.panel-img-wrapper {
    background: #080c14;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.panel-img-wrapper:hover img {
    transform: scale(1.02);
}

@media (max-width: 960px) {
    .panel-grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
    }
    .panel-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 540px) {
    .panel-grid-3, .panel-grid-4 {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* Comparison side-by-side */
.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Responsive Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    min-width: 680px;
    table-layout: fixed;
}

.custom-table th {
    text-align: left;
    padding: 10px 12px;
    background: rgba(13, 17, 23, 0.8);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.custom-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.custom-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.thumbnail-cell img {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border-light);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-content {
    background: #161b22;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    max-width: 850px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

/* ========================================================
   Responsive Breakpoints for All Viewports
   ======================================================== */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }

    .sidebar-close-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
    }

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

    .top-navbar {
        padding: 0 16px;
    }

    .content-body {
        padding: 16px 12px;
    }

    .card {
        padding: 16px;
    }

    .comparison-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .content-body {
        padding: 12px 8px;
    }

    .card {
        padding: 14px;
    }
}