* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: 'Segoe UI', sans-serif;
    background: #0b1120;
    color: #e2e8f0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 10px;
}
#app {
    max-width: 480px;
    width: 100%;
    background: #111b2e;
    border-radius: 28px;
    padding: 16px 18px 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    min-height: 90vh;
}
#main-content { flex:1; }
header { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; padding-bottom:10px; border-bottom:1px solid #1e2a3a; }
.header-left { display:flex; align-items:center; gap:8px; }
.app-title { font-size:1.2rem; font-weight:600; }
.status-badge { background:#ef4444; padding:4px 12px; border-radius:20px; font-size:0.7rem; font-weight:600; text-transform:uppercase; }
.status-badge.connected { background:#22c55e; }

.page { display:none; animation:fadeIn 0.3s; }
.page.active { display:block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

.welcome-icon { text-align:center; margin:20px 0 10px; }
.btn-large { padding:16px; font-size:1.2rem; width:100%; }

.setup-progress { display:flex; align-items:center; gap:12px; margin-bottom:16px; }
.step-indicator { font-size:0.9rem; color:#94a3b8; }
.progress-bar { flex:1; height:6px; background:#1a253a; border-radius:3px; overflow:hidden; }
#progress-fill { height:100%; background:#3b82f6; transition:width 0.5s; }

.setup-step { animation:fadeIn 0.3s; }
.setup-step h3 { font-size:1.3rem; margin-bottom:8px; }
.setup-step p { color:#94a3b8; margin-bottom:12px; }
.device-credentials { background:#0b1120; border-radius:12px; padding:12px; margin:10px 0; }
.device-credentials div { margin:4px 0; }
.instruction { font-style:italic; color:#94a3b8; }

.btn-primary, .btn-success, .btn-danger, .btn-secondary {
    border:none; padding:12px 24px; border-radius:30px; font-weight:600; font-size:1rem; cursor:pointer;
    display:inline-flex; align-items:center; gap:8px; justify-content:center; width:100%; transition:0.2s;
}
.btn-primary { background:#3b82f6; color:white; }
.btn-primary:hover { background:#2563eb; }
.btn-success { background:#22c55e; color:white; }
.btn-success:hover { background:#16a34a; }
.btn-danger { background:#ef4444; color:white; }
.btn-danger:hover { background:#dc2626; }
.btn-secondary { background:#334155; color:white; }
.btn-secondary:hover { background:#475569; }
.setup-step button, .session-summary button { margin-top:10px; }
.setup-step button:first-of-type { margin-top:0; }

.status-message { margin-top:10px; font-size:0.9rem; color:#facc15; }

.form-group { margin-bottom:14px; }
.form-group label { display:block; font-size:0.85rem; color:#94a3b8; margin-bottom:6px; }
.form-group input, .form-group select { width:100%; padding:10px 12px; border-radius:10px; border:1px solid #2a3a4f; background:#0b1120; color:#e2e8f0; font-size:0.95rem; }
.form-group input:focus, .form-group select:focus { outline:none; border-color:#3b82f6; }
.form-row { display:flex; gap:10px; }
.form-row .form-group { flex:1; }
.guide-list { margin:0 0 14px 20px; color:#cbd5e1; line-height:1.8; font-size:0.92rem; }
.guide-list li { margin-bottom:4px; }
.analysis-note { text-align:center; font-size:0.9rem; color:#93c5fd; margin-bottom:6px; min-height:1.2em; }
.disclaimer { text-align:center; font-size:0.72rem; color:#64748b; margin-bottom:10px; font-style:italic; }
.session-summary { background:#0b1120; border:1px solid #22c55e; border-radius:12px; padding:16px; margin:12px 0; text-align:center; }
.session-summary h4 { color:#22c55e; margin-bottom:8px; }
.session-summary p { color:#cbd5e1; margin-bottom:12px; }

#lead-guide-container { display:flex; justify-content:center; margin:12px 0; }
#body-svg { width:100%; max-width:280px; height:auto; background:transparent; }
.placement-tips { background:#0b1120; border-radius:10px; padding:10px; font-size:0.85rem; line-height:1.6; }

.monitor-controls { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.monitor-controls .btn-danger { width:auto; padding:8px 16px; }
#heart-rate-display { font-size:1.4rem; font-weight:700; color:#facc15; }
.frequency-control { display:flex; align-items:center; gap:4px; font-size:0.8rem; background:#1a253a; padding:2px 8px; border-radius:12px; }
.frequency-control select { background:transparent; color:white; border:none; font-size:0.8rem; outline:none; }
.signal-badge { font-size:0.8rem; background:#1a253a; padding:4px 12px; border-radius:20px; display:inline-flex; align-items:center; gap:4px; }

.waveform-container {
    background: #0b1120;
    border-radius: 16px;
    padding: 8px;
    border: 1px solid #2a3a4f;
    margin-bottom: 12px;
    width: 100%;
    overflow: hidden;
}
#ecgCanvas {
    display: block;
    width: 100%;
    height: auto;
    background: #0b1120;
    border-radius: 8px;
}

.rhythm-info { text-align:center; font-size:1.1rem; margin-bottom:8px; }

.trend-header { display:flex; justify-content:space-between; align-items:center; font-size:0.85rem; color:#94a3b8; margin:14px 0 6px; }
.trend-header i { color:#3b82f6; margin-right:4px; }
#hr-stats { color:#cbd5e1; font-size:0.8rem; }
.trend-container { padding:6px 8px; }
#hrTrendCanvas { display:block; width:100%; height:auto; background:#0b1120; border-radius:8px; }
.placement-check { background:#1a253a; border-radius:10px; padding:10px; margin:8px 0 16px; display:flex; align-items:center; gap:10px; font-size:0.9rem; border-left:4px solid #facc15; }
.placement-check i { color:#facc15; }

#bottom-nav { display:flex; justify-content:space-around; background:#0b1120; border-radius:20px; padding:8px 0; margin:16px 0 8px; border:1px solid #1e2a3a; }
.nav-item { display:flex; flex-direction:column; align-items:center; color:#64748b; padding:6px 12px; border-radius:12px; cursor:pointer; font-size:0.7rem; gap:2px; flex:1; }
.nav-item i { font-size:1.2rem; }
.nav-item.active { color:#3b82f6; background:#1a253a; }

#history-list { margin-top:12px; max-height:55vh; overflow-y:auto; }
.history-item { background:#1a253a; border-radius:12px; padding:14px; margin-bottom:10px; border:1px solid #2a3a4f; cursor:pointer; transition:0.2s; }
.history-item:hover { border-color:#3b82f6; transform:scale(1.01); }
.history-item .hdr-time { font-weight:600; color:#e2e8f0; }
.history-item .hdr-summary { display:flex; justify-content:space-between; margin-top:6px; font-size:0.9rem; flex-wrap:wrap; }
.history-item .hdr-patient { color:#93c5fd; }
.history-item .hdr-rhythm { font-weight:600; }
.history-item .hdr-hr { color:#facc15; }
.loading-spinner { text-align:center; color:#94a3b8; padding:20px; }

.modal { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); display:flex; align-items:center; justify-content:center; z-index:1000; padding:20px; }
.modal.hidden { display:none; }
.modal-content { background:#1e293b; padding:28px; border-radius:16px; max-width:500px; width:100%; max-height:90vh; overflow-y:auto; position:relative; }
.modal-content .close { position:absolute; top:10px; right:18px; font-size:2rem; cursor:pointer; color:#94a3b8; }
#modal-canvas { width:100%; height:auto; background:#0b1120; border-radius:8px; margin:10px 0; border:1px solid #2a3a4f; }

#history-list::-webkit-scrollbar { width:4px; }
#history-list::-webkit-scrollbar-track { background:#0b1120; }
#history-list::-webkit-scrollbar-thumb { background:#3b82f6; border-radius:4px; }

footer { text-align:center; font-size:0.7rem; color:#475569; margin-top:16px; padding-top:12px; border-top:1px solid #1e2a3a; }

@media (max-width:400px) {
    #app { padding:12px; }
    .step-card { padding:12px; }
    #body-svg { max-width:200px; }
    .modal-content { padding:20px; }
    .choice-group { flex-direction:column; }
    .btn-next, .btn-back { width:100%; }
}
