/* Monodata - Medical Record Processor */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --success: #16b852;
    --success-dark: #16a34a;
    --error: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Focus ring */
    --ring: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   SCREENS
   ============================================================================ */

.screen {
    min-height: 100vh;
}

/* ============================================================================
   LOGIN SCREEN
   ============================================================================ */

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(188deg, #1e3a8a, #2563eb 66.39%, #3b82f6);
    position: relative;
    overflow: hidden;
}

/* Subtle background pattern */
#login-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 40%);
    pointer-events: none;
}

.login-container {
    background: white;
    padding: 48px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    text-align: center;
    max-width: 420px;
    width: 90%;
    position: relative;
    z-index: 1;
}

.login-container h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
    letter-spacing: -0.025em;
}

.login-container .subtitle {
    color: var(--gray-500);
    margin-bottom: 36px;
    font-size: 15px;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#login-form input {
    padding: 12px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--gray-50);
}

#login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
    background: white;
}

#login-form button {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#login-form button:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

#login-form button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

#login-form button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.message {
    margin-top: 16px;
    color: var(--success);
    font-size: 14px;
}

.error {
    margin-top: 16px;
    color: var(--error);
    font-size: 14px;
}

/* ============================================================================
   OTP VERIFICATION
   ============================================================================ */

#otp-section {
    text-align: center;
}

#otp-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.otp-instruction {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.6;
}

#otp-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#otp-input {
    padding: 14px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    font-size: 24px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    letter-spacing: 8px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--gray-50);
}

#otp-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
    background: white;
}

#otp-form button {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#otp-form button:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

#otp-form button:active {
    transform: translateY(0);
}

#otp-form button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.otp-back {
    margin-top: 20px;
    font-size: 14px;
}

.otp-back a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.otp-back a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ============================================================================
   MAIN SCREEN
   ============================================================================ */

#main-screen {
    padding: 0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.025em;
}

/* ============================================================================
   PROFILE MENU
   ============================================================================ */

.profile-menu {
    position: relative;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
}

.profile-avatar:hover {
    box-shadow: 0 0 0 3px var(--primary-100);
    transform: scale(1.05);
}

.profile-avatar:active {
    transform: scale(0.97);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    z-index: 100;
    animation: dropdown-in 0.15s ease-out;
}

@keyframes dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.profile-dropdown.hidden {
    display: none;
}

.dropdown-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--gray-400);
}

.profile-dropdown-email {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-600);
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}

.profile-dropdown-item:hover:not(:disabled) {
    background: var(--gray-50);
}

.profile-dropdown-item:disabled {
    color: var(--gray-400);
    cursor: default;
}

.profile-dropdown-logout {
    font-weight: 600;
    color: var(--gray-900);
}

.profile-dropdown-logout .dropdown-icon {
    color: var(--gray-900);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-secondary {
    padding: 8px 16px;
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
}

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 32px;
}

/* ============================================================================
   UPLOAD SECTION
   ============================================================================ */

#upload-section {
    margin-bottom: 48px;
}

#dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 40px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}

#dropzone:hover {
    border-color: var(--primary-light);
    background: var(--primary-50);
    box-shadow: var(--shadow-md);
}

#dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: scale(1.01);
}

.dropzone-content {
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--gray-400);
    margin-bottom: 16px;
    transition: color 0.2s;
}

#dropzone:hover .upload-icon {
    color: var(--primary-light);
}

#dropzone p {
    color: var(--gray-600);
    margin-bottom: 4px;
    font-weight: 500;
}

#dropzone .hint {
    color: var(--gray-400);
    font-size: 14px;
    font-weight: 400;
}

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */

#upload-progress {
    margin-top: 24px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--gray-600);
}

.progress-bar {
    height: 8px;
    background: var(--gray-100);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar.large {
    height: 10px;
    margin-bottom: 32px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 99px;
    transition: width 0.4s ease;
    width: 0%;
    position: relative;
}

.progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================================================
   JOBS SECTION
   ============================================================================ */

#jobs-section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

.jobs-info {
    font-size: 13px;
    color: var(--gray-400);
    margin-bottom: 16px;
}

#jobs-list {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.empty-state {
    padding: 48px 32px;
    text-align: center;
    color: var(--gray-400);
    font-size: 15px;
}

.job-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
}

.job-item:last-child {
    border-bottom: none;
}

.job-item:hover {
    background: var(--gray-50);
}

.job-item.job-clickable {
    cursor: pointer;
}

.job-item.job-clickable:hover {
    background: var(--primary-50);
}

.job-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.job-id {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 15px;
}

.job-date {
    font-size: 13px;
    color: var(--gray-400);
}

.job-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.status-badge.uploading,
.status-badge.queued,
.status-badge.waiting {
    background: var(--gray-100);
    color: var(--gray-500);
}

.status-badge.processing,
.status-badge.ocr,
.status-badge.classifying,
.status-badge.grouping,
.status-badge.splitting,
.status-badge.extracting,
.status-badge.indexing,
.status-badge.packaging {
    background: var(--primary-100);
    color: var(--primary-dark);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.status-badge.complete {
    background: #dcfce7;
    color: #166534;
}

.status-badge.error,
.status-badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

.btn-download {
    padding: 8px 16px;
    background: white;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-download:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.download-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* ============================================================================
   PROCESSING SCREEN
   ============================================================================ */

#processing-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
}

.processing-container {
    background: white;
    padding: 48px;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.processing-container h2 {
    margin-bottom: 32px;
    color: var(--gray-800);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}

#processing-phases {
    text-align: left;
    margin-bottom: 32px;
}

.phase {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    color: var(--gray-500);
    transition: color 0.3s;
    font-size: 15px;
}

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

.phase.complete {
    color: var(--success);
}

.phase-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.phase.complete .phase-icon {
    background: #dcfce7;
    border-radius: 50%;
    color: #166534;
    font-size: 12px;
}

.phase.active .phase-icon::after {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
}

.phase.active .phase-icon {
    font-size: 0;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
        opacity: 1;
    }
    70% {
        box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
        opacity: 0.7;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
        opacity: 1;
    }
}

/* ============================================================================
   VIEW BUTTON
   ============================================================================ */

.btn-view {
    padding: 8px 16px;
    background: var(--gray-600);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-view:hover {
    background: var(--gray-700);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

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

/* ============================================================================
   FILE VIEWER SCREEN
   ============================================================================ */

#viewer-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#viewer-screen.hidden {
    display: none !important;
}

.viewer-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.viewer-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 6px;
    background: transparent;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: var(--gray-600);
}

.btn-icon:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

#viewer-patient-name {
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

.viewer-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ============================================================================
   FILE TREE SIDEBAR
   ============================================================================ */

.file-tree {
    width: 240px;
    min-width: 200px;
    max-width: 400px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-tree-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-tree-actions {
    display: flex;
    gap: 4px;
}

.file-tree-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.file-tree-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Scrollbar styling */
.file-tree-content::-webkit-scrollbar {
    width: 6px;
}

.file-tree-content::-webkit-scrollbar-track {
    background: transparent;
}

.file-tree-content::-webkit-scrollbar-thumb {
    background: var(--gray-200);
    border-radius: 3px;
}

.file-tree-content::-webkit-scrollbar-thumb:hover {
    background: var(--gray-300);
}

/* Tree Items */
.tree-folder {
    display: flex;
    flex-direction: column;
}

.tree-folder-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    border-left: 3px solid transparent;
    user-select: none;
    transition: background 0.1s;
}

.tree-file {
    display: flex;
    align-items: flex-start;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    color: var(--gray-600);
    border-left: 3px solid transparent;
    user-select: none;
    transition: all 0.1s;
}

.tree-file .tree-icon {
    margin-top: 2px;
}

.tree-folder-header:hover,
.tree-file:hover {
    background: var(--gray-50);
}

.tree-file.active {
    background: var(--primary-50);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
}

.tree-icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    flex-shrink: 0;
}

.tree-folder-header > .tree-icon {
    color: var(--warning);
}

.tree-file > .tree-icon {
    color: var(--gray-400);
}

.tree-file.is-snapshot > .tree-icon {
    color: var(--primary);
}

.tree-file.is-snapshot {
    font-weight: 500;
}

.tree-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-children {
    margin-left: 20px;
}

.tree-folder.collapsed > .tree-children {
    display: none;
}

.tree-folder-header > .folder-toggle {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    transition: transform 0.2s;
}

.tree-folder.collapsed .folder-toggle {
    transform: rotate(-90deg);
}

/* ============================================================================
   VIEWER MAIN AREA
   ============================================================================ */

.viewer-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--gray-100);
    position: relative;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* Split Pane */
.split-pane {
    flex: 1;
    display: flex;
    overflow: hidden;
    gap: 0;
    padding: 0;
}

.pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

.pdf-pane {
    flex: 1;
    min-width: 300px;
}

.md-pane {
    flex: 1;
    min-width: 300px;
}

.pane-header {
    padding: 8px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pane-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.pane-resizer {
    width: 6px;
    background: var(--gray-200);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
}

.pane-resizer:hover {
    background: var(--primary);
}

/* PDF Viewer */
#pdf-viewer,
#patient-pdf-viewer {
    width: 100%;
    height: 100%;
    border: none;
}

/* Markdown Viewer */
#md-viewer,
#snapshot-viewer,
#patient-md-viewer,
#patient-snapshot-viewer {
    padding: 12px 16px;
    margin: 0;
}

/* Snapshot Pane (Full Width) */
.snapshot-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

/* ============================================================================
   MARKDOWN STYLING
   ============================================================================ */

.markdown-body {
    font-size: 14px;
    line-height: 1.75;
    color: var(--gray-800);
}

.markdown-body h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.75em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid var(--gray-100);
    letter-spacing: -0.015em;
    color: var(--gray-900);
}

.markdown-body h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.75em 0 0.5em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid var(--gray-100);
    letter-spacing: -0.01em;
    color: var(--gray-900);
}

.markdown-body h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5em 0 0.5em;
    color: var(--gray-800);
}

.markdown-body h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 1.25em 0 0.5em;
    color: var(--gray-700);
}

.markdown-body p {
    margin: 0 0 1em;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0 0 1em;
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25em 0;
    font-size: 13px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.markdown-body th,
.markdown-body td {
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    text-align: left;
}

.markdown-body th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.markdown-body tr:hover {
    background: var(--gray-50);
}

.markdown-body code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: var(--gray-700);
}

.markdown-body pre {
    background: var(--gray-800);
    color: var(--gray-100);
    padding: 16px 20px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 1.25em 0;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 16px;
    margin: 1.25em 0;
    color: var(--gray-600);
    font-style: italic;
}

.markdown-body a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.markdown-body a:hover {
    text-decoration: underline;
}

/* Clickable file links in Snapshot */
.markdown-body .file-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.markdown-body .file-link:hover {
    text-decoration-style: solid;
}

/* Clickable PDF references */
.markdown-body .pdf-ref {
    cursor: pointer;
    background: linear-gradient(to bottom, transparent 60%, rgba(37, 99, 235, 0.12) 60%);
    border-radius: 2px;
    transition: background 0.15s;
}

.markdown-body .pdf-ref:hover {
    background: rgba(37, 99, 235, 0.12);
}

/* ============================================================================
   PDF REFERENCE TOAST
   ============================================================================ */

.pdf-ref-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    animation: toast-slide-up 0.3s ease-out;
}

.pdf-ref-toast.fade-out {
    animation: toast-fade-out 0.3s ease-out forwards;
}

.pdf-ref-toast .toast-icon {
    font-size: 16px;
}

@keyframes toast-slide-up {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toast-fade-out {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.viewer-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    color: var(--gray-400);
    font-size: 14px;
}

.viewer-loading.hidden {
    display: none;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.pane-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 5;
}

.pane-spinner .loading-spinner {
    margin-bottom: 0;
}

/* ============================================================================
   TEAM MANAGEMENT
   ============================================================================ */

.team-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 32px;
}

.team-section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

.team-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-primary-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.btn-primary-sm:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

.btn-secondary-sm {
    padding: 8px 16px;
    background: white;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary-sm:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.2s ease;
}

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

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-container {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: modalSlideIn 0.25s ease;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-field > label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}

.modal-field input[type="text"],
.modal-field input[type="email"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--gray-800);
}

.modal-field input[type="text"]:focus,
.modal-field input[type="email"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.modal-field input[type="text"]::placeholder,
.modal-field input[type="email"]::placeholder {
    color: var(--gray-400);
}

.modal-field select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    color: var(--gray-800);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--gray-100);
}

/* PHI Warning Modal */
.warning-modal {
    max-width: 520px;
}

.warning-modal-body {
    align-items: center;
    text-align: center;
}

.warning-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-500);
    flex-shrink: 0;
}

.warning-modal-body p {
    color: var(--gray-600);
    font-size: 14px;
    line-height: 1.6;
}

/* Dedup Info */
.dedup-info {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* Session Expired Banner */
.session-expired-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    background: var(--gray-800);
    color: white;
    padding: 12px 24px;
    animation: modalSlideIn 0.25s ease;
}

.session-expired-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
}

/* Members Table */
.team-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.team-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.team-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

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

.team-table tr:hover {
    background: var(--gray-50);
}

.member-email {
    font-weight: 500;
    color: var(--gray-800);
}

.badge-you {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-50);
    padding: 2px 8px;
    border-radius: 99px;
    margin-left: 8px;
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.role-badge.role-admin {
    background: #fef3c7;
    color: #92400e;
}

.role-badge.role-member {
    background: var(--primary-100);
    color: var(--primary-dark);
}

.role-badge.role-viewer {
    background: var(--gray-100);
    color: var(--gray-600);
}

.date-cell {
    font-size: 13px;
    color: var(--gray-400);
}

.actions-cell {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.btn-edit-member {
    padding: 5px 12px;
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-edit-member:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-remove-member {
    padding: 5px 12px;
    background: white;
    color: var(--error);
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-remove-member:hover {
    background: #fef2f2;
    border-color: var(--error);
}

/* ============================================================================
   USAGE SECTION
   ============================================================================ */

.usage-section {
    margin-top: 40px;
}

.usage-month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.usage-month-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    min-width: 140px;
    text-align: center;
}

.btn-icon-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--gray-200);
    border-radius: 6px;
    background: white;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon-sm:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-700);
}

.usage-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.usage-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 32px;
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: 12px;
    min-width: 140px;
}

.usage-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.02em;
}

.usage-stat-label {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 640px) {
    .login-container {
        padding: 32px 24px;
    }

    header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
    }

    main {
        padding: 24px 16px;
    }

    #dropzone {
        padding: 40px 16px;
    }

    .job-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 900px) {
    .file-tree {
        width: 220px;
    }

    .split-pane {
        flex-direction: column;
    }

    .pane-resizer {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }

    .pdf-pane,
    .md-pane {
        min-width: 0;
        min-height: 200px;
    }

    .patient-toolbar {
        flex-wrap: wrap;
    }

    .patient-breadcrumb {
        width: 100%;
        margin-left: 0;
    }

    .upload-queue {
        width: 280px;
        right: 12px;
        bottom: 12px;
    }
}

/* ============================================================================
   Patient Select Step (Upload Wizard Step 2)
   ============================================================================ */

#patient-select-step {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
}

.patient-select-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--success);
    font-size: 0.875rem;
    font-weight: 500;
}

.patient-select-header .step-check {
    font-size: 1rem;
}

#patient-select-step h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--gray-800);
}

.patient-search-box {
    margin-bottom: 12px;
}

.patient-search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

.patient-search-box input:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.patient-select-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 12px;
}

.patient-select-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background-color 0.1s;
}

.patient-select-item:last-child {
    border-bottom: none;
}

.patient-select-item:hover {
    background: var(--gray-50);
}

.patient-select-item.selected {
    background: var(--primary-50);
    border-color: var(--primary-100);
}

.patient-select-item .patient-info {
    display: flex;
    flex-direction: column;
}

.patient-select-item .patient-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-800);
}

.patient-select-item .patient-dob {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.patient-select-item .select-indicator {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    flex-shrink: 0;
}

.patient-select-item.selected .select-indicator {
    border-color: var(--primary);
    background: var(--primary);
    position: relative;
}

.patient-select-item.selected .select-indicator::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.new-patient-inline {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.new-patient-inline .modal-field {
    margin-bottom: 10px;
}

.new-patient-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 16px;
    display: block;
}

.btn-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.patient-select-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

/* ============================================================================
   Main Patients List (Hybrid List)
   ============================================================================ */

.patients-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.patients-main-header .patient-search-box {
    flex: 1;
    margin-bottom: 0;
}

.patients-main-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.patients-hybrid-list {
    display: flex;
    flex-direction: column;
}

.patient-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s;
}

.patient-row:hover {
    background: var(--gray-50);
    box-shadow: var(--shadow-sm);
}

.patient-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.patient-row-info {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

.patient-row-name {
    font-weight: 500;
    font-size: 0.9375rem;
    display: block;
}

.patient-row-meta {
    font-size: 0.8125rem;
    color: var(--gray-500);
    display: block;
}

.patient-row-stats {
    text-align: right;
    margin-left: 16px;
    flex-shrink: 0;
}

.patient-row-files {
    font-size: 0.8125rem;
    color: var(--gray-600);
    display: block;
}

.patient-row-date {
    font-size: 0.75rem;
    color: var(--gray-400);
    display: block;
}

.patient-row-arrow {
    margin-left: 8px;
    color: var(--gray-300);
    flex-shrink: 0;
}

/* ============================================================================
   Patient Detail Screen
   ============================================================================ */

.patient-detail-main {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Patient info in header bar */
.header-patient-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.header-patient-info .patient-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-patient-info .patient-name-row h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-patient-info .patient-name-row .btn-icon-sm {
    color: var(--gray-400);
    padding: 4px;
    border: none;
    background: transparent;
    flex-shrink: 0;
}

.header-patient-info .patient-name-row .btn-icon-sm:hover {
    color: var(--primary);
}

.header-patient-info .patient-detail-dob {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin: 0;
}

#patient-detail-screen .patient-avatar-lg {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

#patient-detail-screen .team-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Upload FAB */
.upload-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    z-index: 20;
    transition: all 0.15s;
}

.upload-fab:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

.upload-fab svg {
    flex-shrink: 0;
}


.patient-tab-content.hidden {
    display: none;
}

/* Full-width mode when embedded viewer is active */
.patient-detail-main.patient-detail-main--viewer {
    max-width: 100%;
    padding: 0;
}

/* Loading state */
.patient-files-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* Empty state dropzone */
.patient-files-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 16px;
}

.patient-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    background: var(--gray-50);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    max-width: 480px;
    width: 100%;
}

.patient-dropzone:hover {
    border-color: var(--primary-light);
    background: var(--primary-50);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.patient-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.patient-dropzone .upload-icon {
    width: 48px;
    height: 48px;
    color: var(--gray-400);
    margin-bottom: 16px;
    transition: color 0.2s;
}

.patient-dropzone:hover .upload-icon {
    color: var(--primary);
}

.patient-dropzone-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 6px;
}

.patient-dropzone-hint {
    font-size: 0.875rem;
    color: var(--gray-400);
    margin: 0;
}

/* Embedded viewer in patient files tab */
.patient-files-viewer {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    overflow: hidden;
}

/* Toolbar row: FILES label + Download Zip + breadcrumb */
.patient-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: white;
    flex-shrink: 0;
}

.patient-toolbar-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    letter-spacing: 0.02em;
}

.patient-toolbar .btn-secondary-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.patient-breadcrumb {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: center;
}

/* File tree + content body (horizontal layout below toolbar) */
.patient-files-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* File tree without header */
.file-tree--no-header .file-tree-content {
    padding-top: 8px;
}

/* File tree: two-line file item (name + date) */
.tree-file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.tree-file-info .tree-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-file-date {
    font-size: 0.6875rem;
    color: var(--gray-400);
    margin-top: 1px;
    white-space: nowrap;
}

/* Legacy job date badge (keep for backward compat) */
.file-job-date {
    font-size: 0.6875rem;
    color: var(--gray-400);
    margin-left: 8px;
    flex-shrink: 0;
}

/* Upload Queue - floating card */
.upload-queue {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    overflow: hidden;
}

.upload-queue-header {
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

.upload-queue-items {
    max-height: 240px;
    overflow-y: auto;
}

.upload-queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-50);
}

.upload-queue-item:last-child {
    border-bottom: none;
}

.upload-queue-item-icon {
    width: 20px;
    height: 20px;
    color: var(--gray-400);
    flex-shrink: 0;
}

.upload-queue-item-info {
    flex: 1;
    min-width: 0;
}

.upload-queue-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.upload-queue-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.upload-queue-item-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    flex-shrink: 0;
}

.upload-queue-progress {
    height: 4px;
    background: var(--gray-100);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.upload-queue-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
}

.upload-queue-progress-bar.complete {
    background: var(--success);
}

.upload-queue-item-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.upload-queue-phase {
    font-size: 11px;
    color: var(--gray-500);
}

.upload-queue-eta {
    font-size: 11px;
    color: var(--gray-400);
}

.eta-dots::after {
    content: '···';
    animation: eta-pulse 1.5s infinite;
}

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

.upload-queue-item.is-complete .upload-queue-item-icon {
    color: var(--success);
}

.upload-queue-item.is-error .upload-queue-item-icon {
    color: var(--error, #ef4444);
}

.upload-queue-item.is-error .upload-queue-phase {
    color: var(--error, #ef4444);
}

.upload-queue-item.is-waiting .upload-queue-item-icon {
    color: var(--text-secondary);
    animation: waiting-pulse 2s ease-in-out infinite;
}

.upload-queue-item.is-waiting .upload-queue-phase {
    color: var(--text-secondary);
    font-style: italic;
}

@keyframes waiting-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.patient-detail-jobs {
    margin-top: 8px;
}

/* ============================================================================
   Upload Modal
   ============================================================================ */

.upload-modal-container {
    max-width: 520px;
}

/* Upload Confirm Modal */
.upload-confirm-container {
    max-width: 420px;
}

.upload-confirm-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 24px 16px;
}

.upload-confirm-label {
    font-size: 13px;
    color: var(--text-secondary, #718096);
    margin: 8px 0 0;
}

.upload-confirm-label:first-child {
    margin-top: 0;
}

.upload-confirm-file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.upload-confirm-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    padding: 12px 16px;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1a202c);
    word-break: break-all;
}

.upload-confirm-file svg {
    flex-shrink: 0;
    color: var(--text-secondary, #718096);
}

.upload-confirm-patient {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    padding: 12px 16px;
    width: 100%;
}

.upload-confirm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary, #4361ee);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.upload-confirm-patient-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.upload-confirm-patient-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary, #1a202c);
}

.upload-confirm-patient-dob {
    font-size: 13px;
    color: var(--text-secondary, #718096);
}
