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

:root {
  --blue:       #2563eb;
  --blue-dark:  #1d4ed8;
  --blue-light: #eff6ff;
  --green:      #16a34a;
  --red:        #dc2626;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
  --radius:     12px;
  --transition: .18s ease;
}


body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #dbeafe 0%, #ede9fe 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  color: var(--gray-800);
}

/* ── Container / Card ─────────────────────────────────────────────────────── */
.container { width: 100%; max-width: 680px; }

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-header {
  background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
  color: #fff;
  padding: 28px 40px 24px;
  text-align: center;
}

/* Brand row — logo + name */
.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.brand-logo {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  background: rgba(255,255,255,.15);
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #fff;
  white-space: nowrap;
}

.header-divider {
  width: 48px;
  height: 2px;
  background: rgba(255,255,255,.3);
  border-radius: 2px;
  margin: 16px auto 14px;
}

.card-header h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.card-header .subtitle { font-size: .9rem; opacity: .8; }

form { padding: 32px 40px; }

/* ── Form layout ──────────────────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-800);
}

.required { color: var(--red); }
.optional { color: var(--gray-400); font-weight: 400; font-size: .8rem; }

input[type="text"],
input[type="tel"],
input[type="email"],
textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

input:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
  background: #fff;
}

input.invalid, textarea.invalid { border-color: var(--red); }
input.valid, textarea.valid { border-color: var(--green); }

textarea { resize: vertical; min-height: 120px; }

.char-count {
  font-size: .75rem;
  color: var(--gray-400);
  text-align: right;
  margin-top: 2px;
}

/* ── CAPTCHA ──────────────────────────────────────────────────────────────── */
.captcha-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.captcha-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 8px 12px;
}

#captchaImg {
  height: 70px;
  width: 200px;
  border-radius: 6px;
  display: block;
  user-select: none;
  pointer-events: none;
}

.btn-refresh {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  display: flex;
}
.btn-refresh:hover { color: var(--blue); }

/* ── Checkbox ─────────────────────────────────────────────────────────────── */
.checkbox-group { margin-bottom: 24px; }

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-text { font-size: .9rem; line-height: 1.5; }
.link { color: var(--blue); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ── Submit button ────────────────────────────────────────────────────────── */
.btn-submit {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-submit:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; }

.btn-spinner svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.error-msg {
  font-size: .78rem;
  color: var(--red);
  min-height: 16px;
}

.form-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  text-align: center;
}

.form-message.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.form-message.error {
  background: #fee2e2;
  color: #7f1d1d;
  border: 1px solid #fecaca;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--gray-800); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--gray-600);
}

/* ── Admin-specific ───────────────────────────────────────────────────────── */
.admin-body {
  background: var(--gray-50);
  min-height: 100vh;
  padding: 0;
  align-items: flex-start;
}

.admin-header {
  background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
  color: #fff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header h1 { font-size: 1.3rem; font-weight: 700; }

.admin-main { padding: 28px 32px; max-width: 1200px; margin: 0 auto; width: 100%; }

.filters-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: #fff;
  padding: 20px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 160px;
}

.filter-group label { font-size: .8rem; font-weight: 600; color: var(--gray-600); }

.filter-group input {
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  background: var(--gray-50);
}
.filter-group input:focus { border-color: var(--blue); background: #fff; }

.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; font-size: .8rem; padding: 5px 12px; }
.btn-outline { background: #fff; color: var(--gray-800); border: 1.5px solid var(--gray-200); }

.table-wrapper {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.table-header h2 { font-size: 1rem; }

.badge {
  background: var(--blue-light);
  color: var(--blue);
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}

table { width: 100%; border-collapse: collapse; }

th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: .875rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
  max-width: 200px;
  word-break: break-word;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.desc-cell {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--gray-200);
}

.page-info { font-size: .85rem; color: var(--gray-600); }

/* ── Login — split panel ──────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  z-index: 200;
  font-family: inherit;
}

/* LEFT — gradient branding panel */
.login-left {
  flex: 1;
  background: linear-gradient(145deg, #1e40af 0%, #4f46e5 55%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 56px;
  position: relative;
  overflow: hidden;
}

/* subtle decorative circles */
.login-left::before,
.login-left::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.login-left::before { width: 420px; height: 420px; top: -120px; left: -120px; }
.login-left::after  { width: 280px; height: 280px; bottom: -80px; right: -80px; }

.login-left-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  color: #fff;
}

/* Centred logo + name block */
.login-left-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 0;
}

.login-logo-hero {
  width: 140px;
  height: 140px;
  border-radius: 28px;
  object-fit: cover;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
  margin-bottom: 28px;
}

.login-left-name {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: #fff;
  margin: 0 0 8px;
}

.login-left-tagline {
  font-size: 1rem;
  color: rgba(255,255,255,.65);
  margin: 0;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Smaller logo variants used elsewhere */
.login-logo-img {
  width: 46px; height: 46px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.login-logo-sm-img {
  width: 32px; height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.admin-header-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 1px 6px rgba(0,0,0,.2);
}

.lf-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.login-left-footer {
  font-size: .75rem;
  color: rgba(255,255,255,.4);
  margin-top: 0;
  padding-bottom: 8px;
}

/* RIGHT — form panel */
.login-right {
  width: 480px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 52px;
  overflow-y: auto;
}

.login-form-wrap { width: 100%; max-width: 360px; }

.login-form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 36px;
}

.login-logo-sm {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.login-form-header span {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.01em;
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gray-800);
  letter-spacing: -.03em;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: .9rem;
  color: var(--gray-400);
  margin-bottom: 32px;
}

.login-field {
  margin-bottom: 20px;
}

.login-field label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 7px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 14px;
  color: var(--gray-400);
  display: flex;
  pointer-events: none;
}

.login-input-wrap input {
  width: 100%;
  padding: 12px 44px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.login-input-wrap input:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.login-eye {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  display: flex;
  padding: 2px;
  border-radius: 4px;
  transition: color var(--transition);
}
.login-eye:hover { color: var(--gray-800); }

.login-btn {
  width: 100%;
  padding: 13px 20px;
  margin-top: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  letter-spacing: -.01em;
}

.login-btn:hover:not(:disabled) {
  opacity: .93;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,.4);
}

.login-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.login-hint {
  margin-top: 24px;
  font-size: .75rem;
  color: var(--gray-400);
  text-align: center;
  line-height: 1.6;
}

.login-hint code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .72rem;
  color: var(--gray-600);
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  background: #fff;
  border-bottom: 2px solid var(--gray-200);
  padding: 0 32px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 13px 20px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--blue); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Role / status badges ─────────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-600);
}
.role-badge.role-super_admin { background: #fef3c7; color: #92400e; }
.role-badge.role-admin        { background: #dbeafe; color: #1e40af; }
.role-badge.role-doctor       { background: #d1fae5; color: #065f46; }
.role-badge.role-receptionist { background: #ede9fe; color: #5b21b6; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
}
.status-badge.active   { background: #dcfce7; color: #166534; }
.status-badge.inactive { background: #fee2e2; color: #7f1d1d; }

/* ── Roles grid ───────────────────────────────────────────────────────────── */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.role-card {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.role-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.role-card-head strong { font-size: 1rem; color: var(--gray-800); }

.sys-badge {
  font-size: .68rem;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
}

.role-desc { font-size: .83rem; color: var(--gray-600); margin-bottom: 12px; line-height: 1.5; }

.perms-list { display: flex; flex-wrap: wrap; gap: 5px; }

.perm-tag {
  font-size: .72rem;
  font-weight: 600;
  background: var(--blue-light);
  color: var(--blue);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}

/* ── Permission checkboxes (role modal) ───────────────────────────────────── */
.perms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.perm-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--gray-50);
  transition: background var(--transition);
}
.perm-check-label:hover { background: var(--blue-light); }
.perm-check-label input { width: 14px; height: 14px; accent-color: var(--blue); }

/* ── Select element ───────────────────────────────────────────────────────── */
select {
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
  background-color: #fff;
}

/* ── Touch / mobile globals ───────────────────────────────────────────────── */

/* Eliminate 300 ms tap delay and blue flash on iOS / Android */
button, a, select, label,
.checkbox-label, .perm-check-label, .desc-cell {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Scrollable tab bar — no visible scrollbar on any browser */
.tab-bar {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn { white-space: nowrap; flex-shrink: 0; }

/* Momentum scroll in content areas */
.modal-body, .login-right { -webkit-overflow-scrolling: touch; }

/* Safe-area insets — iPhone X notch / Dynamic Island */
@supports (padding: env(safe-area-inset-bottom)) {
  body        { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .admin-body { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
  .login-overlay { padding-bottom: env(safe-area-inset-bottom); }
  .admin-header {
    padding-left:  max(32px, calc(16px + env(safe-area-inset-left)));
    padding-right: max(32px, calc(16px + env(safe-area-inset-right)));
  }
}

/* ── Admin table → card view on mobile ───────────────────────────────────── */
/* Requires class="table-mobile-cards" on <table> and data-label="…" on <td> */
@media (max-width: 600px) {
  .table-mobile-cards thead { display: none; }

  .table-mobile-cards tbody tr {
    display: block;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    margin: 0 0 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .table-mobile-cards tbody tr:hover td { background: transparent; }

  .table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--gray-100);
    font-size: .875rem;
    max-width: 100%;
    word-break: break-word;
    white-space: normal !important;
  }

  .table-mobile-cards tbody tr:last-child td:last-child { border-bottom: none; }

  /* Index (#) column hidden on mobile */
  .table-mobile-cards tbody td[data-label="idx"] { display: none; }

  /* Data cells — label prefix via ::before */
  .table-mobile-cards tbody td:not([data-label="idx"]):not([data-label="action"])::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    min-width: 76px;
    flex-shrink: 0;
    padding-top: 2px;
    line-height: 1.5;
  }

  /* Action column — buttons flush right, no label */
  .table-mobile-cards tbody td[data-label="action"] {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-bottom: none;
  }

  /* Description: 2-line clamp; tap to see full */
  .table-mobile-cards .desc-cell {
    max-width: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Card action buttons */
  .table-mobile-cards td[data-label="action"] .btn {
    min-height: 40px;
    padding: 8px 16px;
    font-size: .85rem;
  }
}

/* ── 860px — Tablet landscape / small desktop ─────────────────────────────── */
@media (max-width: 860px) {
  .login-left  { display: none; }
  .login-right { width: 100%; padding: 40px 28px; }
}

/* ── 768px — iPad portrait / Android tablets ──────────────────────────────── */
@media (max-width: 768px) {
  .admin-main   { padding: 20px; }
  .admin-header { padding: 14px 20px; }
  .tab-bar      { padding: 0 16px; }
  .filters-bar  { padding: 16px; gap: 10px; }
  .filter-group { min-width: 140px; }
}

/* ── 600px — Phone landscape / compact tablet ─────────────────────────────── */
@media (max-width: 600px) {
  /* Patient form */
  form, .card-header { padding: 24px 20px; }
  .form-row { grid-template-columns: 1fr; }

  /* Admin layout */
  .admin-main   { padding: 14px; }
  .admin-header { padding: 12px 16px; }
  .tab-bar      { padding: 0 8px; }

  /* Filter bars stack vertically */
  .filters-bar  { flex-direction: column; padding: 14px; gap: 10px; }
  .filter-group { width: 100%; min-width: unset; flex: unset; }
  .filters-actions { flex-direction: column; width: 100%; }
  .filters-actions .btn { width: 100%; justify-content: center; min-height: 44px; }

  /* Table cells */
  table { font-size: .78rem; }
  th, td { padding: 8px; }
  .perms-grid   { grid-template-columns: 1fr; }
  .login-right  { padding: 32px 20px; }
  .table-header { flex-wrap: wrap; gap: 8px; }
  .pagination   { gap: 6px; flex-wrap: wrap; padding: 12px 8px; }
}

/* ── 480px — Phone portrait ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  body { padding: 16px 12px; }

  /* Patient form card */
  .card-header { padding: 20px 16px; }
  .card-header h1 { font-size: 1.2rem; }
  .card-header .subtitle { font-size: .82rem; }
  form { padding: 20px 16px; }
  .brand-name { font-size: 1.1rem; }
  .brand-logo { width: 44px; height: 44px; }

  /* CAPTCHA */
  #captchaImg { width: 160px; }
  .captcha-display { padding: 6px 10px; }

  /* Admin */
  .admin-header { flex-wrap: wrap; gap: 6px; }
  .admin-header h1 { font-size: 1rem; }
  .admin-main { padding: 10px; }
  .tab-btn { padding: 12px 14px; font-size: .82rem; min-height: 44px; }

  /* Login */
  .login-right { padding: 28px 18px; }
  .login-title { font-size: 1.5rem; }
  .login-subtitle { font-size: .85rem; margin-bottom: 24px; }
  .login-form-header { margin-bottom: 24px; }
  .login-btn, .btn-submit { min-height: 48px; }

  /* Modals → bottom sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-height: 88vh; border-radius: 20px 20px 0 0; margin: 0; }
  .modal-header { padding: 16px 20px; }
  .modal-body   { padding: 16px 20px; }

  .roles-grid { grid-template-columns: 1fr; }
  .table-header h2 { font-size: .9rem; }
}

/* ── 375px — iPhone SE / small Android ───────────────────────────────────── */
@media (max-width: 375px) {
  body { padding: 12px 8px; }
  .card-header { padding: 16px 14px; }
  form { padding: 16px 14px; }
  .brand-name { font-size: 1rem; }

  .login-right { padding: 24px 14px; }
  .login-title { font-size: 1.25rem; }

  #captchaImg { width: 140px; height: 56px; }

  .admin-main { padding: 8px; }
  .tab-btn    { padding: 10px 12px; font-size: .78rem; }

  th  { font-size: .7rem;  padding: 7px 5px; }
  td  { font-size: .78rem; padding: 7px 5px; }

  .btn { padding: 10px 12px; font-size: .82rem; }
}
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    #pPagination button {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }
}
