/* ============================================
   PsyTest Platform - Main Stylesheet
   Mobile-first, responsive design
   ============================================ */

/* CSS Variables */
:root {
    /* Colors */
    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-secondary: #95a5a6;
    --color-success: #27ae60;
    --color-success-dark: #219a52;
    --color-warning: #f39c12;
    --color-danger: #e74c3c;
    --color-danger-dark: #c0392b;

    --color-bg: #f8f9fa;
    --color-bg-white: #ffffff;
    --color-text: #2c3e50;
    --color-text-light: #7f8c8d;
    --color-border: #e0e0e0;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Layout */
    --container-max-width: 1200px;
    --header-height: 60px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ============================================
   Header
   ============================================ */
.site-header {
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    color: var(--color-text);
    font-weight: 600;
    font-size: var(--font-size-xl);
}

.logo-icon {
    font-size: 1.5em;
}

.header-nav {
    display: flex;
    gap: var(--spacing-md);
}

.nav-link {
    text-decoration: none;
    color: var(--color-text-light);
    font-weight: 500;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--color-primary);
    background: var(--color-bg);
}

/* ============================================
   Main Content
   ============================================ */
.site-main {
    flex: 1;
    padding: var(--spacing-xl) 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-base);
    font-weight: 500;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-bg-white);
    color: var(--color-text);
    border-color: var(--color-border);
}

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

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--color-success-dark);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-danger-dark);
}

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

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

.btn-block {
    width: 100%;
}

/* Owner dashboard: intentionally small and separate from the public catalog. */
.owner-panel {
    max-width: 720px;
    margin: var(--spacing-xl) auto;
    padding: var(--spacing-xl);
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.owner-login-panel {
    max-width: 440px;
}

.owner-panel-eyebrow {
    margin: 0 0 var(--spacing-xs);
    color: var(--color-primary);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.owner-panel h1,
.owner-panel h2 {
    margin-top: 0;
}

.owner-panel-intro,
.owner-help {
    color: var(--color-text-light);
    line-height: 1.6;
}

.owner-form,
.owner-action-form {
    display: grid;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
}

.owner-form label,
.owner-delete-form label {
    font-weight: 600;
}

.owner-form input[type="text"],
.owner-form input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
}

.owner-notice {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}

.owner-notice--success {
    background: #edf8f1;
    color: #17693a;
}

.owner-notice--error {
    background: #fff0f0;
    color: #a32929;
}

.owner-case {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.owner-case-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.owner-case-details div {
    min-width: 0;
}

.owner-case-details dt {
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.owner-case-details dd {
    margin: 0.25rem 0 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.owner-logout {
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}

@media (max-width: 600px) {
    .owner-panel {
        margin: var(--spacing-md) 0;
        padding: var(--spacing-lg);
    }

    .owner-case-details {
        grid-template-columns: 1fr;
    }
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-sm);
}

/* ============================================
   Tests List Page
   ============================================ */
.tests-list-wrapper {
    max-width: 1000px;
    margin: 0 auto;
}

.page-header {
    text-align: center;
    margin-bottom: var(--spacing-xxl);
}

.page-title {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.page-description {
    font-size: var(--font-size-lg);
    color: var(--color-text-light);
}

.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-lg);
}

.test-card {
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.test-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.test-card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.test-card-title {
    font-size: var(--font-size-xl);
    color: var(--color-text);
}

.test-card-body {
    padding: var(--spacing-lg);
}

.test-card-description {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-md);
    line-height: 1.6;
}

.test-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-bg);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
}

.meta-badge-pair {
    background: #e8f4fd;
    color: var(--color-primary);
}

.test-card-scales {
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

.test-card-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.empty-state {
    text-align: center;
    padding: var(--spacing-xxl);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

/* ============================================
   Test Taking Page
   ============================================ */
.test-wrapper {
    max-width: 820px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

.test-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.test-title {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-sm);
}

.test-description {
    font-size: var(--font-size-lg);
    color: var(--color-text-light);
    margin-bottom: var(--spacing-lg);
}

.test-meta {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-text-light);
}

.meta-icon {
    font-size: 1.2em;
}

/* Progress Bar */
.progress-container {
    position: sticky;
    top: var(--header-height);
    background: var(--color-bg-white);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    min-width: 60px;
    text-align: right;
}

/* Test Form */
.test-form {
    margin-top: var(--spacing-xl);
}

.questions-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.question-card {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.question-text {
    font-size: var(--font-size-lg);
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.answer-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.answer-option:hover {
    background: var(--color-bg);
}

.answer-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.option-text {
    font-size: var(--font-size-base);
    color: var(--color-text);
}

/* Ternary Answer Options (SMIL) */
.answer-options.has-ternary {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.answer-option.answer-true {
    border: 2px solid #27ae60;
    background: rgba(39, 174, 96, 0.05);
}

.answer-option.answer-true:hover {
    background: rgba(39, 174, 96, 0.15);
}

.answer-option.answer-true input[type="radio"]:checked+.option-text {
    color: #27ae60;
    font-weight: 600;
}

.answer-option.answer-false {
    border: 2px solid #e74c3c;
    background: rgba(231, 76, 60, 0.05);
}

.answer-option.answer-false:hover {
    background: rgba(231, 76, 60, 0.15);
}

.answer-option.answer-false input[type="radio"]:checked+.option-text {
    color: #e74c3c;
    font-weight: 600;
}

.answer-option.answer-unknown {
    border: 2px solid #95a5a6;
    background: rgba(149, 165, 166, 0.05);
}

.answer-option.answer-unknown:hover {
    background: rgba(149, 165, 166, 0.15);
}

.answer-option.answer-unknown input[type="radio"]:checked+.option-text {
    color: #7f8c8d;
    font-weight: 600;
}

/* Test Navigation */
.test-navigation {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    position: sticky;
    bottom: var(--spacing-md);
}

/* Completion Notice */
.completion-notice {
    text-align: center;
    padding: var(--spacing-xxl);
}

.notice-icon {
    font-size: 5rem;
    margin-bottom: var(--spacing-md);
}

/* ============================================
   Results Page
   ============================================ */
.results-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.results-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.clinical-safety-notice {
    margin: 0 0 var(--spacing-xl);
    padding: var(--spacing-lg);
    color: #7c2d12;
    background: #fff7ed;
    border: 2px solid #c2410c;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.clinical-safety-notice__title {
    margin: 0 0 var(--spacing-sm);
    color: inherit;
    font-size: 1.25rem;
}

.clinical-safety-notice__message {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
}

.results-title {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-sm);
}

.results-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-text-light);
}

.results-meta {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
    color: var(--color-text-light);
}

.results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-bottom: var(--spacing-xl);
}

.results-content {
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

/* Results Sections */
.results-section {
    margin-bottom: var(--spacing-xl);
}
.results-section:last-child {
    margin-bottom: 0;
}
.section-title {
    font-size: 1.1rem;
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-md) 0;
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--color-border);
}

/* Score Badge — visual scale for BDI/HADS/BAI */
.score-badge {
    text-align: center;
}
.score-badge__header {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}
.score-badge__number {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1;
}
.score-badge__divider {
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--color-text-secondary);
}
.score-badge__level {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 4px 16px;
    border-radius: var(--radius-pill, 100px);
    line-height: 1.4;
}
.score-badge--normal .score-badge__level {
    background: #e8f5e9;
    color: #2e7d32;
}
.score-badge--minimal .score-badge__level {
    background: #e8f5e9;
    color: #2e7d32;
}
.score-badge--mild .score-badge__level,
.score-badge--subclinical .score-badge__level {
    background: #fff3e0;
    color: #e65100;
}
.score-badge--moderate .score-badge__level,
.score-badge--clinical .score-badge__level {
    background: #fce4ec;
    color: #c62828;
}
.score-badge--severe .score-badge__level,
.score-badge--high .score-badge__level {
    background: #f3e5f5;
    color: #6a1b9a;
}

/* Scale bar with threshold zones */
.score-badge__scale {
    position: relative;
    display: flex;
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    margin: 0 auto 6px;
    max-width: 500px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}
.score-badge__zone {
    height: 100%;
    position: relative;
    border-right: 1px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
}
.score-badge__zone:last-child {
    border-right: none;
}
.score-badge__zone--normal,
.score-badge__zone--minimal {
    background: #66bb6a;
}
.score-badge__zone--mild,
.score-badge__zone--subclinical {
    background: #ffa726;
}
.score-badge__zone--moderate,
.score-badge__zone--clinical {
    background: #ef5350;
}
.score-badge__zone--severe,
.score-badge__zone--high {
    background: #ab47bc;
}

/* BAI override: green → orange → red (no purple) */
.test-beck-anxiety .score-badge__zone--moderate {
    background: #ffa726;
}
.test-beck-anxiety .score-badge__zone--high {
    background: #ef5350;
}
.test-beck-anxiety .score-badge--moderate .score-badge__level {
    background: #fff3e0;
    color: #e65100;
}
.test-beck-anxiety .score-badge--high .score-badge__level {
    background: #fce4ec;
    color: #c62828;
}

/* Lazarus override: red (dissatisfied) → green (satisfied) */
.score-badge__zone--dissatisfied {
    background: #ef5350;
}
.score-badge__zone--satisfied {
    background: #66bb6a;
}
.score-badge--dissatisfied .score-badge__level {
    background: #fce4ec;
    color: #c62828;
}
.score-badge--satisfied .score-badge__level {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Marker — visible pointer on the scale */
.score-badge__marker {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 3px;
    background: #2c3e50;
    border-radius: 2px;
    transform: translateX(-50%);
    z-index: 2;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Scale labels below the bar */
.score-badge__scale-labels {
    display: flex;
    max-width: 500px;
    margin: 0 auto var(--spacing-lg);
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}
.score-badge__scale-label {
    flex-shrink: 0;
}

.score-badge__description {
    margin: var(--spacing-sm) 0 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}


/* SMIL Results Specific */
.smil-results {
    width: 100%;
}

.smil-invalid .alert {
    padding: var(--spacing-lg);
    background: #fef3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-md);
}

.validity-section {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.validity-section h3 {
    margin-bottom: var(--spacing-md);
}

.validity-indicators {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.indicator {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.indicator .label {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
}

.indicator .value {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
}

.validity-status {
    font-weight: 600;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    display: inline-block;
}

.status-valid .validity-status {
    background: #d4edda;
    color: #155724;
}

.status-invalid .validity-status {
    background: #f8d7da;
    color: #721c24;
}

/* Profile Chart */
.profile-chart-container {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.profile-chart-container h3 {
    margin-bottom: var(--spacing-md);
}

/* Scores Table */
.scores-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-xl);
}

.scores-table th,
.scores-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.scores-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text);
}

.scores-table .score {
    font-weight: 600;
    font-size: var(--font-size-lg);
}

.level-low {
    background: #e3f2fd;
}

.level-normal {
    background: #e8f5e9;
}

.level-elevated {
    background: #fff3e0;
}

.level-high {
    background: #ffebee;
}

.level-very_high {
    background: #fce4ec;
}

/* Interpretation Section */
.interpretation-section {
    padding: var(--spacing-lg);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.interpretation-block {
    background: var(--color-bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.interpretation-text {
    line-height: 1.8;
    color: var(--color-text);
}

.interpretation-text h3 {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.interpretation-text ul {
    margin-left: var(--spacing-lg);
}

/* Disclaimer */
.results-disclaimer {
    padding: var(--spacing-lg);
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: #856404;
}

/* Pair Comparison */
.pair-comparison {
    background: var(--color-bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
    background: var(--color-bg-white);
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-xl) 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
}

.footer-info p {
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

.footer-disclaimer {
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

.footer-links {
    display: flex;
    gap: var(--spacing-md);
}

.footer-link {
    color: var(--color-text-light);
    text-decoration: none;
    font-size: var(--font-size-sm);
}

.footer-link:hover {
    color: var(--color-primary);
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--color-bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: var(--spacing-md);
}

.modal-content p {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-lg);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.modal-danger .btn-danger {
    order: 2;
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
    position: fixed;
    bottom: var(--spacing-xl);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
}

/* ============================================
   Error Page
   ============================================ */
.error-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.error-content {
    text-align: center;
}

.error-icon {
    font-size: 6rem;
    font-weight: 700;
    color: var(--color-secondary);
    margin-bottom: var(--spacing-md);
}

.error-title {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-sm);
}

.error-message {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-xl);
}

.error-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    :root {
        --font-size-3xl: 1.75rem;
    }

    .header-nav {
        display: none;
    }

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

    .test-meta {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .answer-options {
        flex-direction: column;
    }

    .test-navigation {
        flex-direction: column;
    }

    .test-navigation .btn {
        width: 100%;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        width: 100%;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .validity-indicators {
        grid-template-columns: 1fr 1fr;
    }

    .scores-table {
        font-size: var(--font-size-sm);
    }

    .scores-table th,
    .scores-table td {
        padding: var(--spacing-xs);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-sm);
    }

    .validity-indicators {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {

    .site-header,
    .site-footer,
    .results-actions,
    .test-navigation,
    .progress-container,
    .demographics-section {
        display: none !important;
    }

    .site-main {
        padding: 0;
    }

    .results-wrapper,
    .test-wrapper {
        max-width: 100%;
    }

    .results-content,
    .interpretation-block {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ============================================
   Demographics Section
   ============================================ */
.demographics-section {
    background: var(--color-bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 500px;
    margin: var(--spacing-xl) auto;
}

.demographics-title {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.demographics-subtitle {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-lg);
}

.demographics-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.demographic-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.demographic-option:hover {
    border-color: var(--color-primary);
    background: var(--color-bg);
}

.demographic-option input[type="radio"] {
    display: none;
}

.demographic-option:has(input:checked) {
    border-color: var(--color-primary);
    background: #e8f4fd;
}

.option-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
}

.option-label {
    font-weight: 500;
    color: var(--color-text);
}

.age-input-group {
    margin-bottom: var(--spacing-lg);
}

.age-input-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.age-input-group input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
}

.age-input-group small {
    display: block;
    margin-top: var(--spacing-xs);
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

/* ============================================
   BAI Results Styles
   ============================================ */
.bai-results {
    max-width: 800px;
    margin: 0 auto;
}

.bai-results .results-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.bai-results .test-subtitle {
    color: var(--color-text-light);
    font-size: var(--font-size-lg);
}

.bai-results .score-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.bai-results .score-main {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--spacing-sm);
}

.bai-results .score-value {
    font-size: 4rem;
    font-weight: 700;
}

.bai-results .score-max {
    font-size: var(--font-size-xl);
    opacity: 0.9;
}

.bai-results .score-percentage {
    font-size: var(--font-size-lg);
    margin-top: var(--spacing-sm);
    opacity: 0.9;
}

.bai-results .score-level {
    margin-top: var(--spacing-md);
    font-size: var(--font-size-xl);
    font-weight: 600;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    display: inline-block;
}

.bai-results .severity-scale-container {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.bai-results .severity-scale {
    display: flex;
    height: 40px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: var(--spacing-lg) 0;
    position: relative;
}

.bai-results .scale-segment {
    height: 100%;
}

.bai-results .scale-segment.minimal {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.bai-results .scale-segment.moderate {
    background: linear-gradient(90deg, #f39c12, #f1c40f);
}

.bai-results .scale-segment.high {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.bai-results .scale-marker {
    position: absolute;
    top: -5px;
    width: 4px;
    height: 50px;
    background: #2c3e50;
    transform: translateX(-50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.bai-results .scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    margin-top: var(--spacing-sm);
}

.bai-results .scale-legend {
    margin-top: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.bai-results .legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

.bai-results .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.bai-results .dot.minimal {
    background: #27ae60;
}

.bai-results .dot.moderate {
    background: #f39c12;
}

.bai-results .dot.high {
    background: #e74c3c;
}

.bai-results .interpretation-card,
.bai-results .symptoms-card,
.bai-results .recommendations-card {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.bai-results .interpretation-card h3,
.bai-results .symptoms-card h3,
.bai-results .recommendations-card h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.bai-results .symptoms-note {
    margin-top: -0.5em;
    margin-bottom: var(--spacing-md);
    color: var(--color-text-light);
}

.bai-results .interpretation-text {
    font-size: var(--font-size-lg);
    line-height: 1.6;
    color: var(--color-text);
}

.bai-results .symptoms-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bai-results .symptoms-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.bai-results .symptoms-list li:last-child {
    border-bottom: none;
}

.bai-results .symptom-name {
    flex: 1;
    color: var(--color-text);
}

.bai-results .symptom-score {
    font-weight: 600;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}

.bai-results .symptom-score.high {
    background: #ffebee;
    color: #c0392b;
}

.bai-results .symptom-score.moderate {
    background: #fff3e0;
    color: #f39c12;
}

.bai-results .symptom-score.low {
    background: #e8f5e9;
    color: #27ae60;
}

.bai-results .recommendations-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bai-results .recommendations-list li {
    padding: var(--spacing-sm) 0;
    padding-left: var(--spacing-lg);
    position: relative;
    color: var(--color-text);
}

.bai-results .recommendations-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--color-success);
    font-weight: 600;
}

.bai-results .disclaimer-card {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: #856404;
}

.bai-results .disclaimer-card p {
    margin: 0;
    line-height: 1.6;
}

/* ============================================
   SMIL Results Styles
   ============================================ */
.smil-results {
    max-width: 1000px;
    margin: 0 auto;
}

.smil-results .validity-section {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .validity-section h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.smil-results .validity-indicators {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.smil-results .indicator {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.smil-results .indicator .label {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    font-weight: 500;
}

.smil-results .indicator .value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text);
}

.smil-results .validity-status {
    font-weight: 600;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    display: inline-block;
    margin-bottom: var(--spacing-md);
}

.status-valid .validity-status {
    background: #d4edda;
    color: #155724;
}

.status-invalid .validity-status {
    background: #f8d7da;
    color: #721c24;
}

.smil-results .validity-warnings {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

.smil-results .validity-warnings ul {
    margin: 0;
    padding-left: var(--spacing-md);
}

.smil-results .validity-warnings li {
    color: #856404;
    margin-bottom: var(--spacing-xs);
}

.smil-results .indices-section {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .indices-section h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
}

.smil-results .indices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
}

.smil-results .index-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.smil-results .index-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
}

.smil-results .index-value {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

.smil-results .profile-chart-container {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .profile-chart-container h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
}

.smil-results .scores-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-xl);
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.smil-results .scores-table th,
.smil-results .scores-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.smil-results .scores-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text);
    position: sticky;
    top: 0;
}

.smil-results .scores-table .score {
    font-weight: 700;
    font-size: var(--font-size-lg);
    text-align: center;
}

.smil-results .scores-table tr.level-low {
    background: #e3f2fd;
}

.smil-results .scores-table tr.level-normal {
    background: #e8f5e9;
}

.smil-results .scores-table tr.level-elevated {
    background: #fff3e0;
}

.smil-results .scores-table tr.level-high {
    background: #ffebee;
}

.smil-results .scores-table tr.level-very_high {
    background: #fce4ec;
}

.smil-results .interpretation-section {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .interpretation-section h3,
.smil-results .interpretation-section h4 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.smil-results .interpretation-section p {
    line-height: 1.6;
    color: var(--color-text);
}

.smil-results .interpretation-section ul {
    margin-left: var(--spacing-lg);
}

.smil-results .interpretation-section li {
    margin-bottom: var(--spacing-xs);
    color: var(--color-text);
}

.smil-results .smil-invalid .alert {
    padding: var(--spacing-lg);
    background: #fef3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-md);
}

.smil-results .smil-invalid h3 {
    margin-top: 0;
    color: #856404;
}

.smil-results .smil-invalid p {
    color: #856404;
}

/* Detailed Report Styles */
.smil-results .report-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xl);
}

.smil-results .report-header h2 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-2xl);
}

.smil-results .report-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.smil-results .meta-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.smil-results .meta-item .label {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

.smil-results .meta-item .value {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.smil-results .scores-section {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .scores-section h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.smil-results .section-note {
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
}

.smil-results .scores-table.raw-scores,
.smil-results .scores-table.t-scores {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-white);
}

.smil-results .scores-table th {
    background: var(--color-bg);
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
}

.smil-results .scores-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.smil-results .scores-table .score {
    font-weight: 700;
    font-size: var(--font-size-lg);
    text-align: center;
}

.smil-results .scores-table .corrected {
    background: #e8f4fd;
    font-weight: 700;
}

.smil-results .scores-table .description {
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

.smil-results .k-correction-note {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: #f8f9fa;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
}

.smil-results .k-correction-note p {
    margin: 0;
    color: var(--color-text);
    font-size: var(--font-size-sm);
}

.smil-results .clinical-scales-detail {
    margin-bottom: var(--spacing-xl);
}

.smil-results .clinical-scales-detail h3 {
    margin-bottom: var(--spacing-lg);
}

.smil-results .scale-detail-card {
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    border-left: 4px solid var(--color-border);
}

.smil-results .scale-detail-card.level-low {
    border-left-color: #3498db;
}

.smil-results .scale-detail-card.level-normal {
    border-left-color: #27ae60;
}

.smil-results .scale-detail-card.level-elevated {
    border-left-color: #f39c12;
}

.smil-results .scale-detail-card.level-high {
    border-left-color: #e67e22;
}

.smil-results .scale-detail-card.level-very_high {
    border-left-color: #e74c3c;
}

.smil-results .scale-header {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--color-bg);
    gap: var(--spacing-md);
}

.smil-results .scale-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: var(--font-size-lg);
}

.smil-results .scale-info {
    flex: 1;
}

.smil-results .scale-info h4 {
    margin: 0 0 var(--spacing-xs) 0;
    font-size: var(--font-size-base);
    color: var(--color-text);
}

.smil-results .scale-score {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
}

.smil-results .scale-interpretation {
    padding: var(--spacing-md);
}

.smil-results .scale-interpretation p {
    margin: 0;
    line-height: 1.6;
    color: var(--color-text);
}

.smil-results .profile-type-section {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .profile-type-section h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-lg);
}

.smil-results .profile-type-card,
.smil-results .code-type-card {
    background: #f8f9fa;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.smil-results .profile-type-card h4,
.smil-results .code-type-card h4 {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.smil-results .profile-type-card p,
.smil-results .code-type-card p {
    margin: 0;
    color: var(--color-text-light);
    line-height: 1.6;
}

.smil-results .dominant-scales {
    margin-top: var(--spacing-lg);
}

.smil-results .dominant-scales h4 {
    margin-bottom: var(--spacing-md);
}

.smil-results .dominant-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.smil-results .dominant-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-md);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.smil-results .scale-badge {
    font-weight: 600;
    color: var(--color-text);
}

.smil-results .score-value {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
}

.smil-results .recommendations-section {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .recommendations-section h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-lg);
}

.smil-results .recommendations-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--spacing-lg) 0;
}

.smil-results .recommendation-item {
    padding: var(--spacing-sm) 0;
    color: var(--color-text);
    line-height: 1.6;
    border-bottom: 1px solid var(--color-border);
}

.smil-results .recommendation-item:last-child {
    border-bottom: none;
}

.smil-results .disclaimer-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

.smil-results .disclaimer-box p {
    margin: 0;
    color: #856404;
    line-height: 1.6;
    font-size: var(--font-size-sm);
}

/* Additional Scales Styles */
.smil-results .additional-scales {
    margin-top: var(--spacing-xl);
}

.smil-results .additional-scales h4 {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    color: var(--color-primary);
    font-size: var(--font-size-lg);
}

.smil-results .scores-table.additional-scores {
    font-size: var(--font-size-sm);
}

.smil-results .scores-table.additional-scores th {
    font-size: var(--font-size-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
}

.smil-results .scores-table.additional-scores td {
    padding: var(--spacing-xs) var(--spacing-sm);
}

.smil-results .scores-table.additional-scores .score {
    font-size: var(--font-size-base);
}

.smil-results .scores-table.additional-scores .description {
    font-size: var(--font-size-xs);
    color: var(--color-text-light);
}

/* Profile Chart Styles */
.smil-results .profile-chart-container {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .profile-chart-container h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.smil-results .chart-wrapper {
    position: relative;
    height: 300px;
    margin-bottom: var(--spacing-md);
}

.smil-results .chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    justify-content: center;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.smil-results .legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.smil-results .legend-color {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.smil-results .legend-color.low {
    background: #3498db;
}

.smil-results .legend-color.normal {
    background: #27ae60;
}

.smil-results .legend-color.elevated {
    background: #f39c12;
}

.smil-results .legend-color.high {
    background: #e67e22;
}

.smil-results .legend-color.very-high {
    background: #e74c3c;
}

/* Additional Scales Accordion */
.smil-results .scale-accordion {
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.smil-results .scale-accordion-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-bg);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text);
    transition: background 0.2s;
}

.smil-results .scale-accordion-header:hover {
    background: #f0f0f0;
}

.smil-results .category-icon {
    font-size: 1.2em;
}

.smil-results .category-title {
    flex: 1;
}

.smil-results .category-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    font-weight: 400;
}

.smil-results .scale-accordion-content {
    padding: 0;
    background: var(--color-bg-white);
}

.smil-results .scale-accordion-content table {
    margin: 0;
    border-radius: 0;
}

.smil-results details[open] .scale-accordion-header {
    background: var(--color-primary);
    color: white;
}

.smil-results details[open] .category-count {
    color: rgba(255, 255, 255, 0.8);
}

/* Raw Scores Accordion */
.smil-results .raw-scores-accordion {
    margin-bottom: var(--spacing-xl);
}

.smil-results .scores-accordion-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-bg);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text);
    transition: background 0.2s;
    list-style: none;
}

.smil-results .scores-accordion-header:hover {
    background: #f0f0f0;
}

.smil-results .scores-accordion-content {
    padding: 0;
    background: var(--color-bg-white);
}

.smil-results .scores-accordion-content table {
    margin: 0;
    border-radius: 0;
}

.smil-results details[open] .scores-accordion-header {
    background: var(--color-primary);
    color: white;
}

/* Visual Scale Indicator */
.smil-results .visual-scale {
    background: var(--color-bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

.smil-results .scale-zones {
    display: flex;
    height: 60px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    margin-bottom: var(--spacing-md);
}

.smil-results .scale-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    transition: opacity 0.3s;
}

.smil-results .scale-zone.low {
    flex: 0 0 15%;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.smil-results .scale-zone.normal {
    flex: 1;
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
}

.smil-results .scale-zone.high {
    flex: 1;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.smil-results .scale-zone.very-high {
    flex: 0 0 15%;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.smil-results .scale-zone .zone-label {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.smil-results .scale-zone .zone-range {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

.smil-results .scale-marker {
    position: relative;
    height: 40px;
    margin-bottom: var(--spacing-md);
}

.smil-results .scale-marker::before {
    content: '';
    position: absolute;
    left: var(--marker-position);
    top: 0;
    width: 4px;
    height: 100%;
    background: #2c3e50;
    transform: translateX(-50%);
    border-radius: var(--radius-sm);
}

.smil-results .scale-marker::after {
    content: '';
    position: absolute;
    left: var(--marker-position);
    top: -8px;
    width: 20px;
    height: 20px;
    background: #e74c3c;
    border: 3px solid white;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.smil-results .marker-value {
    position: absolute;
    left: var(--marker-position);
    top: -35px;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--font-size-sm);
    white-space: nowrap;
}

.smil-results .scale-legend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--color-border);
}

/* Results Navigation */
.smil-results .results-navigation {
    position: sticky;
    top: var(--header-height);
    background: var(--color-bg-white);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    z-index: 100;
}

.smil-results .results-navigation .nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.smil-results .results-navigation .nav-link:hover {
    background: var(--color-primary);
    color: white;
    transform: translateY(-2px);
}

/* Scale Indicator Wrapper */
.smil-results .scale-indicator-wrapper {
    background: var(--color-bg);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.smil-results .scale-indicator-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.smil-results .scale-code {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: var(--font-size-base);
}

.smil-results .scale-name {
    flex: 1;
    font-weight: 600;
    color: var(--color-text);
}

.smil-results .scale-value {
    font-weight: 700;
    font-size: var(--font-size-lg);
    color: var(--color-primary);
}

.smil-results .visual-scale-container {
    min-height: 100px;
}

/* Compact T-Scores Table */
.smil-results .t-scores-compact {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.smil-results .t-scores-compact th {
    background: var(--color-bg);
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
}

.smil-results .t-scores-compact td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.smil-results .t-scores-compact .score-value {
    font-weight: 700;
    font-size: var(--font-size-lg);
    color: var(--color-primary);
}

.smil-results .t-scores-compact tr.level-low {
    background: #e3f2fd;
}

.smil-results .t-scores-compact tr.level-normal {
    background: #e8f5e9;
}

.smil-results .t-scores-compact tr.level-elevated {
    background: #fff3e0;
}

.smil-results .t-scores-compact tr.level-high {
    background: #ffebee;
}

.smil-results .t-scores-compact tr.level-very_high {
    background: #fce4ec;
}

/* Mini Visual Scale */
.smil-results .mini-visual-scale {
    width: 100%;
    height: 20px !important;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative !important;
    background: linear-gradient(90deg,
            #3498db 0%,
            #27ae60 30%,
            #27ae60 60%,
            #f39c12 60%,
            #e67e22 80%,
            #e74c3c 80%,
            #e74c3c 100%) !important;
}

.smil-results .mini-visual-scale::after {
    content: '' !important;
    position: absolute !important;
    left: var(--marker-pos) !important;
    top: 0 !important;
    width: 2px !important;
    height: 100% !important;
    background: #2c3e50 !important;
    transform: translateX(-50%) !important;
    z-index: 10 !important;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5) !important;
}

/* Calculations Table */
.smil-results .calculations-table {
    width: 100%;
    font-size: var(--font-size-sm);
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.smil-results .calculations-table th {
    background: var(--color-bg);
    padding: var(--spacing-xs) var(--spacing-sm);
    text-align: left;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.smil-results .calculations-table td {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

.smil-results .calculations-table .score,
.smil-results .calculations-table .t-score {
    font-weight: 700;
    color: var(--color-primary);
}

.smil-results .calculations-table .formula {
    font-family: monospace;
    color: var(--color-text-light);
}

.smil-results .calculations-table .correction {
    color: var(--color-success);
    font-weight: 600;
}

/* Additional Scales Grid */
.smil-results .additional-scales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

/* Additional Scales Table */
.smil-results .additional-scores-table {
    width: 100%;
    font-size: var(--font-size-sm);
    background: var(--color-bg-white);
}

.smil-results .additional-scores-table th {
    background: var(--color-bg);
    padding: var(--spacing-xs) var(--spacing-sm);
    text-align: left;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.smil-results .additional-scores-table td {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

.smil-results .additional-scores-table tr.level-low {
    background: #e3f2fd;
}

.smil-results .additional-scores-table tr.level-normal {
    background: #e8f5e9;
}

.smil-results .additional-scores-table tr.level-elevated {
    background: #fff3e0;
}

.smil-results .additional-scores-table tr.level-high {
    background: #ffebee;
}

.smil-results .additional-scores-table tr.level-very_high {
    background: #fce4ec;
}

.smil-results .additional-scores-table .score-value {
    font-weight: 700;
    color: var(--color-primary);
}

.smil-results .scale-name-tooltip {
    cursor: help;
    border-bottom: 1px dotted var(--color-text-light);
    position: relative;
}

.smil-results .scale-name-tooltip:hover {
    background: var(--color-primary);
    color: white;
}

/* Custom tooltip */
.smil-results .scale-name-tooltip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--spacing-xs);
}

.smil-results .scale-name-tooltip[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    margin-bottom: -6px;
    z-index: 1000;
}
/* ============================================
   Classic SMIL Profile Chart (MMPI-style)
   ============================================ */

.classic-profile-container {
    max-width: 560px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.classic-profile-holder {
    position: relative;
    width: 100%;
}

.profile-background {
    width: 100%;
    display: block;
}

.profile-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .classic-profile-container {
        max-width: 100%;
        padding: 0 0.5rem;
    }
}

/* Profile Legend */
.profile-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

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

.legend-line {
    width: 30px;
    height: 3px;
    background: darkblue;
}

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

.legend-point {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.legend-point.normal {
    background: darkgreen;
}

.legend-point.deviation {
    background: crimson;
}

/* ============================================
   LAZARUS — Dual-scale question (Я + Партнёр)
   ============================================ */
.dual-scale {
    margin-top: var(--spacing-md);
}
.dual-scale__legend {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-sm);
    font-size: 0.72rem;
    color: var(--color-text-secondary, #7f8c8d);
    margin-bottom: var(--spacing-sm);
    padding-left: 90px;
}
.dual-scale__label-mid {
    text-align: center;
    flex: 1;
}
.dual-scale__row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 6px 0;
}
.dual-scale__row + .dual-scale__row {
    border-top: 1px dashed var(--color-border, #e0e0e0);
}
.dual-scale__who {
    flex-shrink: 0;
    width: 90px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-primary, #2c3e50);
}
.dual-scale__who-hint {
    display: block;
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--color-text-secondary, #7f8c8d);
}
.dual-scale__options {
    display: flex;
    flex: 1;
    gap: 4px;
    justify-content: space-between;
}
.scale-option {
    position: relative;
    cursor: pointer;
    flex: 1;
    text-align: center;
}
.scale-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.scale-option__num {
    display: block;
    padding: 8px 0;
    border: 1px solid var(--color-border, #d0d0d0);
    border-radius: 6px;
    background: var(--color-bg-white, #fff);
    color: var(--color-text-primary, #2c3e50);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}
.scale-option:hover .scale-option__num {
    border-color: var(--color-primary, #3498db);
    background: #eaf4fb;
}
.scale-option input[type="radio"]:checked + .scale-option__num {
    background: var(--color-primary, #3498db);
    border-color: var(--color-primary, #3498db);
    color: #fff;
    font-weight: 700;
}
.question-card--dual {
    /* full width of the test-wrapper, no extra constraint */
    max-width: 100%;
}
@media (max-width: 600px) {
    .dual-scale__legend {
        padding-left: 70px;
        font-size: 0.65rem;
    }
    .dual-scale__who {
        width: 70px;
        font-size: 0.82rem;
    }
    .scale-option__num {
        display: grid;
        min-height: 44px;
        padding: 0;
        place-items: center;
        font-size: 0.9rem;
    }
    .dual-scale__row {
        align-items: flex-start;
    }
    .dual-scale__options {
        display: grid;
        grid-template-columns: repeat(5, minmax(44px, 1fr));
        gap: 8px;
    }
}

/* ============================================
   PAIR MODE — invite & comparison
   ============================================ */
.pair-invite-block {
    background: #f0f7ff;
    border: 1px solid #cfe2f3;
    border-radius: 10px;
    padding: var(--spacing-lg);
}
.pair-invite__text {
    margin: 0 0 var(--spacing-md);
    color: var(--color-text-primary, #2c3e50);
}
.pair-invite__link-box {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}
.pair-invite__input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border, #d0d0d0);
    border-radius: 6px;
    background: #fff;
    font-family: monospace;
    font-size: 0.85rem;
}
.pair-invite__hint {
    font-size: 0.85rem;
    color: var(--color-text-secondary, #7f8c8d);
    margin: 0;
}

.pair-comparison-block { margin-top: var(--spacing-md); }
.pair-comparison__summary {
    font-size: 1.05rem;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: #f8f9fa;
    border-left: 4px solid var(--color-primary, #3498db);
}
.pair-comparison__agreement {
    margin-bottom: var(--spacing-lg);
}
.agreement-bar {
    width: 100%;
    max-width: 400px;
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
}
.agreement-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c 0%, #f39c12 50%, #27ae60 100%);
    transition: width 0.5s ease;
}
.agreement-label {
    display: block;
    margin-top: 6px;
    font-weight: 600;
    color: var(--color-text-primary, #2c3e50);
}
.pair-comparison__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.pair-comparison__table th {
    text-align: left;
    padding: 10px 8px;
    background: #f0f3f5;
    border-bottom: 2px solid var(--color-border, #d0d0d0);
    font-weight: 600;
    color: var(--color-text-primary, #2c3e50);
}
.pair-comparison__table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--color-border, #e8e8e8);
    vertical-align: top;
}
.pair-comparison__table .col-score,
.pair-comparison__table .col-diff,
.pair-comparison__table .col-gap {
    text-align: center;
}
.pair-comparison__table .item-domain {
    display: block;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--color-text-secondary, #7f8c8d);
}
.pair-comparison__table .item-text {
    display: block;
    max-width: 320px;
}
.diff-match { color: #27ae60; font-weight: 600; }
.diff-mismatch { color: #e74c3c; font-weight: 600; }
.gap-large { color: #e74c3c; font-weight: 600; }
.row-diff-0 { background: #f6fff9; }
.pair-comparison__legend {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border, #e0e0e0);
    font-size: 0.82rem;
    color: var(--color-text-secondary, #7f8c8d);
}
.pair-comparison__legend p { margin: 4px 0; }
@media (max-width: 700px) {
    .pair-invite__link-box { flex-direction: column; }
    .pair-comparison__table { font-size: 0.78rem; }
    .pair-comparison__table .item-text { max-width: 180px; }
}

/* ============================================
   LAZARUS — items table (single result)
   ============================================ */
.lazarus-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.lazarus-items-table th {
    text-align: left;
    padding: 12px 10px;
    background: #f0f3f5;
    border-bottom: 2px solid var(--color-border, #d0d0d0);
    font-weight: 600;
    color: var(--color-text-primary, #2c3e50);
    font-size: 0.82rem;
}
.lazarus-items-table th.col-score,
.lazarus-items-table th.col-gap {
    text-align: center;
}
.lazarus-items-table td {
    padding: 10px;
    border-bottom: 1px solid var(--color-border, #e8e8e8);
    vertical-align: top;
}
.lazarus-items-table td.col-score,
.lazarus-items-table td.col-gap {
    text-align: center;
    font-weight: 600;
}
.lazarus-items-table .of-10 {
    color: var(--color-text-secondary, #95a5a6);
    font-weight: 400;
    font-size: 0.78rem;
}
.lazarus-items-table .item-domain {
    display: block;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--color-text-secondary, #7f8c8d);
    margin-bottom: 2px;
}
.lazarus-items-table .item-text {
    display: block;
    max-width: 380px;
}
.lazarus-items-table tr.level--low td.col-score:first-of-type { color: #c62828; }
.lazarus-items-table tr.level--high td.col-score:first-of-type { color: #2e7d32; }
.gap-zero { color: #27ae60; }
.gap-small { color: var(--color-text-secondary, #7f8c8d); }
.gap-large { color: #e67e22; font-weight: 700; }
.lazarus-items-hint {
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--color-text-secondary, #7f8c8d);
    line-height: 1.5;
}

/* Simple interpretation block (Lazarus) */
.interpretation-block--simple {
    padding: var(--spacing-md) var(--spacing-lg);
    background: #f0f7ff;
    border-left: 4px solid var(--color-primary, #3498db);
    border-radius: 0 8px 8px 0;
}
.interpretation-block--simple .interpretation-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-primary, #2c3e50);
}

/* Premium UX polish — test taking */
.test-wrapper {
    background: var(--color-bg, #f8f9fa);
    min-height: calc(100vh - 60px);
}
.question-card {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.question-card.answered {
    border-color: var(--color-primary, #3498db);
}
.question-card.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}
.progress-container {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-bg, #f8f9fa);
    padding: var(--spacing-sm) 0;
}
.test-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border, #e0e0e0);
}
