/* ============================================================
   NetworkSuite — Scientific Network Analysis Platform
   v5.0 — Clean Light Theme, Publication-Grade
   ============================================================ */

/* ── Design Tokens ───────────────────────────────────────── */
:root {
    /* Surfaces — clean white/grey scientific palette */
    --bg: #F3F4F6;
    --bg-raised: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #F9FAFB;
    --surface-3: #F3F4F6;
    --surface-4: #E5E7EB;

    /* Accents */
    --accent: #2563EB;
    --accent-dim: #1D4ED8;
    --accent-bg: rgba(37, 99, 235, 0.07);
    --accent-alt: #7C3AED;
    --accent-alt-bg: rgba(124, 58, 237, 0.06);

    /* Semantic */
    --green: #059669;
    --green-bg: rgba(5, 150, 105, 0.07);
    --amber: #D97706;
    --amber-bg: rgba(217, 119, 6, 0.07);
    --red: #DC2626;
    --red-bg: rgba(220, 38, 38, 0.06);
    --teal: #0891B2;

    /* Text */
    --text-1: #111827;
    --text-2: #4B5563;
    --text-3: #9CA3AF;
    --text-code: #2563EB;

    /* Borders */
    --border: rgba(0, 0, 0, 0.06);
    --border-2: rgba(0, 0, 0, 0.10);
    --border-3: rgba(0, 0, 0, 0.16);

    /* Radii */
    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.10);
    --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.12);

    /* Layout */
    --sidebar-w: 260px;
    --results-w: 420px;
    --header-h: 52px;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --t: 0.18s;
}

/* ── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    color-scheme: light;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-1);
    overflow: hidden;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 13px;
    line-height: 1.5;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-4);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #D1D5DB;
}

/* ══════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════ */
.app-header {
    height: var(--header-h);
    min-height: var(--header-h);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 10px;
    z-index: 100;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.h-sep {
    width: 1px;
    height: 22px;
    background: var(--border-2);
    flex-shrink: 0;
}

/* Logo */
.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    transition: background var(--t) var(--ease);
    flex-shrink: 0;
}

.app-logo:hover {
    background: var(--surface-3);
}

.logo-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.logo-mark svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    line-height: 1.15;
}

.logo-brand {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: -0.4px;
    display: block;
}

.logo-sub {
    font-size: 8.5px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 1.8px;
    display: block;
}

/* Icon Buttons */
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t) var(--ease);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text-1);
    border-color: var(--border-2);
}

/* Search */
.header-search {
    position: relative;
    width: 220px;
    flex-shrink: 0;
}

.header-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 11px;
    pointer-events: none;
    transition: color var(--t);
}

.header-search:focus-within i {
    color: var(--accent);
}

.header-search input {
    width: 100%;
    height: 32px;
    background: var(--surface-3);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 0 12px 0 32px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-1);
    outline: none;
    transition: all var(--t) var(--ease);
}

.header-search input::placeholder {
    color: var(--text-3);
}

.header-search input:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Pills */
.header-pills {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-3);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 4px 11px;
    height: 30px;
}

.pill-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    min-width: 20px;
    text-align: right;
}

.pill-lbl {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hbtn {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--t) var(--ease);
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.hbtn-ghost {
    background: var(--surface-3);
    color: var(--text-2);
    border: 1px solid var(--border-2);
}

.hbtn-ghost:hover {
    background: var(--surface-4);
    color: var(--text-1);
    border-color: var(--border-3);
}

.hbtn-primary {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.hbtn-primary:hover {
    background: var(--accent-dim);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

.hbtn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.chevron-sm {
    font-size: 9px;
    opacity: 0.5;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-float);
    min-width: 220px;
    z-index: 300;
    overflow: hidden;
}

.dropdown-group-label {
    padding: 8px 14px 4px;
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--accent-bg);
    color: var(--accent);
}

.dropdown-item i {
    width: 14px;
    text-align: center;
    color: var(--accent);
    font-size: 12px;
}

.dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ══════════════════════════════════════════════════════════
   APP BODY
═══════════════════════════════════════════════════════════ */
.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-raised);
    border-right: 1px solid var(--border-2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s var(--ease), min-width 0.25s var(--ease), opacity 0.25s;
    z-index: 20;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-2);
    flex-shrink: 0;
    padding: 4px 6px 0;
    gap: 2px;
}

.stab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px 10px;
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all var(--t) var(--ease);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-radius: var(--r-xs) var(--r-xs) 0 0;
    font-family: inherit;
}

.stab:hover {
    color: var(--text-2);
    background: var(--surface-3);
}

.stab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.stab i {
    font-size: 13px;
}

/* Sidebar Scroll */
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-sticky-footer {
    padding: 8px 10px;
    border-top: 1px solid var(--border-2);
    flex-shrink: 0;
    background: var(--bg-raised);
}

/* ── Panels (collapsible sections) ───────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: border-color var(--t);
}

.panel:hover {
    border-color: var(--border-3);
}

.panel-head {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background var(--t);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-1);
}

.panel-head:hover {
    background: var(--surface-3);
}

.panel-icon {
    color: var(--accent);
    font-size: 12px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.panel-head span {
    flex: 1;
}

.panel-chev {
    color: var(--text-3);
    font-size: 10px;
    transition: transform 0.2s var(--ease);
}

.panel-head.open .panel-chev {
    transform: rotate(180deg);
}

.panel-body {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    border-top: 1px solid var(--border);
}

/* ── Form Elements ───────────────────────────────────────── */
.field-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    display: block;
}

.field-input,
.field-select,
.field-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    padding: 7px 10px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-1);
    outline: none;
    transition: all var(--t) var(--ease);
    appearance: none;
}

.field-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236B7280' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 28px;
    cursor: pointer;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.field-textarea {
    resize: vertical;
    min-height: 64px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.7;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: end;
}

.field-col {
    display: flex;
    flex-direction: column;
}

.col-full {
    grid-column: 1 / -1;
}

.field-color {
    width: 100%;
    height: 34px;
    padding: 2px;
    cursor: pointer;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.field-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: var(--surface-4);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
}

.field-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.3);
    transition: transform 0.1s;
}

.field-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.field-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.hint-text {
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.6;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all var(--t) var(--ease);
    white-space: nowrap;
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.btn-accent:hover {
    background: var(--accent-dim);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-2);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

.btn-secondary {
    background: var(--surface-3);
    color: var(--text-2);
    border: 1px solid var(--border-2);
}

.btn-secondary:hover {
    background: var(--surface-4);
    color: var(--text-1);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.12);
}

.btn-sm {
    padding: 5px 9px;
    font-size: 11px;
    border-radius: var(--r-xs);
}

.w-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ── Drop Zone ───────────────────────────────────────────── */
.drop-zone {
    border: 1.5px dashed var(--border-3);
    border-radius: var(--r-md);
    padding: 20px 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--t) var(--ease);
    background: var(--surface-2);
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.dz-icon {
    font-size: 22px;
    color: var(--text-3);
    margin-bottom: 6px;
    transition: color var(--t);
}

.drop-zone:hover .dz-icon {
    color: var(--accent);
}

.dz-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.dz-hint {
    font-size: 10.5px;
    color: var(--text-3);
    margin-top: 2px;
}

.divider-text {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-2);
}

/* Result box */
.result-box {
    background: var(--accent-bg);
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: var(--r-sm);
    padding: 10px;
    margin-top: 4px;
}

.result-box.warn {
    background: var(--amber-bg);
    border-color: rgba(217, 119, 6, 0.12);
}

.result-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 3px;
}

.result-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--text-1);
    line-height: 1.6;
    word-break: break-all;
}

/* ══════════════════════════════════════════════════════════
   CANVAS AREA
═══════════════════════════════════════════════════════════ */
.canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #FFFFFF;
}

/* Subtle dot grid */
.canvas-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
}

#cy {
    width: 100%;
    height: 100%;
}

/* Empty State */
.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.4s;
    z-index: 2;
}

.empty-state.hidden {
    opacity: 0;
}

.es-graphic {
    margin-bottom: 20px;
}

.es-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.es-desc {
    font-size: 13px;
    color: var(--text-3);
    text-align: center;
    max-width: 280px;
    line-height: 1.5;
}

/* Floating Toolbar */
.float-toolbar {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border-2);
    border-radius: var(--r-xl);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 7px;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.ft-btn {
    height: 30px;
    width: 30px;
    border-radius: var(--r-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--t) var(--ease);
}

.ft-btn:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

.ft-btn.active {
    background: var(--accent);
    color: #fff;
}

.ft-sep {
    width: 1px;
    height: 16px;
    background: var(--border-2);
    margin: 0 2px;
}

/* Progress Float */
.progress-float {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-2);
    border-radius: 999px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 20;
    min-width: 280px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.progress-info {
    flex: 1;
}

.progress-step {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
}

.progress-track {
    background: var(--surface-4);
    border-radius: 999px;
    height: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-alt));
    transition: width 0.3s var(--ease-out);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

.progress-pct {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
}

@keyframes shimmer {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(300%);
    }
}

/* Node Info Box */
#info-box {
    position: absolute;
    bottom: 64px;
    right: 18px;
    width: 240px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(12px) scale(0.97);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s var(--ease);
    z-index: 15;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

#info-box.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.ib-head {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
}

.ib-head h3 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
}

.ib-close {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-4);
    border: none;
    cursor: pointer;
    color: var(--text-3);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t);
}

.ib-close:hover {
    background: var(--red);
    color: #fff;
}

.ib-body {
    padding: 10px 12px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--text-2);
}

.ib-body div {
    margin-bottom: 3px;
}

/* ══════════════════════════════════════════════════════════
   RESULTS PANEL
═══════════════════════════════════════════════════════════ */
.results-panel {
    width: var(--results-w);
    min-width: var(--results-w);
    background: var(--bg-raised);
    border-left: 1px solid var(--border-2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.25s var(--ease);
    flex-shrink: 0;
}

.results-panel.open {
    transform: translateX(0);
}

.rp-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.rp-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rp-head-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rp-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.2px;
}

.rp-close-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    border: 1px solid var(--border-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    font-size: 11px;
    transition: all var(--t);
}

.rp-close-btn:hover {
    background: var(--red-bg);
    color: var(--red);
    border-color: rgba(220, 38, 38, 0.15);
}

/* Results Tabs */
.rp-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-2);
    padding: 0 6px;
    flex-shrink: 0;
    overflow-x: auto;
}

.rp-tabs::-webkit-scrollbar {
    display: none;
}

.rptab {
    padding: 9px 11px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all var(--t) var(--ease);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.rptab:hover {
    color: var(--text-2);
}

.rptab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.rp-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

/* Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    padding: 14px 12px;
    text-align: center;
    transition: all var(--t) var(--ease);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.stat-card.c-blue::before {
    background: var(--accent);
}

.stat-card.c-purple::before {
    background: var(--accent-alt);
}

.stat-card.c-teal::before {
    background: var(--teal);
}

.stat-card.c-amber::before {
    background: var(--amber);
}

.stat-card:hover {
    background: var(--surface-2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card.c-blue .stat-val {
    color: var(--accent);
}

.stat-card.c-purple .stat-val {
    color: var(--accent-alt);
}

.stat-card.c-teal .stat-val {
    color: var(--teal);
}

.stat-card.c-amber .stat-val {
    color: var(--amber);
}

.stat-lbl {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

/* Steps Log */
.steps-log {
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    padding: 12px;
}

.step-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 11.5px;
    color: var(--text-2);
    animation: fadeIn 0.3s var(--ease);
}

.step-row i {
    color: var(--green);
    font-size: 11px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-6px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Tab summary */
.tab-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-2);
}

/* Empty Tab */
.empty-tab {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-3);
}

.empty-tab i {
    font-size: 32px;
    display: block;
    margin-bottom: 14px;
    opacity: 0.3;
}

.empty-tab p {
    font-size: 12px;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.tag-blue {
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid rgba(37, 99, 235, 0.12);
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th {
    padding: 7px 10px;
    text-align: left;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-2);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-1);
    transition: background var(--t);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td {
    background: var(--accent-bg);
}

.mono-cell {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

.truncate-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.data-table.compact th {
    padding: 5px 8px;
}

.data-table.compact td {
    padding: 5px 8px;
}

/* Rank badges */
.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    background: var(--surface-3);
    color: var(--text-2);
    border: 1px solid var(--border-2);
}

.rank-top {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Enrichment Groups */
.enrichment-group {
    margin-bottom: 16px;
}

.eg-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.eg-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.eg-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-1);
}

/* Chart Cards */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    overflow: hidden;
    margin-bottom: 12px;
}

.chart-card:hover {
    border-color: var(--border-3);
}

.chart-card-head {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.chart-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-1);
}

.chart-sub {
    font-size: 10px;
    color: var(--text-3);
    margin-top: 1px;
}

.chart-actions {
    display: flex;
    gap: 4px;
}

.chart-body {
    padding: 10px 12px 12px;
    height: 320px;
    position: relative;
}

.chart-body canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Cluster Cards */
.cluster-card {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color var(--t), background var(--t);
}

.cluster-card:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.cluster-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.cluster-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-1);
}

.cluster-genes {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-3);
    line-height: 1.7;
}

/* ══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(70px);
    background: var(--bg-raised);
    border: 1px solid var(--border-2);
    color: var(--text-1);
    border-radius: var(--r-xl);
    padding: 9px 18px 9px 12px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-float);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: all 0.3s var(--ease);
    z-index: 9999;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border-color: rgba(220, 38, 38, 0.2);
}

.toast-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast:not(.error) .toast-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.toast.error .toast-dot {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

/* ══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg-raised);
    border: 1px solid var(--border-2);
    border-radius: var(--r-xl);
    width: min(640px, 92vw);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-float);
    transform: scale(0.95) translateY(8px);
    transition: transform 0.25s var(--ease);
}

.modal-overlay.open .modal-box {
    transform: scale(1) translateY(0);
}

.modal-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-head h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.3px;
}

.modal-body {
    padding: 18px 20px;
}

.doc-section {
    margin-bottom: 18px;
}

.doc-section h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.doc-section p {
    font-size: 12.5px;
    color: var(--text-2);
    line-height: 1.7;
}

.doc-section code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: var(--surface-3);
    color: var(--text-code);
    padding: 2px 5px;
    border-radius: var(--r-xs);
}

/* ── Utility Classes ── */
.flex-spacer {
    flex: 1;
}

.rp-icon {
    color: var(--accent);
    font-size: 14px;
}

.modal-icon {
    color: var(--accent);
    margin-right: 8px;
}

.u-hidden {
    display: none;
}

.file-input-hidden {
    display: none;
}

/* ── Spinner ── */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 260px;
        --results-w: 100vw;
    }

    .header-pills {
        display: none;
    }

    .results-panel {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
    }
}

@media (max-width: 600px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 40;
    }

    .logo-sub {
        display: none;
    }

    .pill-lbl {
        display: none;
    }

    .hbtn span:not(.spinner) {
        display: none;
    }
}