/* ============================================
   医疗检查报告AI解读系统 V3 - 统一设计系统
   ============================================ */

/* ---- CSS 变量 ---- */
:root {
    --primary-50: #f0f9ff; --primary-100: #e0f2fe; --primary-200: #bae6fd;
    --primary-300: #7dd3fc; --primary-400: #38bdf8; --primary-500: #0ea5e9;
    --primary-600: #0284c7; --primary-700: #0369a1; --primary-800: #075985;
    --indigo-500: #6366f1; --indigo-600: #4f46e5;
    --success-50: #ecfdf5; --success-100: #d1fae5; --success-500: #10b981; --success-600: #059669;
    --warning-50: #fffbeb; --warning-100: #fef3c7; --warning-500: #f59e0b; --warning-600: #d97706;
    --danger-50: #fef2f2; --danger-100: #fee2e2; --danger-500: #ef4444; --danger-600: #dc2626;
    --info-50: #eff6ff; --info-100: #dbeafe; --info-500: #3b82f6; --info-600: #2563eb;
    --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1;
    --slate-400: #94a3b8; --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155;
    --slate-800: #1e293b; --slate-900: #0f172a;
    --bg: var(--slate-50); --card-bg: #ffffff;
    --text-primary: var(--slate-800); --text-secondary: var(--slate-500);
    --border: var(--slate-200);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --sidebar-width: 260px; --header-height: 64px;
    --radius-sm: 8px; --radius: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-full: 9999px;
    --transition-fast: 150ms ease; --transition: 200ms ease; --transition-slow: 300ms ease;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-sans); color: var(--text-primary); background: var(--bg); line-height: 1.6; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; outline: none; }
input, textarea, select { font-family: inherit; font-size: inherit; outline: none; }
ul, ol { list-style: none; }

/* ---- Layout ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width); background: var(--card-bg); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    transition: width var(--transition-slow);
}
.sidebar-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.75rem; }
.sidebar-logo {
    width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.sidebar-title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.nav-group { margin-bottom: 0.5rem; }
.nav-group-label { padding: 0.5rem 1rem; font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem; border-radius: var(--radius);
    color: var(--slate-600); font-size: 0.875rem; font-weight: 500; transition: all var(--transition-fast);
    position: relative; margin-bottom: 0.125rem;
}
.nav-item:hover { background: var(--primary-50); color: var(--primary-600); }
.nav-item.active { background: var(--primary-50); color: var(--primary-600); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--primary-500); border-radius: 0 3px 3px 0; }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.8; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }
.user-mini { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: var(--radius); cursor: pointer; transition: background var(--transition-fast); }
.user-mini:hover { background: var(--slate-50); }
.user-avatar {
    width: 36px; height: 36px; border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 0.875rem; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-tier { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }

.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left var(--transition-slow); }

.topbar { height: var(--header-height); background: var(--card-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; position: sticky; top: 0; z-index: 50; }
.page-title { font-size: 1.25rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.content-body { flex: 1; padding: 2rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---- Components ---- */
.card { background: var(--card-bg); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: box-shadow var(--transition); }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }

.stat-card { background: var(--card-bg); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); padding: 1.5rem; display: flex; align-items: flex-start; gap: 1rem; transition: transform var(--transition), box-shadow var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.primary { background: var(--primary-50); color: var(--primary-600); }
.stat-icon.success { background: var(--success-50); color: var(--success-600); }
.stat-icon.warning { background: var(--warning-50); color: var(--warning-600); }
.stat-icon.danger { background: var(--danger-50); color: var(--danger-600); }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.625rem 1.25rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
    transition: all var(--transition-fast); cursor: pointer; border: 1px solid transparent; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary-500); color: white; border-color: var(--primary-500); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); border-color: var(--primary-600); }
.btn-secondary { background: var(--slate-100); color: var(--slate-700); border-color: var(--slate-200); }
.btn-secondary:hover:not(:disabled) { background: var(--slate-200); }
.btn-success { background: var(--success-500); color: white; border-color: var(--success-500); }
.btn-success:hover:not(:disabled) { background: var(--success-600); }
.btn-danger { background: var(--danger-500); color: white; border-color: var(--danger-500); }
.btn-danger:hover:not(:disabled) { background: var(--danger-600); }
.btn-outline { background: transparent; color: var(--slate-600); border-color: var(--slate-300); }
.btn-outline:hover:not(:disabled) { background: var(--slate-50); border-color: var(--slate-400); }
.btn-ghost { background: transparent; color: var(--slate-600); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--slate-100); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.25rem 0.625rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600;
}
.badge-primary { background: var(--primary-50); color: var(--primary-700); }
.badge-success { background: var(--success-50); color: var(--success-700); }
.badge-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-danger { background: var(--danger-50); color: var(--danger-700); }
.badge-info { background: var(--info-50); color: var(--info-700); }
.badge-secondary { background: var(--slate-100); color: var(--slate-700); }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 0.625rem 0.875rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card-bg); color: var(--text-primary); font-size: 0.875rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px var(--primary-100); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--slate-400); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }

.progress-bar { width: 100%; height: 8px; background: var(--slate-100); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary-500); border-radius: var(--radius-full); transition: width var(--transition-slow); }
.progress-fill.success { background: var(--success-500); }
.progress-fill.warning { background: var(--warning-500); }
.progress-fill.danger { background: var(--danger-500); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th, .data-table td { padding: 0.875rem 1rem; text-align: left; font-size: 0.875rem; border-bottom: 1px solid var(--border); }
.data-table th { font-weight: 600; color: var(--text-secondary); background: var(--slate-50); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }
.data-table tbody tr:hover { background: var(--slate-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 0.5rem); background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 180px; z-index: 200;
    opacity: 0; visibility: hidden; transform: translateY(-4px); transition: all var(--transition-fast);
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 1rem; font-size: 0.875rem; color: var(--slate-700); transition: background var(--transition-fast); }
.dropdown-item:hover { background: var(--slate-50); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 0.5rem 0; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px);
    z-index: 300; display: flex; align-items: center; justify-content: center; padding: 1rem;
    opacity: 0; visibility: hidden; transition: all var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
    max-width: 520px; width: 100%; max-height: 90vh; overflow: hidden;
    display: flex; flex-direction: column; transform: scale(0.95); transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--slate-400); transition: all var(--transition-fast); }
.modal-close:hover { background: var(--slate-100); color: var(--text-primary); }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-icon { width: 80px; height: 80px; margin: 0 auto 1.5rem; background: var(--slate-100); border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--slate-400); }
.empty-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.empty-desc { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 1.5rem; }

.alert { padding: 1rem 1.25rem; border-radius: var(--radius); display: flex; align-items: flex-start; gap: 0.75rem; font-size: 0.875rem; }
.alert-info { background: var(--info-50); color: var(--info-700); border: 1px solid var(--info-100); }
.alert-success { background: var(--success-50); color: var(--success-700); border: 1px solid var(--success-100); }
.alert-warning { background: var(--warning-50); color: var(--warning-700); border: 1px solid var(--warning-100); }
.alert-danger { background: var(--danger-50); color: var(--danger-700); border: 1px solid var(--danger-100); }

.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 400; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 1rem 1.25rem; border-radius: var(--radius); background: var(--card-bg); box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-500); display: flex; align-items: flex-start; gap: 0.75rem;
    min-width: 300px; max-width: 400px; animation: toastSlideIn 300ms ease;
}
.toast.success { border-left-color: var(--success-500); }
.toast.error { border-left-color: var(--danger-500); }
.toast.warning { border-left-color: var(--warning-500); }

.steps { display: flex; align-items: center; justify-content: center; gap: 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.step-number { width: 36px; height: 36px; border-radius: var(--radius-full); background: var(--slate-100); color: var(--slate-500); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; transition: all var(--transition); }
.step.active .step-number { background: var(--primary-500); color: white; }
.step.completed .step-number { background: var(--success-500); color: white; }
.step-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.step.active .step-label { color: var(--primary-600); font-weight: 600; }
.step-line { flex: 1; height: 2px; background: var(--slate-200); max-width: 80px; margin: 0 0.75rem; margin-bottom: 1.5rem; }
.step-line.completed { background: var(--success-500); }

.upload-zone {
    border: 2px dashed var(--slate-300); border-radius: var(--radius-lg); padding: 3rem 2rem;
    text-align: center; transition: all var(--transition); cursor: pointer; background: var(--slate-50);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary-400); background: var(--primary-50); }
.upload-icon { width: 56px; height: 56px; margin: 0 auto 1rem; color: var(--slate-400); }
.upload-zone:hover .upload-icon, .upload-zone.dragover .upload-icon { color: var(--primary-500); }
.upload-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.375rem; }
.upload-desc { font-size: 0.8rem; color: var(--text-secondary); }

.spinner { width: 24px; height: 24px; border: 2px solid var(--slate-200); border-top-color: var(--primary-500); border-radius: var(--radius-full); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.accordion-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.75rem; }
.accordion-header { padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; cursor: pointer; background: var(--slate-50); transition: background var(--transition-fast); }
.accordion-header:hover { background: var(--slate-100); }
.accordion-title { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 0.5rem; }
.accordion-icon { transition: transform var(--transition); color: var(--slate-400); }
.accordion-item.open .accordion-icon { transform: rotate(180deg); }
.accordion-body { padding: 1.25rem; display: none; border-top: 1px solid var(--border); }
.accordion-item.open .accordion-body { display: block; }

.lock-overlay { position: relative; }
.lock-content {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
    justify-content: center; z-index: 10; gap: 0.75rem; text-align: center; padding: 1.5rem;
    background: rgba(255,255,255,0.9); backdrop-filter: blur(2px);
}
.lock-icon { width: 48px; height: 48px; background: var(--warning-50); border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--warning-500); }
.lock-text { font-weight: 600; }
.lock-hint { font-size: 0.8rem; color: var(--text-secondary); }

/* ---- Utilities ---- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary-600); }
.text-success { color: var(--success-600); }
.text-danger { color: var(--danger-600); }
.text-warning { color: var(--warning-600); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .content-body { padding: 1.5rem; }
}

@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: fixed; bottom: 0; left: 0; top: auto; flex-direction: row; border-right: none; border-top: 1px solid var(--border); z-index: 100; padding: 0.5rem; justify-content: space-around; }
    .sidebar-header, .sidebar-footer, .nav-group-label { display: none; }
    .sidebar-nav { display: flex; flex-direction: row; width: 100%; padding: 0; gap: 0; }
    .nav-group { margin: 0; display: flex; flex: 1; }
    .nav-item { flex-direction: column; padding: 0.5rem; gap: 0.25rem; font-size: 0.7rem; flex: 1; justify-content: center; }
    .nav-item.active::before { display: none; }
    .nav-item.active { background: var(--primary-50); }
    .main-content { margin-left: 0; margin-bottom: 70px; }
    .topbar { padding: 0 1rem; }
    .content-body { padding: 1rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stat-card { padding: 1rem; }
    .modal { margin: 1rem; max-height: calc(100vh - 2rem); }
}

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastSlideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-fade-in { animation: fadeIn 0.3s ease; }
.animate-slide-up { animation: slideUp 0.4s ease; }
.animate-slide-in-right { animation: slideInRight 0.3s ease; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.page-enter { animation: fadeIn 0.3s ease; }

/* ---- Login page specific (no sidebar) ---- */
.login-page { min-height: 100vh; display: flex; }
.login-left {
    flex: 1; display: flex; flex-direction: column; justify-content: center;
    padding: 3rem; background: linear-gradient(135deg, var(--primary-600), var(--indigo-600));
    color: white;
}
.login-right { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 3rem; background: var(--bg); }
.login-brand { font-size: 2rem; font-weight: 700; margin-bottom: 1rem; }
.login-tagline { font-size: 1.1rem; opacity: 0.9; margin-bottom: 2rem; }
.login-feature { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; font-size: 0.95rem; }
.login-feature svg { width: 20px; height: 20px; opacity: 0.9; flex-shrink: 0; }
.login-form-card { max-width: 420px; width: 100%; margin: 0 auto; }
.login-form-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-form-subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-toggle { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-secondary); }
.login-toggle a { color: var(--primary-600); font-weight: 500; }
.login-toggle a:hover { text-decoration: underline; }

@media (max-width: 768px) {
    .login-page { flex-direction: column; }
    .login-left { padding: 2rem; min-height: 30vh; }
    .login-right { padding: 2rem; }
    .login-brand { font-size: 1.5rem; }
}

/* ---- Tier badges ---- */
.tier-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
.tier-badge.basic { background: var(--slate-100); color: var(--slate-600); }
.tier-badge.premium { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.tier-badge.vip { background: linear-gradient(135deg, #ede9fe, #c4b5fd); color: #5b21b6; }

/* ---- Doctor card ---- */
.doctor-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; transition: all var(--transition); }
.doctor-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary-200); }
.doctor-avatar { width: 48px; height: 48px; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary-200), var(--primary-400)); display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 1rem; }
.doctor-name { font-weight: 600; font-size: 0.95rem; }
.doctor-title { font-size: 0.8rem; color: var(--text-secondary); }
.doctor-hospital { font-size: 0.8rem; color: var(--text-secondary); }
.doctor-dept { font-size: 0.75rem; }
.doctor-specialty { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* ---- Family member card ---- */
.member-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; transition: all var(--transition); cursor: pointer; }
.member-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary-200); transform: translateY(-2px); }
.member-avatar { width: 56px; height: 56px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 1.25rem; }
.member-name { font-weight: 600; font-size: 1rem; }
.member-relation { font-size: 0.8rem; color: var(--text-secondary); }
.member-stats { display: flex; gap: 1rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.member-stat { text-align: center; }
.member-stat-value { font-weight: 700; font-size: 1.1rem; }
.member-stat-label { font-size: 0.7rem; color: var(--text-secondary); }

/* ========== Stream Overlay (Analysis Phase) ========== */
.stream-overlay {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    min-height: 520px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    position: relative;
    overflow: hidden;
}

/* 装饰性背景网格 */
.stream-overlay::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(rgba(56,189,248,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56,189,248,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

/* 顶部状态栏 */
.stream-header {
    text-align: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(148,163,184,0.15);
    position: relative;
    z-index: 1;
}

.stream-status {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.stream-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34,197,94,0.7);
    animation: streamPulse 2s infinite;
}

@keyframes streamPulse {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.7); }
    70% { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.stream-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: 0.02em;
}

.stream-meta {
    font-size: 0.8rem;
    color: #94a3b8;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

/* 终端内容区 */
.stream-terminal {
    flex: 1;
    background: rgba(2,6,23,0.6);
    border: 1px solid rgba(148,163,184,0.12);
    border-radius: var(--radius);
    padding: 1.25rem;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #cbd5e1;
    position: relative;
    z-index: 1;
    min-height: 280px;
    max-height: 420px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,0.3) transparent;
}

.stream-terminal::-webkit-scrollbar { width: 6px; }
.stream-terminal::-webkit-scrollbar-track { background: transparent; }
.stream-terminal::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.25); border-radius: 3px; }

.stream-content { white-space: pre-wrap; word-break: break-word; }

/* 段落标签 */
.stream-content .sc-tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.sc-tag-conclusion { background: rgba(34,197,94,0.15); color: #4ade80; }
.sc-tag-layman    { background: rgba(56,189,248,0.15); color: #38bdf8; }
.sc-tag-detailed  { background: rgba(251,191,36,0.15); color: #fbbf24; }
.sc-tag-rec       { background: rgba(244,63,94,0.15); color: #fb7185; }

/* Markdown 在流式终端中的渲染 */
.stream-content h3, .stream-content h4 {
    color: #e2e8f0;
    margin: 0.75rem 0 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
}
.stream-content strong { color: #f1f5f9; font-weight: 600; }
.stream-content blockquote {
    border-left: 3px solid var(--primary-500);
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    color: #94a3b8;
}
.stream-content ul, .stream-content ol {
    margin: 0.35rem 0;
    padding-left: 1.25rem;
}
.stream-content li { margin: 0.15rem 0; }
.stream-content p { margin: 0.35rem 0; }

/* 闪烁光标 */
.stream-cursor {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    background: #38bdf8;
    border-radius: 1px;
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: streamBlink 1s step-end infinite;
}

@keyframes streamBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 底部进度 */
.stream-footer {
    position: relative;
    z-index: 1;
    padding-top: 0.5rem;
}

.stream-progress-bar {
    height: 4px;
    background: rgba(148,163,184,0.15);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.stream-progress-fill {
    height: 100%;
    width: 5%;
    background: linear-gradient(90deg, #0ea5e9, #22d3ee);
    border-radius: 2px;
    transition: width 0.8s ease;
    box-shadow: 0 0 8px rgba(14,165,233,0.4);
}

.stream-progress-text {
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

/* 完成状态 */
.stream-overlay.done .stream-pulse {
    background: #38bdf8;
    animation: none;
    box-shadow: 0 0 0 0;
}
.stream-overlay.done .stream-title {
    color: #38bdf8;
}
.stream-overlay.done .stream-cursor {
    display: none;
}

/* ---- Term highlight & tooltip ---- */
.term-highlight {
    border-bottom: 2px dotted var(--primary-400);
    color: var(--primary-600);
    font-weight: 600;
    cursor: help;
    transition: all var(--transition-fast);
}
.term-highlight:hover {
    border-bottom-style: solid;
    border-bottom-color: var(--primary-500);
    background: var(--primary-50);
    border-radius: 2px;
}

.term-tooltip {
    position: absolute;
    z-index: 500;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.75rem 1rem;
    max-width: 320px;
    min-width: 200px;
    font-size: 0.875rem;
    line-height: 1.5;
    pointer-events: auto;
    animation: fadeIn 150ms ease;
}
.term-tooltip-title {
    font-weight: 700;
    color: var(--primary-700);
    margin-bottom: 0.375rem;
    font-size: 0.95rem;
}
.term-tooltip-body {
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}
.term-tooltip-cat {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--primary-50);
    color: var(--primary-600);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}
.term-tooltip-loading {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ========== 术语高亮与Tooltip ========== */
.term-highlight {
    border-bottom: 1px dashed #38bdf8;
    color: #7dd3fc;
    cursor: help;
    transition: all 0.2s ease;
    position: relative;
}

.term-highlight:hover {
    border-bottom-style: solid;
    background: rgba(56, 189, 248, 0.1);
    border-radius: 2px;
}

/* Tooltip 容器 */
.term-tooltip {
    position: absolute;
    z-index: 1000;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    font-size: 0.8rem;
    line-height: 1.6;
    color: #e2e8f0;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.2s ease;
}

.term-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.term-tooltip::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    width: 10px;
    height: 10px;
    background: #0f172a;
    border-right: 1px solid rgba(56, 189, 248, 0.25);
    border-bottom: 1px solid rgba(56, 189, 248, 0.25);
    transform: rotate(45deg);
}

.term-tooltip-term {
    font-weight: 700;
    font-size: 0.85rem;
    color: #38bdf8;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.term-tooltip-term::before {
    content: '💡';
    font-size: 0.75rem;
}

.term-tooltip-explanation {
    color: #cbd5e1;
}

.term-tooltip-meta {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    font-size: 0.7rem;
    color: #64748b;
    display: flex;
    justify-content: space-between;
}
