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

:root {
    /* Teal trust palette (Soft UI Evolution) */
    --primary: #0f766e;
    --primary-dark: #115e59;
    --secondary: #134e4a;
    --accent: #0369a1;
    --accent-dark: #075985;
    --accent-green: #059669;
    --accent-red: #dc2626;
    --accent-amber: #b45309;

    --bg-page: #f0fdfa;
    --bg-white: #ffffff;
    --bg-muted: #e8f0f3;
    --text-primary: #134e4a;
    --text-secondary: #4b6360;
    --border: #99f6e4;
    --border-soft: #cbe9e4;

    /* Soft UI shadows — softer than flat, clearer than neumorphism */
    --shadow-sm: 0 1px 2px rgba(15, 118, 110, 0.06), 0 1px 3px rgba(15, 118, 110, 0.08);
    --shadow: 0 4px 16px rgba(15, 118, 110, 0.08), 0 2px 6px rgba(15, 118, 110, 0.06);
    --shadow-lg: 0 16px 48px rgba(15, 118, 110, 0.16), 0 6px 16px rgba(15, 118, 110, 0.10);
    --shadow-focus: 0 0 0 3px rgba(15, 118, 110, 0.18);

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;

    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-6: 48px;
    --space-8: 64px;

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
}

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: auto;
    padding: 0 var(--space-3);
}

/* ===== NAVBAR ===== */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    padding: var(--space-2) 0;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--primary);
}

.nav-brand i {
    font-size: 1.4rem;
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: var(--space-3);
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 6px 4px;
    position: relative;
    transition: color 0.2s ease;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--primary);
    transition: width 0.2s ease;
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-links a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ===== HERO ===== */
.hero {
    position: relative;
    text-align: center;
    padding: var(--space-8) 0 var(--space-6);
    background: linear-gradient(140deg, var(--secondary) 0%, var(--primary-dark) 55%, var(--accent-dark) 100%);
    color: white;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(20, 184, 166, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 85% 75%, rgba(3, 105, 161, 0.35) 0%, transparent 45%);
    pointer-events: none;
}

.hero .container {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: var(--space-2);
    letter-spacing: -1px;
}

.hero p {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    opacity: 0.9;
    margin-bottom: var(--space-3);
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.hero-badges {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

.badge i {
    opacity: 0.85;
}

/* ===== PREDICTION FORM ===== */
.prediction-section {
    padding: var(--space-8) 0;
}

.prediction-section h2,
.metrics-section h2,
.importance-section h2 {
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: var(--space-1);
    color: var(--text-primary);
}

.prediction-section > .container > h2 {
    margin-bottom: var(--space-4);
}

.prediction-form {
    background: var(--bg-white);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-3);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-soft);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    background: var(--bg-page);
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

.form-group input:hover,
.form-group select:hover {
    border-color: var(--border);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
    background: var(--bg-white);
}

.form-group input.input-error,
.form-group select.input-error {
    border-color: var(--accent-red);
    background: #fef2f2;
}

.field-error {
    font-size: 0.8rem;
    color: var(--accent-red);
    margin-top: 5px;
    min-height: 1em;
}

.form-error {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fef2f2;
    color: var(--accent-red);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-top: var(--space-2);
    font-size: 0.9rem;
    border: 1px solid #fecaca;
}

.btn-predict {
    width: 100%;
    margin-top: var(--space-3);
    padding: 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 4px 14px rgba(15, 118, 110, 0.28);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-predict:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(15, 118, 110, 0.35);
    filter: brightness(1.05);
}

.btn-predict:active {
    transform: translateY(0);
}

.btn-predict:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.btn-predict:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== LOADING ===== */
.loading-spinner {
    text-align: center;
    margin-top: var(--space-4);
    padding: var(--space-4);
}

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid var(--border-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-2);
}

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

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.warmup-note {
    font-size: 0.8rem !important;
    opacity: 0.6;
    margin-top: 4px;
}

/* ===== RESULT ===== */
.result-section {
    margin-top: var(--space-4);
    animation: result-in 0.4s ease both;
}

@keyframes result-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-card {
    position: relative;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.result-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.18) 0%, transparent 50%);
    pointer-events: none;
}

.result-card > * {
    position: relative;
    z-index: 1;
}

.result-card h3 {
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
    margin-bottom: var(--space-1);
}

.price-display {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: 700;
    margin: 8px 0;
    letter-spacing: -1.5px;
    line-height: 1;
}

.confidence-interval {
    font-size: 0.95rem;
    opacity: 0.92;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.confidence-badge {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.result-footer {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: var(--space-3);
}

.result-footer i {
    margin-right: 5px;
}

.btn-secondary {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.2s ease, transform 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.btn-secondary:focus-visible {
    outline: 2px solid white;
    outline-offset: 3px;
}

/* ===== METRICS / COMPARISON TABLE ===== */
.metrics-section {
    padding: var(--space-8) 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.98rem;
    margin-bottom: var(--space-4);
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.table-loading,
.importance-loading {
    text-align: center;
    padding: var(--space-4);
    color: var(--text-secondary);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-soft);
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    overflow: hidden;
}

.comparison-table th {
    background: var(--secondary);
    color: white;
    padding: 15px 18px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
}

.comparison-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.95rem;
}

.comparison-table tbody tr {
    transition: background 0.15s ease;
}

.comparison-table tbody tr:last-child td {
    border-bottom: none;
}

.comparison-table tbody tr:hover {
    background: var(--bg-page);
}

.comparison-table .best-row {
    background: #ecfdf5;
    font-weight: 600;
}

.comparison-table .best-row:hover {
    background: #d1fae5;
}

.comparison-table .rank-col {
    text-align: center;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}

.rank-1 { background: #fef3c7; color: #b45309; }
.rank-2 { background: #e5e7eb; color: #374151; }
.rank-3 { background: #cffafe; color: #0e7490; }
.rank-4 { background: #e0e7ff; color: #3730a3; }

.dataset-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: var(--space-3);
    padding: 14px 22px;
    background: var(--bg-page);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.dataset-note i {
    color: var(--primary);
}

/* ===== FEATURE IMPORTANCE ===== */
.importance-section {
    padding: var(--space-8) 0;
    background: var(--bg-page);
}

.importance-image-wrapper {
    max-width: 700px;
    margin: 0 auto;
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.importance-image {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-soft);
    background: var(--bg-white);
}

.importance-ranking {
    max-width: 500px;
    margin: var(--space-3) auto 0;
    padding: var(--space-3);
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-soft);
}

.importance-ranking h4 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: var(--space-1);
    color: var(--text-primary);
}

.importance-ranking ol {
    padding-left: 1.25rem;
}

.importance-ranking li {
    padding: 7px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ===== SERVER STATUS ===== */
.server-status {
    margin-top: var(--space-2);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 7px 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.5s ease;
}

.server-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.server-status.waking {
    background: rgba(255, 255, 255, 0.16);
    color: #fde68a;
}

.server-status.waking::before {
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.server-status.ready {
    background: rgba(255, 255, 255, 0.16);
    color: #6ee7b7;
}

.server-status.fade-out {
    opacity: 0;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--secondary);
    color: white;
    text-align: center;
    padding: var(--space-4) 0;
}

.footer .footer-title {
    font-family: var(--font-display);
    font-weight: 600;
    margin-bottom: 4px;
}

.footer p:last-child {
    opacity: 0.7;
    font-size: 0.9rem;
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .prediction-form {
        padding: var(--space-3);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .nav-brand span {
        font-size: 1rem;
    }

    .nav-links {
        gap: var(--space-2);
    }

    .comparison-table th,
    .comparison-table td {
        padding: 11px 13px;
        font-size: 0.85rem;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
