/* ================================================================
   CytoPeak Web – Clean, Light, Minimal Design
   Ascetic & intuitive. Maximum clarity, minimum noise.
   ================================================================ */

:root {
    /* Background */
    --bg-app: #fafbfc;
    --bg-surface: #ffffff;
    --bg-input: #f3f4f6;
    --bg-hover: #eef0f3;

    /* Borders */
    --border: #e5e7eb;
    --border-light: #f0f0f2;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    /* Phase colors - the ONLY vivid colors in the UI */
    --color-g1: #6A5ACD;
    --color-s: #E85D9C;
    --color-g2: #4169E1;
    --color-debris: #b0b0b0;
    --color-aggregates: #9370DB;

    /* Accent - very subtle indigo */
    --accent: #4f46e5;
    --accent-light: #eef2ff;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --danger: #dc2626;

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 48px;
    --radius: 8px;
    --radius-sm: 6px;

    --transition: 0.15s ease;
}

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

html {
    font-size: 13.5px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* --- Scrollbar (thin, muted) --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* --- Utility --- */
.hidden { display: none !important; }

/* Remove glass class effect - now just a clean panel */
.glass {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ================================================================
   LOADING SCREEN - clean, airy
   ================================================================ */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #FAFBFC;
}

/* ================================================================
   AUTH SCREEN - Gatekeeper
   ================================================================ */

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(250, 251, 252, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 360px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.auth-error {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--danger);
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.btn-logout:hover {
    background: var(--bg-hover);
    color: var(--danger);
    border-color: var(--danger);
}

.loading-logo-wrapper {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.loading-logo-wrapper .ring {
    width: 72px;
    height: 72px;
    margin-bottom: 8px;
}

.loading-title {
    font-size: 36px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin: 0;
}

.loading-title .sub {
    font-weight: 400;
    opacity: 0.7;
    margin-left: 2px;
}

.loading-subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.25em;
    opacity: 0.8;
    text-transform: uppercase;
    margin: 0;
}

.loading-progress-wrapper {
    position: absolute;
    bottom: 8vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.loading-status {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
    animation: pulse-text 2s infinite ease-in-out;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.loading-bar-container {
    width: 280px;
    height: 2px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7C4DFF, #22D3EE);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================
   HEADER - minimal strip
   ================================================================ */

.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo { font-size: 1.2rem; }

.header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header-divider {
    color: var(--border);
    font-weight: 200;
    font-size: 1rem;
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 400;
}

.author-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.author-link:hover {
    color: var(--accent);
    background: var(--accent-light);
}

/* ================================================================
   LAYOUT
   ================================================================ */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ================================================================
   SIDEBAR - clean, light
   ================================================================ */

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 14px;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-section { margin-bottom: 10px; }

.section-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-primary);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
}

/* File upload - clean bordered box */
.file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px dashed var(--border);
    transition: var(--transition);
    font-family: inherit;
}
.file-upload-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}
.file-upload-btn.loaded {
    border-style: solid;
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}

.file-info {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 5px;
    text-align: center;
}

/* Model selector */
.model-selector { margin-top: 12px; }

.field-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.segmented-control {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 1px;
}

.seg-btn {
    flex: 1;
    padding: 6px 4px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.seg-btn:hover {
    color: var(--text-primary);
}
.seg-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--text-primary);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background: #1f2937;
}

.btn-large {
    padding: 11px 14px;
    font-size: 0.9rem;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.export-group {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.export-group .btn {
    flex: 1;
    padding: 7px 8px;
    font-size: 0.75rem;
}

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

/* Logs */
.sidebar-logs {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.section-title-small {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.log-box {
    flex: 1;
    background: var(--bg-app);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: 'Inter', monospace;
    font-size: 0.68rem;
    line-height: 1.6;
    color: var(--text-muted);
    overflow-y: auto;
    min-height: 60px;
}

.log-entry { padding: 0; }
.log-entry.error { color: var(--danger); }
.log-entry.success { color: var(--success); }

/* ================================================================
   CONTENT
   ================================================================ */

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 14px;
    overflow: hidden;
    min-width: 0;
}

/* Current file banner */
.current-file-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
}

.current-file-banner .file-icon {
    font-size: 0.85rem;
}

.current-file-banner .file-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.charts-row {
    display: flex;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.chart-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

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

.chart-header h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 2px 7px;
    background: var(--bg-input);
    border-radius: 4px;
}
.chart-badge.good {
    color: var(--success);
    background: var(--success-light);
}
.chart-badge.warn {
    color: var(--warning);
    background: #fffbeb;
}
.chart-badge.active-gate {
    color: var(--accent);
    background: var(--accent-light);
}

/* Gate controls */
.gate-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-gate {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.btn-gate:hover:not(:disabled) {
    border-color: var(--text-muted);
    color: var(--text-primary);
}
.btn-gate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-gate.drawing {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.btn-gate-clear:hover:not(:disabled) {
    border-color: var(--danger);
    color: var(--danger);
}

/* ================================================================
   GATE PARAMETER SLIDERS - SybioLab style
   ================================================================ */

.gate-sliders-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
}

.gate-sliders-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 14px;
    border-bottom: 1px solid var(--border-light);
}

.gate-sliders-title {
    font-size: 0.63rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
}

.slider-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.69rem;
    font-weight: 500;
    color: var(--text-secondary);
    width: 88px;
    flex-shrink: 0;
    cursor: default;
    user-select: none;
}

/* Single neutral dot - no per-slider color */
.slider-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;   /* slate-400 */
    flex-shrink: 0;
}

/* Slider track - filled portion set via JS using #2563eb */
.gate-slider {
    flex: 1;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    /* background gradient updated by JS updateSliderFill() */
}
.gate-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    margin-top: -4px; /* center on 3px track: -(11-3)/2 */
    border-radius: 50%;
    background: #fff;
    border: 2px solid #2563eb;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(37,99,235,0.20);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.gate-slider:hover::-webkit-slider-thumb,
.gate-slider:active::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.gate-slider::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 2px;
}

/* Value badge - unified slate style */
.slider-val {
    font-size: 0.69rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
    min-width: 36px;
    text-align: center;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    background: #f1f5f9;   /* slate-100 */
    color: #475569;         /* slate-600 */
    border: 1px solid #e2e8f0;
}
/* Remove old color variants */
.slider-val.blue, .slider-val.purple, .slider-val.orange {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.slider-reset-row {
    display: flex;
    justify-content: flex-end;
    padding: 4px 14px 6px;
    border-top: 1px solid var(--border-light);
}

.btn-reset-gate {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 3px 10px;
    font-size: 0.64rem;
    font-weight: 500;
    color: #64748b;   /* slate-500 */
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    letter-spacing: 0.01em;
}
.btn-reset-gate:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}



.chart-container {
    flex: 1;
    min-height: 0;
    padding: 2px;
}

/* ================================================================
   DASHBOARD - calm, clean grid
   ================================================================ */

.dashboard {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    min-height: 100px;
}

.dash-section {
    flex: 1;
    padding: 10px 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dash-divider {
    width: 1px;
    background: var(--border-light);
    margin: 10px 0;
}

.dash-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-big .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.stat-big .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.stat-small {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 3px;
}

.stat-grid-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px 0;
}

.stat-label-sm {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-val-sm {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Phase cards - clean, color only on labels */
.phase-cards {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.phase-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 64px;
}

.phase-name {
    font-size: 0.78rem;
    font-weight: 600;
}

.phase-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}

/* ================================================================
   SPINNER - simple
   ================================================================ */

.analyzing-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(250, 251, 252, 0.75);
    border-radius: var(--radius);
    z-index: 10;
}

.analyzing-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
    /* Uwalniamy ruch przewijania dla wszystkiego ucinającego się poniżej pełnego układu stacjonarnego */
    body, html {
        overflow: auto;
    }
    .app {
        height: auto;
    }
    
    /* GŁÓWNY UKŁAD: Kładziemy Sidebar na całej szerokości a resztę aplikacji (wykresy) spuszczamy pod niego */
    .main-layout {
        flex-direction: column; 
        overflow: visible;
    }
    
    /* SIDEBAR (Teraz jako górny kokpit) */
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid var(--border);
        overflow-y: visible; /* Wyłączony zagnieżdżony ciasny scroll */
        padding-bottom: 24px; 
    }
    
    /* ZAWARTOŚĆ I WYKRESY (Teraz na uwalnioną pełną szerokość ekranu) */
    .content {
        overflow: visible;
        gap: 20px;
        padding-bottom: 40px;
    }
    
    /* Wykresy jeden pod drugim zamiast obok siebie */
    .charts-row { 
        flex-direction: column; 
    }
    
    .chart-container {
        min-height: 380px; /* Konkretna wysokość dla dotyku, by Plotly miał przestrzeń do renderowania osi na telefonie */
    }
    
    .chart-header {
        flex-wrap: wrap; /* Zabezpieczenie przed zgniataniem przycisków wykresu "Apply Gate" itd. */
        gap: 10px;
    }

    /* DASHBOARD DOLNY (Statystyki) */
    .dashboard { 
        flex-direction: column; 
        min-height: auto; 
    }
    .dash-divider { 
        width: auto; 
        height: 1px; 
        margin: 16px 8px; 
    }
    
    /* Uchronienie procentowych wartości Cell Cycle przed wyjazdem poza krawędzie bloku */
    .phase-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 500px) {
    /* Ekstremalne zawężania typowo i wyłącznie dla smartfonów */
    .header {
        height: auto;
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .header-left {
        flex-wrap: wrap;
        gap: 6px;
    }
    .header-divider {
        display: none; 
    }
}

/* ================================================================
   LOGO STYLES
   ================================================================ */

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 26px;
    color: var(--text-primary);
}

.ring {
    width: 44px;
    height: 44px;
}

.ring circle {
    stroke-linecap: round;
    stroke-dasharray: 10 10;
    animation: flow 6s linear infinite;
}

@keyframes flow {
    to { stroke-dashoffset: -20; }
}

.text {
    font-weight: 500;
    letter-spacing: -0.2px;
}

.sub {
    font-weight: 400;
    opacity: 0.7;
    margin-left: 6px;
}

/* === Cloud sync styles (prod) === */
.export-group .btn {
    flex: 1;
    padding: 7px 8px;
    font-size: 0.75rem;
}

/* Cloud sync toggle checkbox */
.cloud-sync-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    cursor: pointer;
    user-select: none;
}

.cloud-sync-toggle input[type="checkbox"] {
    display: none;
}

.cloud-sync-checkmark {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    background: var(--bg-app);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cloud-sync-toggle input:checked + .cloud-sync-checkmark {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.cloud-sync-toggle input:checked + .cloud-sync-checkmark::after {
    content: '';
    display: block;
    width: 4px;
    height: 7px;
    border: 1.5px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-0.5px, -1px);
}

.cloud-sync-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
    transition: var(--transition);
}

.cloud-sync-toggle:hover .cloud-sync-text {
    color: var(--text-secondary);
}

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


/* Logs */
.sidebar-logs {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.section-title-small {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.log-box {
    flex: 1;
    background: var(--bg-app);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: 'Inter', monospace;
    font-size: 0.68rem;
    line-height: 1.6;
    color: var(--text-muted);
    overflow-y: auto;
    min-height: 60px;
}

.log-entry { padding: 0; }
.log-entry.error { color: var(--danger); }
.log-entry.success { color: var(--success); }

/* ================================================================
   CONTENT
   ================================================================ */

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 14px;
    overflow: hidden;
    min-width: 0;
}

.charts-row {
    display: flex;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.chart-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

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

.chart-header h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 2px 7px;
    background: var(--bg-input);
    border-radius: 4px;
}
.chart-badge.good {
    color: var(--success);
    background: var(--success-light);
}
.chart-badge.warn {
    color: var(--warning);
    background: #fffbeb;
}
.chart-badge.active-gate {
    color: var(--accent);
    background: var(--accent-light);
}

/* Gate controls */
.gate-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-gate {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.btn-gate:hover:not(:disabled) {
    border-color: var(--text-muted);
    color: var(--text-primary);
}
.btn-gate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-gate.drawing {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.btn-gate-clear:hover:not(:disabled) {
    border-color: var(--danger);
    color: var(--danger);
}

.chart-container {
    flex: 1;
    min-height: 0;
    padding: 2px;
}

/* ================================================================
   DASHBOARD - calm, clean grid
   ================================================================ */

.dashboard {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    min-height: 100px;
}

.dash-section {
    flex: 1;
    padding: 10px 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dash-divider {
    width: 1px;
    background: var(--border-light);
    margin: 10px 0;
}

.dash-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-big .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.stat-big .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.stat-small {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 3px;
}

.stat-grid-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px 0;
}

.stat-label-sm {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-val-sm {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Phase cards - clean, color only on labels */
.phase-cards {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.phase-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 64px;
}

.phase-name {
    font-size: 0.78rem;
    font-weight: 600;
}

.phase-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}

/* ================================================================
   SPINNER - simple
   ================================================================ */

.analyzing-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(250, 251, 252, 0.75);
    border-radius: var(--radius);
    z-index: 10;
}

.analyzing-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
    /* Uwalniamy ruch przewijania dla wszystkiego ucinającego się poniżej pełnego układu stacjonarnego */
    body, html {
        overflow: auto;
    }
    .app {
        height: auto;
    }
    
    /* GŁÓWNY UKŁAD: Kładziemy Sidebar na całej szerokości a resztę aplikacji (wykresy) spuszczamy pod niego */
    .main-layout {
        flex-direction: column; 
        overflow: visible;
    }
    
    /* SIDEBAR (Teraz jako górny kokpit) */
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid var(--border);
        overflow-y: visible; /* Wyłączony zagnieżdżony ciasny scroll */
        padding-bottom: 24px; 
    }
    
    /* ZAWARTOŚĆ I WYKRESY (Teraz na uwalnioną pełną szerokość ekranu) */
    .content {
        overflow: visible;
        gap: 20px;
        padding-bottom: 40px;
    }
    
    /* Wykresy jeden pod drugim zamiast obok siebie */
    .charts-row { 
        flex-direction: column; 
    }
    
    .chart-container {
        min-height: 380px; /* Konkretna wysokość dla dotyku, by Plotly miał przestrzeń do renderowania osi na telefonie */
    }
    
    .chart-header {
        flex-wrap: wrap; /* Zabezpieczenie przed zgniataniem przycisków wykresu "Apply Gate" itd. */
        gap: 10px;
    }

    /* DASHBOARD DOLNY (Statystyki) */
    .dashboard { 
        flex-direction: column; 
        min-height: auto; 
    }
    .dash-divider { 
        width: auto; 
        height: 1px; 
        margin: 16px 8px; 
    }
    
    /* Uchronienie procentowych wartości Cell Cycle przed wyjazdem poza krawędzie bloku */
    .phase-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 500px) {
    /* Ekstremalne zawężania typowo i wyłącznie dla smartfonów */
    .header {
        height: auto;
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .header-left {
        flex-wrap: wrap;
        gap: 6px;
    }
    .header-divider {
        display: none; 
    }
}

/* ================================================================
   LOGO STYLES
   ================================================================ */

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 26px;
    color: var(--text-primary);
}

.ring {
    width: 44px;
    height: 44px;
}

.ring circle {
    stroke-linecap: round;
    stroke-dasharray: 10 10;
    animation: flow 6s linear infinite;
}

@keyframes flow {
    to { stroke-dashoffset: -20; }
}

.text {
    font-weight: 500;
    letter-spacing: -0.2px;
}

.sub {
    font-weight: 400;
    opacity: 0.7;
    margin-left: 6px;
}
