:root {
    --primary-blue: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --status-good: #10b981;
    --status-warning: #fbbf24;
    --status-danger: #ef4444; 
    --status-purple: #8b5cf6;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main); line-height: 1.6; padding: 2rem 1rem; min-height: 100vh;
}

.app-container { max-width: 1400px; margin: 0 auto; }

.app-header {
    display: flex; align-items: center; margin-bottom: 2rem; gap: 1.2rem;
    border-bottom: 2px solid var(--primary-blue); padding-bottom: 1rem;
}

.hospital-brand { display: flex; align-items: center; gap: 1rem; }
.hospital-logo { width: 60px; height: 60px; display: block; object-fit: contain; }
.hospital-name { display: flex; flex-direction: column; }
.hospital-name h2 { font-size: 1.5rem; font-weight: 800; color: #C03535; letter-spacing: 1px; line-height: 1.2; }
.hospital-name span { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase; }

.title-wrap h1 { font-size: 1.4rem; font-weight: 700; color: var(--primary-blue); letter-spacing: -0.5px; }
.title-wrap p { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.2rem; }

.main-content { display: grid; grid-template-columns: 35% 65%; gap: 1.5rem; align-items: flex-start; }
.card { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 2rem; border: 1px solid var(--border-color); }

.section-title-wrap { display: flex; align-items: center; margin-bottom: 1.5rem; border-bottom: 2px solid var(--primary-light); padding-bottom: 0.8rem; }
.section-icon { font-size: 1.4rem; color: var(--primary-blue); margin-right: 0.8rem; }
.section-title { font-size: 1.3rem; font-weight: 700; }
.subsection-title { font-size: 1.1rem; font-weight: 600; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text-muted); }
.required { color: var(--status-danger); }
input[type="text"], input[type="number"], select { padding: 0.7rem 0.8rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 1rem; background-color: var(--bg-color); outline: none; }
input[type="text"]:focus, input[type="number"]:focus, select:focus { border-color: var(--primary-blue); background-color: #fff; box-shadow: 0 0 0 3px var(--primary-light); }

.divider { height: 1px; background-color: var(--border-color); margin: 1.8rem 0; }

.checkbox-group { justify-content: center; }
.switch-container { display: flex; align-items: center; cursor: pointer; user-select: none; }
.switch-container input { opacity: 0; width: 0; height: 0; }
.slider { position: relative; display: inline-block; width: 44px; height: 24px; background-color: #cbd5e1; border-radius: 24px; transition: .3s; margin-right: 12px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; border-radius: 50%; transition: .3s; }
input:checked + .slider { background-color: var(--primary-blue); }
input:checked + .slider:before { transform: translateX(20px); }
.toggle-label { font-size: 0.95rem; font-weight: 500; }

.form-actions { margin-top: 2rem; }
.btn-primary { width: 100%; background-color: var(--primary-blue); color: white; font-size: 1.1rem; font-weight: 600; padding: 1rem; border: none; border-radius: var(--radius-md); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-primary:hover { background-color: var(--primary-hover); }

.report-actions { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.btn-icon { background: white; border: 1px solid var(--border-color); padding: 0.5rem 1rem; border-radius: var(--radius-sm); color: var(--primary-blue); font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; }

.empty-state, .loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 500px; color: var(--text-muted); }
.empty-icon-wrap { font-size: 48px; color: #cbd5e1; margin-bottom: 1rem; }
.hidden { display: none !important; }
.spinner { width: 48px; height: 48px; border: 4px solid var(--border-color); border-top-color: var(--primary-blue); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 1.5rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 打印与格式化表样式 */
.printable-report { background: white; padding: 2rem; border-radius: var(--radius-md); box-shadow: 0 0 0 1px var(--border-color); }
.printable-report canvas { max-width: 100% !important; max-height: 100% !important; }
.report-header { text-align: center; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 2px solid var(--primary-blue); }
.report-meta { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.5rem; }

.mt-4 { margin-top: 2rem; }
.report-block { margin-bottom: 1.5rem; page-break-inside: avoid; }
.block-title { font-size: 1.2rem; font-weight: 700; color: var(--text-main); background: var(--primary-light); padding: 0.6rem 1rem; border-left: 4px solid var(--primary-blue); border-radius: 4px; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }

/* 风险评估数值化展示区 */
.risk-overview-flex {
    display: flex; align-items: center; gap: 1.5rem; background: #f8fafc;
    padding: 1.5rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    min-width: 0;
}
.risk-values-box { min-width: 250px; }
.val-grid { display: grid; grid-template-columns: 1fr; row-gap: 0.5rem; font-size: 0.9rem; }
.val-item { display: flex; justify-content: space-between; }
.val-item strong { color: var(--primary-blue); font-size: 1rem; }

/* 视觉图表容器 */
.chart-container { width: 100%; position: relative; min-width: 0; }

/* 心脏年龄时间轴可视化 */
.heart-age-visualizer { background: #f8fafc; border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 2rem; position: relative; min-width: 0; }
.visualizer-header { display: flex; justify-content: space-around; margin-bottom: 2rem; }
.vh-item { text-align: center; }
.vh-item span { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 0.3rem;}
.vh-item h3 { font-size: 1.8rem; margin: 0; }
.age-timeline { position: relative; height: 60px; margin: 0 auto; width: 80%; }
.timeline-track { position: absolute; top: 30px; left: 0; width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; }
.timeline-marker { position: absolute; top: 12px; display: flex; flex-direction: column; align-items: center; transform: translateX(-50%); transition: left 1s ease-out; }
.timeline-marker p { font-size: 0.8rem; font-weight: 600; white-space: nowrap; margin-top: 4px;}
.actual-marker { left: 30%; color: var(--primary-blue); }
.actual-marker i { display: block; width: 18px; height: 18px; background: var(--primary-blue); border-radius: 50%; border: 3px solid white; box-shadow: 0 0 0 2px var(--primary-blue); }
.heart-marker { left: 30%; color: var(--status-danger); z-index: 2; }
.heart-marker i { display: block; width: 22px; height: 22px; background: var(--status-danger); border-radius: 50%; border: 3px solid white; box-shadow: 0 0 0 2px var(--status-danger); }

/* 并列小图 */
.peer-visuals-grid { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 1.5rem; min-width: 0; }
.pv-col { flex: 1; border: 1px solid var(--border-color); padding: 1rem; border-radius: var(--radius-sm); background: #fafafa; min-width: 0; width: 50%; }
.pv-sub { font-size: 0.95rem; text-align: center; margin-bottom: 1rem; color: var(--text-main); }
.gauge-center-text { position: absolute; top: 60%; left: 50%; transform: translate(-50%, -50%); font-size: 2rem; font-weight: 800; color: var(--text-main); }

/* 干预处方 */
.prescription-content { display: flex; flex-direction: column; gap: 1rem; }
.presc-item { padding: 1.2rem; border-left: 4px solid var(--primary-blue); background: #f8fafc; border-radius: 0 8px 8px 0; }
.presc-item h4 { font-size: 1.1rem; color: var(--text-main); display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.presc-item h4 i { color: var(--primary-blue); }
.presc-item ul { margin-top: 0.5rem; padding-left: 1.5rem; list-style-type: disc; font-size: 0.95rem; }

.report-footer { text-align: center; font-size: 0.85rem; color: var(--text-muted); border-top: 1px dashed var(--border-color); padding-top: 1rem; margin-top: 2rem; }

@media (max-width: 1100px) { 
    .main-content { grid-template-columns: 1fr; } 
}
@media (max-width: 768px) { 
    .risk-overview-flex { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; } 
    .app-header { flex-direction: column; text-align: center; gap: 0.5rem; }
    .title-wrap { margin-left: 0 !important; text-align: center !important; }
}

/* --------------- 打印极简核心样式 --------------- */
@media print {
    /* 采用0边距暴力关闭所有浏览器默认页眉(网址)与页脚，同时依靠 thead/tfoot 进行物理防撞 */
    @page { margin: 0; size: A4 portrait; }
    .print-page-spacer { height: 15mm; }
    body { background-color: white; margin: 0; padding: 0; }
    .app-header, .form-section, .report-actions, .empty-state, .loading-state { display: none !important; }
    .main-content { display: block; }
    .printable-report { padding: 0 !important; border: none !important; box-shadow: none !important; width: 100%; max-width: 100%; }

    /* 绝对防御打印界面的缩放导致 Flex 盒子坍塌为移动端形态 */
    .risk-overview-flex, .peer-visuals-grid {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
    }
    .pv-col, .risk-values-box, .chart-container {
        flex: 1 !important;
    }
    .val-item { font-size: 0.8rem; } /* 缩小左侧文字保障图表右侧空间 */
    
    /* 采用多重属性硬性约束，严防模块中途被腰斩 */
    .report-block {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        margin-bottom: 2rem !important;
    }
}
