/* ================================================================
   MediCare Pro — Stylesheet
   Mobile-first, light/dark mode, gynecology clinical theme
   ================================================================ */

/* ── CSS VARIABLES ──────────────────────────────────────────── */
:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --text:        #0f172a;
  --text2:       #475569;
  --text3:       #94a3b8;
  --primary:     #1a56db;
  --primary-h:   #1e40af;
  --primary-s:   #dbeafe;
  --accent:      #be185d;
  --accent-s:    #fce7f3;
  --success:     #0e9f6e;
  --success-s:   #d1fae5;
  --warning:     #d97706;
  --warning-s:   #fef3c7;
  --danger:      #e02424;
  --danger-s:    #fee2e2;
  --info:        #0284c7;
  --info-s:      #e0f2fe;
  --sidebar-w:   240px;
  --topbar-h:    60px;
  --bottom-h:    60px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.15);
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition:  .18s ease;
}

[data-theme="dark"] {
  --bg:       #0f172a;
  --surface:  #1e293b;
  --surface2: #243045;
  --border:   #334155;
  --border2:  #475569;
  --text:     #f1f5f9;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --primary-s:#1e3a5f;
  --accent-s: #4a0020;
  --success-s:#052e16;
  --warning-s:#3d2000;
  --danger-s: #3b0a0a;
  --info-s:   #0c2d48;
}

/* ── RESET & BASE ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }
img { max-width: 100%; display: block; }
textarea { resize: vertical; }

/* ── SCREENS ─────────────────────────────────────────────────── */
.screen { display: none; height: 100vh; }
.screen.show { display: flex; }

/* ── AUTH SCREEN ─────────────────────────────────────────────── */
#auth-screen {
  background: linear-gradient(135deg, #1e3a8a 0%, #1a56db 50%, #be185d 100%);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  margin: 16px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #1a56db, #be185d);
  border-radius: 16px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.auth-logo p  { font-size: 13px; color: var(--text2); margin-top: 4px; }
.auth-tabs { display: flex; background: var(--surface2); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 24px; }
.auth-tab  {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text2);
  transition: var(--transition);
  text-align: center;
}
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { font-size: 13px; font-weight: 500; color: var(--text2); display: block; margin-bottom: 5px; }
.auth-form input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-error { color: var(--danger); font-size: 13px; display: none; }
.auth-error.show { display: block; }
.btn-auth {
  width: 100%; padding: 13px;
  background: var(--primary); color: #fff;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  transition: background var(--transition);
}
.btn-auth:hover { background: var(--primary-h); }
.auth-skip { text-align: center; font-size: 12px; color: var(--text3); margin-top: 8px; }
.auth-skip a { color: var(--primary); cursor: pointer; }

/* ── SETUP SCREEN ────────────────────────────────────────────── */
#setup-screen {
  background: var(--bg);
  align-items: center; justify-content: center;
}
.setup-card {
  background: var(--surface); border-radius: 16px;
  padding: 36px 32px; max-width: 520px; width: 100%;
  margin: 16px; box-shadow: var(--shadow-md);
}
.setup-card h2 { font-size: 20px; margin-bottom: 6px; }
.setup-card p  { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.setup-card pre {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  font-size: 12px; white-space: pre-wrap; overflow-x: auto;
  color: var(--text2);
}

/* ── APP SHELL ───────────────────────────────────────────────── */
#app-shell {
  height: 100vh;
  flex-direction: row;
  overflow: hidden;
}

/* ── SIDEBAR (desktop) ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
}
.sidebar-logo {
  padding: 18px 16px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #1a56db, #be185d);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-logo-text { font-size: 14px; font-weight: 700; color: var(--text); }
.sidebar-logo-sub  { font-size: 11px; color: var(--text3); }

.sidebar-doctor {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-av {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #be185d, #9f1239);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
#sidebar-doc-name { font-size: 13px; font-weight: 600; color: var(--text); }
#sidebar-doc-spec { font-size: 11px; color: var(--text3); }

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-section-label {
  font-size: 10px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 12px 16px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  font-size: 13.5px; font-weight: 500; color: var(--text2);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  user-select: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-s); color: var(--primary); font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 99px;
  min-width: 18px; text-align: center;
}

.sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.sync-badge {
  font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 99px;
  display: inline-block;
}
.sync-badge.online  { background: var(--success-s); color: var(--success); }
.sync-badge.offline { background: var(--warning-s); color: var(--warning); }

/* ── MAIN AREA ───────────────────────────────────────────────── */
.main-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  z-index: 5;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-search {
  position: relative; flex: 1; max-width: 320px;
}
.topbar-search input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: 13px; background: var(--surface2); color: var(--text);
  transition: border-color var(--transition);
}
.topbar-search input:focus { outline: none; border-color: var(--primary); }
.topbar-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--text3); pointer-events: none;
}
#search-results {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-height: 360px; overflow-y: auto;
  z-index: 100;
}
#search-results.open { display: block; }
.search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  transition: background var(--transition);
}
.search-item:hover { background: var(--surface2); }
.search-av {
  width: 34px; height: 34px;
  background: var(--primary-s);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--primary);
  flex-shrink: 0;
}
.search-name { font-size: 13px; font-weight: 600; color: var(--text); }
.search-sub  { font-size: 11px; color: var(--text3); }
.search-empty { padding: 16px; text-align: center; color: var(--text3); font-size: 13px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text2);
  transition: background var(--transition);
}
.icon-btn:hover { background: var(--surface2); }

/* Mobile topbar — hidden on desktop */
.mobile-topbar { display: none; }

/* ── MAIN CONTENT ────────────────────────────────────────────── */
#main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 24px;
  background: var(--bg);
}

/* ── BOTTOM NAV (mobile) ─────────────────────────────────────── */
.bottom-nav { display: none; }

/* ── MOBILE DRAWER ───────────────────────────────────────────── */
.drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 199;
}
.drawer-backdrop.open { display: block; }
#mobile-drawer {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 260px;
  background: var(--surface);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
#mobile-drawer.open { transform: translateX(0); }

/* ── PAGES ───────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.blue::before   { background: var(--primary); }
.stat-card.pink::before   { background: var(--accent); }
.stat-card.green::before  { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-icon {
  font-size: 22px; margin-bottom: 8px;
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 2px; }
.stat-delta { font-size: 11px; color: var(--success); margin-top: 4px; }

/* ── GRID HELPERS ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap; user-select: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #9f1239; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface2); }
.btn-ghost  { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── FORM ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-row-4  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
label { font-size: 13px; font-weight: 500; color: var(--text2); display: block; margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.form-control:disabled { background: var(--surface2); color: var(--text3); }
textarea.form-control { min-height: 80px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 13px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .04em;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* ── TABLE ───────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto; border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
th {
  background: var(--surface2); color: var(--text2);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
.table-actions { display: flex; gap: 6px; }
.table-actions .btn { padding: 5px 10px; font-size: 12px; }

/* ── BADGE ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-blue    { background: var(--primary-s); color: var(--primary); }
.badge-pink    { background: var(--accent-s);  color: var(--accent); }
.badge-green   { background: var(--success-s); color: var(--success); }
.badge-orange  { background: var(--warning-s); color: var(--warning); }
.badge-red     { background: var(--danger-s);  color: var(--danger); }
.badge-gray    { background: var(--surface2);  color: var(--text3); }

/* ── AVATAR ──────────────────────────────────────────────────── */
.av {
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
  flex-shrink: 0;
}

/* ── PATIENT CARD ────────────────────────────────────────────── */
.patient-list { display: flex; flex-direction: column; gap: 0; }
.patient-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.patient-row:last-child { border-bottom: none; }
.patient-row:hover { background: var(--surface2); }
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 14px; font-weight: 600; }
.patient-sub  { font-size: 12px; color: var(--text3); margin-top: 2px; }
.patient-meta { text-align: right; flex-shrink: 0; }
.patient-meta .badge { display: block; margin-bottom: 3px; }
.patient-no   { font-size: 11px; color: var(--text3); }

/* ── TIMELINE ────────────────────────────────────────────────── */
.timeline { padding: 0; }
.timeline-item {
  display: flex; gap: 14px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item::before {
  content: ''; position: absolute;
  left: 15px; top: 28px; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-s); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.timeline-content { flex: 1; }
.timeline-date { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.timeline-title { font-size: 14px; font-weight: 600; color: var(--text); }
.timeline-body  { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* ── ANC TABLE ───────────────────────────────────────────────── */
.anc-table th, .anc-table td { padding: 8px 10px; font-size: 12.5px; }

/* ── MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text3);
  cursor: pointer; transition: background var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body {
  padding: 20px;
  overflow-y: auto; flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── TABS ────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 9px 18px; font-size: 13.5px; font-weight: 500;
  color: var(--text2); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--primary); border-color: var(--primary); }
.tab-btn:hover  { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── PATIENT DETAIL TABS ─────────────────────────────────────── */
.patient-detail-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  display: flex; gap: 16px; align-items: flex-start;
}
.patient-detail-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 700;
  flex-shrink: 0;
}
.patient-detail-name { font-size: 20px; font-weight: 700; }
.patient-detail-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.patient-detail-meta span { font-size: 13px; color: var(--text2); }
.patient-detail-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── DRUG ROW ────────────────────────────────────────────────── */
.drug-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.drug-row:last-child { border-bottom: none; }

/* ── INVOICE ─────────────────────────────────────────────────── */
.invoice-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.invoice-totals { text-align: right; padding-top: 12px; }
.invoice-totals .total-row { font-size: 14px; margin-bottom: 4px; }
.invoice-totals .total-row.grand { font-size: 17px; font-weight: 700; color: var(--primary); }

/* ── TOAST ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 80px; right: 16px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow-md);
  font-size: 13.5px; max-width: 320px;
  opacity: 0; transform: translateX(20px);
  transition: opacity .25s, transform .25s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: none; }
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info); }

/* ── LOADING OVERLAY ─────────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 900;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
}
[data-theme="dark"] #loading-overlay { background: rgba(15,23,42,.7); }
#loading-overlay.show { display: flex; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; color: var(--text2); }

/* ── CONFIRM DIALOG ──────────────────────────────────────────── */
#confirm-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 600; align-items: center; justify-content: center;
}
#confirm-overlay.open { display: flex; }
.confirm-box {
  background: var(--surface);
  border-radius: 14px; padding: 28px 28px 22px;
  width: 100%; max-width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.confirm-box p { font-size: 15px; color: var(--text); margin-bottom: 20px; }
.confirm-btns { display: flex; gap: 10px; justify-content: center; }

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p  { font-size: 13px; color: var(--text3); }

/* ── PILL FILTER ─────────────────────────────────────────────── */
.pill-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-btn {
  padding: 5px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text2);
  transition: all var(--transition);
}
.pill-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ── PRESCRIPTION PRINT ──────────────────────────────────────── */
.rx-print-header { text-align: center; margin-bottom: 20px; border-bottom: 2px solid #1a56db; padding-bottom: 12px; }
.rx-print-header h2 { font-size: 20px; color: #1a56db; }
.rx-print-header p  { font-size: 12px; color: #666; }
.rx-drug-list    { list-style: none; padding: 0; }
.rx-drug-item    { padding: 10px 0; border-bottom: 1px dashed #e5e7eb; }
.rx-drug-item:last-child { border-bottom: none; }
.rx-drug-name    { font-size: 15px; font-weight: 600; }
.rx-drug-sig     { font-size: 13px; color: #666; margin-top: 3px; }

/* ── DASHBOARD QUICK ACTIONS ─────────────────────────────────── */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.qa-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  cursor: pointer; transition: all var(--transition);
  text-align: center;
}
.qa-btn:hover { border-color: var(--primary); background: var(--primary-s); }
.qa-icon { font-size: 24px; }
.qa-label { font-size: 12px; font-weight: 600; color: var(--text2); }

/* ── APPOINTMENT SLOT ────────────────────────────────────────── */
.appt-slot {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: var(--surface);
  cursor: pointer; transition: background var(--transition);
}
.appt-slot:hover { background: var(--surface2); }
.appt-time  { font-size: 13px; font-weight: 700; min-width: 50px; }
.appt-info  { flex: 1; }
.appt-name  { font-size: 14px; font-weight: 600; }
.appt-type  { font-size: 12px; color: var(--text3); }

/* ── VITALS GRID ─────────────────────────────────────────────── */
.vitals-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.vital-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  text-align: center;
}
.vital-label { font-size: 11px; color: var(--text3); }
.vital-value { font-size: 20px; font-weight: 700; }
.vital-unit  { font-size: 11px; color: var(--text3); }

/* ── REMINDER CARD ───────────────────────────────────────────── */
.reminder-list { display: flex; flex-direction: column; gap: 8px; }
.reminder-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--warning-s);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.reminder-item.overdue { background: var(--danger-s); border-color: var(--danger); }
.reminder-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex-shrink: 0; }
.reminder-item.overdue .reminder-dot { background: var(--danger); }

/* ── PREGNANCY SUMMARY ───────────────────────────────────────── */
.preg-card {
  background: linear-gradient(135deg, #1e40af 0%, #be185d 100%);
  border-radius: var(--radius);
  padding: 20px; color: #fff;
  margin-bottom: 20px;
}
.preg-edd   { font-size: 13px; opacity: .8; }
.preg-weeks { font-size: 32px; font-weight: 700; }
.preg-label { font-size: 14px; opacity: .85; }

/* ── FILE UPLOAD ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary); background: var(--primary-s);
}
.upload-zone p { font-size: 13px; color: var(--text3); margin-top: 8px; }

/* ── RESPONSIVE — MOBILE ─────────────────────────────────────── */
@media (max-width: 768px) {
  #app-shell { flex-direction: column; }
  .sidebar   { display: none; }

  .mobile-topbar {
    display: flex; align-items: center;
    height: var(--topbar-h); min-height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 12px; gap: 10px;
    z-index: 5;
  }
  .mobile-title { font-size: 16px; font-weight: 700; flex: 1; }
  .topbar { display: none; }

  .bottom-nav {
    display: flex;
    height: var(--bottom-h); min-height: var(--bottom-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 10;
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; cursor: pointer;
    color: var(--text3); font-size: 10px;
    transition: color var(--transition);
    padding: 6px;
  }
  .bottom-nav-item .bn-icon { font-size: 20px; }
  .bottom-nav-item.active   { color: var(--primary); }

  #main-content { padding: 14px; }

  .stats-grid    { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .drug-row    { grid-template-columns: 1fr 1fr 1fr; }
  .invoice-row { grid-template-columns: 1fr 1fr; }
  .vitals-grid { grid-template-columns: 1fr 1fr; }

  .patient-detail-actions { flex-direction: column; }
  .modal { max-height: 95vh; border-radius: 14px 14px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  #toast-container { bottom: 72px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}

/* ── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── UTILITY ─────────────────────────────────────────────────── */
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm  { font-size: 12px; }
.text-muted { color: var(--text3); }
.fw-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.fw-600  { font-weight: 600; }
.ml-4    { margin-left: 4px; }
.ml-8    { margin-left: 8px; }
.mb-20   { margin-bottom: 20px; }

/* ── PURPLE STAT CARD ────────────────────────────────────────── */
.stat-card.purple { background: linear-gradient(135deg,#7c3aed,#6d28d9); }
.stat-card.red    { background: linear-gradient(135deg,#e11d48,#be123c); }

/* ── DASHBOARD HEADER ────────────────────────────────────────── */
.dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.dash-greeting { font-size: 22px; font-weight: 700; margin: 0; }
.dash-date     { margin: 4px 0 0; font-size: 13px; }

/* ── QUICK ACTIONS ───────────────────────────────────────────── */
.quick-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.qa-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--border2); background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text);
  transition: all var(--transition); white-space: nowrap;
}
.qa-btn:hover   { border-color: var(--primary); color: var(--primary); background: var(--primary-s); }
.qa-btn.qa-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.qa-btn.qa-primary:hover { background: var(--primary-h); }
.qa-icon { font-size: 16px; }

/* ── DASHBOARD GRID ──────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ── APPOINTMENT ROW ─────────────────────────────────────────── */
.appt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.appt-row:last-child { border-bottom: none; }
.appt-row:hover { background: var(--surface2); margin: 0 -16px; padding: 10px 16px; border-radius: 6px; }
.appt-time { font-size: 12px; font-weight: 700; color: var(--primary); width: 46px; flex-shrink: 0; }

/* ── FOLLOW-UP / DELIVERY / HIGH-RISK ROWS ───────────────────── */
.fu-row, .del-row, .hr-row, .anc-row, .bill-row, .recent-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.fu-row:last-child, .del-row:last-child, .hr-row:last-child,
.anc-row:last-child, .bill-row:last-child, .recent-row:last-child { border-bottom: none; }
.fu-row:hover, .del-row:hover, .hr-row:hover, .anc-row:hover,
.bill-row:hover, .recent-row:hover { background: var(--surface2); margin: 0 -16px; padding: 8px 16px; border-radius: 6px; }

.del-avatar, .hr-av {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.monthly-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.monthly-stat:last-child { border-bottom: none; }

/* ── QUICK SEARCH ────────────────────────────────────────────── */
.dash-quick-search { position: relative; min-width: 260px; }
.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 14px; pointer-events: none;
}
.search-wrap input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border2); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.search-wrap input:focus { outline: none; border-color: var(--primary); }
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1.5px solid var(--border2);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 200; max-height: 320px; overflow-y: auto;
}
.search-item:hover { background: var(--primary-s); }

/* ── EMPTY STATE SM ──────────────────────────────────────────── */
.empty-state-sm {
  padding: 20px 0; text-align: center; color: var(--text3); font-size: 13px;
}

/* ── STAT CARD ICONS ─────────────────────────────────────────── */
.stat-icon { font-size: 22px; margin-bottom: 4px; }

/* ── KBD ─────────────────────────────────────────────────────── */
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 5px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 4px; font-family: monospace; font-size: 11px;
  box-shadow: 0 1px 0 var(--border2);
}

/* ── BTN ACTIVE ──────────────────────────────────────────────── */
.btn-active { background: var(--primary); color: #fff; border-color: var(--primary) !important; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; border: 1px solid var(--border2); cursor:pointer; background:var(--surface); }
.btn-xs.btn-outline { border-color: var(--primary); color: var(--primary); }
.btn-xs.btn-active  { background: var(--primary); color: #fff; border-color: var(--primary); }
.badge-grey { background: var(--surface2); color: var(--text3); }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* ── TEMPLATES ───────────────────────────────────────────────── */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.tpl-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.tpl-card:hover { box-shadow: var(--shadow-md); border-color: var(--border2); }
.tpl-card.tpl-fav { border-color: #f59e0b; }
.tpl-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tpl-name { font-weight: 700; font-size: 14px; color: var(--text); }
.tpl-meta { margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.tpl-cc, .tpl-dx { font-size: 12.5px; color: var(--text2); }
.tpl-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-pill {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 99px; white-space: nowrap;
}
.pill-rx     { background: #e0f2fe; color: #0369a1; }
.pill-lab    { background: #f0fdf4; color: #166534; }
.pill-advice { background: #fef9c3; color: #854d0e; }
.tpl-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── MEDICINE & DIAGNOSIS ROWS ───────────────────────────────── */
.med-row, .dx-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.med-row:last-child, .dx-row:last-child { border-bottom: none; }

/* ── TEMPLATE FORM ROWS ──────────────────────────────────────── */
.tpl-med-row, .tpl-inv-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.tpl-med-row .form-control, .tpl-inv-row .form-control { margin-bottom: 0; }

/* ── TEMPLATE PREVIEW MODAL ──────────────────────────────────── */
#modal-tpl-preview .modal-body { max-height: 70vh; overflow-y: auto; }

/* ── MOBILE RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  .dash-header { flex-direction: column; }
  .dash-quick-search { min-width: 100%; }
  .dash-grid { grid-template-columns: 1fr; }
  .quick-actions { gap: 8px; }
  .qa-btn { flex: 1; min-width: 100px; justify-content: center; padding: 8px 10px; font-size: 12px; }
  .tpl-grid { grid-template-columns: 1fr; }
  .tpl-med-row { flex-wrap: wrap; }
}

