:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dfe4ea;
  --text: #1c2733;
  --muted: #64748b;
  --primary: #0d6efd;
  --primary-dark: #0952c7;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
header.topbar {
  background: #0f172a;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.topbar a { color: #fff; text-decoration: none; font-weight: 600; }
header.topbar .role-badge {
  background: var(--primary);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
main.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px 60px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; }
button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  margin-top: 12px;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button.secondary { background: #64748b; }
button.danger { background: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.success { background: #dcfce7; color: var(--success); }
.badge.warning { background: #fef3c7; color: var(--warning); }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.info { background: #dbeafe; color: var(--primary-dark); }
.badge.muted { background: #e2e8f0; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.nav-links a {
  background: #fff;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
}
.nav-links a:hover { border-color: var(--primary); color: var(--primary); }
.msg { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin: 10px 0; }
.msg.error { background: #fee2e2; color: var(--danger); }
.msg.success { background: #dcfce7; color: var(--success); }
.hint { font-size: 12px; color: var(--muted); }

/* ============================================================
   App shell: sidebar + topbar layout, used by renderAppShell()
   in api.js across every logged-in page. Keeps the visual system
   in one place instead of duplicated per page.
   ============================================================ */
:root {
  --shell-sidebar-w: 240px;
  --shell-topbar-h: 64px;
  --accent-blue: #eff6ff;
  --accent-blue-ink: #1d4ed8;
  --accent-green: #f0fdf4;
  --accent-green-ink: #15803d;
  --accent-pink: #fef2f2;
  --accent-pink-ink: #dc2626;
  --accent-amber: #fffbeb;
  --accent-amber-ink: #b45309;
  --accent-purple: #f5f3ff;
  --accent-purple-ink: #6d28d9;
}
body.shell-body { margin: 0; }
.shell-topbar {
  position: fixed; top: 0; left: var(--shell-sidebar-w); right: 0; height: var(--shell-topbar-h);
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 20;
}
.shell-topbar .shell-search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; color: var(--muted);
}
.shell-topbar-right { display: flex; align-items: center; gap: 18px; }
.shell-bell { position: relative; display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; }
.shell-bell .shell-bell-dot {
  position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; line-height: 1.3;
}
.shell-avatar-menu { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.shell-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.shell-avatar-name { font-size: 13px; font-weight: 600; }

.shell-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--shell-sidebar-w);
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 30; overflow-y: auto;
}
.shell-brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px;
  font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none;
}
.shell-brand-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}
.shell-brand-sub { font-size: 11px; color: var(--muted); font-weight: 400; display: block; }
.shell-nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.shell-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500; position: relative;
}
.shell-nav a:hover { background: var(--bg); color: var(--text); }
.shell-nav a.active { background: var(--accent-blue); color: var(--accent-blue-ink); font-weight: 600; }
.shell-nav a .shell-nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.shell-nav a .shell-nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.shell-nav-section { padding: 14px 12px 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: #94a3b8; }

.shell-main { margin-left: var(--shell-sidebar-w); padding-top: var(--shell-topbar-h); min-height: 100vh; }
.shell-main > .container { max-width: 1180px; }
@media (max-width: 900px) {
  .shell-sidebar { width: 72px; }
  .shell-sidebar .shell-brand-sub, .shell-sidebar .shell-nav-label, .shell-sidebar .shell-nav-section { display: none; }
  .shell-nav a { justify-content: center; }
  .shell-nav a .shell-nav-badge { position: absolute; top: 4px; right: 4px; margin-left: 0; }
  .shell-topbar { left: 72px; }
  .shell-main { margin-left: 72px; }
  .shell-topbar .shell-search { display: none; }
}

/* Dashboard-specific components (greeting banner, quick actions, health widgets) */
.dash-hero {
  background: linear-gradient(135deg, #1d4ed8, #2563eb 60%, #3b82f6);
  border-radius: 16px; padding: 28px 32px; color: #fff; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.dash-hero h1 { margin: 4px 0 8px; font-size: 26px; }
.dash-hero p { margin: 0; opacity: 0.9; font-size: 14px; max-width: 46ch; }
.dash-hero-eyebrow { font-size: 13px; opacity: 0.85; }
.dash-hero-actions { display: flex; gap: 10px; margin-top: 16px; }
.dash-hero-actions .btn { margin-top: 0; }
.dash-hero-actions .btn.ghost { background: rgba(255,255,255,0.15); }
.dash-hero-img { font-size: 64px; opacity: 0.9; flex-shrink: 0; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .quick-actions { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) {
  .quick-actions { grid-template-columns: 1fr; }
  .dash-hero { flex-direction: column; align-items: flex-start; padding: 22px; }
  .dash-hero-img { display: none; }
  .dash-hero-actions { flex-wrap: wrap; }
}
.quick-action {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 12px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer;
}
.quick-action .qa-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.quick-action.blue { background: var(--accent-blue); } .quick-action.blue .qa-icon { background: #dbeafe; color: var(--accent-blue-ink); }
.quick-action.green { background: var(--accent-green); } .quick-action.green .qa-icon { background: #dcfce7; color: var(--accent-green-ink); }
.quick-action.pink { background: var(--accent-pink); } .quick-action.pink .qa-icon { background: #fee2e2; color: var(--accent-pink-ink); }
.quick-action.amber { background: var(--accent-amber); } .quick-action.amber .qa-icon { background: #fef3c7; color: var(--accent-amber-ink); }
.quick-action:hover { filter: brightness(0.97); }
.quick-action-chevron { margin-left: auto; opacity: 0.5; }

.vitals-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .vitals-grid { grid-template-columns: repeat(2, 1fr); } }
.vital-card { display: flex; align-items: center; gap: 12px; }
.vital-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.vital-value { font-size: 20px; font-weight: 700; line-height: 1.1; }
.vital-label { font-size: 11.5px; color: var(--muted); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.section-head h3 { margin: 0; }
.section-head a { font-size: 12.5px; color: var(--primary); text-decoration: none; font-weight: 600; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.list-row-title { font-weight: 600; font-size: 13.5px; }
.list-row-sub { font-size: 12px; color: var(--muted); }
.list-row-meta { margin-left: auto; text-align: right; }

/* Appointment slot picker (booking + reschedule) */
.slot-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: 6px 0; }
.slot-legend span { display: inline-flex; align-items: center; gap: 5px; }
.slot-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.slot-btn { padding: 9px 6px; border-radius: 8px; font-size: 12.5px; font-weight: 600; text-align: center; border: 1px solid transparent; margin: 0; }
.slot-btn.slot-green { background: #dcfce7; color: #15803d; cursor: pointer; }
.slot-btn.slot-green:hover { background: #bbf7d0; }
.slot-btn.slot-red { background: #fee2e2; color: #b91c1c; cursor: not-allowed; opacity: 0.8; }
.slot-btn.slot-grey { background: #e2e8f0; color: #64748b; cursor: not-allowed; opacity: 0.8; }
.slot-btn.slot-selected { background: var(--primary); color: #fff; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-card { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 520px; width: 100%; max-height: 85vh; overflow-y: auto; }
.modal-card h3 { margin-top: 0; }

.join-hint { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; }
