/* ============================================
   CliniqAI — Powered by Arcanum Cloud
   Red & Black Theme
   ============================================ */

:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --primary-light: #fee2e2;
  --accent: #f97316;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #0a0a0a;
  --text-sec: #404040;
  --text-muted: #737373;
  --border: #e5e5e5;
  --grad-start: #1a1a1a;
  --grad-end: #991b1b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---- Screens ---- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ---- Login & Lock Screens ---- */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
}

.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
  font-size: 3rem; margin-bottom: 0.5rem;
}

.login-title {
  font-size: 1.8rem; font-weight: 700; color: white;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.8rem; color: #737373; margin-top: 0.25rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}

.login-card {
  background: white; border-radius: 16px; padding: 1.75rem;
  width: 100%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-info {
  font-size: 0.85rem; color: var(--text-sec);
  margin-bottom: 1rem; line-height: 1.5;
}

.btn-login {
  width: 100%; padding: 0.8rem; border-radius: 10px; border: none;
  background: var(--primary); color: white;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  margin-top: 0.5rem; transition: background 0.15s;
}

.btn-login:hover { background: var(--primary-dark); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-signout {
  width: 100%; padding: 0.6rem; border-radius: 10px;
  border: 1px solid var(--border); background: white;
  color: var(--text-sec); font-size: 0.85rem; cursor: pointer;
  margin-top: 0.5rem;
}

.btn-signout-settings {
  width: 100%; padding: 0.75rem; border-radius: 12px;
  border: 1.5px solid var(--danger); background: white;
  color: var(--danger); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; margin-top: 0.5rem;
}

.login-error {
  color: var(--danger); font-size: 0.8rem;
  margin-top: 0.75rem; text-align: center;
}

.forgot-link {
  text-align: center; margin-top: 0.75rem; font-size: 0.8rem;
}

.forgot-link a {
  color: var(--primary); text-decoration: none; font-weight: 500;
}

.forgot-link a:hover { text-decoration: underline; }

.login-footer {
  color: #525252; font-size: 0.7rem; margin-top: 1.5rem;
  text-align: center;
}

/* ---- Top Bars ---- */
.top-bar {
  padding: 0.9rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.gradient-bar {
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  color: white;
}

.dark-bar { background: #0f172a; color: white; }

.white-bar {
  background: white;
  border-bottom: 1px solid var(--border);
}

.top-bar-left { display: flex; align-items: center; gap: 0.6rem; }
.top-bar-right { display: flex; gap: 0.5rem; }

.app-logo {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

.app-name { font-size: 1.1rem; font-weight: 700; }
.app-subtitle { font-size: 0.65rem; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.05em; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: white;
  font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.back-link {
  background: none; border: none; color: var(--primary);
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
}

.top-bar-title-light { font-size: 1rem; font-weight: 600; color: white; }
.top-bar-title-dark { font-size: 1rem; font-weight: 600; color: var(--text); }

.top-actions { display: flex; gap: 0.5rem; }

.action-pill {
  padding: 0.35rem 0.7rem; border-radius: 20px;
  border: 1px solid var(--border); background: white;
  font-size: 0.8rem; cursor: pointer;
}

.primary-pill {
  background: var(--primary); color: white; border-color: var(--primary);
}

/* ---- Provider Card ---- */
.provider-card {
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  padding: 0 1.25rem 1.25rem;
  color: white;
  border-radius: 0 0 20px 20px;
}

.provider-info { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; }

.provider-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
  border: 2px solid rgba(255,255,255,0.3);
}

.provider-details h2 { font-size: 1rem; font-weight: 600; }
.provider-details p { font-size: 0.78rem; opacity: 0.8; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; margin-top: 0.5rem; }

.stat-box {
  background: rgba(255,255,255,0.12);
  border-radius: 12px; padding: 0.5rem; text-align: center;
}

.stat-number { font-size: 1.2rem; font-weight: 700; }
.stat-label { font-size: 0.6rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- Content ---- */
.content { padding: 1.25rem; padding-bottom: 100px; flex: 1; }

.section-title {
  font-size: 0.7rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.6rem;
}

/* ---- Quick Actions ---- */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 1.5rem; }

.action-card {
  background: var(--card); border-radius: 14px; padding: 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); cursor: pointer;
  border: 1px solid var(--border); transition: transform 0.15s;
}

.action-card:active { transform: scale(0.97); }

.action-card.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border: none;
}

.action-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}

.action-card.primary .action-icon { background: rgba(255,255,255,0.2); }
.action-card:not(.primary) .action-icon { background: var(--primary-light); }
.action-label { font-size: 0.85rem; font-weight: 600; }

/* ---- Encounter List ---- */
.encounter-list { display: flex; flex-direction: column; gap: 0.5rem; }

.encounter-card {
  background: var(--card); border-radius: 12px; padding: 0.85rem 1rem;
  display: flex; align-items: center; gap: 0.7rem;
  border: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}

.encounter-card:active { background: #f1f5f9; }

.enc-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}

.enc-details { flex: 1; min-width: 0; }
.enc-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enc-meta { font-size: 0.7rem; color: var(--text-muted); }

.enc-badge {
  padding: 0.15rem 0.5rem; border-radius: 20px;
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase; flex-shrink: 0;
}

.badge-done { background: var(--success-light); color: #065f46; }
.badge-pending { background: var(--primary-light); color: #991b1b; }
.badge-fail { background: #fee2e2; color: #991b1b; }

.enc-arrow { color: var(--text-muted); font-size: 1rem; flex-shrink: 0; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-img { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; margin-bottom: 0.75rem; }
.empty-state h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.empty-state p { font-size: 0.8rem; color: var(--text-muted); }

/* ---- FAB ---- */
.fab {
  position: fixed; bottom: calc(68px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border: 3px solid white;
  box-shadow: 0 4px 16px rgba(220,38,38,0.4);
  font-size: 1.5rem; cursor: pointer; z-index: 101;
  display: flex; align-items: center; justify-content: center;
}

.fab:active { transform: translateX(-50%) scale(0.93); }

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px;
  background: white; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 0.4rem 0 calc(0.4rem + var(--safe-bottom));
  z-index: 100;
}

.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  padding: 0.2rem 0.5rem; border: none; background: none;
  cursor: pointer; color: var(--text-muted); font-size: 0.6rem; font-weight: 500;
}

.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 1.2rem; }
.nav-item.spacer { opacity: 0; pointer-events: none; width: 60px; }

/* ---- Recording Screen ---- */
.recording-screen {
  background: #0f172a;
  min-height: 100vh;
  display: flex; flex-direction: column;
  color: white;
}

.patient-bar {
  margin: 0 1.25rem;
  background: rgba(255,255,255,0.06);
  border-radius: 12px; padding: 0.65rem 0.85rem;
  display: flex; justify-content: space-between; align-items: center;
}

.patient-info { display: flex; align-items: center; gap: 0.5rem; }

.patient-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(220,38,38,0.15);
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}

.patient-name { font-size: 0.85rem; font-weight: 600; }
.patient-id { font-size: 0.65rem; color: var(--text-muted); }

.specialty-tag {
  background: rgba(220,38,38,0.1); color: #fca5a5;
  padding: 0.2rem 0.5rem; border-radius: 20px;
  font-size: 0.65rem; font-weight: 500;
}

.waveform-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1.5rem; gap: 1rem;
}

.pre-record { text-align: center; }

.big-mic-btn {
  width: 110px; height: 110px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 24px rgba(220,38,38,0.4);
  transition: transform 0.15s;
}

.big-mic-btn:active { transform: scale(0.93); }
.pre-record-text { color: var(--text-muted); font-size: 0.9rem; }

.active-record { width: 100%; text-align: center; }

.waveform {
  width: 100%; height: 80px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
}

.wave-bar {
  width: 3px; border-radius: 3px;
  background: linear-gradient(to top, var(--primary), var(--accent));
  animation: wave 1.2s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% { height: 6px; opacity: 0.3; }
  50% { opacity: 1; }
}

.timer {
  font-size: 3rem; font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em; margin: 0.5rem 0;
}

.recording-label {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--danger); font-weight: 500;
}

.rec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); animation: blink 1s infinite;
}

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

.live-transcript {
  background: rgba(255,255,255,0.05);
  border-radius: 10px; padding: 0.75rem;
  width: 100%; max-height: 80px; overflow: hidden;
  margin-top: 0.5rem;
}

.live-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.controls {
  padding: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

.stop-btn {
  width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2);
  background: var(--danger); color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 24px rgba(239,68,68,0.3);
}

.stop-icon { width: 22px; height: 22px; border-radius: 4px; background: white; }

/* ---- Processing Screen ---- */
.processing-screen {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  color: white;
}

.processing-content { text-align: center; padding: 2rem; }

.processing-animation {
  position: relative; width: 120px; height: 120px; margin: 0 auto 1.5rem;
}

.proc-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid transparent;
}

.ring1 { border-top-color: var(--primary); animation: spin 2s linear infinite; }
.ring2 { inset: 10px; border-right-color: #f97316; animation: spin 1.5s linear infinite reverse; }
.ring3 { inset: 20px; border-bottom-color: #fbbf24; animation: spin 3s linear infinite; }

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

.proc-center {
  position: absolute; inset: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

.proc-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.5rem; }

.pipeline-steps { text-align: left; display: inline-block; }

.pipe-step {
  padding: 0.4rem 0; font-size: 0.85rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 0.5rem;
}

.pipe-step.active { color: white; font-weight: 500; }
.pipe-step.done { color: var(--success); }
.pipe-step.error { color: var(--danger); }
.pipe-icon { font-size: 1rem; width: 20px; text-align: center; }

/* ---- Results Screen ---- */
.encounter-header {
  background: white; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}

.encounter-title-row { display: flex; justify-content: space-between; align-items: flex-start; }
.enc-title { font-size: 1.05rem; font-weight: 700; }
.enc-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }

.status-pill {
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.6rem; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600;
  background: var(--success-light); color: #065f46;
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }

.meta-chips { display: flex; gap: 0.35rem; margin-top: 0.6rem; flex-wrap: wrap; }

.chip {
  padding: 0.2rem 0.5rem; border-radius: 8px;
  font-size: 0.65rem; font-weight: 500;
  background: #f1f5f9; color: var(--text-sec);
}

/* Tabs */
.tabs {
  display: flex; background: white; border-bottom: 1px solid var(--border);
  overflow-x: auto; position: sticky; top: 52px; z-index: 99;
}

.tab {
  padding: 0.65rem 0.85rem; font-size: 0.78rem; font-weight: 600;
  color: var(--text-muted); border: none; background: none;
  cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.rtab { display: none; }
.rtab.active { display: block; }

/* SOAP sections */
.soap-section {
  background: white; border-radius: 12px; margin-bottom: 0.6rem;
  overflow: hidden; border: 1px solid var(--border);
}

.soap-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.85rem; background: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.soap-letter {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: white; flex-shrink: 0;
}

.soap-letter.s { background: #dc2626; }
.soap-letter.o { background: #0a0a0a; }
.soap-letter.a { background: #f97316; }
.soap-letter.p { background: #7c2d12; }

.soap-title { font-size: 0.8rem; font-weight: 600; }

.soap-body {
  padding: 0.7rem 0.85rem; font-size: 0.82rem;
  line-height: 1.6; color: var(--text-sec); white-space: pre-wrap;
}

/* Codes */
.code-card {
  background: white; border: 1px solid var(--border);
  border-radius: 10px; padding: 0.65rem 0.85rem;
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem;
}

.code-badge {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 0.25rem 0.5rem; border-radius: 6px;
  font-size: 0.75rem; font-weight: 700;
  font-family: 'SF Mono', monospace; flex-shrink: 0;
}

.code-desc { font-size: 0.8rem; flex: 1; }
.code-conf { font-size: 0.7rem; color: var(--success); font-weight: 600; flex-shrink: 0; }

/* Entities */
.entity-group { margin-bottom: 0.6rem; }
.entity-group-title {
  font-size: 0.65rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem;
}

.entity-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.entity-tag {
  padding: 0.2rem 0.55rem; border-radius: 20px;
  font-size: 0.7rem; font-weight: 500;
}

.tag-med { background: #fee2e2; color: #991b1b; }
.tag-cond { background: #fef3c7; color: #92400e; }
.tag-anat { background: #d1fae5; color: #065f46; }
.tag-proc { background: #f5f5f5; color: #171717; }
.tag-time { background: #fce7f3; color: #9d174d; }
.tag-other { background: #f5f5f5; color: var(--text-sec); }

/* Transcript */
.transcript-box {
  background: white; border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem;
  font-size: 0.82rem; line-height: 1.7; color: var(--text-sec);
  max-height: 400px; overflow-y: auto;
}

/* Patient Visit Summary */
.patient-summary-card {
  background: white; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}

.summary-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1rem; background: #fef2f2;
  border-bottom: 1px solid #fecaca;
}

.summary-icon { font-size: 1.5rem; }

.summary-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.summary-subtitle { font-size: 0.7rem; color: var(--text-muted); }

.summary-body {
  padding: 1rem; font-size: 0.88rem; line-height: 1.75;
  color: var(--text-sec); white-space: pre-wrap;
}

/* Bottom Actions */
.bottom-actions {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px;
  background: white; border-top: 1px solid var(--border);
  padding: 0.65rem 1.25rem calc(0.65rem + var(--safe-bottom));
  display: flex; gap: 0.5rem;
}

.bottom-btn {
  flex: 1; padding: 0.65rem; border-radius: 10px; border: none;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
}

.outline-btn { background: white; color: var(--text); border: 1.5px solid var(--border); }
.success-btn { background: var(--success); color: white; }
.ehr-btn { background: #1e40af; color: white; }

/* ---- Settings ---- */
.settings-card {
  background: white; border-radius: 14px; padding: 1.25rem;
  border: 1px solid var(--border); margin-bottom: 1rem;
}

.settings-card h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.settings-about { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }

.form-group { margin-bottom: 0.85rem; }
.form-group label {
  display: block; font-size: 0.7rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 0.25rem;
}

.form-group input,
.form-group select {
  width: 100%; padding: 0.55rem 0.7rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; background: white;
}

.form-group input:focus,
.form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

/* ---- Patient Search & Select ---- */
.patient-search-wrap {
  position: relative; margin-bottom: 1rem;
}

.patient-search-input {
  width: 100%; padding: 0.85rem 1rem;
  border: 2px solid var(--border); border-radius: 14px;
  font-size: 1rem; background: white;
  transition: border-color 0.15s;
}

.patient-search-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

.patient-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: white; border: 1px solid var(--border);
  border-radius: 12px; margin-top: 0.35rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 240px; overflow-y: auto; z-index: 50;
}

.pd-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.7rem 1rem; cursor: pointer;
  transition: background 0.1s; border-bottom: 1px solid #f5f5f5;
}

.pd-item:last-child { border-bottom: none; }
.pd-item:active, .pd-item:hover { background: #fef2f2; }

.pd-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}

.pd-info { flex: 1; }
.pd-name { font-size: 0.85rem; font-weight: 600; }
.pd-id { font-size: 0.65rem; color: var(--text-muted); }

.pd-new {
  color: var(--primary); font-weight: 600;
}

.pd-new .pd-avatar {
  background: var(--primary); color: white; font-size: 1.1rem;
}

.selected-patient-card {
  background: white; border: 2px solid var(--primary);
  border-radius: 14px; padding: 1rem;
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem;
}

.selected-patient-card .sp-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
}

.selected-patient-card .sp-info { flex: 1; }
.selected-patient-card .sp-name { font-size: 1rem; font-weight: 700; }
.selected-patient-card .sp-id { font-size: 0.75rem; color: var(--text-muted); }

.selected-patient-card .sp-change {
  background: none; border: none; color: var(--primary);
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  text-decoration: underline;
}

.btn-start-encounter {
  width: 100%; padding: 0.9rem; border-radius: 14px; border: none;
  background: var(--primary); color: white;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  box-shadow: 0 4px 16px rgba(220,38,38,0.3);
  transition: background 0.15s;
}

.btn-start-encounter:hover { background: var(--primary-dark); }
.btn-start-encounter:active { transform: scale(0.98); }

.mrn-section { margin-bottom: 1rem; }

.optional-tag {
  font-size: 0.6rem; font-weight: 400; color: var(--text-muted);
  text-transform: none; letter-spacing: 0;
}

/* ---- EHR Modal ---- */
.ehr-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 1rem;
}

.ehr-modal {
  background: white; border-radius: 16px; width: 100%;
  max-width: 480px; max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.ehr-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}

.ehr-modal-header h3 { font-size: 1rem; font-weight: 700; }

.ehr-modal-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--text-muted); padding: 0.25rem;
}

.ehr-modal-body { padding: 1.25rem; overflow-y: auto; }

.ehr-modal-info {
  font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;
}

.ehr-modal-actions {
  display: flex; gap: 0.5rem; margin-bottom: 1rem;
}

.ehr-modal-actions .btn-login { flex: 1; font-size: 0.85rem; padding: 0.65rem; }

.ehr-modal-preview {
  background: #f5f5f5; border-radius: 8px; padding: 0.75rem;
  max-height: 200px; overflow-y: auto; margin-bottom: 0.75rem;
}

.ehr-modal-preview pre {
  font-size: 0.7rem; font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: pre-wrap; word-break: break-all; color: var(--text-sec);
  margin: 0;
}

.ehr-queue-note {
  font-size: 0.75rem; color: var(--success); text-align: center;
  font-weight: 500;
}

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: calc(80px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  background: #1e293b; color: white;
  padding: 0.65rem 1.25rem; border-radius: 8px;
  font-size: 0.85rem; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2); z-index: 1000;
  animation: toastIn 0.25s ease;
}

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ---- Responsive ---- */
@media (max-width: 380px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}
