/* cap-emergency.css v7-p7 — 紧急求助子页面样式 + 暗色模式 + SOS FAB + P2组件 + P3增强 + P4修复 + P5优化 + P6功能增强 + P7安全加固 */
.cap-emer-container{width:100%;max-width:100%;margin:0;padding:8px;box-sizing:border-box;}
.cap-emer-tabs-wrap{position:relative;margin-bottom:12px;}
.cap-emer-tabs{display:flex;gap:4px;overflow-x:auto;padding-bottom:4px;scrollbar-width:thin;-webkit-overflow-scrolling:touch;}
.cap-emer-tabs::-webkit-scrollbar{height:3px;}
.cap-emer-tabs::-webkit-scrollbar-thumb{background:#ccc;border-radius:2px;}
.cap-emer-tabs .h-tab{white-space:nowrap;padding:6px 14px;border:none;background:#f0f0f0;border-radius:20px;cursor:pointer;font-size:14px;color:#666;transition:all .2s;flex-shrink:0;}
.cap-emer-tabs .h-tab.active{background:#E53935;color:#fff;}
.cap-emer-tabs .h-tab:hover{background:#e0e0e0;}
.cap-emer-tabs .h-tab.active:hover{background:#c62828;}

/* SOS大按钮 */
.cap-emer-sos-wrap{text-align:center;padding:30px 16px;}
.cap-emer-sos-btn{width:120px;height:120px;border-radius:50%;border:none;background:linear-gradient(135deg,#E53935,#c62828);color:#fff;font-size:20px;font-weight:700;cursor:pointer;box-shadow:0 4px 20px rgba(229,57,53,.4);transition:all .3s;position:relative;}
.cap-emer-sos-btn:hover{transform:scale(1.05);box-shadow:0 6px 30px rgba(229,57,53,.5);}
.cap-emer-sos-btn:active{transform:scale(0.95);}
.cap-emer-sos-btn .pulse{position:absolute;top:-4px;left:-4px;right:-4px;bottom:-4px;border-radius:50%;border:3px solid rgba(229,57,53,.4);animation:emerPulse 2s infinite;}
@keyframes emerPulse{0%{transform:scale(1);opacity:1;}100%{transform:scale(1.3);opacity:0;}}
.cap-emer-sos-countdown{font-size:48px;font-weight:700;color:#E53935;margin-top:12px;}
.cap-emer-sos-cancel{margin-top:8px;padding:6px 20px;border:1px solid #ddd;border-radius:20px;background:#fff;color:#666;cursor:pointer;font-size:14px;}
.cap-emer-sos-cancel:hover{background:#f5f5f5;}
.cap-emer-sos-hint{margin-top:12px;font-size:13px;color:#999;}

/* P1: 活跃警报 */
.cap-emer-active-alerts{margin-bottom:16px;}
.cap-emer-active-alert-card{background:#ffebee;border-radius:12px;padding:14px;margin-bottom:8px;border-left:4px solid #E53935;animation:emerAlertPulse 3s ease-in-out infinite;}
@keyframes emerAlertPulse{0%,100%{box-shadow:0 1px 3px rgba(229,57,53,.15);}50%{box-shadow:0 2px 12px rgba(229,57,53,.3);}}
.cap-emer-active-alert-header{display:flex;align-items:center;gap:6px;margin-bottom:6px;}
.cap-emer-active-alert-icon{font-size:20px;}
.cap-emer-active-alert-title{font-size:15px;font-weight:700;color:#c62828;}
.cap-emer-active-alert-time{margin-left:auto;font-size:12px;color:#999;}
.cap-emer-active-alert-detail{font-size:13px;color:#555;margin-top:2px;}

/* P1: 场景选择pills */
.cap-emer-scenario-select{margin:0 0 16px 0;}
.cap-emer-scenario-pills{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px;}
.cap-emer-scenario-pill{padding:6px 12px;border:1px solid #ddd;border-radius:16px;background:#fff;color:#666;cursor:pointer;font-size:13px;transition:all .2s;}
.cap-emer-scenario-pill.active{background:#E53935;color:#fff;border-color:#E53935;}
.cap-emer-scenario-pill:hover{background:#f5f5f5;}
.cap-emer-scenario-pill.active:hover{background:#c62828;}

/* P1: 解决按钮 */
.cap-emer-btn-resolve{margin-top:8px;padding:6px 16px;border:1px solid #4CAF50;border-radius:8px;background:#e8f5e9;color:#2e7d32;cursor:pointer;font-size:13px;transition:all .2s;}
.cap-emer-btn-resolve:hover{background:#c8e6c9;}

/* P1: 场景SOS按钮 */
.cap-emer-scenario-sos-btn{display:block;width:100%;margin-top:8px;padding:8px;border:none;border-radius:8px;background:rgba(229,57,53,.1);color:#c62828;cursor:pointer;font-size:13px;font-weight:600;transition:all .2s;}
.cap-emer-scenario-sos-btn:hover{background:rgba(229,57,53,.2);}

/* 热线 */
.cap-emer-hotlines{display:flex;gap:8px;justify-content:center;margin-top:16px;flex-wrap:wrap;}
.cap-emer-hotline-btn{padding:10px 20px;border:none;border-radius:12px;color:#fff;font-size:15px;font-weight:600;cursor:pointer;transition:all .2s;text-decoration:none;display:inline-flex;align-items:center;gap:6px;}
.cap-emer-hotline-120{background:#E53935;}
.cap-emer-hotline-110{background:#1565C0;}
.cap-emer-hotline-96110{background:#FF8F00;}
.cap-emer-hotline-btn:hover{opacity:.9;transform:translateY(-1px);}

/* 联系人快捷 */
.cap-emer-quick-contacts{margin-top:16px;}
.cap-emer-quick-contact{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-radius:10px;background:#f8f9fa;margin-bottom:6px;}
.cap-emer-quick-contact-name{font-weight:600;font-size:14px;}
.cap-emer-quick-contact-rel{font-size:12px;color:#999;margin-left:6px;}
.cap-emer-quick-call{padding:4px 12px;border:none;border-radius:16px;background:#4CAF50;color:#fff;cursor:pointer;font-size:13px;text-decoration:none;}

/* Section */
.cap-emer-section{background:#fff;border-radius:12px;padding:16px;margin-bottom:12px;box-shadow:0 1px 3px rgba(0,0,0,.06);}
.cap-emer-section-title{font-size:16px;font-weight:600;margin-bottom:12px;color:#333;}
.cap-emer-scenario-desc{font-size:13px;color:#999;margin-bottom:12px;}

/* 统计卡片 */
.cap-emer-stats-row{display:flex;gap:8px;margin-bottom:16px;}
.cap-emer-stat-box{flex:1;text-align:center;padding:14px 8px;border-radius:12px;}
.cap-emer-stat-num{font-size:24px;font-weight:700;}
.cap-emer-stat-label{font-size:12px;margin-top:4px;opacity:.8;}
.cap-emer-stat-contacts{background:#e3f2fd;color:#1565C0;}
.cap-emer-stat-alerts{background:#ffebee;color:#c62828;}
.cap-emer-stat-checkins{background:#e8f5e9;color:#2e7d32;}
.cap-emer-stat-falls{background:#fff3e0;color:#e65100;}

/* 联系人卡片 */
.cap-emer-contact-card{background:#fff;border-radius:10px;padding:14px;margin-bottom:8px;box-shadow:0 1px 2px rgba(0,0,0,.05);display:flex;align-items:center;justify-content:space-between;}
.cap-emer-contact-info{flex:1;}
.cap-emer-contact-name{font-size:15px;font-weight:600;}
.cap-emer-contact-phone{font-size:13px;color:#888;margin-top:2px;}
.cap-emer-contact-priority{font-size:11px;background:#f0f0f0;padding:2px 8px;border-radius:10px;margin-left:6px;}
.cap-emer-contact-actions{display:flex;gap:6px;}
.cap-emer-btn-sm{padding:4px 10px;border:1px solid #ddd;border-radius:16px;background:#fff;cursor:pointer;font-size:13px;color:#555;transition:all .2s;text-decoration:none;}
.cap-emer-btn-sm:hover{background:#f5f5f5;}
.cap-emer-btn-danger{color:#c62828;border-color:#ffcdd2;}
.cap-emer-btn-danger:hover{background:#ffebee;}

/* 添加按钮 */
.cap-emer-add-btn{width:100%;padding:12px;border:2px dashed #E53935;border-radius:12px;background:transparent;color:#E53935;cursor:pointer;font-size:15px;font-weight:600;margin-bottom:12px;transition:all .2s;}
.cap-emer-add-btn:hover{background:#ffebee;}

/* 表单 */
.cap-emer-form{background:#fff;border-radius:12px;padding:16px;margin-bottom:12px;box-shadow:0 1px 3px rgba(0,0,0,.06);}
.cap-emer-form-title{font-size:16px;font-weight:600;margin-bottom:12px;}
.cap-emer-form-row{margin-bottom:10px;}
.cap-emer-form-row label{display:block;font-size:13px;color:#666;margin-bottom:4px;}
.cap-emer-form-row input{width:100%;padding:8px 12px;border:1px solid #ddd;border-radius:8px;font-size:14px;box-sizing:border-box;background:#fff;color:#333;}
.cap-emer-form-row input:focus{border-color:#E53935;outline:none;}
.cap-emer-form-actions{display:flex;gap:8px;margin-top:12px;}
.cap-emer-btn-primary{padding:8px 20px;border:none;border-radius:8px;background:#E53935;color:#fff;cursor:pointer;font-size:14px;transition:all .2s;}
.cap-emer-btn-primary:hover{background:#c62828;}
.cap-emer-btn-cancel{padding:8px 20px;border:1px solid #ddd;border-radius:8px;background:#fff;color:#666;cursor:pointer;font-size:14px;}

/* P1: 确认弹窗 */
.cap-emer-confirm-modal{background:#fff;border-radius:12px;padding:20px;max-width:320px;width:90%;box-shadow:0 4px 20px rgba(0,0,0,.15);}
.cap-emer-confirm-title{font-size:16px;font-weight:600;margin-bottom:6px;color:#333;}
.cap-emer-confirm-desc{font-size:13px;color:#666;margin-bottom:16px;}
.cap-emer-confirm-actions{display:flex;gap:8px;justify-content:flex-end;}

/* 场景卡片 */
.cap-emer-scenario-card{border-radius:10px;padding:14px;margin-bottom:8px;cursor:pointer;transition:all .2s;}
.cap-emer-scenario-card:hover{transform:translateY(-2px);box-shadow:0 3px 12px rgba(0,0,0,.1);}
.cap-emer-scenario-card-danger{background:linear-gradient(135deg,#ffebee,#fce4ec);border-left:4px solid #E53935;}
.cap-emer-scenario-card-warning{background:linear-gradient(135deg,#fff8e1,#fff3e0);border-left:4px solid #FF8F00;}
.cap-emer-scenario-header{display:flex;align-items:center;gap:8px;margin-bottom:6px;}
.cap-emer-scenario-icon{font-size:24px;}
.cap-emer-scenario-label{font-size:15px;font-weight:600;}
.cap-emer-scenario-hotline{margin-left:auto;font-size:12px;padding:2px 8px;border-radius:10px;background:#E53935;color:#fff;}
.cap-emer-scenario-keywords{font-size:12px;color:#999;margin-bottom:6px;}
.cap-emer-scenario-advice{display:none;margin-top:8px;padding-top:8px;border-top:1px dashed rgba(0,0,0,.1);}
.cap-emer-scenario-card.expanded .cap-emer-scenario-advice{display:block;}
.cap-emer-advice-step{font-size:13px;color:#555;padding:3px 0;line-height:1.5;}

/* 事件历史 */
.cap-emer-event-card{background:#fff;border-radius:10px;padding:12px;margin-bottom:8px;box-shadow:0 1px 2px rgba(0,0,0,.05);}
.cap-emer-event-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;}
.cap-emer-event-type{font-size:14px;font-weight:600;}
.cap-emer-event-time{font-size:12px;color:#999;}
.cap-emer-event-status{font-size:11px;padding:2px 8px;border-radius:10px;}
.cap-emer-event-status-active{background:#ffebee;color:#c62828;}
.cap-emer-event-status-resolved{background:#e8f5e9;color:#2e7d32;}
.cap-emer-event-status-completed{background:#e8f5e9;color:#2e7d32;}
.cap-emer-event-status-pending{background:#fff3e0;color:#e65100;}
.cap-emer-event-status-detected{background:#e3f2fd;color:#1565C0;}
.cap-emer-event-detail{font-size:13px;color:#666;margin-top:4px;}
.cap-emer-event-source{font-size:11px;color:#bbb;margin-top:2px;}

/* 签到 */
.cap-emer-checkin-row{display:flex;gap:8px;margin-bottom:12px;}
.cap-emer-checkin-btn{flex:1;padding:14px;border:none;border-radius:12px;cursor:pointer;font-size:15px;font-weight:600;transition:all .2s;}
.cap-emer-checkin-morning{background:linear-gradient(135deg,#FFF59D,#FFB74D);color:#E65100;}
.cap-emer-checkin-evening{background:linear-gradient(135deg,#90CAF9,#5C6BC0);color:#fff;}
.cap-emer-checkin-btn:hover{transform:translateY(-2px);box-shadow:0 3px 10px rgba(0,0,0,.15);}
.cap-emer-checkin-btn.done{opacity:.5;cursor:default;transform:none;box-shadow:none;}
.cap-emer-checkin-btn.done:hover{transform:none;box-shadow:none;}

/* 设置 */
.cap-emer-setting-row{display:flex;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid #f0f0f0;}
.cap-emer-setting-row:last-child{border-bottom:none;}
.cap-emer-setting-label{font-size:14px;color:#333;}
.cap-emer-setting-desc{font-size:12px;color:#999;margin-top:2px;}
.cap-emer-switch{position:relative;width:44px;height:24px;background:#ccc;border-radius:12px;cursor:pointer;transition:all .2s;flex-shrink:0;}
.cap-emer-switch.on{background:#4CAF50;}
.cap-emer-switch::after{content:'';position:absolute;top:2px;left:2px;width:20px;height:20px;background:#fff;border-radius:50%;transition:all .2s;}
.cap-emer-switch.on::after{left:22px;}
.cap-emer-info-row{padding:6px 0;font-size:14px;color:#555;line-height:1.5;}
.cap-emer-info-row strong{color:#333;}
.cap-emer-disclaimer{background:#fff3e0;border-radius:8px;padding:10px 14px;margin:8px 0;font-size:13px;color:#e65100;line-height:1.5;}

/* 空状态 */
.cap-emer-empty{text-align:center;padding:24px;color:#999;font-size:14px;}
.cap-emer-empty-guide{text-align:center;padding:40px 20px;}
.cap-emer-empty-guide-icon{font-size:48px;margin-bottom:12px;opacity:.6;}
.cap-emer-empty-guide-title{font-size:16px;font-weight:600;color:#555;margin-bottom:6px;}
.cap-emer-empty-guide-desc{font-size:13px;color:#999;margin-bottom:16px;line-height:1.5;}
.cap-emer-empty-guide-btn{padding:8px 24px;border:none;border-radius:20px;background:#E53935;color:#fff;cursor:pointer;font-size:14px;transition:all .2s;}
.cap-emer-empty-guide-btn:hover{background:#c62828;}
.cap-emer-loading{text-align:center;padding:24px;color:#999;}

/* Toast */
.cap-emer-toast{position:fixed;bottom:80px;left:50%;transform:translateX(-50%);background:rgba(0,0,0,.8);color:#fff;padding:10px 20px;border-radius:8px;font-size:14px;z-index:99999;animation:emerFadeIn .3s;}
@keyframes emerFadeIn{from{opacity:0;transform:translateX(-50%) translateY(10px);}to{opacity:1;transform:translateX(-50%) translateY(0);}}

/* P1: SOS FAB 浮动按钮 */
.emer-sos-fab{position:fixed;bottom:90px;right:20px;width:56px;height:56px;border-radius:50%;background:linear-gradient(135deg,#E53935,#c62828);border:3px solid #fff;box-shadow:0 4px 15px rgba(229,57,53,.4);cursor:pointer;z-index:99997;display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:700;color:#fff;transition:all .3s;animation:emerFabPulse 2.5s ease-in-out infinite;}
.emer-sos-fab:hover{animation:none;transform:scale(1.1);box-shadow:0 6px 20px rgba(229,57,53,.6);}
.emer-sos-fab:active{transform:scale(0.95);}
@keyframes emerFabPulse{0%,100%{box-shadow:0 4px 15px rgba(229,57,53,.3);}50%{box-shadow:0 4px 28px rgba(229,57,53,.6),0 0 0 6px rgba(229,57,53,.08);}}
/* SOS FAB: 仅长辈区和个人区显示 */
body:not([data-l1-active="elder"]):not([data-l1-active="personal"]) .emer-sos-fab{display:none !important;}

/* ============ P1: 暗色模式 ============ */
html[data-theme="dark"] .cap-emer-tabs .h-tab{background:#2d2d2d;color:#aaa;}
html[data-theme="dark"] .cap-emer-tabs .h-tab.active{background:#E53935;color:#fff;}
html[data-theme="dark"] .cap-emer-tabs .h-tab:hover{background:#3d3d3d;}
html[data-theme="dark"] .cap-emer-sos-cancel{background:#2d2d2d;color:#aaa;border-color:#444;}
html[data-theme="dark"] .cap-emer-sos-hint{color:#888;}
html[data-theme="dark"] .cap-emer-section{background:#1e1e2e;box-shadow:0 1px 3px rgba(0,0,0,.3);}
html[data-theme="dark"] .cap-emer-section-title{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-scenario-desc{color:#888;}
html[data-theme="dark"] .cap-emer-quick-contact{background:#2d2d3d;}
html[data-theme="dark"] .cap-emer-quick-contact-name{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-quick-contact-rel{color:#888;}
html[data-theme="dark"] .cap-emer-contact-card{background:#1e1e2e;box-shadow:0 1px 2px rgba(0,0,0,.2);}
html[data-theme="dark"] .cap-emer-contact-name{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-contact-phone{color:#888;}
html[data-theme="dark"] .cap-emer-contact-priority{background:#3d3d3d;color:#aaa;}
html[data-theme="dark"] .cap-emer-btn-sm{background:#2d2d2d;color:#aaa;border-color:#444;}
html[data-theme="dark"] .cap-emer-btn-sm:hover{background:#3d3d3d;}
html[data-theme="dark"] .cap-emer-add-btn{color:#ef5350;border-color:#ef5350;}
html[data-theme="dark"] .cap-emer-add-btn:hover{background:rgba(239,83,80,.1);}
html[data-theme="dark"] .cap-emer-form{background:#1e1e2e;box-shadow:0 1px 3px rgba(0,0,0,.3);}
html[data-theme="dark"] .cap-emer-form-title{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-form-row label{color:#aaa;}
html[data-theme="dark"] .cap-emer-form-row input{background:#2d2d2d;color:#e0e0e0;border-color:#444;}
html[data-theme="dark"] .cap-emer-btn-cancel{background:#2d2d2d;color:#aaa;border-color:#444;}
html[data-theme="dark"] .cap-emer-confirm-modal{background:#1e1e2e;}
html[data-theme="dark"] .cap-emer-confirm-title{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-confirm-desc{color:#aaa;}
html[data-theme="dark"] .cap-emer-scenario-card-danger{background:linear-gradient(135deg,#3d1515,#3d1a22);border-left-color:#E53935;}
html[data-theme="dark"] .cap-emer-scenario-card-warning{background:linear-gradient(135deg,#3d2d10,#3d2510);border-left-color:#FF8F00;}
html[data-theme="dark"] .cap-emer-scenario-label{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-scenario-keywords{color:#888;}
html[data-theme="dark"] .cap-emer-advice-step{color:#bbb;}
html[data-theme="dark"] .cap-emer-scenario-sos-btn{background:rgba(229,57,53,.15);color:#ef5350;}
html[data-theme="dark"] .cap-emer-scenario-sos-btn:hover{background:rgba(229,57,53,.25);}
html[data-theme="dark"] .cap-emer-event-card{background:#1e1e2e;box-shadow:0 1px 2px rgba(0,0,0,.2);}
html[data-theme="dark"] .cap-emer-event-type{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-event-time{color:#888;}
html[data-theme="dark"] .cap-emer-event-detail{color:#aaa;}
html[data-theme="dark"] .cap-emer-event-source{color:#666;}
html[data-theme="dark"] .cap-emer-btn-resolve{background:rgba(76,175,80,.1);color:#66bb6a;border-color:#388e3c;}
html[data-theme="dark"] .cap-emer-btn-resolve:hover{background:rgba(76,175,80,.2);}
html[data-theme="dark"] .cap-emer-setting-label{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-setting-desc{color:#888;}
html[data-theme="dark"] .cap-emer-setting-row{border-bottom-color:#333;}
html[data-theme="dark"] .cap-emer-info-row{color:#bbb;}
html[data-theme="dark"] .cap-emer-info-row strong{color:#e0e0e0;}
html[data-theme="dark"] .cap-emer-disclaimer{background:rgba(255,143,0,.1);color:#ffb74d;}
html[data-theme="dark"] .cap-emer-empty-guide-title{color:#aaa;}
html[data-theme="dark"] .cap-emer-empty-guide-desc{color:#888;}
html[data-theme="dark"] .cap-emer-loading{color:#888;}
html[data-theme="dark"] .cap-emer-active-alert-card{background:rgba(229,57,53,.1);}
html[data-theme="dark"] .cap-emer-active-alert-detail{color:#ccc;}
html[data-theme="dark"] .cap-emer-scenario-pill{background:#2d2d2d;color:#aaa;border-color:#444;}
html[data-theme="dark"] .cap-emer-scenario-pill:hover{background:#3d3d3d;}
html[data-theme="dark"] .cap-emer-stat-contacts{background:rgba(21,101,192,.15);}
html[data-theme="dark"] .cap-emer-stat-alerts{background:rgba(229,57,53,.15);}
html[data-theme="dark"] .cap-emer-stat-checkins{background:rgba(46,125,50,.15);}
html[data-theme="dark"] .cap-emer-checkin-btn.done{opacity:.4;}

/* ============ P2: 新增组件样式 ============ */

/* P2: 加载态spinner */
.cap-emer-loading-spin{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:40px 20px;color:#999;gap:12px;}
.cap-emer-spinner{width:28px;height:28px;border:3px solid #f0f0f0;border-top-color:#E53935;border-radius:50%;animation:emerSpin 0.8s linear infinite;}
@keyframes emerSpin{to{transform:rotate(360deg);}}
html[data-theme="dark"] .cap-emer-loading-spin{color:#888;}
html[data-theme="dark"] .cap-emer-spinner{border-color:#333;border-top-color:#E53935;}

/* P2: 事件工具栏（搜索+过滤） */
.cap-emer-event-toolbar{display:flex;gap:8px;margin-bottom:12px;}
.cap-emer-event-search{flex:1;padding:8px 12px;border:1px solid #ddd;border-radius:8px;font-size:14px;box-sizing:border-box;background:#fff;color:#333;}
.cap-emer-event-search:focus{border-color:#E53935;outline:none;}
.cap-emer-event-filter{padding:8px 12px;border:1px solid #ddd;border-radius:8px;font-size:14px;background:#fff;color:#333;cursor:pointer;flex-shrink:0;}
html[data-theme="dark"] .cap-emer-event-search{background:#2d2d2d;color:#e0e0e0;border-color:#444;}
html[data-theme="dark"] .cap-emer-event-filter{background:#2d2d2d;color:#e0e0e0;border-color:#444;}

/* P2: 事件计数 */
.cap-emer-event-count{font-size:12px;color:#999;margin-bottom:8px;}
html[data-theme="dark"] .cap-emer-event-count{color:#888;}

/* P2: 事件展开详情 */
.cap-emer-event-details{margin-top:8px;padding-top:8px;border-top:1px dashed rgba(0,0,0,.08);}
.cap-emer-event-card.expanded{background:#fafafa;}
.cap-emer-event-actions{display:flex;gap:8px;margin-top:8px;flex-wrap:wrap;}
html[data-theme="dark"] .cap-emer-event-details{border-top-color:rgba(255,255,255,.08);}
html[data-theme="dark"] .cap-emer-event-card.expanded{background:#252535;}

/* P2: 加载更多按钮 */
.cap-emer-load-more{display:block;width:100%;padding:10px;border:1px dashed #ccc;border-radius:8px;background:transparent;color:#666;cursor:pointer;font-size:13px;transition:all .2s;margin-top:8px;}
.cap-emer-load-more:hover{background:#f5f5f5;border-color:#999;}
html[data-theme="dark"] .cap-emer-load-more{color:#aaa;border-color:#444;}
html[data-theme="dark"] .cap-emer-load-more:hover{background:#2d2d2d;border-color:#666;}

/* P2: 趋势图（CSS柱状图） */
.cap-emer-trend-chart{display:flex;align-items:flex-end;justify-content:space-between;height:80px;gap:4px;padding:8px 4px 0;margin-top:4px;}
.cap-emer-trend-bar-wrap{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;}
.cap-emer-trend-bar{width:60%;max-width:24px;min-height:4px;background:linear-gradient(180deg,#E53935,#ef5350);border-radius:4px 4px 0 0;position:relative;transition:height .3s;display:flex;align-items:flex-start;justify-content:center;}
.cap-emer-trend-count{font-size:10px;color:#E53935;font-weight:600;position:absolute;top:-16px;}
.cap-emer-trend-label{font-size:10px;color:#999;margin-top:4px;}
html[data-theme="dark"] .cap-emer-trend-label{color:#888;}
html[data-theme="dark"] .cap-emer-trend-count{color:#ef5350;}

/* P2: 类型分布 */
.cap-emer-type-dist{margin-top:8px;}
.cap-emer-type-dist-item{display:flex;justify-content:space-between;padding:6px 12px;border-radius:8px;background:#f5f5f5;margin-bottom:4px;font-size:13px;}
.cap-emer-type-dist-count{font-weight:600;color:#E53935;}
html[data-theme="dark"] .cap-emer-type-dist-item{background:#2d2d2d;color:#ccc;}

/* 移动端 */
@media(max-width:600px){
  .cap-emer-stats-row{flex-wrap:wrap;}
  .cap-emer-stat-box{min-width:45%;}
  .cap-emer-stat-num{font-size:20px;}
  .cap-emer-sos-btn{width:100px;height:100px;font-size:18px;}
  .cap-emer-hotlines{flex-direction:column;}
  .cap-emer-hotline-btn{width:100%;justify-content:center;}
  .cap-emer-checkin-row{flex-direction:column;}
  .emer-sos-fab{width:52px;height:52px;font-size:18px;bottom:80px;}
  /* P2: 移动端事件工具栏 */
  .cap-emer-event-toolbar{flex-direction:column;}
  .cap-emer-event-filter{width:100%;}
  .cap-emer-trend-chart{height:60px;}
  .cap-emer-trend-bar{width:50%;}
}

/* ============ P3: 增强样式 ============ */

/* P3: 倒计时紧迫度颜色 */
.cap-emer-sos-countdown.countdown-normal{color:#E53935;}
.cap-emer-sos-countdown.countdown-warning{color:#FF8F00;animation:emerCountPulse 0.5s ease-in-out infinite alternate;}
.cap-emer-sos-countdown.countdown-urgent{color:#B71C1C;animation:emerCountPulse 0.3s ease-in-out infinite alternate;}
@keyframes emerCountPulse{from{transform:scale(1);}to{transform:scale(1.15);}}

/* P3: 0联系人警告 */
.cap-emer-no-contact-warning{background:#fff3e0;border:1px solid #FFB74D;border-radius:10px;padding:10px 14px;margin-bottom:12px;font-size:13px;color:#E65100;line-height:1.5;}
html[data-theme="dark"] .cap-emer-no-contact-warning{background:rgba(255,143,0,.1);color:#ffb74d;border-color:rgba(255,143,0,.3);}

/* P3: focus-visible 键盘焦点样式 */
.cap-emer-sos-btn:focus-visible,.cap-emer-sos-cancel:focus-visible{outline:3px solid #1565C0;outline-offset:3px;}
.cap-emer-tabs .h-tab:focus-visible{outline:2px solid #1565C0;outline-offset:2px;}
.cap-emer-btn-primary:focus-visible,.cap-emer-btn-cancel:focus-visible{outline:2px solid #1565C0;outline-offset:2px;}
.cap-emer-add-btn:focus-visible{outline:2px solid #1565C0;outline-offset:2px;}
.cap-emer-scenario-pill:focus-visible{outline:2px solid #1565C0;outline-offset:2px;}
.cap-emer-checkin-btn:focus-visible{outline:2px solid #1565C0;outline-offset:2px;}
.emer-sos-fab:focus-visible{outline:3px solid #1565C0;outline-offset:3px;}

/* P3: prefers-reduced-motion 禁用脉冲动画 */
@media (prefers-reduced-motion: reduce){
  .cap-emer-sos-btn .pulse,.cap-emer-active-alert-card,.emer-sos-fab,.cap-emer-sos-countdown.countdown-warning,.cap-emer-sos-countdown.countdown-urgent{animation:none !important;}
  .cap-emer-sos-btn:hover,.cap-emer-sos-btn:active,.emer-sos-fab:hover,.emer-sos-fab:active{transform:none !important;}
  .cap-emer-scenario-card:hover{transform:none !important;}
  .cap-emer-checkin-btn:hover{transform:none !important;box-shadow:none !important;}
}

/* P3: 打印样式——医疗信息卡可打印 */
@media print{
  .cap-emer-tabs-wrap,.cap-emer-sos-wrap,.cap-emer-hotlines,.cap-emer-quick-contacts,.cap-emer-checkin-row,.cap-emer-add-btn,.emer-sos-fab{display:none !important;}
  .cap-emer-container{max-width:100%;padding:0;}
  .cap-emer-section{box-shadow:none;border:1px solid #ccc;page-break-inside:avoid;}
  .cap-emer-form-row input{border:1px solid #999;color:#000;-webkit-print-color-adjust:exact;print-color-adjust:exact;}
  body{background:#fff !important;}
}

/* P3: 360px 超小屏优化 */
@media(max-width:360px){
  .cap-emer-tabs .h-tab{padding:5px 10px;font-size:13px;}
  .cap-emer-sos-btn{width:90px;height:90px;font-size:16px;}
  .cap-emer-sos-countdown{font-size:40px;}
  .cap-emer-stat-num{font-size:18px;}
  .cap-emer-stats-row{gap:4px;}
  .cap-emer-stat-box{padding:10px 4px;}
}

/* === P6 新增样式 === */
/* 症状输入框 */
.cap-emer-symptom-input-wrap{margin:12px 0;}
.cap-emer-symptom-input{width:100%;padding:10px 14px;border:2px solid #e0e0e0;border-radius:12px;font-size:15px;outline:none;transition:border-color .2s;box-sizing:border-box;}
.cap-emer-symptom-input:focus{border-color:#E53935;}
.cap-emer-symptom-result{margin-top:8px;}
.cap-emer-detect-result{background:#FFF3E0;border-radius:12px;padding:12px;border-left:3px solid #FF9800;}
.cap-emer-detect-title{font-size:14px;font-weight:600;color:#E65100;margin-bottom:8px;}
.cap-emer-detect-item{display:flex;align-items:center;gap:8px;padding:10px;background:#fff;border-radius:8px;margin-bottom:6px;cursor:pointer;transition:box-shadow .2s;}
.cap-emer-detect-item:hover{box-shadow:0 2px 8px rgba(0,0,0,.12);}
.cap-emer-detect-icon{font-size:20px;}
.cap-emer-detect-label{font-weight:600;color:#333;flex-shrink:0;}
.cap-emer-detect-kw{font-size:12px;color:#888;flex:1;}
.cap-emer-detect-action{font-size:13px;color:#E53935;font-weight:600;flex-shrink:0;}
.cap-emer-detect-empty{padding:10px;text-align:center;color:#888;font-size:14px;}

/* 活跃警报横幅 */
.cap-emer-active-alert-banner{display:flex;align-items:center;gap:12px;background:linear-gradient(135deg,#FFEBEE,#FFCDD2);border-radius:12px;padding:12px 16px;margin-bottom:12px;cursor:pointer;animation:cap-emer-pulse-banner 2s ease-in-out infinite;}
@keyframes cap-emer-pulse-banner{0%,100%{box-shadow:0 0 0 0 rgba(229,57,53,.3);}50%{box-shadow:0 0 0 6px rgba(229,57,53,0);}}
.cap-emer-alert-banner-icon{font-size:28px;}
.cap-emer-alert-banner-title{font-size:15px;font-weight:700;color:#B71C1C;}
.cap-emer-alert-banner-desc{font-size:12px;color:#C62828;}

/* SOS辅助按钮 */
.cap-emer-sos-aux-buttons{display:flex;gap:8px;margin-bottom:12px;}
.cap-emer-btn-aux{flex:1;padding:10px;border:1px solid #e0e0e0;border-radius:10px;background:#f5f5f5;color:#555;font-size:14px;cursor:pointer;transition:all .2s;}
.cap-emer-btn-aux:hover{background:#eee;border-color:#bbb;}
.cap-emer-btn-aux:active{transform:scale(.97);}

/* === P7 新增样式 === */
/* 批量解除按钮 */
.cap-emer-btn-resolve-all{flex-shrink:0;padding:6px 14px;background:#E53935;color:#fff;border:none;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;transition:all .2s;}
.cap-emer-btn-resolve-all:hover{background:#C62828;}
.cap-emer-btn-resolve-all:active{transform:scale(.97);}

/* 离线横幅 */
.cap-emer-offline-banner{background:#FF6F00;color:#fff;padding:10px 14px;border-radius:8px;margin-bottom:10px;font-size:14px;text-align:center;font-weight:500;}

/* 屏幕阅读器专用 */
.cap-emer-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}

/* ============ P8: 浅色模式按钮修复（击败 theme.v2.css button override） ============ */
html[data-theme="light"] .cap-emer-btn-primary{background:#E53935 !important;color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-btn-primary:hover{background:#c62828 !important;}
html[data-theme="light"] .cap-emer-btn-cancel{background:#fff !important;color:#666 !important;border:1px solid #ddd !important;}
html[data-theme="light"] .cap-emer-add-btn{background:transparent !important;color:#E53935 !important;border:2px dashed #E53935 !important;}
html[data-theme="light"] .cap-emer-add-btn:hover{background:#ffebee !important;}
html[data-theme="light"] .cap-emer-sos-cancel{background:#fff !important;color:#666 !important;border:1px solid #ddd !important;}
html[data-theme="light"] .cap-emer-sos-cancel:hover{background:#f5f5f5 !important;}
html[data-theme="light"] .cap-emer-empty-guide-btn{background:#E53935 !important;color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-empty-guide-btn:hover{background:#c62828 !important;}
html[data-theme="light"] .cap-emer-checkin-morning{background:linear-gradient(135deg,#FFF59D,#FFB74D) !important;color:#E65100 !important;border:none !important;}
html[data-theme="light"] .cap-emer-checkin-evening{background:linear-gradient(135deg,#90CAF9,#5C6BC0) !important;color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-btn-resolve{background:#e8f5e9 !important;color:#2e7d32 !important;border:1px solid #4CAF50 !important;}
html[data-theme="light"] .cap-emer-btn-resolve:hover{background:#c8e6c9 !important;}
html[data-theme="light"] .cap-emer-btn-resolve-all{background:#E53935 !important;color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-btn-resolve-all:hover{background:#C62828 !important;}
html[data-theme="light"] .cap-emer-btn-aux{background:#f5f5f5 !important;color:#555 !important;border:1px solid #e0e0e0 !important;}
html[data-theme="light"] .cap-emer-btn-aux:hover{background:#eee !important;border-color:#bbb !important;}
html[data-theme="light"] .cap-emer-scenario-sos-btn{background:rgba(229,57,53,.1) !important;color:#c62828 !important;border:none !important;}
html[data-theme="light"] .cap-emer-scenario-sos-btn:hover{background:rgba(229,57,53,.2) !important;}
html[data-theme="light"] .cap-emer-sos-btn{background:linear-gradient(135deg,#E53935,#c62828) !important;color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-load-more{background:transparent !important;color:#666 !important;border:1px dashed #ccc !important;}
html[data-theme="light"] .cap-emer-load-more:hover{background:#f5f5f5 !important;border-color:#999 !important;}
html[data-theme="light"] .cap-emer-hotline-btn{color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-hotline-120{background:#E53935 !important;}
html[data-theme="light"] .cap-emer-hotline-110{background:#1565C0 !important;}
html[data-theme="light"] .cap-emer-hotline-96110{background:#FF8F00 !important;}
html[data-theme="light"] .cap-emer-quick-call{background:#4CAF50 !important;color:#fff !important;border:none !important;}
html[data-theme="light"] .cap-emer-btn-sm{background:#fff !important;color:#555 !important;border:1px solid #ddd !important;}
html[data-theme="light"] .cap-emer-btn-sm:hover{background:#f5f5f5 !important;}
html[data-theme="light"] .cap-emer-btn-danger{color:#c62828 !important;border-color:#ffcdd2 !important;}
html[data-theme="light"] .cap-emer-btn-danger:hover{background:#ffebee !important;}
html[data-theme="light"] .cap-emer-tabs .h-tab{background:#f0f0f0 !important;color:#666 !important;border:none !important;}
html[data-theme="light"] .cap-emer-tabs .h-tab.active{background:#E53935 !important;color:#fff !important;}
html[data-theme="light"] .cap-emer-tabs .h-tab:hover{background:#e0e0e0 !important;}
html[data-theme="light"] .cap-emer-tabs .h-tab.active:hover{background:#c62828 !important;}
html[data-theme="light"] .cap-emer-scenario-pill{background:#fff !important;color:#666 !important;border:1px solid #ddd !important;}
html[data-theme="light"] .cap-emer-scenario-pill.active{background:#E53935 !important;color:#fff !important;border-color:#E53935 !important;}
html[data-theme="light"] .cap-emer-scenario-pill:hover{background:#f5f5f5 !important;}
html[data-theme="light"] .cap-emer-scenario-pill.active:hover{background:#c62828 !important;}
html[data-theme="light"] .cap-emer-event-filter{background:#fff !important;color:#333 !important;border:1px solid #ddd !important;}

/* P8: 语音按钮样式 */
.cap-emer-voice-btn{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border:1px solid #ddd;border-radius:16px;background:#f5f5f5;color:#555;cursor:pointer;font-size:13px;transition:all .2s;vertical-align:middle;margin-left:8px;}
.cap-emer-voice-btn:hover{background:#eee;}
.cap-emer-voice-btn.speaking{background:#E53935;color:#fff;border-color:#E53935;animation:emerVoicePulse 1s ease-in-out infinite;}
@keyframes emerVoicePulse{0%,100%{opacity:1;}50%{opacity:.7;}}
html[data-theme="dark"] .cap-emer-voice-btn{background:#2d2d2d;color:#aaa;border-color:#444;}
html[data-theme="dark"] .cap-emer-voice-btn:hover{background:#3d3d3d;}
html[data-theme="dark"] .cap-emer-voice-btn.speaking{background:#E53935;color:#fff;border-color:#E53935;}
html[data-theme="light"] .cap-emer-voice-btn{background:#f5f5f5 !important;color:#555 !important;border:1px solid #ddd !important;}
html[data-theme="light"] .cap-emer-voice-btn:hover{background:#eee !important;}
html[data-theme="light"] .cap-emer-voice-btn.speaking{background:#E53935 !important;color:#fff !important;border-color:#E53935 !important;}

/* === SOS FAB: PC sidebar + mobile draggable === */

/* PC sidebar mode */
.emer-sos-fab-sidebar {
  position: relative !important;
  bottom: auto !important;
  right: auto !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  margin: 16px auto 8px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  font-size: 16px !important;
}
.emer-sos-fab-sidebar .emer-sos-fab-label {
  display: block !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  margin-top: 1px !important;
  letter-spacing: 0.5px !important;
}
.emer-sos-fab-sidebar .emer-sos-fab-icon {
  font-size: 16px !important;
}

/* Mobile draggable mode */
.emer-sos-fab .emer-sos-fab-label {
  display: none;
}
.emer-sos-fab .emer-sos-fab-icon {
  font-size: 20px;
}
.emer-sos-fab.dragging {
  opacity: 0.85;
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(229,57,53,0.5) !important;
  animation: none !important;
  z-index: 100000 !important;
}
.emer-sos-fab {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Dark mode adjustments */
html[data-theme="dark"] .emer-sos-fab-sidebar {
  border-color: rgba(255,255,255,0.2) !important;
}
