:root {
    --bg: #0a0e1a;
    --bg-card: #111827;
    --bg-elevated: #1a2235;
    --border: #1f2937;
    --border-light: #374151;
    --text: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --red-500: #ef4444;
    --red-300: #fca5a5;
    --blue-500: #3b82f6;
    --blue-300: #93c5fd;
    --green-400: #4ade80;
    --yellow-400: #facc15;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo h1 {
    font-size: 1rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

/* Upload */
.upload-area {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1.5rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--blue-500);
    background: rgba(59, 130, 246, 0.05);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.upload-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.upload-link {
    color: var(--blue-500);
    text-decoration: underline;
    cursor: pointer;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Heatmap */
.heatmap-section {
    margin-bottom: 1.5rem;
}

.heatmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.highlight-controls label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.highlight-controls input {
    accent-color: var(--blue-500);
}

.heatmap-container {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.heatmap-table {
    border-collapse: collapse;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.heatmap-table th {
    padding: 0.375rem 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.heatmap-table th.row-header {
    text-align: right;
}

.heatmap-cell {
    width: 52px;
    height: 44px;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.6875rem;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.heatmap-cell:hover {
    border-color: #fff;
    z-index: 2;
    transform: scale(1.05);
}

.heatmap-cell.strong {
    outline: 2px solid var(--yellow-400);
    outline-offset: -2px;
}

.heatmap-cell.sig {
    font-style: normal;
}

/* Legend */
.legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: center;
}

.legend-label {
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.legend-gradient {
    width: 200px;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #3b82f6, #1e293b, #ef4444);
}

/* Scatter */
.scatter-section {
    margin-bottom: 1.5rem;
}

.scatter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

#scatter-canvas {
    width: 100%;
    max-width: 600px;
    height: auto;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    display: block;
    margin: 0 auto;
}

.scatter-info {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-family: var(--font-mono);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
    .upload-area {
        padding: 2rem 1rem;
    }

    .heatmap-cell {
        width: 40px;
        height: 36px;
        font-size: 0.5625rem;
    }
}