/* ============================================================
   CAMEDYC HAITI — Design System CSS
   Polices: Poppins | Palette: #d60001 #ffffff
   ============================================================ */

/* ---- Reset & Variables ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #d60001;
  --primary-dark:   #a80001;
  --primary-light:  #ff3334;
  --primary-bg:     #fff5f5;
  --white:          #ffffff;
  --bg:             #f0f2f5;
  --bg-card:        #ffffff;
  --sidebar-bg:     #1a1d23;
  --sidebar-hover:  #2a2d35;
  --sidebar-active: rgba(214,0,1,.15);
  --sidebar-text:   #a0a7b5;
  --sidebar-active-text: #d60001;
  --text-primary:   #1a1d23;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --border:         #e5e7eb;
  --border-light:   #f3f4f6;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.14);
  --radius:         10px;
  --radius-lg:      16px;
  --sidebar-w:      260px;
  --sidebar-collapsed: 70px;
  --header-h:       64px;
  --transition:     .25s ease;
  --font:           'Poppins', sans-serif;
}

html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
input, select, textarea, button { font-family: var(--font); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Mobile Warning ---- */
.mobile-warning {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: var(--white);
  align-items: center; justify-content: center;
  padding: 2rem; text-align: center;
}
.mobile-warning-content { max-width: 380px; }
.mobile-warning-icon { font-size: 4rem; color: var(--primary); margin-bottom: 1.5rem; }
.mobile-warning h2 { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); margin-bottom: .75rem; }
.mobile-warning p { color: var(--text-secondary); margin-bottom: .5rem; }
.mobile-warning small { color: var(--primary); font-weight: 500; }
@media (max-width: 767px) {
  .mobile-warning { display: flex; }
  .app-wrapper { display: none !important; }
  .app-footer { display: none !important; }
}

/* ---- Patient role: mobile accessible, no warning ---- */
@media (max-width: 767px) {
  .patient-app-wrapper { display: flex !important; }
  .patient-app-wrapper .app-footer { display: block !important; }
  /* Sidebar compact on mobile for patient */
  .patient-app-wrapper .sidebar {
    width: 220px;
    transform: translateX(-100%);
    transition: transform .25s;
    z-index: 300;
  }
  .patient-app-wrapper .sidebar.open { transform: translateX(0); }
  .patient-app-wrapper .main-content { margin-left: 0 !important; width: 100% !important; }
  .patient-app-wrapper .top-header { padding: .5rem .75rem; }
  .patient-app-wrapper .page-content { padding: .75rem; }
  /* Table responsive scrolling */
  .patient-app-wrapper .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Cards stack */
  .patient-app-wrapper .form-grid { grid-template-columns: 1fr !important; }
  .patient-app-wrapper .stat-grid  { grid-template-columns: 1fr 1fr !important; }
  /* Hide non-essential columns */
  .patient-app-wrapper table th:nth-child(3),
  .patient-app-wrapper table td:nth-child(3) { display: none; }
}

/* ---- App Layout ---- */
.app-wrapper { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR — toujours visible, pas de collapse
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: #12151c;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  box-shadow: 2px 0 20px rgba(0,0,0,.28);
}

/* ---- Logo Header ---- */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.12);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: .85rem; }
.logo-icon { width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 8px; }
.logo-icon svg { width: 40px; height: 40px; display: block; flex-shrink: 0; }
.logo-icon img { width: 40px; height: 40px; object-fit: contain; display: block; border-radius: 8px; }
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-name { font-size: .95rem; font-weight: 800; color: #fff; letter-spacing: .6px; }
.logo-sub  { font-size: .55rem; font-weight: 700; color: var(--primary); letter-spacing: 3.5px; text-transform: uppercase; margin-top: 2px; }
.sidebar-logo-full { width: 100%; }
.sidebar-logo-full img { height: 42px; max-width: 100%; width: auto; object-fit: contain; display: block; }

/* ---- Nav scroll ---- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .5rem 0 .75rem;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

/* ---- Section labels ---- */
.nav-divider {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.25rem .4rem;
}
.nav-divider span {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: rgba(255,255,255,.28);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.06);
}

/* ---- Nav item — même rendu pour <a> et <button> ---- */
.nav-item {
  /* reset complet pour <button> */
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  font-family: var(--font);
  /* layout */
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  /* espacement */
  padding: .62rem 1rem .62rem 1.1rem;
  /* typographie */
  font-size: .83rem;
  font-weight: 500;
  line-height: 1.4;
  color: rgba(175,185,205,.72);
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  /* bordure gauche accent */
  border: none;
  border-left: 3px solid transparent;
  /* fond */
  background: transparent;
  cursor: pointer;
  /* transition */
  transition: color .15s, background .15s, border-color .15s;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.065);
  border-left-color: rgba(214,0,1,.4);
}
.nav-item.active {
  color: #fff;
  font-weight: 600;
  background: rgba(214,0,1,.14);
  border-left-color: var(--primary);
}
.nav-item.active .nav-icon { color: var(--primary); }
.nav-item:hover .nav-icon { color: rgba(255,255,255,.85); }

/* ---- Icône ---- */
.nav-icon {
  width: 18px;
  min-width: 18px;
  font-size: .88rem;
  text-align: center;
  color: rgba(175,185,205,.5);
  flex-shrink: 0;
  transition: color .15s;
}

/* ---- Texte ---- */
.nav-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Flèche groupe ---- */
.nav-arrow {
  font-size: .58rem;
  flex-shrink: 0;
  color: rgba(175,185,205,.3);
  transition: transform .2s, color .15s;
  margin-left: auto;
}
.nav-item:hover .nav-arrow { color: rgba(255,255,255,.4); }

/* ---- Groupes ---- */
.nav-group { display: block; width: 100%; }

.nav-group.open > .nav-group-toggle .nav-arrow {
  transform: rotate(90deg);
  color: var(--primary);
}
.nav-group.open > .nav-group-toggle {
  color: rgba(255,255,255,.88);
  background: rgba(255,255,255,.045);
  border-left-color: rgba(214,0,1,.3);
}
.nav-group.open > .nav-group-toggle .nav-icon { color: rgba(255,255,255,.65); }

/* ---- Sous-menu ---- */
.nav-submenu {
  display: none;
  padding: .2rem 0 .3rem 0;
  margin-left: 2.85rem;   /* aligne avec le début du texte parent */
  border-left: 1.5px solid rgba(214,0,1,.2);
  background: rgba(0,0,0,.12);
}
.nav-group.open .nav-submenu {
  display: block;
  animation: submenuIn .18s ease;
}
@keyframes submenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-subitem {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .42rem .75rem .42rem .8rem;
  color: rgba(155,168,192,.65);
  font-size: .79rem;
  font-weight: 400;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: color .15s, background .15s;
}
.nav-subitem span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-subitem .fa-circle-dot {
  font-size: .36rem;
  color: rgba(214,0,1,.45);
  flex-shrink: 0;
}
.nav-subitem:hover {
  color: #fff;
  background: rgba(255,255,255,.065);
}
.nav-subitem:hover .fa-circle-dot { color: rgba(214,0,1,.75); }
.nav-subitem.active {
  color: #fff;
  font-weight: 600;
  background: rgba(214,0,1,.09);
}
.nav-subitem.active .fa-circle-dot { color: var(--primary); }

/* ---- Footer utilisateur ---- */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: .6rem 1.1rem;
  background: rgba(0,0,0,.12);
  flex-shrink: 0;
  margin: 0;
}
.sidebar-user { display: flex; align-items: center; gap: .75rem; overflow: hidden; }
.sidebar-user-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: .82rem; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(214,0,1,.3);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  display: block; color: #fff; font-size: .8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.sidebar-user-role {
  display: block; color: rgba(155,168,192,.6);
  font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */
.top-header {
  height: var(--header-h); background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.sidebar-toggle {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: .5rem; border-radius: 8px;
  font-size: 1.1rem; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--primary); background: var(--primary-bg); }

/* Logout at bottom of sidebar */
.sidebar-logout-wrap {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-logout-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .9rem; border-radius: 8px;
  color: #f87171; text-decoration: none;
  font-size: .82rem; font-weight: 500;
  transition: background .18s, color .18s;
}
.sidebar-logout-link:hover {
  background: rgba(239,68,68,.12);
  color: #ef4444;
}
.page-title-header { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.header-center { flex: 1; max-width: 500px; }

/* Global Search */
.global-search { position: relative; }
.global-search input {
  width: 100%; height: 38px; border: 1px solid var(--border);
  border-radius: 20px; padding: 0 1rem 0 2.5rem;
  font-size: .82rem; font-family: var(--font);
  background: var(--bg); color: var(--text-primary);
  transition: var(--transition); outline: none;
}
.global-search input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(214,0,1,.1); }
.search-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .8rem; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 300; display: none; max-height: 380px; overflow-y: auto;
}
.search-results.show { display: block; }
.search-result-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; cursor: pointer; transition: var(--transition); }
.search-result-item:hover { background: var(--bg); }
.search-result-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.search-result-icon.patient     { background: #dbeafe; color: #2563eb; }
.search-result-icon.doctor      { background: #dcfce7; color: #16a34a; }
.search-result-icon.invoice     { background: #fef9c3; color: #ca8a04; }
.search-result-icon.appointment { background: #ffedd5; color: #ea580c; }
.search-result-icon.form        { background: #ede9fe; color: #7c3aed; }
.search-result-meta strong { display: block; font-size: .82rem; font-weight: 600; color: var(--text-primary); }
.search-result-meta span { font-size: .75rem; color: var(--text-muted); }
.search-no-results { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: .82rem; }

.header-right { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; margin-left: auto; }
.header-datetime { text-align: right; line-height: 1.3; }
.header-date { font-size: .75rem; font-weight: 600; color: var(--text-primary); }
.header-time { font-size: .7rem; color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: .5rem; }
.header-btn {
  background: none; border: none; cursor: pointer; padding: .5rem;
  border-radius: 8px; color: var(--text-secondary); position: relative;
  display: flex; align-items: center; gap: .4rem;
  font-family: var(--font); font-size: .825rem; font-weight: 500;
  transition: var(--transition);
}
.header-btn:hover { color: var(--primary); background: var(--primary-bg); }
.badge-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: .65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white); padding: 0 3px;
}
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-avatar-default {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.user-name-header { font-size: .82rem; font-weight: 500; }

/* Dropdowns */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 300;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 200px; display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.dropdown-header span { font-size: .82rem; font-weight: 600; }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }
.dropdown-footer { padding: .6rem 1rem; border-top: 1px solid var(--border); text-align: center; }
.dropdown-footer a { font-size: .78rem; color: var(--primary); font-weight: 500; }
.dropdown-item {
  display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem;
  font-size: .82rem; color: var(--text-primary); cursor: pointer; transition: var(--transition);
}
.dropdown-item:hover { background: var(--bg); color: var(--primary); }
.dropdown-item i { width: 16px; text-align: center; color: var(--text-muted); }
.dropdown-item.text-danger { color: #dc2626; }
.dropdown-item.text-danger:hover { background: #fef2f2; }

/* Notifications */
.notif-menu { width: 340px; }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 1rem;
  cursor: pointer; transition: var(--transition); border-bottom: 1px solid var(--border-light);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-bg); }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.notif-appointment { background: #dbeafe; color: #2563eb; }
.notif-payment      { background: #dcfce7; color: #16a34a; }
.notif-lab_result   { background: #fef3c7; color: #d97706; }
.notif-stock_alert  { background: #fee2e2; color: #dc2626; }
.notif-system       { background: #f3e8ff; color: #7c3aed; }
.notif-general      { background: #f0f9ff; color: #0284c7; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: .8rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-msg { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: .7rem; color: var(--text-muted); }
.notif-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: .82rem; }
.notif-empty i { display: block; font-size: 1.5rem; margin-bottom: .5rem; }
.mark-all-read { font-size: .75rem; color: var(--primary); cursor: pointer; }
.notif-recovery-icon { background: #fef3c7; color: #b45309; }
.notif-link:hover { background: var(--primary-bg) !important; }
a.notif-item { display: flex; }
.profile-menu-header { padding: .75rem 1rem; }
.profile-menu-header strong { display: block; font-size: .85rem; font-weight: 600; }
.profile-menu-header small { color: var(--text-muted); font-size: .75rem; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { flex: 1; padding: 1.5rem; }

/* Alert */
.alert {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.25rem; border-radius: var(--radius); margin: 1rem 1.5rem 0;
  font-size: .85rem; font-weight: 500; position: relative;
  animation: slideDown .3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error    { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-warning  { background: #fef9c3; color: #a16207; border: 1px solid #fde68a; }
.alert-info     { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-close { position: absolute; right: .75rem; background: none; border: none; cursor: pointer; color: inherit; opacity: .7; padding: .25rem; border-radius: 4px; }
.alert-close:hover { opacity: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-title { font-size: .9rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: .6rem; }
.card-title i { color: var(--primary); }
.card-body { padding: 1.5rem; }
.card-footer { padding: .85rem 1.5rem; border-top: 1px solid var(--border); background: var(--bg); }

/* Stat Cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 1rem;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  width: 54px; height: 54px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.stat-icon.yellow { background: #fef9c3; color: #ca8a04; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-icon.indigo { background: #e0e7ff; color: #4f46e5; }
.stat-info {}
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); font-weight: 500; margin-top: .25rem; }
.stat-delta { font-size: .75rem; font-weight: 600; margin-top: .3rem; }
.stat-delta.up   { color: #16a34a; }
.stat-delta.down { color: #dc2626; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.table th {
  padding: .75rem 1rem; text-align: left;
  background: var(--bg); color: var(--text-secondary);
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tbody tr:hover { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; align-items: center; gap: .4rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem 1.1rem; border-radius: 8px; font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); border: 1.5px solid transparent;
  text-decoration: none; white-space: nowrap; font-family: var(--font);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover   { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--white); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }
.btn-success   { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover   { background: #15803d; color: #fff; }
.btn-danger    { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover    { background: #b91c1c; color: #fff; }
.btn-warning   { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover   { background: #b45309; color: #fff; }
.btn-info      { background: #0284c7; color: #fff; border-color: #0284c7; }
.btn-info:hover      { background: #0369a1; color: #fff; }
.btn-light     { background: var(--bg); color: var(--text-primary); border-color: var(--border); }
.btn-light:hover     { background: var(--border); }
.btn-sm  { padding: .35rem .75rem; font-size: .775rem; }
.btn-lg  { padding: .75rem 1.5rem; font-size: .9rem; }
.btn-icon { padding: .45rem; width: 32px; height: 32px; border-radius: 6px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem; }
.form-grid-2{ display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.form-grid-3{ display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.1rem; }
/* form-row = alias 2 colonnes adaptable */
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text-primary); }
.form-label.required::after { content: ' *'; color: var(--primary); }
.form-control {
  width: 100%; height: 40px; padding: 0 .85rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .82rem; font-family: var(--font); color: var(--text-primary);
  background: var(--white); transition: var(--transition); outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214,0,1,.1); }
.form-control.is-invalid { border-color: #dc2626; }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { height: auto; padding: .65rem .85rem; resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .75rem; color: var(--text-muted); }
.form-error { font-size: .75rem; color: #dc2626; }
.form-section { margin-bottom: 1.5rem; }
.form-section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  color: var(--primary); margin-bottom: 1rem; padding-bottom: .5rem;
  border-bottom: 2px solid var(--primary-bg);
  display: flex; align-items: center; gap: .5rem;
}
.form-actions { display: flex; align-items: center; gap: .75rem; justify-content: flex-end; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Photo Upload */
.photo-upload { display: flex; align-items: center; gap: 1.5rem; }
.photo-preview {
  width: 90px; height: 90px; border-radius: var(--radius);
  border: 2px dashed var(--border); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-muted); font-size: 1.5rem;
  cursor: pointer; flex-shrink: 0;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload-btn { display: flex; flex-direction: column; gap: .4rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem; border-radius: 100px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #dc2626; }
.badge-warning  { background: #fef9c3; color: #a16207; }
.badge-info     { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary  { background: #fee2e2; color: #d60001; }
.badge-purple   { background: #f3e8ff; color: #7c3aed; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.pagination .page-link {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--white);
  font-size: .82rem; color: var(--text-secondary); cursor: pointer;
  transition: var(--transition); text-decoration: none;
}
.pagination .page-link:hover { border-color: var(--primary); color: var(--primary); }
.pagination .page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page-link.disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  padding: 1rem; overflow-y: auto;
}
.modal-overlay.show,
.modal-overlay.active { display: flex; }
/* .modal = legacy name  /  .modal-dialog = current name — both are the white container */
.modal,
.modal-dialog {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
  animation: modalIn .25s ease;
  overflow: hidden;
}
.modal-lg, .modal-dialog.modal-lg { max-width: 860px; }
.modal-sm, .modal-dialog.modal-sm { max-width: 400px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: .3rem; border-radius: 6px; font-size: 1rem; transition: var(--transition); }
.modal-close:hover { color: var(--primary); background: var(--primary-bg); }
/* body scrolls inside the dialog; footer always stays pinned */
.modal-body { padding: 1.5rem; flex: 1; overflow-y: auto; min-height: 0; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; flex-shrink: 0; background: var(--white); }
/* form wrapping body+footer: must also be flex column so footer stays at bottom */
.modal-dialog > form,
.modal > form {
  display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header-left {}
.page-header h1 { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }
.page-header p  { font-size: .82rem; color: var(--text-secondary); margin-top: .2rem; }
.page-header-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ============================================================
   FILTERS / SEARCH BAR
   ============================================================ */
.filter-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.5rem; background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}
.filter-search {
  display: flex; align-items: center; gap: .5rem;
  border: 1.5px solid var(--border); border-radius: 8px; padding: .42rem .85rem;
  background: var(--bg); flex: 1; min-width: 180px;
  transition: border-color .15s, box-shadow .15s;
}
.filter-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214,0,1,.08); }
.filter-search input {
  border: none; background: none; outline: none;
  font-size: .82rem; font-family: var(--font);
  flex: 1; min-width: 0; width: 100%;
  color: var(--text-primary); height: 28px;
}
.filter-search i { color: var(--text-muted); font-size: .8rem; }
.filter-select { height: 38px; border: 1.5px solid var(--border); border-radius: 8px; padding: 0 .8rem; font-size: .82rem; font-family: var(--font); background: var(--white); color: var(--text-primary); outline: none; cursor: pointer; }
.filter-select:focus { border-color: var(--primary); }
.filter-count { margin-left: auto; font-size: .8rem; color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   PATIENT / DOCTOR CARD
   ============================================================ */
.person-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border);
}
.person-avatar-default {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.avatar-m { background: #dbeafe; color: #2563eb; }
.avatar-f { background: #fce7f3; color: #db2777; }
.person-info strong { display: block; font-size: .83rem; font-weight: 600; color: var(--text-primary); }
.person-info span { font-size: .75rem; color: var(--text-muted); }

/* ============================================================
   DASHBOARD CHARTS
   ============================================================ */
.chart-container { position: relative; height: 280px; }
.chart-container canvas { max-height: 280px; }

/* Revenue Cards (legacy — superseded by .kpi-grid below, kept for any other page still using it) */
.revenue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.revenue-card {
  background: var(--bg); border-radius: var(--radius); padding: 1rem 1.25rem;
  border: 1px solid var(--border);
}
.revenue-card .rev-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.revenue-card .rev-value { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); margin-top: .2rem; }

/* ============================================================
   KPI CARDS (Revenus — dashboard admin)
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.kpi-card {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem; transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary);
}
.kpi-card.kpi-red::before    { background: #dc2626; }
.kpi-card.kpi-blue::before   { background: #2563eb; }
.kpi-card.kpi-green::before  { background: #16a34a; }
.kpi-card.kpi-purple::before { background: #7c3aed; }
.kpi-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.kpi-card-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi-card-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .95rem;
  background: var(--primary-bg); color: var(--primary);
}
.kpi-card.kpi-red .kpi-card-icon    { background: #fee2e2; color: #dc2626; }
.kpi-card.kpi-blue .kpi-card-icon   { background: #dbeafe; color: #2563eb; }
.kpi-card.kpi-green .kpi-card-icon  { background: #dcfce7; color: #16a34a; }
.kpi-card.kpi-purple .kpi-card-icon { background: #f3e8ff; color: #7c3aed; }
.kpi-card-value { font-size: 1.55rem; font-weight: 800; color: var(--text-primary); margin-top: .6rem; letter-spacing: -.02em; }
.kpi-card-trend { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700; margin-top: .5rem; }
.kpi-card-trend.up   { color: #16a34a; }
.kpi-card-trend.down { color: #dc2626; }
.kpi-card-trend.flat { color: var(--text-muted); }
.kpi-card-trend span.trend-ctx { color: var(--text-muted); font-weight: 500; }

/* Chart card polish */
.chart-card-pro { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.chart-card-pro .card-header { border-bottom: 1px solid var(--border-light); }

/* ============================================================
   ATTENDANCE WIDGET (Pointage — tous les tableaux de bord staff)
   ============================================================ */
.attendance-widget { border-left: 4px solid var(--primary); }
.attendance-widget-body {
  display: flex; align-items: center; justify-content: space-between; gap: 1.25rem;
  padding: 1.1rem 1.5rem; flex-wrap: wrap;
}
.attendance-widget-info { display: flex; align-items: center; gap: 1rem; }
.attendance-widget-icon {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
  background: var(--primary-bg); color: var(--primary);
}
.attendance-widget-title { font-size: .85rem; font-weight: 700; color: var(--text-primary); }
.attendance-widget-sub { font-size: .8rem; color: var(--text-secondary); margin-top: .2rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.attendance-widget-actions form { margin: 0; }
.attendance-widget-done { padding: .55rem 1rem; font-size: .8rem; }

/* Présence — mini table + stat cards on admin attendance overview */
.attendance-mini-table td, .attendance-mini-table th { white-space: nowrap; }

/* Activity Feed */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; align-items: flex-start; gap: .85rem;
  padding: .75rem 0; border-bottom: 1px solid var(--border-light);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.activity-body { flex: 1; min-width: 0; }
.activity-body p { font-size: .8rem; color: var(--text-primary); }
.activity-body p strong { color: var(--primary); }
.activity-body small { font-size: .72rem; color: var(--text-muted); }

/* ============================================================
   CALENDAR (Appointments)
   ============================================================ */
/* Calendar toolbar */
.cal-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.75rem; margin-bottom:1rem; }
.cal-nav { display:flex; align-items:center; gap:.75rem; }
.cal-month-label { font-size:1.05rem; font-weight:700; min-width:160px; text-align:center; }
.cal-stats { display:flex; gap:.35rem; }
.cal-stat { display:inline-flex; align-items:center; justify-content:center; min-width:26px; height:22px; border-radius:11px; font-size:.72rem; font-weight:700; padding:0 .4rem; cursor:default; }
.cal-stat.programmed { background:#dbeafe; color:#1e40af; }
.cal-stat.confirmed  { background:#dcfce7; color:#166534; }
.cal-stat.pending    { background:#fef9c3; color:#92400e; }
.cal-stat.done       { background:#f3f4f6; color:#4b5563; }
.cal-stat.cancelled  { background:#fee2e2; color:#991b1b; }
/* Calendar grid */
.calendar-grid { display:grid; grid-template-columns:repeat(7,1fr); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.calendar-day-header { text-align:center; font-size:.72rem; font-weight:700; text-transform:uppercase; color:var(--text-muted); padding:.55rem 0; background:var(--bg); border-bottom:1px solid var(--border); }
.calendar-day { min-height:90px; padding:.4rem .5rem; border-right:1px solid var(--border-light); border-bottom:1px solid var(--border-light); background:var(--white); cursor:pointer; transition:background .15s; position:relative; }
.calendar-day:nth-child(7n) { border-right:none; }
.calendar-day:hover { background:#f9fafb; }
.calendar-day.other-month { background:var(--bg); opacity:.5; cursor:default; pointer-events:none; }
.calendar-day.past .calendar-day-num { color:var(--text-muted); }
.calendar-day-num { font-size:.8rem; font-weight:600; color:var(--text-primary); margin-bottom:.3rem; width:26px; height:26px; display:flex; align-items:center; justify-content:center; border-radius:50%; }
.today-num { background:var(--primary); color:#fff !important; font-weight:800; }
/* Events */
.calendar-event { display:flex; align-items:center; gap:.25rem; padding:.18rem .4rem; border-radius:4px; font-size:.68rem; font-weight:500; margin-bottom:.18rem; cursor:pointer; overflow:hidden; white-space:nowrap; transition:filter .1s; }
.calendar-event:hover { filter:brightness(.9); }
.calendar-event.programmed { background:#dbeafe; color:#1e40af; }
.calendar-event.confirmed  { background:#dcfce7; color:#166534; }
.calendar-event.pending    { background:#fef9c3; color:#92400e; }
.calendar-event.cancelled  { background:#fee2e2; color:#991b1b; opacity:.7; }
.calendar-event.done       { background:#f3f4f6; color:#4b5563; }
.cal-ev-time { font-weight:700; flex-shrink:0; }
.cal-ev-name { overflow:hidden; text-overflow:ellipsis; }
.cal-ev-more { font-size:.65rem; color:var(--text-muted); text-align:right; padding:.1rem .4rem; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { border-bottom: 2px solid var(--border); display: flex; gap: 0; margin-bottom: 1.5rem; }
.tab-btn {
  padding: .7rem 1.25rem; font-size: .82rem; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; border: none;
  background: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: var(--transition); font-family: var(--font);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: .5rem; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-dot {
  position: absolute; left: -1.55rem; width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--white); box-shadow: 0 0 0 3px rgba(214,0,1,.15); top: 4px;
}
.timeline-content { background: var(--bg); border-radius: var(--radius); padding: .85rem 1rem; border: 1px solid var(--border); }
.timeline-content h4 { font-size: .82rem; font-weight: 700; margin-bottom: .25rem; }
.timeline-content p  { font-size: .78rem; color: var(--text-secondary); }
.timeline-date { font-size: .72rem; color: var(--text-muted); margin-top: .3rem; display: block; }

/* ============================================================
   PATIENT VIEW
   ============================================================ */
.patient-header {
  display: flex; align-items: center; gap: 1.5rem; padding: 1.5rem;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #2a2d35 100%); border-radius: var(--radius-lg);
  color: var(--white); margin-bottom: 1.5rem;
}
.patient-header-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.3); object-fit: cover; flex-shrink: 0;
}
.patient-header-avatar-default {
  width: 80px; height: 80px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700;
  border: 3px solid rgba(255,255,255,.3); flex-shrink: 0;
}
.patient-header-info h2 { font-size: 1.1rem; font-weight: 800; }
.patient-header-info p { font-size: .82rem; opacity: .7; margin-top: .25rem; }
.patient-header-tags { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.patient-header-tag { padding: .2rem .7rem; border-radius: 100px; font-size: .72rem; font-weight: 600; background: rgba(255,255,255,.15); }

/* ============================================================
   INFO GRID
   ============================================================ */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.info-item {}
.info-label { font-size: .73rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: .2rem; }
.info-value { font-size: .85rem; font-weight: 500; color: var(--text-primary); }

/* ============================================================
   PRINT STYLES (PDF preview)
   ============================================================ */
.pdf-document {
  background: var(--white); width: 8.5in; max-width: 100%; min-height: 11in; box-sizing: border-box;
  margin: 0 auto 2rem; padding: 0.5in; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
}
.pdf-document.pdf-flex-page { display: flex; flex-direction: column; }
/* Sélecteur d'ENFANT DIRECT seulement : la signature du Certificat de Naissance est désormais
   imbriquée DANS .pdf-cert-bordered-body (voir plus bas), donc cette règle de "collage en bas de
   page" ne doit s'appliquer qu'aux types de certificat (visite/médical) dont la signature reste un
   enfant direct de .pdf-flex-page. Un sélecteur descendant (sans >) capturerait aussi la signature
   imbriquée et la sortirait de la bordure — exactement le bug que ce > évite. */
.pdf-document.pdf-flex-page > .pdf-cert-signatures { margin-top: auto; padding-top: 2rem; }
/* Certificat de Naissance : la bordure décorative pointillée encadre TOUT le certificat, logo,
   texte ET zone de signature (tous imbriqués dans ce même bloc) — un seul document visuellement
   complet, jamais de signature "flottante" hors du cadre. Le padding de 1.5rem garde une marge de
   sécurité constante entre le contenu et le contour, empêchant tout chevauchement.
   min-height 8.5in : le contour doit respecter les 4 marges de la page comme sur le papier
   original (haut/bas/gauche/droite symétriques), pas juste envelopper le texte et laisser un grand
   vide en dessous. Volontairement un peu SOUS le maximum disponible (~9.3in après le padding de
   .pdf-document) pour garder une marge de sécurité à l'impression — voir la même logique déjà
   appliquée à pdf-flex-page pour les autres types de certificat. */
.pdf-cert-bordered-body { outline: 3px dashed var(--primary); outline-offset: -14px; padding: 1.5rem; min-height: 8.5in; }
.pdf-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--primary); }
.pdf-logo { display: flex; align-items: center; gap: .75rem; }
.pdf-logo-icon { width: 50px; height: 50px; }
.pdf-logo-name { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.pdf-logo-sub  { font-size: .75rem; color: var(--text-muted); }
.pdf-doc-info { text-align: right; }
.pdf-doc-info strong { display: block; font-size: .9rem; font-weight: 700; }
.pdf-doc-info span { font-size: .78rem; color: var(--text-muted); }
.pdf-section-title { font-size: .85rem; font-weight: 700; text-transform: uppercase; color: var(--primary); margin: 1.25rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.pdf-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: .5rem; }
.pdf-table th { background: var(--bg); padding: .5rem .75rem; text-align: left; font-weight: 700; border: 1px solid var(--border); }
.pdf-table td { padding: .5rem .75rem; border: 1px solid var(--border); }
.pdf-qr  { text-align: center; padding: 1rem 0; }
.pdf-footer { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--text-muted); text-align: center; }
.pdf-signature { display: inline-block; min-width: 150px; border-bottom: 1.5px solid var(--text-muted); padding-top: 2rem; margin-top: 1.5rem; text-align: center; font-size: .78rem; }

/* Format papier fixe 8,5 x 11 po (Letter) pour tous les documents imprimés/téléchargés en PDF.
   Marge @page à 0 : élimine l'en-tête/pied de page injecté par le navigateur (date, titre, URL,
   numéro de page) — Chrome/Edge n'ont pas la place de les dessiner sans marge de page. La marge
   visuelle de 0.5in est reproduite via le padding de .pdf-document, qui reste actif à l'impression. */
@page { size: 8.5in 11in; margin: 0; }
@media print {
  body { margin: 0; }
  .pdf-document { width: 100%; min-height: 0; margin: 0 auto; box-shadow: none; border: none; }
  .no-print { display: none !important; }
  /* La signature doit rester collée au bas de la page ET tenir sur une seule page.
     min-height + margin-top:auto (flex) est fiable à l'écran mais déborde d'un fil à
     l'impression réelle, créant une 2e page quasi vide. Solution fiable : fixer la hauteur
     du document un peu SOUS une pleine page (10.3in au lieu de 11in — l'équivalent d'environ
     3 lignes de marge de sécurité) et sortir la signature du flux (position:absolute), collée
     au bas de cette boîte réduite. Ça élimine tout risque de débordement (marge non imprimable
     du pilote d'impression comprise) tout en gardant la signature bien "assise" au bas visuel
     de la page, pas collée au tout dernier bord. */
  .pdf-document.pdf-flex-page { display: block; position: relative; height: 10.3in; min-height: 0; overflow: hidden; }
  /* Enfant direct seulement — voir le commentaire sur la règle écran équivalente plus haut :
     la signature du Certificat de Naissance, imbriquée dans .pdf-cert-bordered-body, ne doit
     jamais être sortie de son cadre par un position:absolute, ni à l'écran ni à l'impression. */
  .pdf-document.pdf-flex-page > .pdf-cert-signatures { position: absolute; left: 0; right: 0; bottom: 0; margin-top: 0; padding-top: 0; margin-bottom: 0; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state-icon { font-size: 3.5rem; color: var(--text-muted); margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: .5rem; }
.empty-state p { font-size: .85rem; color: var(--text-muted); max-width: 360px; margin: 0 auto 1.5rem; }

/* ============================================================
   SPINNER / LOADING
   ============================================================ */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  min-width: 280px; max-width: 380px; padding: .85rem 1.25rem; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: .82rem; font-weight: 500;
  display: flex; align-items: center; gap: .75rem; animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast-success { background: #15803d; color: #fff; }
.toast-error   { background: #dc2626; color: #fff; }
.toast-warning { background: #d97706; color: #fff; }
.toast-info    { background: #0284c7; color: #fff; }
.toast-close   { margin-left: auto; cursor: pointer; opacity: .7; background: none; border: none; color: inherit; }
.toast-close:hover { opacity: 1; }

/* ============================================================
   GRID UTILITIES
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 1.25rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .grid-1-2, .grid-2-1,
  .form-grid-2, .form-grid-3, .form-row { grid-template-columns: 1fr; }
}
/* Modal forms — collapse grids inside dialogs on small screens */
@media (max-width: 600px) {
  .modal, .modal-dialog { margin: .5rem; max-height: calc(100vh - 1rem); width: calc(100% - 1rem); }
  .modal-body { padding: 1rem; }
  .modal-dialog [style*="grid-template-columns: 1fr 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  .modal-dialog [style*="grid-template-columns: 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-search { min-width: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .7rem; }
}

/* ============================================================
   SPACING UTILITIES
   ============================================================ */
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; } .align-center { align-items: center; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.text-right { text-align: right; } .text-center { text-align: center; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-primary-color { color: var(--primary); }
.text-success { color: #16a34a; } .text-danger { color: #dc2626; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background-color: #1a1d23;
  background-image: url('../images/camedyc-building.jpg');
  background-size: cover; background-position: center top; background-repeat: no-repeat;
  background-attachment: fixed;
  padding: 1rem; position: relative;
}
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(26,29,35,.82) 0%, rgba(214,0,1,.35) 100%);
  backdrop-filter: blur(1px);
}
.login-page > * { position: relative; z-index: 1; }
.login-card {
  background: rgba(255,255,255,.97); border-radius: var(--radius-lg); padding: 2.5rem;
  width: 100%; max-width: 430px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.3);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 1rem; }
.login-logo svg { width: 64px; height: 64px; filter: drop-shadow(0 2px 6px rgba(214,0,1,.4)); }
.login-logo-full { width: 100%; max-width: 280px; height: auto; margin: 0 auto 1rem; }
.login-logo-full img { width: 100%; height: auto; object-fit: contain; }
.login-title { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); letter-spacing: .02em; }
.login-subtitle { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }
.login-form { display: flex; flex-direction: column; gap: 1.1rem; }
.login-input-group { position: relative; }
.login-input-group .login-input-icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .9rem; }
.login-input-group input {
  width: 100%; height: 48px; padding: 0 1rem 0 2.75rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: var(--font); color: var(--text-primary);
  background: var(--bg); transition: var(--transition); outline: none;
}
.login-input-group input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(214,0,1,.1); }
.login-btn {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  background: linear-gradient(135deg, #d60001 0%, #b50001 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  font-family: var(--font);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  box-shadow: 0 4px 18px rgba(214,0,1,.38), 0 1px 4px rgba(0,0,0,.12);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.login-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.12) 0%, transparent 60%);
  border-radius: inherit;
  pointer-events: none;
}
.login-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #e60002 0%, #c00001 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(214,0,1,.48), 0 2px 6px rgba(0,0,0,.14);
}
.login-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(214,0,1,.3);
}
.login-btn:disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
}
.login-footer { text-align: center; margin-top: 1.5rem; font-size: .75rem; color: var(--text-muted); line-height: 1.7; }
.login-quicklinks { display:grid; grid-template-columns:1fr 1fr; gap:.75rem; margin-top:1.1rem; }
.login-quicklink {
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.5rem;
  text-align:center; padding:1rem .6rem; border-radius:14px;
  border:1.5px solid var(--border); background:#f9fafb;
  color:var(--text-secondary); font-size:.72rem; font-weight:700; line-height:1.35;
  text-decoration:none; transition:all .2s ease;
  box-shadow:0 1px 3px rgba(0,0,0,.03);
}
.login-quicklink i {
  width:34px; height:34px; border-radius:50%; background:#fff;
  display:flex; align-items:center; justify-content:center;
  font-size:.9rem; color:var(--primary);
  box-shadow:0 2px 6px rgba(0,0,0,.08);
  transition:all .2s ease;
}
.login-quicklink:hover {
  border-color:var(--primary); background:#fff5f5; color:var(--primary);
  transform:translateY(-2px); box-shadow:0 8px 18px rgba(214,0,1,.14);
}
.login-quicklink:hover i { background:var(--primary); color:#fff; box-shadow:0 3px 8px rgba(214,0,1,.35); }
.login-error { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; border-radius: 8px; padding: .75rem 1rem; font-size: .82rem; font-weight: 500; text-align: center; }
.login-bg-credit {
  position: fixed; bottom: .75rem; right: 1rem; z-index: 1;
  font-size: .7rem; color: rgba(255,255,255,.5); pointer-events: none;
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  background: var(--white); border-top: 1px solid var(--border);
  padding: .75rem 1.5rem; text-align: center;
  font-size: .76rem; color: var(--text-muted);
  margin-left: var(--sidebar-w);
}

/* ============================================================
   STOCK ALERT
   ============================================================ */
.stock-low  { color: #d97706; font-weight: 600; }
.stock-out  { color: #dc2626; font-weight: 600; }
.stock-ok   { color: #16a34a; }

/* ============================================================
   ALIAS & MISSING CLASSES
   ============================================================ */

/* data-table = alias pour .table */
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th {
  padding: .75rem 1rem; text-align: left;
  background: var(--bg); color: var(--text-secondary);
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* stats-grid = alias pour .stat-grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

/* icon-btn: petit bouton carré transparent pour actions inline */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--bg); border: 1.5px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  font-size: .78rem; transition: var(--transition);
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.icon-btn.text-danger:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }

/* row-muted: ligne de table désactivée */
.row-muted td { opacity: .5; }

/* badge-light: badge neutre clair */
.badge-light { background: #f8f9fa; color: #6b7280; }

/* person-info: cellule combinée avatar + texte */
.person-info { display: flex; align-items: center; gap: .65rem; }
.person-info strong { display: block; font-size: .83rem; font-weight: 600; color: var(--text-primary); }
.person-info span  { font-size: .75rem; color: var(--text-muted); }

/* tab-pane aussi accessible sans data-tabs (standalone) */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* progress bar */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; background: var(--primary); transition: width .4s ease; }
.progress-bar.blue   { background: #2563eb; }
.progress-bar.green  { background: #16a34a; }
.progress-bar.yellow { background: #d97706; }
.progress-bar.purple { background: #7c3aed; }

/* Vitals card */
.vital-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1rem; background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border); text-align: center; gap: .25rem;
}
.vital-card .vital-icon { font-size: 1.2rem; margin-bottom: .2rem; }
.vital-card .vital-val  { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); }
.vital-card .vital-lbl  { font-size: .72rem; color: var(--text-muted); font-weight: 500; }

/* Timeline compact */
.timeline-compact { display: flex; flex-direction: column; gap: .5rem; }
.timeline-compact-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .65rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--white);
}
.timeline-compact-item:hover { border-color: var(--primary); background: var(--primary-bg); }
.timeline-compact-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: .35rem; }
.timeline-compact-body { flex: 1; min-width: 0; }
.timeline-compact-body strong { font-size: .82rem; font-weight: 600; }
.timeline-compact-body p { font-size: .78rem; color: var(--text-secondary); margin-top: .1rem; }
.timeline-compact-body small { font-size: .72rem; color: var(--text-muted); }

/* Statut label inline */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; }
.status-dot.green { background: #16a34a; }
.status-dot.red   { background: #dc2626; }
.status-dot.yellow { background: #d97706; }

/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .stat-value { font-size: 1.3rem; }
}
@media (max-width: 1024px) {
  .page-content { padding: 1rem; }
  .top-header { padding: 0 1rem; }
  .user-name-header { display: none; }
  .header-datetime { display: none; }

  /* Sidebar becomes overlay on tablet */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Overlay backdrop */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 299;
  }
  .sidebar-overlay.active { display: block; }
}

/* On desktop: toggle button hidden, sidebar always visible */
@media (min-width: 1025px) {
  .sidebar-toggle { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ============================================================
   PROFILE PAGE
   ============================================================ */
.profile-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  align-items: start;
}
.profile-sidebar-card { position: sticky; top: calc(var(--header-h) + 1.25rem); }
.profile-avatar-wrap { margin-bottom: 1rem; }
.profile-avatar-img {
  width: 100px; height: 100px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--primary);
  display: block; margin: 0 auto;
}
.profile-avatar-default {
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 700;
  margin: 0 auto;
}
.profile-fullname { font-size: 1.1rem; font-weight: 700; margin: 0 0 .4rem; }
.profile-meta { text-align: left; margin-top: 1.25rem; display: flex; flex-direction: column; gap: .65rem; }
.profile-meta-row {
  display: flex; align-items: flex-start; gap: .6rem;
  font-size: .82rem; color: var(--text-secondary);
}
.profile-meta-row i { color: var(--primary); width: 14px; flex-shrink: 0; margin-top: .15rem; }
.profile-photo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.profile-photo-preview {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--primary); flex-shrink: 0;
}
.profile-photo-preview-default {
  width: 72px !important; height: 72px !important;
  font-size: 1.4rem !important; flex-shrink: 0;
}
.profile-photo-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-sidebar-card { position: static; }
}

/* ============================================================
   PATIENT PORTAL STYLES
   ============================================================ */

/* Base layout */
.patient-portal-body {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.pp-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 56px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.pp-header-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.pp-brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: .02em;
}
.pp-brand-name span {
  color: #d60001;
}
.pp-header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.pp-header-username {
  font-size: .875rem;
  font-weight: 500;
  color: #64748b;
}
.pp-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff1f1;
  color: #d60001;
  text-decoration: none;
  font-size: .95rem;
  transition: background .15s;
}
.pp-logout-btn:hover { background: #fecaca; }

/* ── Main content ── */
.pp-main {
  padding: 1rem;
  padding-bottom: 80px; /* space for bottom nav */
  max-width: 600px;
  margin: 0 auto;
}

/* ── Greeting card ── */
.pp-greeting {
  background: linear-gradient(135deg, #d60001 0%, #9b0001 100%);
  border-radius: 16px;
  padding: 1.25rem 1.25rem 1.25rem 1.25rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}
.pp-greeting-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.4);
}
.pp-greeting-text { flex: 1; min-width: 0; }
.pp-greeting-text h2 {
  margin: 0 0 .2rem;
  font-size: 1.15rem;
  font-weight: 700;
}
.pp-greeting-text p {
  margin: 0;
  font-size: .8rem;
  opacity: .85;
}
.pp-greeting-icon {
  font-size: 2rem;
  opacity: .2;
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
}

/* ── Stats row ── */
.pp-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}
.pp-stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.pp-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.pp-stat-icon.blue  { background: #eff6ff; color: #2563eb; }
.pp-stat-icon.red   { background: #fff1f1; color: #d60001; }
.pp-stat-icon.green { background: #f0fdf4; color: #16a34a; }
.pp-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: #1e293b;
}
.pp-stat-label {
  font-size: .72rem;
  color: #64748b;
  margin-top: .15rem;
}

/* ── Sections ── */
.pp-section {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.pp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .85rem;
  font-size: .9rem;
  font-weight: 600;
  color: #1e293b;
}
.pp-section-header span { display: flex; align-items: center; gap: .4rem; }
.pp-section-header i { color: #d60001; }
.pp-see-all {
  font-size: .78rem;
  color: #d60001;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .25rem;
  font-weight: 500;
}
.pp-see-all:hover { text-decoration: underline; }

/* ── Empty state ── */
.pp-empty {
  text-align: center;
  padding: 1.5rem 0;
  color: #94a3b8;
}
.pp-empty i { font-size: 2rem; display: block; margin-bottom: .5rem; }
.pp-empty p { margin: 0; font-size: .85rem; }

/* ── Appointment cards ── */
.pp-appt-card {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .75rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.pp-appt-card:last-child { border-bottom: none; }
.pp-appt-date-badge {
  width: 48px;
  min-width: 48px;
  background: #fff1f1;
  border-radius: 10px;
  text-align: center;
  padding: .4rem .3rem;
  border: 1px solid #fecaca;
}
.pp-appt-day {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: #d60001;
  line-height: 1;
}
.pp-appt-month {
  display: block;
  font-size: .65rem;
  text-transform: uppercase;
  color: #d60001;
  letter-spacing: .05em;
  font-weight: 600;
}
.pp-appt-info { flex: 1; min-width: 0; }
.pp-appt-doctor {
  font-size: .875rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.pp-appt-doctor i { color: #d60001; font-size: .8rem; }
.pp-appt-time {
  font-size: .78rem;
  color: #64748b;
  margin-top: .2rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.pp-appt-reason {
  font-size: .75rem;
  color: #94a3b8;
  margin-top: .15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp-appt-status {
  font-size: .7rem;
  font-weight: 600;
  padding: .3rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Invoice items ── */
.pp-invoice-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 0;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
}
.pp-invoice-item:last-child { border-bottom: none; }
.pp-invoice-item:hover { background: #f8fafc; margin: 0 -.5rem; padding: .65rem .5rem; border-radius: 8px; }
.pp-invoice-num {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: #64748b;
  min-width: 110px;
}
.pp-invoice-num i { color: #d60001; }
.pp-invoice-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pp-invoice-date { font-size: .75rem; color: #94a3b8; }
.pp-invoice-total { font-size: .875rem; font-weight: 600; color: #1e293b; }
.pp-invoice-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .25rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Prescription badge ── */
.pp-pres-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: .22rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Expanded prescription card (my_prescriptions.php) ── */
.pp-pres-exp-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: .9rem 1rem;
  margin-bottom: .75rem;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.pp-pres-exp-head {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  margin-bottom: .5rem;
}
.pp-pres-exp-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 9px;
  background: #f0fdf4;
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  flex-shrink: 0;
}
.pp-pres-exp-num  { font-size: .82rem; font-weight: 700; color: #374151; }
.pp-pres-exp-dr   { font-size: .8rem; color: #64748b; margin-top: .08rem; }
.pp-pres-exp-meta {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  font-size: .73rem;
  color: #94a3b8;
  margin-bottom: .6rem;
}
.pp-pres-exp-meta i { margin-right: .2rem; }
.pp-pres-exp-drugs {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 9px;
  padding: .55rem .75rem;
  margin-bottom: .55rem;
}
.pp-pres-exp-drugs-title {
  font-size: .7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .4rem;
}
.pp-pres-exp-drugs-title i { color: #d60001; margin-right: .3rem; }
.pp-pres-exp-drug-row {
  padding: .3rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.pp-pres-exp-drug-row:last-child { border-bottom: none; }
.pp-pres-exp-drug-name { font-size: .82rem; font-weight: 700; color: #1e293b; margin-bottom: .12rem; }
.pp-pres-exp-drug-info {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .6rem;
  font-size: .72rem;
  color: #64748b;
}
.pp-pres-exp-drug-info span {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: .05rem .3rem;
}
.pp-pres-exp-drug-instr { font-size: .72rem; color: #94a3b8; font-style: italic; margin-top: .15rem; }
.pp-pres-exp-notes {
  font-size: .75rem;
  color: #64748b;
  padding: .45rem .6rem;
  background: #fffbeb;
  border-radius: 7px;
  border: 1px solid #fde68a;
  margin-bottom: .55rem;
}
.pp-pres-exp-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.pp-pres-exp-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
  padding: .38rem .85rem;
  border-radius: 8px;
  text-decoration: none;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: background .15s;
}
.pp-pres-exp-btn.primary { background: #d60001; color: #fff; border-color: #d60001; }
.pp-pres-exp-btn.primary:hover { background: #b50001; }

/* ── Prescription cards ── */
.pp-pres-card {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .65rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.pp-pres-card:last-child { border-bottom: none; }
.pp-pres-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 8px;
  background: #f0fdf4;
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
}
.pp-pres-doctor { font-size: .875rem; font-weight: 600; color: #1e293b; }
.pp-pres-date   { font-size: .75rem; color: #94a3b8; margin-top: .1rem; }
.pp-pres-notes  { font-size: .78rem; color: #64748b; margin-top: .15rem; }

/* ── Bottom navigation ── */
.pp-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  z-index: 200;
}
.pp-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  flex: 1;
  text-decoration: none;
  color: #94a3b8;
  font-size: .65rem;
  font-weight: 500;
  padding: .4rem 0;
  transition: color .15s;
}
.pp-nav-item i { font-size: 1.2rem; }
.pp-nav-item:hover { color: #d60001; }
.pp-nav-item.active { color: #d60001; }
.pp-nav-item.active i { position: relative; }
.pp-nav-item.active i::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: #d60001;
  border-radius: 50%;
}

/* ── Responsive 375px ── */
@media (max-width: 400px) {
  .pp-main { padding: .75rem; padding-bottom: 80px; }
  .pp-greeting { padding: 1rem; }
  .pp-greeting-text h2 { font-size: 1rem; }
  .pp-stat-card { padding: .75rem; }
  .pp-stat-value { font-size: 1.3rem; }
  .pp-header-username { display: none; }
}

/* ============================================================
   SERVICES & TARIFS
   ============================================================ */

/* Stats row */
.svc-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.svc-stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.svc-stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.svc-stat-body { display: flex; flex-direction: column; }
.svc-stat-value { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.svc-stat-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; margin-top: .2rem; }

/* Main layout */
.svc-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* Category panel */
.svc-cat-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}
.svc-cat-panel-header {
  padding: .85rem 1.1rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.svc-cat-item-wrap { position: relative; }
.svc-cat-item-wrap:hover .svc-cat-actions { opacity: 1; }
.svc-cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1.1rem;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--text-primary);
  font-size: .84rem;
  transition: background .15s;
  cursor: pointer;
}
.svc-cat-item:hover  { background: var(--primary-bg); color: var(--primary); }
.svc-cat-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.svc-cat-item-left   { display: flex; align-items: center; gap: .6rem; }
.svc-cat-dot         { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.svc-cat-name        { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.svc-cat-badge {
  font-size: .68rem; font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 20px;
  background: #f0f2f5;
  color: var(--text-muted);
  flex-shrink: 0;
}
.svc-cat-actions {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  display: flex; gap: .25rem;
  opacity: 0; transition: opacity .15s;
  background: var(--white);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  padding: .2rem .3rem;
}
.svc-cat-btn {
  width: 24px; height: 24px;
  border: none; background: none; cursor: pointer;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}
.svc-cat-btn:hover        { background: #f0f2f5; color: var(--text-primary); }
.svc-cat-btn.danger:hover { background: #fee2e2; color: #dc2626; }
.svc-cat-panel-footer {
  padding: .85rem 1rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

/* Content area */
.svc-content { display: flex; flex-direction: column; gap: 1.25rem; }

/* Search bar */
.svc-search-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  display: flex;
  gap: .75rem;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.svc-search-input {
  position: relative;
  flex: 1;
}
.svc-search-input i {
  position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .85rem;
}
.svc-search-input input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .9rem .55rem 2.4rem;
  font-size: .85rem;
  font-family: var(--font);
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.svc-search-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(214,0,1,.1);
  background: var(--white);
}

/* Group header */
.svc-group { display: flex; flex-direction: column; gap: .85rem; }
.svc-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 2px solid var(--border);
}
.svc-group-title {
  display: flex; align-items: center; gap: .6rem;
  font-size: .95rem; font-weight: 700; color: var(--text-primary);
}
.svc-group-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.svc-group-count {
  font-size: .75rem; color: var(--text-muted);
  background: var(--bg);
  padding: .2rem .65rem;
  border-radius: 20px;
  font-weight: 600;
}

/* Service cards grid */
.svc-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.svc-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s, border-color .2s;
  position: relative;
  overflow: hidden;
}
.svc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  opacity: 0;
  transition: opacity .2s;
}
.svc-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: rgba(214,0,1,.2); }
.svc-card:hover::before { opacity: 1; }
.svc-card-inactive { opacity: .55; }
.svc-card-inactive:hover { opacity: .75; }

.svc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.svc-card-code {
  font-family: 'Courier New', monospace;
  font-size: .7rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--text-muted);
  padding: .2rem .5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  letter-spacing: .04em;
}
.svc-card-status {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .2rem .55rem;
  border-radius: 20px;
}
.svc-card-status.active   { background: #dcfce7; color: #166534; }
.svc-card-status.inactive { background: #f3f4f6; color: #6b7280; }

.svc-card-body { flex: 1; }
.svc-card-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .35rem;
  line-height: 1.3;
}
.svc-card-desc {
  font-size: .77rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.svc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: .75rem;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}
.svc-card-price {
  display: flex;
  align-items: baseline;
  gap: .25rem;
}
.svc-price-currency {
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary);
}
.svc-price-amount {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.svc-card-actions { display: flex; gap: .35rem; }
.svc-action-btn {
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all .15s;
}
.svc-action-btn.edit:hover   { background: #eff6ff; border-color: #93c5fd; color: #3b82f6; }
.svc-action-btn.delete:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* Empty state */
.svc-empty {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.svc-empty-icon {
  font-size: 3.5rem;
  color: var(--border);
  margin-bottom: 1rem;
}
.svc-empty h3  { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: .5rem; }
.svc-empty p   { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.25rem; }

/* Responsive */
@media (max-width: 1200px) {
  .svc-stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .svc-layout { grid-template-columns: 1fr; }
  .svc-cat-panel { position: static; }
  .svc-cards-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 600px) {
  .svc-stats-row { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .svc-cards-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .svc-card { padding: .85rem; }
  .svc-price-amount { font-size: 1.1rem; }
}

/* ============================================================
   PATIENT PORTAL — MOBILE HEADER & MODULE PAGES
   ============================================================ */

/* Patient header brand logo */
.patient-hdr-brand {
  display: none;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .2px;
}
.patient-hdr-brand strong { color: var(--primary); }

/* Patient logout button in header */
.patient-logout-hdr {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.patient-logout-hdr:hover { background: #fee2e2; color: #d60001; }

@media (max-width: 767px) {
  /* Show patient brand logo, hide page title */
  .patient-app-wrapper .patient-hdr-brand { display: flex; }
  .patient-app-wrapper .patient-page-title { display: none; }
  /* Hide search bar entirely for patient */
  .patient-app-wrapper .header-center { display: none !important; }
  /* Hide date/time */
  .patient-app-wrapper .header-datetime { display: none; }
  /* Compact header padding */
  .patient-app-wrapper .top-header { padding: .5rem .875rem; }
  /* Hide profile name & chevron in header for patient */
  .patient-app-wrapper .user-name-header { display: none; }
  /* Header actions gap */
  .patient-app-wrapper .header-actions { gap: .2rem; }
  /* Show patient module cards, hide admin table */
  .patient-app-wrapper .patient-table-section { display: none; }
  .patient-app-wrapper .patient-cards-section { display: block; }
  /* Profile page: single column */
  .patient-app-wrapper .profile-grid-2col { grid-template-columns: 1fr !important; }

  /* ── Notification dropdown: full-width panel on mobile ── */
  .notif-dropdown { position: static; }
  .notif-menu {
    position: fixed !important;
    top: var(--header-h) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 0 0 14px 14px !important;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,.18) !important;
  }
  .notif-list { max-height: calc(80vh - 100px); }
  /* Badge dot always visible */
  .badge-dot { z-index: 10; }
  /* Ensure header-actions always shows */
  .header-actions { flex-shrink: 0 !important; }
  .header-btn { flex-shrink: 0; }
}

/* Patient module cards: hidden on desktop, shown on patient mobile */
.patient-cards-section { display: none; }
.patient-table-section { display: block; }

/* ── Patient appointment cards ── */
.pt-apt-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: .875rem 1rem;
  margin-bottom: .65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.pt-apt-card-top {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .55rem;
}
.pt-apt-date-bdg {
  background: #d60001;
  color: #fff;
  border-radius: 8px;
  width: 46px;
  min-width: 46px;
  text-align: center;
  padding: .3rem .25rem;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  flex-shrink: 0;
}
.pt-apt-day   { font-size: 1.3rem; font-weight: 800; }
.pt-apt-month { font-size: .6rem; font-weight: 600; text-transform: uppercase; }
.pt-apt-info  { flex: 1; min-width: 0; }
.pt-apt-doctor { font-size: .875rem; font-weight: 700; color: #1e293b; }
.pt-apt-doctor i { color: #d60001; font-size: .78rem; margin-right: .25rem; }
.pt-apt-time   { font-size: .78rem; color: #64748b; margin-top: .12rem; }
.pt-apt-time   i { margin-right: .2rem; }
.pt-apt-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.pt-apt-reason {
  font-size: .75rem;
  color: #94a3b8;
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-apt-card-actions { display: flex; gap: .35rem; align-items: center; flex-shrink: 0; }

/* ── Patient invoice cards ── */
.pt-inv-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: .875rem 1rem;
  margin-bottom: .65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.pt-inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .45rem;
}
.pt-inv-num  { font-size: .85rem; font-weight: 700; color: #1e293b; }
.pt-inv-num  i { color: #d60001; margin-right: .3rem; }
.pt-inv-date { font-size: .72rem; color: #94a3b8; }
.pt-inv-amounts {
  display: flex;
  gap: 0;
  margin-bottom: .5rem;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  overflow: hidden;
}
.pt-inv-amt-col {
  flex: 1;
  padding: .45rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .05rem;
  border-right: 1px solid #f1f5f9;
}
.pt-inv-amt-col:last-child { border-right: none; }
.pt-inv-amt-label { font-size: .65rem; color: #94a3b8; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.pt-inv-amt-val   { font-size: .82rem; font-weight: 700; color: #1e293b; }
.pt-inv-amt-col.danger  .pt-inv-amt-val { color: #dc2626; }
.pt-inv-amt-col.success .pt-inv-amt-val { color: #16a34a; }
.pt-inv-footer { display: flex; align-items: center; justify-content: space-between; }

/* ── pt-inv-card new layout helpers ── */
.pt-inv-left  { flex: 1; min-width: 0; }
.pt-inv-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .18rem;
  flex-shrink: 0;
  padding-left: .5rem;
}
.pt-inv-total { font-size: .9rem; font-weight: 800; color: #1e293b; }
.pt-inv-items-preview {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: .4rem .6rem;
  margin-bottom: .35rem;
}
.pt-inv-item-row {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .12rem 0;
  font-size: .75rem;
}
.pt-inv-item-name {
  flex: 1;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-inv-item-price { color: #1e293b; font-weight: 600; flex-shrink: 0; }

/* Tap feedback & expanded for invoice cards */
.pt-inv-card { cursor: pointer; transition: box-shadow .18s, border-color .18s; }
.pt-inv-card:active { box-shadow: 0 2px 12px rgba(214,0,1,.12); border-color: #f5b8b8; }
.pt-inv-card.expanded { border-color: #fecaca; box-shadow: 0 2px 14px rgba(214,0,1,.10); }
.pt-inv-card.expanded .pt-card-toggle { transform: rotate(180deg); color: var(--primary); }

/* ── Patient prescription cards ── */
.pt-pres-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: .875rem 1rem;
  margin-bottom: .65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.pt-pres-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .4rem;
}
.pt-pres-num    { font-size: .78rem; font-weight: 700; color: #64748b; }
.pt-pres-num code { background: #f1f5f9; padding: .1rem .3rem; border-radius: 4px; font-size: .75rem; color: #374151; }
.pt-pres-doctor { font-size: .82rem; font-weight: 600; color: #1e293b; margin-bottom: .08rem; }
.pt-pres-meta   {
  display: flex;
  gap: .6rem;
  font-size: .72rem;
  color: #94a3b8;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}
.pt-pres-meta i { margin-right: .2rem; }
.pt-pres-drugs {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: .5rem .7rem;
  margin-bottom: .5rem;
}
.pt-pres-drug-item {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  padding: .22rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: .78rem;
}
.pt-pres-drug-item:last-child { border-bottom: none; }
.pt-pres-drug-name   { font-weight: 600; color: #1e293b; flex-shrink: 0; }
.pt-pres-drug-detail { color: #94a3b8; font-size: .7rem; }
.pt-pres-drug-more   { font-size: .73rem; color: #64748b; font-style: italic; padding-top: .2rem; }
.pt-pres-footer { display: flex; align-items: center; justify-content: space-between; }

/* ── Expandable card details (patient mobile) ── */
.pt-card-details {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .32s ease, opacity .25s ease, padding .25s ease;
  padding-top: 0;
}
.pt-card-details.open {
  max-height: 600px;
  opacity: 1;
  padding-top: .65rem;
}
.pt-card-toggle {
  transition: transform .25s;
  color: #94a3b8;
  font-size: .8rem;
  padding: .1rem .2rem;
  flex-shrink: 0;
}
.pt-apt-card.expanded .pt-card-toggle,
.pt-pres-card.expanded .pt-card-toggle { transform: rotate(180deg); color: var(--primary); }
.pt-card-hr {
  border: none;
  border-top: 1px dashed #e2e8f0;
  margin: 0 0 .55rem;
}
.pt-card-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  padding: .25rem 0;
  font-size: .78rem;
  border-bottom: 1px solid #f8fafc;
}
.pt-card-detail-row:last-child { border-bottom: none; }
.pt-card-detail-row .lbl { color: #94a3b8; flex-shrink: 0; font-size: .71rem; }
.pt-card-detail-row .val { color: #1e293b; font-weight: 500; text-align: right; word-break: break-word; }
.pt-card-detail-actions { display: flex; gap: .4rem; flex-wrap: wrap; padding-top: .55rem; }
/* Tap feedback */
.pt-apt-card, .pt-pres-card { cursor: pointer; transition: box-shadow .18s, border-color .18s; }
.pt-apt-card:active, .pt-pres-card:active { box-shadow: 0 2px 12px rgba(214,0,1,.12); border-color: #f5b8b8; }
.pt-apt-card.expanded, .pt-pres-card.expanded { border-color: #fecaca; box-shadow: 0 2px 14px rgba(214,0,1,.10); }

/* ── Shared mobile action buttons ── */
.btn-mob {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .75rem;
  font-weight: 600;
  padding: .32rem .7rem;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn-mob:hover { background: #e2e8f0; color: #1e293b; }
.btn-mob.primary { background: #d60001; color: #fff; border-color: #d60001; }
.btn-mob.primary:hover { background: #b50001; color: #fff; }
.btn-mob i { font-size: .68rem; }

/* ── Profile page improvements ── */
.profile-photo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.profile-photo-wrap img,
.profile-photo-wrap .profile-initials-avatar {
  display: block;
  margin: 0 auto;
}
.profile-initials-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
}

@media (max-width: 767px) {
  .profile-grid-2col { grid-template-columns: 1fr !important; }
}

/* ============================================================
   CREDENTIALS SCREEN — after patient creation
   ============================================================ */
.cred-screen {
  max-width: 500px;
  margin: 1.5rem auto;
  text-align: center;
  padding: 1rem;
}
.cred-check-icon {
  font-size: 3.5rem;
  color: #16a34a;
  margin-bottom: .75rem;
  animation: credPop .4s ease;
}
@keyframes credPop {
  0%  { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.15); }
  100%{ transform: scale(1);   opacity: 1; }
}
.cred-title    { font-size: 1.3rem; font-weight: 700; color: #1e293b; margin-bottom: .35rem; }
.cred-subtitle { font-size: .88rem; color: #64748b; margin-bottom: 1.5rem; }
.cred-box {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  text-align: left;
  box-shadow: 0 2px 16px rgba(0,0,0,.07);
}
.cred-box-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #f8fafc;
  padding: .7rem 1.1rem;
  font-size: .82rem;
  font-weight: 700;
  color: #374151;
  border-bottom: 1px solid #e2e8f0;
}
.cred-box-header i { color: #d60001; }
.cred-box-body {
  padding: .85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.cred-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .75rem;
  background: #f8fafc;
  border-radius: 9px;
  border: 1px solid transparent;
}
.cred-row-code {
  background: #fff8f8;
  border-color: #fecaca;
}
.cred-lbl {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .74rem;
  color: #64748b;
  flex-shrink: 0;
  min-width: 115px;
}
.cred-lbl i { color: #94a3b8; font-size: .75rem; }
.cred-val {
  flex: 1;
  font-size: .9rem;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: .02em;
  word-break: break-all;
}
.cred-val-code {
  font-family: 'Courier New', monospace;
  font-size: 1.05rem;
  font-weight: 800;
  color: #d60001;
  letter-spacing: .12em;
}
.cred-copy-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: .3rem .5rem;
  cursor: pointer;
  color: #64748b;
  font-size: .75rem;
  transition: all .15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.cred-copy-btn:hover { background: #e2e8f0; color: #374151; }
.cred-box-note {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  padding: .75rem 1.1rem;
  font-size: .76rem;
  color: #92400e;
  line-height: 1.5;
}
.cred-box-note i { color: #d97706; flex-shrink: 0; margin-top: .1rem; }
.cred-actions {
  display: flex;
  gap: .65rem;
  justify-content: center;
  flex-wrap: wrap;
}
@media (max-width: 767px) {
  .cred-screen { padding: .5rem; margin: .75rem auto; }
  .cred-title { font-size: 1.1rem; }
  .cred-val-code { font-size: .95rem; letter-spacing: .08em; }
  .cred-lbl { min-width: 95px; }
  .cred-actions { flex-direction: column; }
  .cred-actions .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   PRESCRIPTION / BILLING FORM ROWS — scroll on small screens
   ============================================================ */
#medsContainer, #itemsContainer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 1025px) {
  #medsContainer, #itemsContainer { overflow-x: visible; }
  .invoice-row, .med-row { min-width: 0; }
}
@media (max-width: 1024px) {
  .invoice-row, .med-row { min-width: 640px; }
}

/* ============================================================
   DASHBOARD STAT CARD — prevent label overflow
   ============================================================ */
.stat-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1200px) {
  .stat-label { font-size: .72rem; }
}
@media (max-width: 1024px) {
  .stat-label { font-size: .68rem; white-space: normal; }
}

/* ============================================================
   PATIENT PORTAL — Complete Mobile Responsive
   ============================================================ */

/* ── Base patient portal layout ── */
.patient-portal-body { background: #f8fafc; }
.pp-main { padding: 1rem; padding-bottom: 80px; min-height: 100vh; max-width: 700px; margin: 0 auto; }

/* ── Header ── */
.pp-header {
  position: sticky; top: 0; z-index: 100;
  background: #fff; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; height: 54px;
}
.pp-header-brand { display: flex; align-items: center; gap: .5rem; }
.pp-brand-name { font-size: 1rem; font-weight: 700; color: #1e293b; }
.pp-header-right { display: flex; align-items: center; gap: .5rem; }
.pp-header-avatar, .pp-header-avatar-default {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
}
.pp-header-avatar-default {
  background: #d60001; color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pp-logout-btn {
  width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9;
  color: #64748b; display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: .9rem; transition: background .15s;
}
.pp-logout-btn:hover { background: #fee2e2; color: #d60001; }

/* ── Stats row ── */
.pp-stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; margin-bottom: 1rem; }
.pp-stat-card {
  background: #fff; border-radius: 12px; padding: .85rem;
  display: flex; align-items: center; gap: .65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ── Bottom nav ── */
.pp-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: #fff; border-top: 1px solid #e2e8f0;
  display: flex; align-items: stretch;
  height: 60px; padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.pp-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .15rem; padding: .4rem .25rem;
  text-decoration: none; color: #94a3b8; font-size: .6rem;
  font-weight: 500; transition: color .15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.pp-nav-item span:first-child { font-size: 1.15rem; line-height: 1; }
.pp-nav-item.active, .pp-nav-item:active { color: #d60001; }
.pp-nav-item.active .pp-nav-icon-wrap { position: relative; }

/* ── Appointment cards (mobile) ── */
.pt-apt-card {
  background: #fff; border-radius: 12px; padding: .85rem 1rem;
  margin-bottom: .6rem; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pt-apt-card-top { display: flex; align-items: center; gap: .75rem; }
.pt-apt-date-bdg {
  min-width: 44px; width: 44px; background: #fff1f1; border: 1px solid #fecaca;
  border-radius: 10px; text-align: center; padding: .3rem; flex-shrink: 0;
}
.pt-apt-day   { display: block; font-size: 1.1rem; font-weight: 800; color: #d60001; line-height: 1; }
.pt-apt-month { display: block; font-size: .58rem; text-transform: uppercase; color: #d60001; font-weight: 600; letter-spacing: .04em; }
.pt-apt-info  { flex: 1; min-width: 0; }
.pt-apt-doctor { font-size: .82rem; font-weight: 600; color: #1e293b; display: flex; align-items: center; gap: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-apt-time   { font-size: .74rem; color: #64748b; margin-top: .12rem; display: flex; align-items: center; gap: .25rem; }
.pt-apt-reason { font-size: .72rem; color: #94a3b8; margin-top: .3rem; }
.pt-card-toggle { font-size: .75rem; color: #94a3b8; transition: transform .2s; flex-shrink: 0; }
.pt-apt-card.expanded .pt-card-toggle { transform: rotate(180deg); }
.pt-card-details { display: none; overflow: hidden; }
.pt-card-details.open { display: block; animation: fadeSlideDown .2s ease; }
@keyframes fadeSlideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.pt-card-hr { border: none; border-top: 1px solid #f1f5f9; margin: .65rem 0; }
.pt-card-detail-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .35rem; font-size: .78rem; }
.pt-card-detail-row .lbl { color: #94a3b8; flex-shrink: 0; }
.pt-card-detail-row .val { color: #1e293b; font-weight: 500; text-align: right; }
.pt-card-detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .65rem; }
.btn-mob {
  display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem;
  border-radius: 20px; font-size: .78rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid #e2e8f0; background: #fff; color: #475569;
  text-decoration: none; transition: all .15s; -webkit-tap-highlight-color: transparent;
  min-height: 36px;
}
.btn-mob.primary { background: #d60001; color: #fff; border-color: #d60001; }
.btn-mob.primary:hover { background: #b50001; }

/* ── Prescription cards (mobile) ── */
.pt-pres-card {
  background: #fff; border-radius: 12px; padding: .85rem 1rem;
  margin-bottom: .6rem; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pt-pres-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.pt-pres-num  { font-size: .78rem; font-weight: 700; color: #1e293b; font-family: monospace; }
.pt-pres-doctor { font-size: .76rem; color: #64748b; margin-top: .1rem; }
.pt-pres-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; font-size: .72rem; color: #64748b; }
.pt-pres-meta span { display: flex; align-items: center; gap: .2rem; }

/* ── Invoice cards (mobile) ── */
.pt-inv-card {
  background: #fff; border-radius: 12px; padding: .85rem 1rem;
  margin-bottom: .6rem; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pt-inv-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.pt-inv-left   { min-width: 0; }
.pt-inv-right  { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex-shrink: 0; }
.pt-inv-num    { font-size: .78rem; font-weight: 700; color: #1e293b; font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-inv-date   { font-size: .7rem; color: #94a3b8; margin-top: .1rem; }
.pt-inv-total  { font-size: .82rem; font-weight: 700; color: #1e293b; }

/* ── Carousel (flyers) ── */
.fc-outer { position: relative; margin-bottom: 1rem; border-radius: 14px; overflow: hidden; background: #000; }
.fc-stage { position: relative; height: 180px; }
.fc-slide { position: absolute; inset: 0; transition: transform .4s ease, opacity .4s ease; }
.fc-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fc-caption {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #fff; padding: .75rem .85rem .5rem; font-size: .82rem; font-weight: 600;
}
.fc-active  { transform: translateX(0); opacity: 1; z-index: 2; }
.fc-next    { transform: translateX(100%); opacity: 0; z-index: 1; }
.fc-prev    { transform: translateX(-100%); opacity: 0; z-index: 1; }
.fc-hidden  { transform: translateX(100%); opacity: 0; z-index: 0; }
.fc-dots { position: absolute; bottom: .5rem; left: 50%; transform: translateX(-50%); display: flex; gap: .35rem; z-index: 3; }
.fc-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); border: none; cursor: pointer; padding: 0; transition: background .2s; }
.fc-dot.active { background: #fff; width: 18px; border-radius: 4px; }

/* ── Section headers (mobile) ── */
.pt-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 1rem 0 .5rem;
}
.pt-section-title { font-size: .88rem; font-weight: 700; color: #1e293b; display: flex; align-items: center; gap: .35rem; }
.pt-section-title i { color: #d60001; }
.pt-see-all { font-size: .75rem; color: #d60001; font-weight: 600; text-decoration: none; }

/* ── Safe area / notch support ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .pp-bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(60px + env(safe-area-inset-bottom)); }
  .pp-main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* ── Small phones (≤ 375px) ── */
@media (max-width: 375px) {
  .pp-main { padding: .75rem; }
  .pp-stat-card { padding: .65rem .6rem; }
  .pp-stat-value { font-size: 1.25rem; }
  .pp-stat-label { font-size: .65rem; }
  .pp-stat-icon  { width: 38px; height: 38px; font-size: .95rem; }
  .pp-nav-item span:first-child { font-size: 1.05rem; }
  .pp-nav-item { font-size: .55rem; }
  .fc-stage { height: 155px; }
  .pt-apt-day { font-size: 1rem; }
}

/* ── Medium phones (376px – 480px) ── */
@media (min-width: 376px) and (max-width: 480px) {
  .fc-stage { height: 170px; }
}

/* ── Tablets (600px – 1024px) ── */
@media (min-width: 600px) and (max-width: 1024px) {
  .pp-main { padding: 1.25rem; max-width: 780px; }
  .pp-stats-row { grid-template-columns: repeat(4, 1fr); }
  .fc-stage { height: 230px; }
  .pp-header { padding: .85rem 1.25rem; height: 60px; }
  .pp-brand-name { font-size: 1.1rem; }
  .pt-apt-card, .pt-pres-card, .pt-inv-card { padding: 1rem 1.25rem; }
}

/* ── Large tablets / small desktop (≥ 1025px) ── */
@media (min-width: 1025px) {
  .pp-stats-row { grid-template-columns: repeat(4, 1fr); }
  .pp-main { max-width: 900px; padding: 1.5rem; }
  .fc-stage { height: 260px; }
  .pp-bottom-nav { display: none; } /* hide on desktop — use sidebar nav */
}

/* ── Touch targets (all mobile) ── */
@media (max-width: 1024px) {
  .btn-mob, .pp-nav-item, .pp-logout-btn { min-height: 44px; }
  a, button { -webkit-tap-highlight-color: rgba(214,0,1,.08); }
}

/* ── Prescriptions page (my_prescriptions.php) ── */
.pp-pres-exp-card {
  background: #fff; border-radius: 12px; padding: .9rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.pp-pres-exp-head {
  display: flex; align-items: flex-start; gap: .65rem;
}
.pp-pres-exp-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: #fff1f1; color: #d60001; display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.pp-pres-exp-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; font-size: .75rem; color: #64748b; }
.pp-pres-exp-meta span { display: flex; align-items: center; gap: .25rem; }
.pp-pres-exp-meta i { font-size: .7rem; }
.pp-pres-badge { display: inline-flex; padding: .2rem .6rem; border-radius: 20px; font-size: .7rem; font-weight: 700; }
