:root {
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --surface-2: #F0F2F7;
    --border: #E2E6EE;
    --border-strong: #CBD2E0;
    --text-1: #111827;
    --text-2: #4B5563;
    --text-3: #9CA3AF;
    --blue: #3B7BF6;
    --blue-light: #EEF3FE;
    --blue-dark: #2563EB;
    --red: #EF4444;
    --red-light: #FEF2F2;
    --green: #10B981;
    --green-light: #ECFDF5;
    --yellow: #F59E0B;
    --yellow-light: #FFFBEB;
    --purple: #8B5CF6;
    --purple-light: #F5F3FF;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text-1);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ── TOP NAV ── */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--blue);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: white;
    stroke-width: 2;
}

.brand-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-1);
}

.brand-tag {
    font-size: 10px;
    font-weight: 500;
    background: var(--blue-light);
    color: var(--blue);
    padding: 2px 7px;
    border-radius: 20px;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-2);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-tab:hover {
    background: var(--bg);
    color: var(--text-1);
}

.nav-tab.active {
    background: var(--blue-light);
    color: var(--blue);
}

.nav-tab .tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.nav-tab.active .tab-dot {
    opacity: 1;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.api-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-3);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 20px;
}

.api-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

/* ── PAGE LAYOUT ── */
.page {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: calc(100vh - 60px);
}

/* ── SIDEBAR ── */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    margin-bottom: 10px;
}

.upload-card {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
    overflow: hidden;
    min-width: 0;
}

.upload-card:hover {
    border-color: var(--blue);
    background: var(--blue-light);
}

.upload-icon-wrap {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: var(--shadow-sm);
}

.upload-icon-wrap svg {
    width: 22px;
    height: 22px;
    stroke: var(--text-2);
    fill: none;
    stroke-width: 1.8;
}

.upload-title {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-1);
    margin-bottom: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: normal;
}

.upload-title.ready {
    color: var(--blue);
}

.upload-hint {
    font-size: 11.5px;
    color: var(--text-3);
}

.img-preview-thumb {
    width: 100%;
    max-height: 130px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    display: none;
}

.btn-run {
    width: 100%;
    background: var(--blue);
    color: white;
    border: none;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-run:hover {
    background: var(--blue-dark);
}

.btn-run:active {
    transform: scale(0.98);
}

.btn-run svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: white;
    stroke-width: 2;
}

.sidebar-info {
    background: var(--blue-light);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 12px;
    color: var(--blue-dark);
    line-height: 1.5;
    border: 1px solid rgba(59, 123, 246, 0.15);
}

.sidebar-info strong {
    font-weight: 600;
}

/* ── MAIN CONTENT ── */
.main {
    padding: 28px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-1);
}

.page-sub {
    font-size: 13px;
    color: var(--text-3);
    margin-top: 3px;
}

.status-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
}

/* ── STATS GRID ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke-width: 2;
}

.stat-icon.blue {
    background: var(--blue-light);
}

.stat-icon.blue svg {
    stroke: var(--blue);
}

.stat-icon.red {
    background: var(--red-light);
}

.stat-icon.red svg {
    stroke: var(--red);
}

.stat-icon.green {
    background: var(--green-light);
}

.stat-icon.green svg {
    stroke: var(--green);
}

.stat-icon.yellow {
    background: var(--yellow-light);
}

.stat-icon.yellow svg {
    stroke: var(--yellow);
}

.stat-label {
    font-size: 11.5px;
    color: var(--text-3);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.1;
}

.stat-value.red {
    color: var(--red);
}

.stat-value.green {
    color: var(--green);
}

.stat-value.blue {
    color: var(--blue);
}

.stat-value.yellow {
    color: var(--yellow);
}

/* ── RESULT GRID ── */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-1);
}

.chip {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.chip-gray {
    background: var(--surface-2);
    color: var(--text-3);
}

.chip-blue {
    background: var(--blue-light);
    color: var(--blue);
}

.chip-green {
    background: var(--green-light);
    color: var(--green);
}

.chip-red {
    background: var(--red-light);
    color: var(--red);
}

.chip-yellow {
    background: var(--yellow-light);
    color: var(--yellow);
}

.card-body {
    padding: 20px;
    flex: 1;
}

.empty-state {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    gap: 10px;
}

.empty-icon {
    width: 48px;
    height: 48px;
    background: var(--surface-2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: var(--text-3);
    stroke-width: 1.5;
}

.empty-text {
    font-size: 13px;
    text-align: center;
    max-width: 200px;
    line-height: 1.5;
}

/* ── CHART ── */
.chart-wrap {
    height: 220px;
    position: relative;
    margin-bottom: 20px;
}

/* ── TABLE ── */
.table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--surface);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    z-index: 5;
}

.data-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-1);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg);
}

.text-right {
    text-align: right !important;
}

.pill-mal {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--red);
    background: var(--red-light);
    padding: 3px 9px;
    border-radius: 20px;
}

.pill-ben {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--green);
    background: var(--green-light);
    padding: 3px 9px;
    border-radius: 20px;
}

/* ── MRI / IMAGE VIEWER ── */
.img-viewer {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0D0D0D;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    text-align: center;
}

.img-viewer img {
    max-width: 100%;
    max-height: 340px;
    display: block;
    margin: 0 auto;
}

.img-overlay-label {
    position: absolute;
    top: 12px;
    left: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
}

.label-tumor {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.label-clear {
    background: rgba(16, 185, 129, 0.9);
    color: white;
}

.label-yolo {
    background: rgba(245, 158, 11, 0.9);
    color: white;
}

.result-note {
    background: var(--bg);
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-2);
    margin-bottom: 12px;
}

.disclaimer {
    font-size: 11px;
    color: var(--text-3);
    text-align: center;
    font-style: italic;
}

/* ── BRAIN DETAIL ── */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 13px;
    color: var(--text-2);
}

.detail-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-1);
}

/* ── THRESHOLD NOTE ── */
.note-box {
    margin-top: 20px;
    padding: 12px 14px;
    background: var(--yellow-light);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    color: #92400E;
    line-height: 1.5;
}

/* ── HIDDEN ── */
.hidden {
    display: none !important;
}

/* ── OVERLAY LOADER ── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(249, 250, 251, 0.85);
    backdrop-filter: blur(6px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 48px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.overlay-module {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--blue);
    margin-bottom: 6px;
}

.overlay-status {
    font-size: 14px;
    color: var(--text-2);
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--blue);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 9999;
    font-size: 13.5px;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 320px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    border-left-color: var(--red);
}