* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #eef7f2 0%, #f7fbff 50%, #f8f5ff 100%);
    color: #17202a;
}

.page-shell {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1.5rem;
}

.hero-card {
    width: 100%;
    max-width: 960px;
    background: rgba(255, 255, 255, 0.95);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(29, 78, 216, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.08);
}

.top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.reset-form, .feedback-form, .help-form {
    margin: 0;
}

.reset-button, .feedback-button, .help-button {
    padding: 0.85rem 1.15rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    white-space: nowrap;
}

.reset-button:hover {
    background: #e2e8f0;
}

h1, h2 {
    margin-top: 0;
}

h1 {
    color: #5aa469;
    font-size: clamp(3.75rem, 9vw, 6.75rem);
    line-height: 0.95;
    margin-bottom: 1rem;
    letter-spacing: -0.06em;
}

.subtitle {
    color: #334155;
    font-size: clamp(1.35rem, 3vw, 2rem);
    font-weight: 800;
    margin-bottom: 0.9rem;
}

h2 {
    font-size: 1.35rem;
    margin-bottom: 1.25rem;
}

.intro, .helper-text {
    color: #52616b;
    line-height: 1.5;
}

.intro {
    max-width: 700px;
    font-size: 1.05rem;
}

form {
    margin-top: 2rem;
}

.upload-panel, .settings-panel {
    border: 1px solid #dbe7ef;
    border-radius: 18px;
    background: #ffffff;
    padding: 1.5rem;
}

.upload-panel label, .field-group > label {
    display: block;
    font-weight: 800;
    margin-bottom: 0.65rem;
}

input[type="file"], select {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    font-size: 1rem;
}

.analysis-row, .stats-option-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.stats-option-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

button {
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
}

.analysis-button {
    min-height: 4.5rem;
    padding: 1rem;
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #bae6fd;
}

.analysis-button:hover:not(:disabled) {
    background: #bae6fd;
}

.secondary-analysis-button {
    width: 100%;
    margin-top: 0.5rem;
}

.active-option {
    background: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
}

.disabled-option {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.settings-panel {
    margin-top: 1.25rem;
}

.field-group {
    margin-bottom: 1.25rem;
}

.radio-row, .pivot-select-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.radio-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1rem;
    border: 1px solid #dbe7ef;
    border-radius: 14px;
    background: #f8fafc;
    cursor: pointer;
}

.pivot-table-panel {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #dbe7ef;
}

.pivot-output-panel, .statistical-output-panel {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.r-output {
    width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 14px;
    padding: 1rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.pivot-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.pivot-table th,
.pivot-table td {
    padding: 0.75rem;
    border: 1px solid #dbe7ef;
    text-align: left;
}

.pivot-table th {
    background: #f8fafc;
    font-weight: 800;
}

.submit-button {
    width: 100%;
    padding: 1rem 1.25rem;
    background: #2563eb;
    color: #ffffff;
}

.submit-button:hover {
    background: #1d4ed8;
}

.error {
    margin-top: 1rem;
    padding: 0.95rem;
    border-radius: 12px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.hidden {
    display: none;
}

@media (max-width: 760px) {
    .hero-card {
        padding: 1.5rem;
    }

    .top-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .reset-button {
        width: 100%;
    }

    .reset-form, .help-form, .feedback-form {
        width: 100%;
    }

    h1 {
        font-size: clamp(3rem, 16vw, 4.5rem);
    }

    .analysis-row, .stats-option-row, .radio-row, .pivot-select-row {
        grid-template-columns: 1fr;
    }
}
