@font-face {
    font-family: 'Optician Sans';
    src: url('assets/fonts/OpticianSans.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

.va-optotype-font {
    font-family: 'Optician Sans', sans-serif !important;
}

@import url('phase1.css');

:root {
    /* Spacing & Sizes */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;

    /* Safe Areas for iPhone */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    /* Prevent pull-to-refresh on mobile if possible */
    overscroll-behavior-y: none; 
}

/* Screens */
.screen {
    width: 100vw;
    min-height: 100vh;
    padding: calc(var(--safe-top) + var(--spacing-md)) calc(var(--safe-right) + var(--spacing-md)) calc(var(--safe-bottom) + var(--spacing-md)) calc(var(--safe-left) + var(--spacing-md));
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* --- SETUP SCREEN --- */
#setup-screen {
    max-width: 600px;
    margin: 0 auto;
    /* Use natural vertical flow instead of center packing */
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

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

.logo-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.logo {
    max-width: 120px;
    height: auto;
}

.logo-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.setup-header h2 {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-secondary);
}

.selection-section {
    margin-bottom: var(--spacing-xl);
}

.selection-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background-color: var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 2px;
}

.segment {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 4px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: calc(var(--border-radius-sm) - 2px);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    min-height: 44px; /* Large touch target */
}

.segment.active {
    background-color: var(--surface-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: var(--primary-color);
}

/* Cards Container */
.cards-container {
    display: flex;
    gap: var(--spacing-md);
    justify-content: space-between;
}

.card {
    flex: 1;
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg) var(--spacing-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 100px;
}

.card.active {
    border-color: var(--primary-color);
    background-color: rgba(0, 119, 182, 0.05); /* very light primary */
}

.card-icon {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.card.active .card-icon {
    color: var(--primary-color);
}

.card-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.card.active .card-label {
    color: var(--primary-color);
    font-weight: 600;
}

/* Buttons */
.primary-btn, .secondary-btn, .close-btn {
    font-family: inherit;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid transparent;
}

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

.secondary-btn {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

#start-test-btn {
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: auto;
    margin-bottom: var(--spacing-md);
    width: 100%;
}

/* --- TESTING SCREEN --- */
#testing-screen {
    background-color: var(--surface-color); /* White background for test */
    touch-action: none; /* Prevent browser scrolling/zooming on swipe */
    user-select: none; /* Prevent text selection */
}

.testing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.testing-header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* --- VA TESTING VIEWPORT --- */
.testing-screen {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.testing-screen .testing-header {
    flex: 0 0 auto;
    padding-top: calc(var(--v11-space-md) + var(--safe-top)) !important;
    padding-right: calc(var(--v11-space-lg) + var(--safe-right)) !important;
    padding-bottom: var(--v11-space-md) !important;
    padding-left: calc(var(--v11-space-lg) + var(--safe-left)) !important;
}

@supports not (height: 100dvh) {
    .testing-screen {
        height: 100vh;
        min-height: 0;
        max-height: 100vh;
    }
}

.testing-area {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: stretch;
    justify-items: center;
    position: relative;
    overflow: hidden;
    background: white;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    padding-bottom: calc(var(--safe-bottom) + var(--spacing-sm));
}

.debug-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #00ff00;
    padding: 10px;
    font-family: monospace;
    font-size: 14px;
    border-radius: 4px;
    z-index: 100;
    pointer-events: none;
    line-height: 1.4;
    white-space: pre-wrap;
}

.optotype-container {
    grid-row: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
    
    /* CLINICAL ISOLATION: Prevent V1.1 UI typography from cascading into the testing stimulus */
    font-family: initial !important;
    font-size: initial !important;
    font-weight: initial !important;
    line-height: initial !important;
    letter-spacing: initial !important;
}

.optotype-svg {
    /* Explicitly prevent SVGs from inheriting text styling */
    font-family: initial !important;
    letter-spacing: initial !important;
    line-height: initial !important;
}

.optotype-text {
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.optotype-image {
    object-fit: contain;
}

.missing-asset-warning {
    color: #dc3545;
    border: 1px dashed #dc3545;
    padding: 4px;
    font-size: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8d7da;
    border-radius: 4px;
}

.va-display {
    grid-row: 2;
    position: static;
    transform: none;
    align-self: center;
    justify-self: center;
    margin: var(--spacing-sm) 0 0;
    max-width: calc(100vw - 32px);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    background-color: rgba(248, 249, 250, 0.9);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* --- CALIBRATION SCREEN --- */
.calibration-status-container {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.secondary-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    width: 100%;
}

.secondary-btn.warning {
    color: #dc3545;
    border-color: #dc3545;
}

.calibration-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.calibration-instructions {
    margin-bottom: var(--spacing-md);
    text-align: center;
    color: var(--text-secondary);
}

.reference-selector-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

.calibration-reference-wrapper {
    margin-bottom: var(--spacing-xl);
    position: relative;
    padding: 20px 0; /* Increase padding for drag hit area */
}

.calibration-line {
    background-color: var(--text-primary);
    height: 4px;
    width: 378px; /* Initial approx */
    position: relative;
}

.calibration-drag-handle {
    position: absolute;
    right: -20px;
    top: -20px;
    width: 44px;
    height: 44px;
    background-color: rgba(0, 119, 182, 0.2);
    border-radius: 50%;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calibration-drag-handle::after {
    content: '';
    width: 16px;
    height: 16px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

.calibration-ticks {
    display: flex;
    justify-content: space-between;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
}

.tick {
    width: 2px;
    height: 100%;
    background-color: var(--text-primary);
}

.calibration-controls {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
    width: 100%;
    justify-content: center;
}

.cal-btn {
    background-color: #e9ecef;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    flex: 1;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.cal-btn:active {
    background-color: #ced4da;
}

.calibration-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: auto;
}

/* --- MODALS --- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-content {
    background-color: #ffffff;
    opacity: 1;
    padding: 24px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1001;
}

.modal-content h3 {
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    font-size: 20px;
}

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

.readiness-list {
    list-style: none;
    margin-bottom: var(--spacing-xl);
}

.readiness-list li {
    font-size: 16px;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-weight: 500;
}

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

/* --- LANDSCAPE BLOCKER FOR CALIBRATION --- */
.calibration-landscape-blocker {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    z-index: 9999;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    padding: var(--spacing-xl);
}

@media (orientation: landscape) {
    #calibration-screen:not(.hidden) .calibration-landscape-blocker {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* --- ORIENTATION FALLBACK --- */
@media (orientation: portrait) {
    #testing-screen:not(.hidden)::after {
        content: "Please rotate your device\A to landscape for testing.";
        white-space: pre-wrap;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background-color: var(--bg-color);
        color: var(--text-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        font-size: 24px;
        font-weight: 600;
        text-align: center;
        padding: var(--spacing-xl);
    }
}

/* --- DEVICE CHECKLIST --- */
.checklist-final-status {
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    background-color: var(--border-color);
}

.checklist-final-status.ready {
    background-color: #d4edda;
    color: #155724;
}

.checklist-final-status.not-ready {
    background-color: #f8d7da;
    color: #721c24;
}

.ios-install-instructions {
    background-color: #e9ecef;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.5;
}



/* --- OCR Phase 3A Styles --- */
#verification-layout {
    display: block;
}

#verification-layout.verifying {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
}

#verification-layout.verifying #verification-image-container {
    flex: 1;
    position: sticky;
    top: 20px;
    background: #f8f9fa;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 85vh;
    overflow-y: auto;
}

#verification-layout.verifying #verification-form-container {
    flex: 1;
    background: white;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.ocr-highlight {
    box-shadow: 0 0 5px 2px #ffc107 !important;
    border-color: #ffc107 !important;
    transition: box-shadow 0.3s ease;
}

@media (max-width: 768px) {
    #verification-layout.verifying {
        flex-direction: column;
    }
    
    #verification-layout.verifying #verification-image-container {
        position: relative;
        top: 0;
        max-height: 40vh;
        width: 100%;
        margin-bottom: 20px;
    }
    
    #verification-layout.verifying #verification-form-container {
        width: 100%;
    }
}

/* LOGIN UI */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* AUTHENTICATION GATE STATES */
body.auth-checking #login-screen,
body.auth-checking #app-shell {
    display: none !important;
}

body.unauthenticated #login-screen {
    display: flex;
}
body.unauthenticated #app-shell {
    display: none !important;
}

body.authenticated #login-screen {
    display: none !important;
}
body.authenticated #app-shell {
    display: block;
}

/* ========================================================================= */
/* Phase 4K Premium Clinical SaaS Redesign */
/* ========================================================================= */

/* EVENT ACTION TOOLBAR */
.event-action-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid #e2e8f0;
}

.toolbar-btn-add {
    font-size: 0.95rem;
    padding: 10px 18px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,119,182,0.2);
}

.toolbar-btn-capture, .toolbar-btn-import {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-size: 0.9rem;
    padding: 8px 14px;
    font-weight: 500;
}

.toolbar-btn-capture:hover, .toolbar-btn-import:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

.toolbar-btn-capture .nav-icon, .toolbar-btn-import .nav-icon {
    fill: #64748b;
    margin-right: 6px;
}

.utils-group {
    margin-left: auto;
    border-left: none;
    padding-left: 0;
}

.toolbar-btn-util {
    background-color: transparent;
    border: 1px solid transparent;
    color: #64748b;
    font-size: 0.85rem;
    padding: 6px 10px;
}

.toolbar-btn-util:hover {
    background-color: #f1f5f9;
    color: #334155;
}

@media (max-width: 768px) {
    .event-action-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-group {
        border-left: none;
        padding-left: 0;
        flex-direction: column;
        align-items: stretch;
    }
    .utils-group {
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
}

/* WORKSPACE HEADERS */
#record-form-screen {
    background-color: #f8fafc;
    min-height: 100vh;
    padding: 0;
}

/* Dynamic Header Toggling via OCR state */
.capture-record-title { display: none; }
.add-record-title { display: flex; flex-direction: column; }

#record-form-screen.is-capture-mode .capture-record-title { display: flex; flex-direction: column; }
#record-form-screen.is-capture-mode .add-record-title { display: none; }

.workspace-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px;
    display: flex;
    align-items: flex-start;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.workspace-title-group h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.workspace-event-context {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.context-divider {
    color: #94a3b8;
}

.nav-back-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px 8px 8px;
    border-radius: 8px;
    transition: background-color 0.15s, color 0.15s;
    margin-top: -2px; /* optical alignment */
    outline: none;
    box-shadow: none;
}

.nav-back-btn:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

/* VERIFICATION LAYOUT */
#verification-layout {
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px 100px 16px; /* 100px bottom for sticky footer */
}

#record-form-screen.is-capture-mode #verification-layout {
    max-width: 1400px;
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
}

#verification-image-container {
    flex: 1;
    position: sticky;
    top: 100px;
    background: #ffffff;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.image-workspace-header {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

#verif-image {
    width: 100%;
    border-radius: 8px;
    display: block;
}

#verification-form-container {
    flex: 1;
    background: #ffffff;
    padding: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    width: 100%;
}

@media (max-width: 900px) {
    #record-form-screen.is-capture-mode #verification-layout {
        flex-direction: column;
    }
    #verification-image-container {
        position: relative;
        top: 0;
    }
}

/* FORM DESIGN SYSTEM */
.modern-form {
    display: flex;
    flex-direction: column;
}

.form-section {
    padding: 24px 0;
}

.form-section:first-child {
    padding-top: 0;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin-bottom: 24px;
    margin-top: 0;
}

.section-divider {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 0;
}

/* Form Groups & Inputs */
.modern-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

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

.modern-form .form-group.full-width {
    grid-column: 1 / -1;
}

.modern-form .form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.modern-form input[type="text"], 
.modern-form input[type="number"], 
.modern-form input[type="date"], 
.modern-form input[type="tel"], 
.modern-form select, 
.modern-form textarea {
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    border-radius: 6px;
    padding: 8px 12px;
    color: #0f172a;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: 38px;
}

.modern-form textarea {
    height: auto;
    resize: vertical;
}

.modern-form input:focus, 
.modern-form select:focus, 
.modern-form textarea:focus {
    outline: none;
    border-color: #0077b6;
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.15);
}

.input-with-prefix {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: #ffffff;
    height: 38px;
}

.input-with-prefix:focus-within {
    border-color: #0077b6;
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.15);
}

.prefix-label {
    padding: 0 12px;
    font-weight: 600;
    color: #64748b;
    font-size: 0.95rem;
    border-right: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    height: 100%;
    background-color: #f8fafc;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.input-with-prefix input {
    border: none !important;
    box-shadow: none !important;
    height: 100% !important;
    flex: 1;
}

/* Checkboxes and Radios */
.modern-radio-group, .modern-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.radio-card, .checkbox-card {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: #ffffff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    transition: all 0.2s;
    height: 38px;
    padding: 0 16px 0 12px;
}

.radio-card:hover, .checkbox-card:hover {
    border-color: #94a3b8;
    background-color: #f8fafc;
}

.radio-card input, .checkbox-card input {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    accent-color: #0077b6;
}

/* Switch */
.switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    height: 38px;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.switch-text {
    font-weight: 600;
    color: #334155;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .2s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #0077b6;
}

input:checked + .slider:before {
    transform: translateX(16px);
}

/* CLINICAL MATRIX (OD/OS) */
.clinical-matrix {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f8fafc;
}

.matrix-column {
    display: flex;
    flex-direction: column;
}

.matrix-column:first-child {
    border-right: 1px solid #e2e8f0;
}

.matrix-divider {
    display: none; /* Hidden on grid layout */
}

.matrix-header {
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    background-color: #f1f5f9;
    color: #475569;
    letter-spacing: 0.5px;
}

.matrix-group {
    padding: 16px;
}

.ref-group {
    border-top: 1px solid #e2e8f0;
    background-color: #ffffff;
}

.matrix-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.matrix-row:last-child {
    margin-bottom: 0;
}

.matrix-row label {
    width: 40px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0 !important;
}

.matrix-row select, .matrix-row input {
    flex: 1;
}

@media (max-width: 600px) {
    .clinical-matrix {
        grid-template-columns: 1fr;
    }
    .matrix-column:first-child {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
}

/* CONVERSION PANEL */
.conversion-panel {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    margin-top: 24px;
}

.conversion-panel .section-title {
    color: #0f172a;
}

/* STICKY ACTION FOOTER */
.sticky-action-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid #e2e8f0;
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    z-index: 900;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.sticky-action-footer .btn-cancel {
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
}

.sticky-action-footer .btn-cancel:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.sticky-action-footer .btn-save {
    padding: 12px 24px;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .sticky-action-footer {
        padding: 16px;
    }
}


.btn-sm {
    padding: 6px 12px !important;
    font-size: 0.85rem !important;
}



/* --- MODERN VA CALIBRATION CONTROLS --- */
.va-calibration-card {
    width: 100%;
    max-width: 520px;
    background: var(--v11-bg-surface);
    border: 1px solid var(--v11-border-light);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--v11-shadow-md);
}

.va-calibration-heading {
    text-align: left;
    margin-bottom: 22px;
}

.va-calibration-eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--v11-text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.va-calibration-heading .v11-title-page {
    font-size: 1.35rem;
    margin-bottom: 7px;
}

.va-calibration-heading .calibration-instructions {
    margin: 0;
    line-height: 1.5;
}

.va-calibration-reference {
    width: 100%;
    margin: 0 0 12px;
    padding: 20px 12px 28px;
    background: var(--v11-bg-app);
    border: 1px solid var(--v11-border-light);
    border-radius: 16px;
}

.calibration-measurement {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: var(--v11-text-secondary);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.calibration-measurement strong {
    color: var(--v11-text-primary);
    font-size: 0.95rem;
}

.va-calibration-reference .calibration-line {
    width: 160px;
    height: 8px;
    min-width: 60px;
    max-width: 100%;
    margin: 0 auto;
    border-radius: 999px;
    background: var(--v11-text-primary);
    transition: width 90ms ease-out;
}

.calibration-line-endpoint {
    position: absolute;
    top: -9px;
    width: 26px;
    height: 26px;
    border: 3px solid var(--v11-text-primary);
    border-radius: 50%;
    background: var(--v11-bg-surface);
}

.calibration-line-endpoint.left { left: -13px; }
.calibration-line-endpoint.right { right: -13px; }

.va-calibration-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 16px 0 12px;
}

.va-calibration-value span {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--v11-text-primary);
    font-variant-numeric: tabular-nums;
}

.va-calibration-value small {
    color: var(--v11-text-secondary);
    font-size: 0.72rem;
}

.va-calibration-slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
    color: var(--v11-text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.va-calibration-slider {
    width: 100%;
    height: 48px;
    margin: 0;
    accent-color: var(--v11-color-primary);
    cursor: pointer;
    touch-action: manipulation;
}

.va-calibration-stepper {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.va-calibration-step {
    min-height: 52px;
    border: 1px solid var(--v11-border-light);
    border-radius: 14px;
    background: var(--v11-bg-app);
    color: var(--v11-text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 100ms ease, background-color 100ms ease;
}

.va-calibration-step-wide {
    font-size: 0.95rem;
}

.va-calibration-step:active {
    transform: scale(0.96);
    background: var(--v11-border-light);
}

.va-calibration-tip {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--v11-bg-info);
    color: var(--v11-text-info);
    font-size: 0.78rem;
    line-height: 1.45;
    text-align: left;
}

@media (max-width: 420px) {
    .va-calibration-card { padding: 18px; border-radius: 16px; }
    .va-calibration-heading .v11-title-page { font-size: 1.2rem; }
    .va-calibration-step { min-height: 50px; }
}
