/* ============================================================
   Patient Management System — App Styles
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary:       #1a73e8;
  --primary-dark:  #0d47a1;
  --primary-light: #e8f0fe;
  --success:       #1e8a5e;
  --success-bg:    #d4edda;
  --danger:        #c0392b;
  --danger-bg:     #fdecea;
  --warning:       #856404;
  --warning-bg:    #fff3cd;
  --info:          #0a6ebd;
  --info-bg:       #cfe2ff;
  --muted:         #6c757d;
  --border:        #dee2e6;
  --bg:            #f0f4ff;
  --sidebar-w:     220px;
  --card-radius:   14px;
  --transition:    .18s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: #1a202c;
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

#view,
#page-actions,
#view > *,
#view .panel,
#view .metric,
#view .responsive-card,
#view .responsive-card-header > *,
#view .responsive-card-field,
#view .patient-card-mobile {
  min-width: 0;
}
#view a,
#view p,
#view code,
#view td,
#view th,
#view .badge,
#view .responsive-card-title,
#view .responsive-card-subtitle,
#view .responsive-card-field span {
  overflow-wrap: anywhere;
}
#view img {
  max-width: 100%;
  height: auto;
}
#view .form-control,
#view input,
#view select,
#view textarea {
  min-width: 0;
  max-width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  min-height: 0;
  box-sizing: border-box;
  background: linear-gradient(160deg, #0d47a1 0%, #1a73e8 100%);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 100;
  box-shadow: 2px 0 16px rgba(13,71,161,.18);
}
.sidebar .brand {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  margin-bottom: 4px;
}
.sidebar .brand span { color: #a8c8ff; }
.sidebar .role-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  margin-bottom: 24px;
}
.sidebar nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background var(--transition), color var(--transition);
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.sidebar .nav-link i { font-size: 16px; }
.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 12px;
}
.sidebar-footer .btn-logout {
  width: 100%;
  background: rgba(255,255,255,.12);
  border: none;
  color: rgba(255,255,255,.85);
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition);
}
.sidebar-footer .btn-logout:hover { background: rgba(255,255,255,.22); }
.sidebar-footer .logout-button {
  justify-content: flex-start;
  background: rgba(127, 29, 29, .32);
  border: 1px solid rgba(254, 202, 202, .3);
  color: #fff;
}
.sidebar-footer .logout-button:hover {
  background: rgba(127, 29, 29, .58);
}

.sidebar .nav-link { position: relative; }
.sidebar .nav-badge {
  margin-left: auto;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(231,76,60,.4);
}

.live-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(30,138,94,.18);
  border: 1px solid rgba(46,204,113,.25);
  font-size: 11px;
  font-weight: 600;
  color: #a3e635;
  margin-bottom: 10px;
  letter-spacing: .02em;
}
.live-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.7);
  animation: livePulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.7); }
  70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ── Main area ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 32px 36px;
  min-height: 100vh;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.page-header .eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}
.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  color: #0d1f3c;
}

/* ── Cards / Panels ──────────────────────────────────────── */
.panel {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 24px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  margin-bottom: 24px;
}
.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: #0d1f3c;
  margin: 0 0 16px;
}
.metric {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 20px 22px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.metric .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.metric strong { display: block; font-size: 28px; font-weight: 700; color: #0d1f3c; margin: 4px 0; }

/* ── Welcome banner ──────────────────────────────────────── */
.welcome {
  background: linear-gradient(135deg, #0d47a1 0%, #1a73e8 100%);
  border-radius: var(--card-radius);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
}
.welcome h2 { font-size: 20px; margin: 8px 0 4px; }
.welcome p { opacity: .8; margin: 0; }

/* ── Tables ──────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f4f8;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8faff; }
.table-responsive {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Status badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
}
.badge-pending       { background: var(--warning-bg); color: var(--warning); }
.badge-confirmed     { background: var(--info-bg);    color: var(--info); }
.badge-active        { background: var(--success-bg); color: var(--success); }
.badge-completed     { background: #e2e8f0;           color: #475569; }
.badge-cancelled     { background: var(--danger-bg);  color: var(--danger); }
.badge-in_queue      { background: #f3e8ff;           color: #7c3aed; }
.badge-in_consultation { background: #fef9c3;         color: #854d0e; }
.badge-waiting       { background: #fef9c3;           color: #854d0e; }
.badge-called        { background: var(--info-bg);    color: var(--info); }
.badge-verified      { background: var(--success-bg); color: var(--success); }
.badge-rejected      { background: var(--danger-bg);  color: var(--danger); }
.badge-submitted     { background: #e0f2fe;           color: #0369a1; }
.badge-unpaid        { background: var(--danger-bg);  color: var(--danger); }
.badge-paid          { background: var(--success-bg); color: var(--success); }
.badge-partial       { background: var(--warning-bg); color: var(--warning); }
.badge-not_required  { background: #f1f5f9;           color: #64748b; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: opacity var(--transition), transform var(--transition), background var(--transition);
  text-decoration: none;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-success   { background: #1e8a5e;           color: #fff; }
.btn-danger    { background: var(--danger);     color: #fff; }
.btn-warning   { background: #e67e22;           color: #fff; }
.btn-secondary { background: #e2e8f0;           color: #475569; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: #475569; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-xs        { padding: 3px 8px;  font-size: 11px; border-radius: 6px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1a202c;
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrap .form-control {
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.password-toggle:hover { background: #f3f4f6; color: var(--primary); }
.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.option-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}
.option-pill input { accent-color: var(--primary); }
.form-row { display: grid; gap: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Slot picker ─────────────────────────────────────────── */
.slot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.slot-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: #374151;
}
.slot-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.slot-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.slot-btn.disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; border-color: #e2e8f0; }

/* ── Line items builder ──────────────────────────────────── */
.line-item {
  display: grid;
  grid-template-columns: 1fr 90px 110px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.line-item .rm-btn {
  background: var(--danger-bg);
  color: var(--danger);
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: background var(--transition);
}
.line-item .rm-btn:hover { background: #fca5a5; }
.billing-total {
  text-align: right;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1.5px solid var(--border);
}

/* ── File upload ─────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--muted);
}
.file-drop:hover { border-color: var(--primary); background: var(--primary-light); }
.file-drop i { font-size: 28px; display: block; margin-bottom: 8px; }
.file-drop input[type=file] { display: none; }
.file-chosen { font-size: 12px; color: var(--primary); margin-top: 6px; font-weight: 500; }
.lab-signature-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.lab-signature-pad {
  display: block;
  width: 100%;
  height: 150px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}
.lab-signature-pad-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.lab-signature-upload { margin-top: 10px; }
.lab-signature-upload summary {
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 8px;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,31,60,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.modal-close {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  transition: background var(--transition);
}
.modal-close:hover { background: #e2e8f0; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Alert boxes ─────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-danger  { background: var(--danger-bg);  color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info    { background: var(--info-bg);    color: var(--info); }

/* ── Empty states ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state p { font-size: 14px; margin: 0; }

/* ── Login / Register page ───────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d47a1 0%, #1a73e8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 460px;
  padding: 36px 36px 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .brand { font-size: 22px; font-weight: 800; color: #0d1f3c; }
.auth-logo .brand span { color: var(--primary); }
.auth-logo p { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.auth-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--transition);
  border: none;
  background: none;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ── Medical records ─────────────────────────────────────── */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  background: #f8faff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.vital-item label { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.vital-item .val { font-size: 18px; font-weight: 700; color: #0d1f3c; }

/* ── Password Toggle ─────────────────────────────────────── */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.password-wrap input {
  padding-right: 42px !important;
  width: 100%;
}
.password-toggle {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 16px;
  transition: color var(--transition), background var(--transition);
  z-index: 2;
}
.password-toggle:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* ── Multi-Step Mobile Booking Stepper ───────────────────── */
.stepper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 10px 4px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow-x: auto;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
  transition: all var(--transition);
}
.step-item.active {
  color: var(--primary);
  background: #e8f0fe;
}
.step-item.completed {
  color: var(--success);
}
.step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: #e2e8f0;
  color: #64748b;
  font-weight: 700;
}
.step-item.active .step-circle {
  background: var(--primary);
  color: #fff;
}
.step-item.completed .step-circle {
  background: var(--success);
  color: #fff;
}

/* ── Consultation Type Cards (Mobile-first large touch targets) ── */
.consultation-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 12px 0 20px;
}
.type-card {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  background: #fff;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  text-align: left;
}
.type-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26,115,232,0.08);
}
.type-card.selected {
  border-color: var(--primary);
  background: #f0f7ff;
  box-shadow: 0 4px 16px rgba(26,115,232,0.14);
}
.type-card .type-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.type-card .type-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.type-card.selected .type-icon {
  background: var(--primary);
  color: #fff;
}
.type-card .type-check {
  font-size: 20px;
  color: var(--primary);
  opacity: 0;
  transition: opacity var(--transition);
}
.type-card.selected .type-check {
  opacity: 1;
}
.type-card .type-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 4px;
}
.type-card .type-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* ── Availability Slot Badges ────────────────────────────── */
.slot-grid-enhanced {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.slot-card-btn {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
  font-family: inherit;
  width: 100%;
}
.slot-card-btn:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.slot-card-btn.selected {
  border-color: var(--primary);
  background: #1a73e8;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(26,115,232,0.25);
}
.slot-card-btn.selected .slot-status-pill {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.slot-card-btn.disabled {
  background: #f8fafc;
  border-color: #e2e8f0;
  cursor: not-allowed;
  opacity: 0.65;
}
.slot-time-text {
  font-size: 14px;
  font-weight: 700;
}
.slot-status-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.slot-status-pill.avail {
  background: #dcfce7;
  color: #166534;
}
.slot-status-pill.unavail {
  background: #fee2e2;
  color: #991b1b;
}

/* ── Dominant Call Alert (Visually Dominant) ─────────────── */
.call-turn-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.call-turn-modal {
  background: #fff;
  border-radius: 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  padding: 36px 24px 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  animation: callBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 3px solid #ef4444;
  position: relative;
  overflow: hidden;
}
@keyframes callBounce {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.call-turn-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #fee2e2;
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 16px;
  animation: ringPulse 1s infinite alternate;
}
@keyframes ringPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  100% { transform: scale(1.1); box-shadow: 0 0 0 20px rgba(239,68,68,0); }
}
.call-turn-modal h2 {
  font-size: 26px;
  font-weight: 800;
  color: #b91c1c;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}
.call-turn-queue-badge {
  font-size: 38px;
  font-weight: 900;
  color: #0f172a;
  background: #f1f5f9;
  border: 2px dashed #94a3b8;
  border-radius: 16px;
  padding: 12px 20px;
  margin: 16px 0;
  display: inline-block;
  letter-spacing: 1px;
}
.call-present-btn {
  width: 100%;
  min-height: 54px;
  background: #16a34a;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(22,163,74,0.35);
  transition: all var(--transition);
  margin-top: 18px;
}
.call-present-btn:hover {
  background: #15803d;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(22,163,74,0.45);
}

/* ── QR Code Presentation Card ───────────────────────────── */
.qr-present-card {
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  padding: 24px;
  text-align: center;
  max-width: 440px;
  margin: 0 auto;
}
.qr-code-box {
  background: #fff;
  padding: 16px;
  border-radius: 16px;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.qr-token-text {
  font-family: monospace;
  font-size: 13px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  color: #475569;
  display: inline-block;
  margin-top: 8px;
  word-break: break-all;
}

/* ── QR Scanner Viewfinder ───────────────────────────────── */
.scanner-viewport {
  position: relative;
  width: 100%;
  max-width: 380px;
  height: 280px;
  margin: 0 auto 16px;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-laser {
  position: absolute;
  top: 10%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: laserScan 2s ease-in-out infinite alternate;
}
@keyframes laserScan {
  0% { top: 15%; }
  100% { top: 85%; }
}
.scanner-box-guide {
  position: absolute;
  width: 200px;
  height: 200px;
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

/* ── Responsive Admin & Patient Cards (Mobile UI) ────────── */
.mobile-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.responsive-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition);
}
.responsive-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.responsive-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.responsive-card-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.responsive-card-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
}
.responsive-card-field label {
  font-size: 10px;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
  display: block;
}
.responsive-card-field span {
  font-weight: 600;
  color: #334155;
}
.responsive-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid #f1f5f9;
}
.responsive-card-actions .btn {
  flex: 1;
  min-height: 38px;
  justify-content: center;
  font-size: 13px;
}
.bill-item-row {
  display: grid;
  grid-template-columns: minmax(150px, 2fr) minmax(78px, .65fr) minmax(112px, 1fr) minmax(92px, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.bill-item-row > label {
  display: block;
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}
.bill-item-row .form-control {
  margin-top: 4px;
}
.bill-item-subtotal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  font-size: 11px;
  color: #64748b;
}
.bill-item-subtotal strong {
  color: #0f172a;
  font-size: 13px;
}
.notification-panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.notification-hint {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.notification-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #f0f4f8;
}
.notification-item.is-read {
  opacity: .65;
}
.notification-content {
  min-width: 0;
  flex: 1;
}
.notification-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.notification-date {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.notification-content p {
  margin: 6px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.notification-read-label {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
}
.audit-purpose > strong {
  display: block;
  color: #0f172a;
}
.audit-purpose > p {
  margin: 8px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.55;
}

/* ── Mobile Bottom Navigation Bar ────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  z-index: 100;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  transition: color var(--transition);
  position: relative;
  padding: 6px 0;
}
.bottom-nav-item i {
  font-size: 18px;
  transition: transform var(--transition);
}
.bottom-nav-item.active {
  color: var(--primary);
}
.bottom-nav-item.active i {
  transform: translateY(-2px);
}
.bottom-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  border: 1px solid #fff;
}

/* ── Responsive Media Queries ────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 16px 14px 84px !important;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-header #page-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header #page-actions .btn {
    flex: 1 1 140px;
    min-width: 0;
    justify-content: center;
  }
  .consultation-type-grid {
    grid-template-columns: 1fr;
  }
  .slot-grid-enhanced {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .table-responsive {
    display: block;
  }
  .table-responsive.mobile-table-alt {
    display: none;
  }
  .audit-log-table {
    display: block !important;
    overflow: visible;
  }
  .audit-log-table table,
  .audit-log-table tbody,
  .audit-log-table tr,
  .audit-log-table td {
    display: block;
    width: 100%;
  }
  .audit-log-table thead {
    display: none;
  }
  .audit-log-table tr {
    margin-bottom: 12px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
  }
  .audit-log-table td {
    display: grid;
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 8px 0;
    overflow-wrap: anywhere;
  }
  .audit-log-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .audit-log-table td code {
    overflow-wrap: anywhere;
  }
  .mobile-cards-grid {
    display: flex; /* Show touch cards on mobile */
  }
  .clinic-service-list {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    visibility: visible !important;
  }
  .modal {
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    margin-top: auto;
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .bill-item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
  }
  .bill-item-row > label:first-child {
    grid-column: 1 / -1;
  }
  .bill-item-subtotal {
    padding-bottom: 10px;
  }
  .notification-item {
    flex-direction: column;
  }
  .panel {
    padding: 18px;
  }
}

@media (min-width: 901px) {
  .mobile-cards-grid {
    display: none; /* Hide mobile cards on desktop */
  }
  .clinic-service-list {
    display: none !important;
  }
}

/* ── Invoice & Print Styles ──────────────────────────────── */
.invoice-box {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 24px;
}
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 16px;
  margin-bottom: 20px;
}
.invoice-title {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
}
.invoice-sub {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}
.invoice-table th {
  background: #f8fafc;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}
.invoice-table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.invoice-totals {
  width: 300px;
  margin-left: auto;
  margin-top: 16px;
}
.invoice-totals .tot-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: #475569;
}
.invoice-totals .tot-row.grand {
  font-size: 16px;
  font-weight: 800;
  border-top: 2px solid #e2e8f0;
  padding-top: 10px;
  color: #0f172a;
}
.preset-tag-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-tag-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

/* ── NOW SERVING Queue Display (Requirement 3) ─────────────────────────── */
.now-serving-banner {
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.06);
}
.now-serving-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #0369a1;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.now-serving-num {
  font-size: 38px;
  font-weight: 900;
  color: #0284c7;
  line-height: 1;
  margin-bottom: 4px;
}
.now-serving-name {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}
.now-serving-inst {
  font-size: 13px;
  color: #475569;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Clickable Patient Links & Integrated Profile (Requirements 5, 6, 7) ─ */
.patient-link {
  color: #1d4ed8;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.patient-link:hover {
  color: #0d9488;
}
.patient-profile-header {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.patient-profile-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 2px;
  margin-bottom: 16px;
}
.patient-profile-tab {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.patient-profile-tab:hover {
  color: #1e40af;
  background: #eff6ff;
}
.patient-profile-tab.active {
  color: #1d4ed8;
  border-bottom: 3px solid #1d4ed8;
  font-weight: 700;
  background: #f8fafc;
}

/* ── Lightweight Laboratory Result Printing (Requirements 11, 12) ────────── */
.lab-print-document {
  max-width: 780px;
  margin: 0 auto;
  background: #ffffff;
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 24px 32px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.lab-print-header {
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 2px solid #0f172a;
  margin-bottom: 18px;
}
.lab-print-header h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: 0.05em;
  color: #0f172a;
}
.lab-print-header .clinic-meta {
  font-size: 12px;
  color: #475569;
  margin-bottom: 6px;
}
.lab-print-header .doc-type {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0f172a;
  margin-top: 6px;
}
.lab-patient-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 12.5px;
}
.lab-patient-box .field-label {
  font-weight: 600;
  color: #475569;
  margin-right: 6px;
}
.lab-patient-box .field-value {
  font-weight: 700;
  color: #0f172a;
}
.lab-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: 12.5px;
}
.lab-table th {
  border-bottom: 2px solid #0f172a;
  border-top: 1px solid #cbd5e1;
  padding: 7px 10px;
  text-align: left;
  font-weight: 700;
  color: #0f172a;
  background: #f8fafc;
}
.lab-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 7px 10px;
  color: #1e293b;
}
.lab-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
  margin: 14px 0 6px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
}
.lab-section-content {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-line;
}
.lab-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 32px;
  padding-top: 16px;
}
.lab-sig-line {
  border-top: 1px solid #0f172a;
  margin-top: 36px;
  padding-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
}
.lab-report-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #64748b;
  break-inside: avoid;
  page-break-inside: avoid;
}
.lab-report-signature {
  width: 220px;
  min-height: 76px;
  text-align: center;
  color: #0f172a;
}
.lab-signature-image {
  display: block;
  width: auto;
  max-width: 180px;
  height: 52px;
  object-fit: contain;
  margin: 0 auto -2px;
}
.lab-signature-line {
  width: 100%;
  border-top: 1px solid #0f172a;
  margin: 0 auto 4px;
}
.lab-signatory-name {
  font-size: 13px;
  font-weight: 700;
}
.lab-signatory-title {
  margin-top: 2px;
  font-size: 10px;
}
.lab-attachment-error {
  padding: 12px;
  color: #991b1b;
  font-size: 12px;
}
.lab-download-link {
  display: inline-flex;
  margin-top: 8px;
}

.medical-record-print-title {
  display: none;
}

/* ── Clean Print Media Queries (Requirements 11, 12) ─────────────────────── */
@media print {
  @page {
    size: auto;
    margin: 12mm;
  }
  body * {
    visibility: hidden !important;
  }
  #invoice-print-area, #invoice-print-area *,
  #lab-print-area, #lab-print-area *,
  #medical-record-print-area, #medical-record-print-area * {
    visibility: visible !important;
  }
  #invoice-print-area, #lab-print-area, #medical-record-print-area {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 16px !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    border: none !important;
  }
  .medical-record-print-title {
    display: block !important;
    margin: 0 0 18px !important;
    padding-bottom: 10px !important;
    border-bottom: 2px solid #334155 !important;
    color: #000000 !important;
    font-size: 20px !important;
  }
  .modal-backdrop {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 0 !important;
    background: transparent !important;
  }
  .modal {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .modal-body {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  #lab-print-area {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
    break-inside: auto;
    page-break-inside: auto;
  }
  .lab-print-document {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    padding: 16px !important;
    max-width: 100% !important;
  }
  .lab-print-document img {
    max-width: 100% !important;
    max-height: 260mm !important;
    object-fit: contain !important;
  }
  .lab-report-footer, .lab-report-signature {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .no-print, .sidebar, .page-header, .mobile-bottom-nav, .modal-close, .modal-footer, .lab-download-link {
    display: none !important;
  }
}

/* ── Patient Link (clickable name) ───────────────────────── */
a.patient-link, .patient-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition);
}
a.patient-link:hover, .patient-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ── Badge Info ──────────────────────────────────────────── */
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid #93c5fd; }

/* ── Button Outline / XS ─────────────────────────────────── */
.btn-outline {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-xs { font-size: 11px !important; padding: 3px 9px !important; border-radius: 6px !important; }

/* ── Search Wrap ─────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input { min-width: 200px; }

/* ── Responsive Card Actions ─────────────────────────────── */
.responsive-card-actions {
  padding: 8px 14px 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid #f1f5f9;
}

/* ── Form Row 2-cols ─────────────────────────────────────── */
.form-row.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 600px) {
  .form-row.cols-2,
  .form-row.cols-3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .search-wrap,
  .search-wrap input {
    width: 100%;
    min-width: 0;
  }
  .invoice-header {
    flex-direction: column;
    gap: 8px;
  }
  .invoice-totals {
    width: 100%;
    max-width: 300px;
  }
  .lab-print-document {
    padding: 16px;
  }
  .lab-patient-box,
  .lab-signatures {
    grid-template-columns: minmax(0, 1fr);
  }
  .lab-signatures {
    gap: 16px;
  }
  .lab-report-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .lab-report-signature {
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
  }
}
