:root {
    --bg-main: #060a14;
    --bg-card: rgba(16, 22, 38, 0.75);
    --border-card: rgba(255, 255, 255, 0.08);
    --text-main: #f0f2f5;
    --text-muted: #6b7280;
    --accent: #4f8cff;
    --accent-hover: #3b74e5;
    --accent-glow: rgba(79, 140, 255, 0.25);
    --green: #22c55e;
    --green-muted: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-muted: rgba(239, 68, 68, 0.15);
    --gold: #facc15;
    --gold-muted: rgba(250, 204, 21, 0.1);
    --radius: 14px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Ambient background effect */
.bg-glow {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(79, 140, 255, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

/* ─── Header ─── */
header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.logo {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #ffffff 20%, #4f8cff 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    line-height: 1.1;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.15rem;
    margin-top: 0.6rem;
    font-weight: 400;
}

.supported-formats {
    color: rgba(107, 114, 128, 0.6);
    font-size: 0.8rem;
    margin-top: 0.4rem;
    letter-spacing: 0.3px;
}

/* ─── State Management ─── */
.hidden { display: none !important; }
.active { display: block; }

/* ─── Upload Section ─── */
#upload-section {
    max-width: 560px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 4.5rem 2rem;
    text-align: center;
    background: var(--bg-card);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    backdrop-filter: blur(12px);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    box-shadow: 0 0 40px var(--accent-glow), inset 0 0 40px rgba(79, 140, 255, 0.03);
    transform: translateY(-3px);
}

.upload-icon {
    margin-bottom: 1.2rem;
}

.upload-svg {
    color: var(--accent);
    opacity: 0.7;
    transition: opacity 0.3s;
}

.drop-zone:hover .upload-svg {
    opacity: 1;
}

.drop-zone h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.demo-trigger {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-card);
}

.demo-trigger p {
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}

/* ─── Buttons ─── */
button {
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    font-size: 1.1em;
}

.btn-primary {
    background: linear-gradient(135deg, #4f8cff, #3b74e5);
    color: white;
    padding: 0.75rem 1.6rem;
    font-size: 0.95rem;
    box-shadow: 0 4px 18px rgba(79, 140, 255, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 140, 255, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px solid var(--border-card);
    padding: 0.55rem 1.1rem;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ─── Loading ─── */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(79, 140, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    color: var(--text-muted);
    margin-top: 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
}

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

/* ─── Dashboard ─── */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border-card);
    animation: fadeIn 0.4s ease;
}

.dataset-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.dataset-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.section-divider {
    border: none;
    height: 1px;
    background-color: var(--border-card);
    margin: 1.5rem 0;
    width: 100%;
}

/* ─── Metrics Grid ─── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 900px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

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

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: visible;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

.metric-card:hover::before {
    opacity: 1;
}

/* Staggered fade-in animation */
.fade-up {
    opacity: 0;
    transform: translateY(16px);
    animation: fadeUp 0.45s ease forwards;
    animation-delay: calc(var(--delay, 0) * 60ms);
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.8px;
    line-height: 1.2;
}

.positive { color: var(--green); }
.negative { color: var(--red); }

/* ─── Pro Gating ─── */
.badge {
    background: var(--gold-muted);
    color: var(--gold);
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    font-weight: 700;
    border: 1px solid rgba(250, 204, 21, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pro-gate {
    border-color: rgba(250, 204, 21, 0.12);
    background: linear-gradient(145deg, rgba(16, 22, 38, 0.85), rgba(250, 204, 21, 0.03));
}

.pro-gate:hover {
    border-color: rgba(250, 204, 21, 0.3);
}

.blur-text {
    filter: blur(7px);
    user-select: none;
    opacity: 0.5;
}

/* ─── Charts ─── */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-top: -0.5rem;
}

.chart-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 18px;
    padding: 1.6rem 1.8rem 2.4rem;
    backdrop-filter: blur(10px);
}

.chart-wrapper h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.main-chart {
    height: 520px;
    position: relative;
}

.pro-gate-chart {
    position: relative;
    min-height: 180px;
    overflow: hidden;
}

.pro-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 20, 0.85);
    backdrop-filter: blur(12px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    padding: 0 2rem;
}

.pro-overlay-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    gap: 2rem;
}

.pro-overlay-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lock-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(250, 204, 21, 0.3));
    flex-shrink: 0;
}

.pro-overlay-text {
    text-align: left;
}

.pro-overlay h3 {
    color: var(--gold);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
}

.pro-desc {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-bottom: 0;
}

.btn-premium {
    background: linear-gradient(135deg, #facc15, #eab308);
    color: #000;
    padding: 0.7rem 1.8rem;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 28px;
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.3);
    letter-spacing: -0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-premium:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 25px rgba(250, 204, 21, 0.5);
}

/* ─── Footer ─── */
footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-card);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: rgba(107, 114, 128, 0.5);
}

.footer-brand {
    font-weight: 600;
    color: rgba(107, 114, 128, 0.7);
}

.footer-sep {
    opacity: 0.3;
}

/* ─── Pro Education Panels ─── */
.pro-edu-trigger {
    color: var(--gold);
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 2px;
    pointer-events: none;
}

.pro-unlocked .pro-edu-trigger {
    opacity: 0.6;
    pointer-events: auto;
}

.pro-edu-trigger:hover {
    opacity: 1 !important;
}

.pro-edu-panel {
    margin-top: 0.6rem;
    padding: 0.75rem 0.85rem;
    background: rgba(6, 10, 20, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    font-size: 0.72rem;
    line-height: 1.55;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    animation: eduFadeIn 0.2s ease;
}

@keyframes eduFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.pro-edu-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.pro-edu-panel p {
    margin: 0 0 0.45rem;
}

.pro-edu-panel em {
    color: var(--accent-blue);
    font-style: normal;
    font-weight: 500;
}

.pro-edu-note {
    margin-bottom: 0.45rem;
    font-size: 0.72rem;
}

.pro-edu-formula {
    background: rgba(255, 255, 255, 0.04);
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    margin-bottom: 0.45rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.pro-edu-formula code {
    color: var(--accent-blue);
    font-size: 0.68rem;
}

.pro-edu-hint {
    color: var(--text-muted);
    font-size: 0.62rem;
    opacity: 0.65;
}

.pro-edu-link {
    display: inline-block;
    color: var(--accent-blue);
    font-size: 0.72rem;
    text-decoration: none;
    font-weight: 500;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.pro-edu-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Scale indicators */
.pro-edu-scale {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.pro-edu-scale span {
    font-size: 0.62rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
}

.scale-bad {
    background: rgba(255, 75, 75, 0.12);
    color: var(--red);
}

.scale-ok {
    background: rgba(255, 200, 50, 0.1);
    color: var(--gold);
}

.scale-great {
    background: rgba(0, 230, 118, 0.1);
    color: var(--green);
}

/* ─── Heatmap Canvas ─── */
#heatmap-chart {
    width: 100%;
}

/* ─── Pro Unlocked State ─── */
.pro-unlocked .blur-text {
    filter: none;
    opacity: 1;
    user-select: auto;
    transition: filter 0.4s ease, opacity 0.4s ease;
}

.pro-unlocked .pro-gate {
    border-color: rgba(79, 140, 255, 0.2);
    background: linear-gradient(145deg, rgba(16, 22, 38, 0.85), rgba(79, 140, 255, 0.03));
    transition: border-color 0.4s ease, background 0.4s ease;
}

.pro-unlocked .pro-gate .badge {
    background: rgba(79, 140, 255, 0.15);
    color: var(--accent);
    border-color: rgba(79, 140, 255, 0.25);
}

.pro-unlocked .pro-overlay {
    display: none;
}

/* ─── Pro Overlay Right Column ─── */
.pro-overlay-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-have-key {
    background: none;
    border: none;
    color: rgba(250, 204, 21, 0.6);
    font-size: 0.72rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
    transition: color 0.2s;
}

.btn-have-key:hover {
    color: var(--gold);
}

/* ─── License Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.hidden { display: none; }

.modal-card {
    background: linear-gradient(165deg, rgba(16, 22, 38, 0.97), rgba(10, 14, 28, 0.98));
    border: 1px solid rgba(79, 140, 255, 0.15);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 440px;
    width: 100%;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(79, 140, 255, 0.05);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text-main); }

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 0.3rem;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.license-input-group {
    display: flex;
    gap: 0.5rem;
}

.license-input-group input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: 'Inter', monospace;
    font-size: 0.88rem;
    letter-spacing: 1px;
    outline: none;
    transition: border-color 0.2s;
}

.license-input-group input:focus {
    border-color: var(--accent);
}

.license-input-group input::placeholder {
    color: rgba(107, 114, 128, 0.4);
    letter-spacing: 2px;
}

.btn-activate {
    background: linear-gradient(135deg, #facc15, #eab308);
    color: #000;
    padding: 0.75rem 1.5rem;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-activate:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.3);
}

.btn-activate:disabled {
    opacity: 0.5;
    cursor: wait;
}

.license-status {
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
}

.license-status.hidden { display: none; }

.license-status.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.license-status.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.modal-footer-text {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 1.2rem;
    text-align: center;
}

.modal-footer-text a {
    color: var(--accent);
    text-decoration: none;
}

.modal-footer-text a:hover {
    text-decoration: underline;
}

.pro-unlocked .pro-gate:hover {
    border-color: rgba(79, 140, 255, 0.4);
}
