/* ============================================================
   MEDICORE PMS — Complete Stylesheet
   Design: Clinical Precision + Modern SaaS
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-fade: #dbeafe;
  --secondary: #0ea5e9;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;

  /* Light Mode */
  --bg: #f1f5f9;
  --bg2: #ffffff;
  --bg3: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: #2563eb;
  --sidebar-active-text: #ffffff;
  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --border: #e2e8f0;
  --border2: #cbd5e1;
  --card-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,.1);
  --input-bg: #f8fafc;
  --input-border: #e2e8f0;
  --input-focus: #2563eb;
  --table-stripe: #f8fafc;
  --modal-overlay: rgba(15,23,42,.5);
  --topbar-bg: #ffffff;
  --topbar-border: #e2e8f0;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --font: 'Inter', sans-serif;
}

.dark-mode {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #0f172a;
  --sidebar-bg: #020617;
  --sidebar-hover: #0f172a;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #475569;
  --border: #1e293b;
  --border2: #334155;
  --card-shadow: 0 1px 3px rgba(0,0,0,.4);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,.5);
  --input-bg: #0f172a;
  --input-border: #334155;
  --table-stripe: #1e293b;
  --modal-overlay: rgba(0,0,0,.7);
  --topbar-bg: #1e293b;
  --topbar-border: #334155;
  --primary-fade: #1e3a8a30;
}

/* ============================================================ RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); transition: background var(--transition), color var(--transition); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); outline: none; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; }

/* ============================================================ SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ============================================================ LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}
.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-bg-shape {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,.3), transparent);
}
.login-bg-shape.s1 { width: 600px; height: 600px; top: -200px; left: -100px; }
.login-bg-shape.s2 { width: 400px; height: 400px; bottom: -100px; right: 100px; background: radial-gradient(circle, rgba(6,182,212,.2), transparent); }
.login-bg-shape.s3 { width: 300px; height: 300px; top: 50%; left: 60%; background: radial-gradient(circle, rgba(99,102,241,.2), transparent); }

.login-card {
  background: rgba(255,255,255,.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 24px;
  padding: 48px 40px;
  width: 420px;
  max-width: calc(100vw - 32px);
  position: relative;
  z-index: 1;
  box-shadow: 0 25px 50px rgba(0,0,0,.5);
}
.login-brand { text-align: center; margin-bottom: 36px; }
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px; color: white;
  box-shadow: 0 8px 24px rgba(37,99,235,.4);
}
.login-brand h1 { color: white; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.login-brand p { color: rgba(255,255,255,.5); font-size: 14px; margin-top: 4px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; color: rgba(255,255,255,.7); font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.input-icon { position: relative; }
.input-icon > i:first-child {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,.3); font-size: 15px; pointer-events: none;
}
.input-icon input {
  width: 100%; padding: 12px 16px 12px 44px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  color: white; font-size: 15px;
  transition: all var(--transition);
}
.input-icon input::placeholder { color: rgba(255,255,255,.3); }
.input-icon input:focus { background: rgba(255,255,255,.12); border-color: rgba(37,99,235,.7); box-shadow: 0 0 0 3px rgba(37,99,235,.2); }
.pw-toggle {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  background: none; color: rgba(255,255,255,.3);
  transition: color var(--transition);
}
.pw-toggle:hover { color: rgba(255,255,255,.7); }

.login-error {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.btn-login {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: white; font-size: 15px; font-weight: 600;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--transition);
  box-shadow: 0 4px 15px rgba(37,99,235,.4);
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 25px rgba(37,99,235,.5); }
.btn-login:active { transform: translateY(0); }
.login-note { text-align: center; color: rgba(255,255,255,.3); font-size: 12px; margin-top: 20px; }

/* ============================================================ APP LAYOUT */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 260px; min-width: 260px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  transition: transform var(--transition), width var(--transition);
  position: relative; z-index: 100;
  border-right: 1px solid rgba(255,255,255,.05);
}
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* SIDEBAR HEADER */
.sidebar-header {
  padding: 20px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
}
.brand-name { color: white; font-weight: 700; font-size: 17px; display: block; line-height: 1; }
.brand-sub { color: rgba(255,255,255,.3); font-size: 10px; display: block; margin-top: 2px; }
.sidebar-close { display: none; background: none; color: rgba(255,255,255,.4); font-size: 16px; }

/* SIDEBAR USER */
.sidebar-user {
  padding: 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.user-avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.user-info { min-width: 0; }
.user-name { color: white; font-size: 13px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-role {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  background: rgba(37,99,235,.3); color: #93c5fd;
  display: inline-block; margin-top: 2px;
}

/* SIDEBAR NAV */
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-section { padding: 8px 0; }
.nav-section-title {
  padding: 6px 16px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: rgba(255,255,255,.2); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 14px; font-weight: 500;
  border-radius: 8px;
  margin: 1px 8px;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--sidebar-active-bg); color: white; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
  display: none;
}
.nav-badge.today { background: var(--success); }
.nav-badge:not(:empty) { display: block; }

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 6px;
}
.theme-toggle, .btn-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  transition: all var(--transition);
  width: 100%;
}
.theme-toggle { background: rgba(255,255,255,.05); color: rgba(255,255,255,.6); }
.theme-toggle:hover { background: rgba(255,255,255,.1); color: white; }
.btn-logout { background: rgba(239,68,68,.1); color: #f87171; }
.btn-logout:hover { background: rgba(239,68,68,.2); }

/* ============================================================ TOPBAR */
.topbar {
  height: 60px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  transition: background var(--transition);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
  background: none; color: var(--text2); font-size: 18px;
  padding: 6px; border-radius: 6px;
  transition: all var(--transition);
  display: none;
}
.menu-toggle:hover { background: var(--bg); color: var(--text); }
.breadcrumb { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.topbar-date { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--text2); font-size: 13px; font-weight: 500; }

/* ============================================================ PAGE CONTENT */
.page-content {
  flex: 1; overflow-y: auto;
  padding: 24px;
  background: var(--bg);
  transition: background var(--transition);
}

/* ============================================================ CARDS */
.card {
  background: var(--bg2);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), background var(--transition);
  overflow: hidden;
}
.card:hover { box-shadow: var(--card-shadow-hover); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 16px;
  transition: all var(--transition);
  cursor: pointer;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #10b981; }
.stat-icon.orange { background: #fef3c7; color: #f59e0b; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red { background: #fee2e2; color: #ef4444; }
.stat-icon.teal { background: #cffafe; color: #06b6d4; }
.dark-mode .stat-icon.blue { background: #1e3a8a30; color: #60a5fa; }
.dark-mode .stat-icon.green { background: #06402430; color: #34d399; }
.dark-mode .stat-icon.orange { background: #78350f30; color: #fbbf24; }
.dark-mode .stat-icon.purple { background: #4c1d9530; color: #a78bfa; }
.dark-mode .stat-icon.red { background: #7f1d1d30; color: #f87171; }
.dark-mode .stat-icon.teal { background: #16434630; color: #22d3ee; }
.stat-info { min-width: 0; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* ============================================================ CHARTS */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.chart-card { background: var(--bg2); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.chart-header { padding: 16px 20px 0; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--text); }
.chart-body { padding: 16px; }
canvas { max-height: 220px !important; }

/* ============================================================ FORMS */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text2); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: all var(--transition);
  width: 100%;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: var(--bg2); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================ BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: var(--bg); color: var(--text2); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-fade); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================ TABLE */
.table-wrapper { overflow-x: auto; }
.table-actions { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  flex: 1; max-width: 320px;
}
.search-box i { color: var(--text3); font-size: 13px; }
.search-box input { background: none; border: none; color: var(--text); font-size: 14px; flex: 1; min-width: 0; }
.search-box input::placeholder { color: var(--text3); }
.data-table { width: 100%; }
.data-table thead th {
  padding: 12px 16px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text2);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--table-stripe); }
.data-table tbody td { padding: 12px 16px; font-size: 13px; color: var(--text); vertical-align: middle; }

/* ============================================================ BADGES */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-gray { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.badge-primary { background: #dbeafe; color: #1e40af; }
.dark-mode .badge-success { background: #06402430; color: #6ee7b7; }
.dark-mode .badge-warning { background: #78350f30; color: #fcd34d; }
.dark-mode .badge-danger { background: #7f1d1d30; color: #fca5a5; }
.dark-mode .badge-info { background: #3730a330; color: #a5b4fc; }
.dark-mode .badge-primary { background: #1e3a8a30; color: #93c5fd; }

/* ============================================================ MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--modal-overlay);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--bg2);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.modal-box.lg { max-width: 860px; }
.modal-box.sm { max-width: 440px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close { background: var(--bg3); color: var(--text2); width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all var(--transition); }
.modal-close:hover { background: var(--danger); color: white; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

/* ============================================================ TOAST */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  min-width: 280px; max-width: 360px;
  animation: toastIn .3s ease;
  font-size: 13px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }
.toast i { font-size: 16px; flex-shrink: 0; }
.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }
.toast-warning i { color: var(--warning); }
.toast-info i { color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ============================================================ LOADING */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ PAGE HEADER */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ============================================================ PATIENT PROFILE */
.profile-header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  color: white;
  display: flex; align-items: center; gap: 20px;
}
.profile-avatar {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  border: 3px solid rgba(255,255,255,.3);
  flex-shrink: 0;
}
.profile-info h2 { font-size: 22px; font-weight: 700; }
.profile-info p { opacity: .8; font-size: 14px; margin-top: 4px; }
.profile-tags { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.profile-tag {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px; font-weight: 500;
}

/* ============================================================ TABS */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 20px;
  background: none; color: var(--text2);
  font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================ PRESCRIPTION PRINT */
.rx-print {
  font-family: var(--font);
  max-width: 720px; margin: 0 auto;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.rx-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--primary); padding-bottom: 16px; margin-bottom: 16px; }
.rx-clinic h2 { color: var(--primary); font-size: 22px; }
.rx-table { width: 100%; margin-top: 16px; }
.rx-table th { background: var(--primary); color: white; padding: 8px 12px; text-align: left; font-size: 13px; }
.rx-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ============================================================ UTILITIES */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.info-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 12px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; min-width: 140px; flex-shrink: 0; }
.info-value { font-size: 13px; color: var(--text); font-weight: 500; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty-state i { font-size: 48px; color: var(--text3); margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text2); }
.empty-state p { font-size: 13px; color: var(--text3); margin-top: 4px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Medicine row in prescription form */
.medicine-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.add-medicine-btn { color: var(--primary); font-size: 13px; font-weight: 600; background: var(--primary-fade); border: 1.5px dashed var(--primary); border-radius: 8px; padding: 8px; text-align: center; cursor: pointer; transition: all var(--transition); }
.add-medicine-btn:hover { background: #dbeafe; }

/* ============================================================ REPORTS */
.report-filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.report-stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.report-stat { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.report-stat .rs-val { font-size: 24px; font-weight: 700; color: var(--primary); }
.report-stat .rs-lbl { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ============================================================ RESPONSIVE */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    z-index: 200;
    width: 260px;
    height: 100vh;
    top: 0; left: 0;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex !important; }
  .menu-toggle { display: flex !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2, .form-grid-2 { grid-template-columns: 1fr; }
  .medicine-row { grid-template-columns: 1fr 1fr; }
  .table-actions { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
  .topbar-date { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal-box { max-width: 100%; margin: 8px; }
}

/* Print styles */
@media print {
  .sidebar, .topbar, .btn, .page-header button, .modal-close { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: white; color: black; }
}
