:root {
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --primary-dark: #115e59;
  --secondary: #0284c7;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 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);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: #f1f5f9;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Switcher */
.header-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary-dark);
}

.brand-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.role-switcher {
  display: flex;
  background: #e2e8f0;
  padding: 0.25rem;
  border-radius: 9999px;
  gap: 0.25rem;
}

.role-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.role-btn.active {
  background: white;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  display: inline-block;
}

/* Layout container */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Common Card */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: white;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--surface-alt);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* Pre-Flight Check UI */
.preflight-container {
  max-width: 800px;
  margin: 1rem auto;
}

.preflight-video-box {
  width: 100%;
  height: 380px;
  background: #0f172a;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preflight-video-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preflight-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.25rem;
}

.diag-item {
  background: var(--surface-alt);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.diag-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.vu-meter-bar {
  width: 100%;
  height: 12px;
  background: #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.vu-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981 60%, #f59e0b 85%, #ef4444 100%);
  transition: width 0.08s ease-out;
}

/* Waiting Room UI */
.waiting-container {
  max-width: 900px;
  margin: 1rem auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .waiting-container {
    grid-template-columns: 1fr;
  }
}

.queue-badge-box {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 1.25rem;
}

.queue-number {
  font-size: 2.8rem;
  font-weight: 800;
  margin: 0.25rem 0;
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Signature Canvas */
.signature-box {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: white;
  position: relative;
  touch-action: none;
}

.signature-canvas {
  width: 100%;
  height: 140px;
  cursor: crosshair;
}

.signature-clear-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}

/* Provider Queue Table */
.queue-table {
  width: 100%;
  border-collapse: collapse;
}

.queue-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--surface-alt);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.queue-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.queue-table tr:hover {
  background-color: #f8fafc;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #e0f2fe; color: #0369a1; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }

/* In-Call Video Suite */
.encounter-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
  height: calc(100vh - 120px);
}

@media (max-width: 1024px) {
  .encounter-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.video-stage {
  background: #020617;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.remote-video-feed {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.local-pip-feed {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 180px;
  height: 120px;
  background: #1e293b;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.3);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.local-pip-feed video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.video-action-bar {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.15);
  z-index: 20;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.3);
}

.ctrl-btn.active-off {
  background: var(--danger);
}

.ctrl-btn.end-call {
  background: var(--danger);
  width: 50px;
  height: 50px;
}

/* Clinical Side Dock */
.side-dock {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dock-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.dock-tab-btn {
  flex: 1;
  padding: 0.75rem 0.5rem;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.dock-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: white;
}

.dock-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Chat In-Call */
.chat-messages {
  height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--surface-alt);
  border-radius: 8px;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.5rem 0.8rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.35;
}

.chat-bubble.doctor {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--border);
}

.chat-bubble.patient {
  align-self: flex-end;
  background: var(--primary);
  color: white;
}

/* Modal Windows */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  overflow-y: auto;
}

.modal-card {
  background: white;
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.2s ease-out;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.25rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  flex-shrink: 0;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--surface-alt);
  flex-shrink: 0;
}

.snapshot-preview-canvas {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #0f172a;
  border-radius: 8px;
}

/* Helper text */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.font-bold { font-weight: 700; }
.text-teal { color: var(--primary); }
.text-muted { color: var(--text-muted); }

/* Home Role Choice Gateway Cards */
.home-choice-card {
  cursor: pointer;
  border: 2.5px solid #cbd5e1;
  border-radius: 20px;
  background: white;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.home-choice-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.home-choice-card.patient-card:hover {
  border-color: var(--secondary);
}

/* ========================================================================= */
/* SENIOR / EASY CONNECT ACCESSIBILITY STYLES (Zero Confusion Interface)      */
/* ========================================================================= */
.senior-container {
  max-width: 800px;
  margin: 1.5rem auto;
}

.senior-card {
  background: white;
  border-radius: 16px;
  border: 3px solid #cbd5e1;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 2.25rem 2rem;
  margin-bottom: 1.5rem;
}

.senior-title {
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.senior-subtitle {
  font-size: 1.15rem;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}

.senior-input {
  width: 100%;
  font-size: 1.35rem;
  padding: 1.1rem 1.25rem;
  border: 3px solid #94a3b8;
  border-radius: 12px;
  outline: none;
  font-weight: 600;
  color: #0f172a;
  background: #f8fafc;
  transition: all 0.2s ease;
  margin-bottom: 1.25rem;
}

.senior-input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.senior-btn-giant {
  width: 100%;
  background: #16a34a;
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 1.25rem 2rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.senior-btn-giant:hover {
  background: #15803d;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.5);
}

.senior-method-tabs {
  display: flex;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: 14px;
  gap: 0.35rem;
  margin-bottom: 1.75rem;
}

.senior-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #475569;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.senior-tab-btn.active {
  background: white;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.senior-help-box {
  background: #fefce8;
  border: 2px solid #fde047;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.senior-voice-btn {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.senior-voice-btn:hover {
  background: #e2e8f0;
}

/* Large Print Mode Toggle (Global Root Scaling + High Contrast) */
html.large-print-mode {
  font-size: 135% !important;
}

html.large-print-mode body {
  font-size: 1.25rem !important;
  background-color: #f8fafc !important;
}

html.large-print-mode .card {
  border-width: 3px !important;
  border-color: #94a3b8 !important;
  box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.18) !important;
}

html.large-print-mode .card-title {
  font-size: 1.85rem !important;
  font-weight: 900 !important;
}

html.large-print-mode .senior-title {
  font-size: 2.85rem !important;
  font-weight: 900 !important;
  color: #022c22 !important;
}

html.large-print-mode .senior-subtitle {
  font-size: 1.5rem !important;
  color: #1e293b !important;
}

html.large-print-mode .senior-btn-giant {
  font-size: 1.85rem !important;
  padding: 1.75rem 2.5rem !important;
  border-radius: 20px !important;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35) !important;
}

html.large-print-mode .senior-input {
  font-size: 1.75rem !important;
  padding: 1.4rem !important;
  border-width: 4px !important;
  border-color: #0d9488 !important;
}

html.large-print-mode .senior-tab-btn {
  font-size: 1.45rem !important;
  padding: 1.25rem 2rem !important;
}

html.large-print-mode .btn,
html.large-print-mode .role-btn {
  font-size: 1.15rem !important;
  padding: 0.75rem 1.25rem !important;
  border-width: 2px !important;
}


