/* ============================================================
   Cancer Registry Extraction System - NIH/NLM Style
   Professional Medical Data Extraction Interface
   ============================================================ */

/* CSS Variables */
:root {
    /* Primary Colors - NIH Blue Theme */
    --primary-50: #e3f2fd;
    --primary-100: #bbdefb;
    --primary-200: #90caf9;
    --primary-300: #64b5f6;
    --primary-400: #42a5f5;
    --primary-500: #1565c0;
    --primary-600: #1976d2;
    --primary-700: #1565c0;
    --primary-800: #0d47a1;
    --primary-900: #0a3d91;

    /* Neutral Colors */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Status Colors */
    --success-light: #e8f5e9;
    --success: #4caf50;
    --success-dark: #2e7d32;

    --warning-light: #fff3e0;
    --warning: #ff9800;
    --warning-dark: #ef6c00;

    --error-light: #ffebee;
    --error: #f44336;
    --error-dark: #c62828;

    --info-light: #e3f2fd;
    --info: #2196f3;
    --info-dark: #1565c0;

    /* Layout */
    --header-height: 64px;
    --sidebar-width: 320px;
    --content-max-width: 1600px;

    /* Typography */
    --font-primary: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;

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

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   Header
   ============================================================ */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-800) 0%, var(--primary-700) 100%);
    color: white;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo-text span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.main-nav {
    display: flex;
    gap: 8px;
}

.nav-item {
    padding: 8px 16px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: white;
}

.header-info {
    display: flex;
    gap: 8px;
}

.info-badge {
    padding: 4px 10px;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ============================================================
   Main Layout
   ============================================================ */
.main-content {
    margin-top: var(--header-height);
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    padding: 20px;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.form-select:hover {
    border-color: var(--primary-400);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.btn-search {
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-search:hover {
    background: var(--gray-100);
    border-color: var(--primary-400);
}

.btn-search svg {
    width: 18px;
    height: 18px;
    color: var(--gray-600);
}

.patient-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 12px;
}

.patient-item {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.patient-item:hover {
    background: var(--primary-50);
    border-color: var(--primary-300);
}

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

.patient-item .patient-id {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-800);
}

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

.placeholder-text {
    color: var(--gray-400);
    font-size: 0.875rem;
    text-align: center;
    padding: 20px;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.upload-zone:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.upload-zone.dragover {
    border-color: var(--primary-500);
    background: var(--primary-100);
}

.upload-zone svg {
    width: 32px;
    height: 32px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.upload-zone span {
    font-size: 0.875rem;
    color: var(--gray-500);
    display: block;
}

/* Section Navigation */
.section-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-nav-item {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
    color: var(--gray-600);
}

.section-nav-item:hover {
    background: var(--gray-100);
}

.section-nav-item.active {
    background: var(--primary-100);
    color: var(--primary-700);
}

.section-nav-item .section-num {
    font-weight: 600;
    min-width: 24px;
}

.section-nav-item .section-count {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--gray-200);
    border-radius: 10px;
}

/* ============================================================
   Content Area
   ============================================================ */
.content-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    max-width: calc(100% - var(--sidebar-width));
}

.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

/* Patient Info Bar */
.patient-info-bar {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-md);
}

.patient-avatar {
    width: 56px;
    height: 56px;
    background: var(--primary-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.patient-avatar svg {
    width: 28px;
    height: 28px;
    color: var(--primary-600);
}

.patient-details {
    flex: 1;
}

.patient-details h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.patient-meta {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.patient-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

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

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-100);
}

.btn-secondary:disabled {
    color: var(--gray-400);
    cursor: not-allowed;
}

/* Progress Bar */
.progress-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-align: center;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-md);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon svg {
    width: 24px;
    height: 24px;
}

.summary-card.correct .card-icon {
    background: var(--success-light);
    color: var(--success-dark);
}

.summary-card.disputed .card-icon {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.summary-card.missing .card-icon {
    background: var(--error-light);
    color: var(--error-dark);
}

.summary-card.total .card-icon {
    background: var(--info-light);
    color: var(--info-dark);
}

.card-content {
    display: flex;
    flex-direction: column;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.card-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Fields Container */
.fields-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.empty-state {
    text-align: center;
    padding: 60px 40px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Section Header */
.section-header {
    padding: 16px 0;
    border-bottom: 2px solid var(--primary-100);
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-700);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--primary-100);
    color: var(--primary-700);
    border-radius: 10px;
}

/* Field Card */
.field-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition-fast);
}

.field-card:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
}

.field-card.correct {
    border-left: 4px solid var(--success);
}

.field-card.disputed {
    border-left: 4px solid var(--warning);
}

.field-card.missing {
    border-left: 4px solid var(--error);
}

.field-header {
    padding: 12px 16px;
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.field-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.field-index {
    font-size: 0.7rem;
    color: var(--gray-500);
    min-width: 24px;
}

.field-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.875rem;
}

.field-display {
    color: var(--gray-500);
    font-size: 0.8rem;
}

.field-values {
    display: flex;
    align-items: center;
    gap: 16px;
}

.field-extracted {
    background: var(--primary-100);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--primary-800);
}

.field-expected {
    color: var(--gray-500);
    font-size: 0.8rem;
}

.field-status {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.field-status.correct {
    background: var(--success-light);
    color: var(--success-dark);
}

.field-status.disputed {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.field-status.missing {
    background: var(--error-light);
    color: var(--error-dark);
}

.field-status svg {
    width: 14px;
    height: 14px;
}

.field-body {
    padding: 16px;
    display: none;
}

.field-card.expanded .field-body {
    display: block;
}

.detail-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

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

.detail-block {
    flex: 1;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.detail-block h4 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.detail-block p {
    font-size: 0.85rem;
    color: var(--gray-700);
    line-height: 1.5;
}

.highlight {
    background: #fff59d;
    padding: 0 2px;
    border-radius: 2px;
}

/* ============================================================
   Analysis View
   ============================================================ */
.analysis-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.analysis-container h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--gray-800);
}

.analysis-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 12px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
    color: var(--gray-600);
}

.tab-btn:hover {
    background: var(--gray-100);
}

.tab-btn.active {
    background: var(--primary-100);
    color: var(--primary-700);
}

.tab-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.tab-icon.correct { background: var(--success); }
.tab-icon.disputed { background: var(--warning); }
.tab-icon.missing { background: var(--error); }

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.analysis-table {
    width: 100%;
    border-collapse: collapse;
}

.analysis-table th,
.analysis-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

.analysis-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

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

/* ============================================================
   Fields Definition View
   ============================================================ */
.fields-definition-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.fields-definition-container h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--gray-800);
}

.fields-filter {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.fields-filter input,
.fields-filter select {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.fields-filter input {
    flex: 1;
}

.fields-filter input:focus,
.fields-filter select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.fields-table {
    width: 100%;
    border-collapse: collapse;
}

.fields-table th,
.fields-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

.fields-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    position: sticky;
    top: 0;
}

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

.fields-table .fhir-code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--primary-700);
    background: var(--primary-50);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

/* ============================================================
   Modal
   ============================================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.125rem;
    color: var(--gray-800);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.source-info,
.summary-text,
.highlighted-text,
.reasoning-info,
.fhir-mapping {
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--gray-700);
}

.highlighted-text mark.highlight {
    background: #fff59d;
    padding: 0 2px;
    border-radius: 2px;
}

.fhir-mapping {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--primary-700);
}

/* ============================================================
   Loading Overlay
   ============================================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-spinner p {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
    }

    .content-area {
        margin-left: 0;
        max-width: 100%;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .patient-info-bar {
        flex-direction: column;
        text-align: center;
    }

    .patient-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================
   Cancer Info Container - Prompt/Extractor Status
   ============================================================ */
.cancer-info-container {
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 16px;
}

.cancer-info-header {
    font-size: 0.875rem;
    color: var(--primary-800);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--primary-200);
}

.cancer-info-header strong {
    font-weight: 600;
}

.cancer-info-header .cancer-id {
    color: var(--primary-600);
    font-size: 0.75rem;
    margin-left: 4px;
}

.cancer-info-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat-item {
    text-align: center;
    padding: 6px;
    background: white;
    border-radius: var(--radius-sm);
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-800);
}

.stat-value.status-ok {
    color: var(--success-dark);
}

.stat-value.status-warning {
    color: var(--warning-dark);
}

.section-status-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.section-status-item {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: help;
    transition: var(--transition-fast);
}

.section-status-item.complete {
    background: var(--success);
    color: white;
}

.section-status-item.partial {
    background: var(--warning);
    color: white;
}

.section-status-item.missing {
    background: var(--error);
    color: white;
}

.section-status-item:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.error-text {
    color: var(--error);
    font-size: 0.8rem;
    text-align: center;
    padding: 8px;
}

/* ============================================================
   Annotation Styles
   ============================================================ */

.analysis-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    gap: 4px;
}

.th-annotation {
    min-width: 220px;
    white-space: nowrap;
}

.td-annotation {
    min-width: 220px;
    padding: 6px 8px !important;
}

.annotation-wrapper {
    display: flex;
    gap: 4px;
    align-items: center;
}

.annotation-input {
    flex: 1;
    padding: 5px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    background: var(--gray-50);
    color: var(--gray-800);
    transition: border-color 0.2s;
    min-width: 0;
}

.annotation-input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}

.annotation-input::placeholder {
    color: var(--gray-400);
    font-size: 0.75rem;
}

.annotation-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: var(--primary-500);
    color: #fff;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
}

.annotation-btn:hover {
    background: var(--primary-800);
    transform: translateY(-1px);
}

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

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

.annotation-btn.saved {
    background: var(--success);
}

.annotation-btn.saved:hover {
    background: var(--success-dark);
}

/* Hospital ID Input */
.form-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: var(--gray-50);
    color: var(--gray-800);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.form-input::placeholder {
    color: var(--gray-400);
    font-size: 0.8rem;
}

/* ============================================================
   LLM Provider Selector (header) — 新增於 v3 整合版
   ============================================================ */
.llm-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--primary-200);
    border-radius: 999px;
    background: var(--primary-50);
    font-size: 0.75rem;
    color: var(--primary-800);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.llm-selector:hover {
    background: var(--primary-100);
    border-color: var(--primary-400);
}
.llm-selector-label {
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--primary-700);
}
.llm-selector-select {
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.78rem;
    color: var(--primary-800);
    cursor: pointer;
    font-weight: 500;
}
#engine-badge {
    background: linear-gradient(135deg, var(--primary-100), var(--primary-50));
    color: var(--primary-800);
    border: 1px solid var(--primary-200);
}
