/* CarePulse Hospital Management System - CSS Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Theme Palette */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  
  --teal: #0d9488;
  --teal-hover: #0f766e;
  --teal-light: #f0fdfa;

  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-active: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-color: #e2e8f0;
  --border-radius: 12px;
  --border-radius-sm: 8px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --purple: #8b5cf6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

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

/* Sidebar (Modern Light Mode Design) */
.app-sidebar {
  width: 260px;
  background-color: #ffffff;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid #e2e8f0;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.04);
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #f1f5f9;
  background-color: #ffffff;
  min-height: 64px;
}

.sidebar-header .brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
}

.sidebar-pin-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-pin-btn:hover {
  background: #eff6ff;
  color: var(--primary, #2563eb);
  border-color: #bfdbfe;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563eb, #0d9488);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Sidebar Menu & Custom Smooth Scrollbar (Fixed Windows Ugly Scrollbar) */
.sidebar-menu {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 10px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.5);
}

.menu-category {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
  padding: 12px 10px 4px 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: #475569;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 2px;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.menu-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: #64748b;
  flex-shrink: 0;
  transition: color 0.2s;
}

.menu-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.menu-item:hover {
  background-color: rgba(37, 99, 235, 0.06);
  color: var(--primary, #2563eb);
  transform: translateX(2px);
}

.menu-item:hover i {
  color: var(--primary, #2563eb);
}

.menu-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.03));
  color: var(--primary, #2563eb);
  font-weight: 600;
  border-left: 3px solid var(--primary, #2563eb);
  border-radius: 0 8px 8px 0;
}

.menu-item.active i {
  color: var(--primary, #2563eb);
}

/* Sidebar User Footer */
.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f8fafc;
  min-height: 60px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--primary, #2563eb);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-details h4 {
  font-size: 13px;
  color: #0f172a;
  font-weight: 600;
  margin: 0;
}

.user-details span {
  font-size: 11px;
  color: #64748b;
}

.btn-logout {
  color: #ef4444;
  font-size: 16px;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s;
  background: transparent;
}

.btn-logout:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ===================================================
   COLLAPSED / MINI SIDEBAR (Enlarges Main Workspace)
   =================================================== */
.app-container.sidebar-collapsed .app-sidebar {
  width: 72px;
}

.app-container.sidebar-collapsed .app-main {
  margin-left: 72px;
}

.app-container.sidebar-collapsed .sidebar-header .brand-name,
.app-container.sidebar-collapsed .sidebar-header .brand-sub,
.app-container.sidebar-collapsed .menu-category,
.app-container.sidebar-collapsed .menu-item span,
.app-container.sidebar-collapsed .user-details {
  display: none !important;
}

.app-container.sidebar-collapsed .sidebar-header {
  padding: 14px 10px;
  justify-content: center;
}

.app-container.sidebar-collapsed .sidebar-header .brand-title-wrap {
  justify-content: center;
}

.app-container.sidebar-collapsed .sidebar-pin-btn {
  display: none;
}

.app-container.sidebar-collapsed .menu-item {
  justify-content: center;
  padding: 11px 0;
  position: relative;
}

.app-container.sidebar-collapsed .menu-item.active {
  border-left: none;
  border-right: 3px solid var(--primary, #2563eb);
  border-radius: 8px 0 0 8px;
}

.app-container.sidebar-collapsed .sidebar-user {
  padding: 12px 6px;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.app-container.sidebar-collapsed .btn-logout {
  padding: 4px;
}

/* Tooltip in collapsed mode */
.app-container.sidebar-collapsed .menu-item[data-title]:hover::after {
  content: attr(data-title);
  position: absolute;
  left: 76px;
  background: #0f172a;
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  z-index: 1050;
  pointer-events: none;
}

/* Main Content Body */
.app-main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================================
   RESPONSIVE DESIGN (Mobile & Tablet <= 992px)
   =================================================== */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 260px !important;
    box-shadow: 4px 0 25px rgba(15, 23, 42, 0.18);
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 999;
  }

  .sidebar-backdrop.active {
    display: block;
  }
}

/* Toggle & Auto-Close Buttons in Top Navbar */
.sidebar-toggle-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: #eff6ff;
  color: var(--primary, #2563eb);
  border-color: #bfdbfe;
}

.autoclose-pill {
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.autoclose-pill:hover {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #bfdbfe !important;
}

.autoclose-pill.active {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #93c5fd !important;
}

.autoclose-pill.active i {
  color: #2563eb;
}

.top-navbar {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.navbar-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.navbar-brand-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.navbar-brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.page-title h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.quick-badge {
  background: #f1f5f9;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e2e8f0;
}

.display-screen-badge {
  text-decoration: none;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  transition: all 0.2s ease;
}

.display-screen-badge:hover {
  background: #d1fae5;
  color: #065f46;
}

/* Page Content Wrapper */
.content-body {
  padding: 28px;
  flex: 1;
  background: #f8fafc;
  min-height: calc(100vh - 64px);
}

/* Cards & Grid System */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

@media (max-width: 1024px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-sidebar { width: 0; transform: translateX(-100%); }
  .app-main { margin-left: 0; }
}

.card {
  background-color: var(--bg-surface);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modern Light Theme Stats Grid & Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -2px rgba(0,0,0,0.08);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.stat-subtext {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

/* KPI Stat Cards */
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.kpi-blue { background: #eff6ff; color: #2563eb; }
.kpi-teal { background: #f0fdfa; color: #0d9488; }
.kpi-amber { background: #fffbe6; color: #d97706; }
.kpi-emerald { background: #ecfdf5; color: #059669; }
.kpi-purple { background: #f3e8ff; color: #9333ea; }

.kpi-val {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.kpi-lbl {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-main);
}

.table tbody tr:hover {
  background-color: #f1f5f9;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary { background-color: var(--primary); color: #fff; }
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-teal { background-color: var(--teal); color: #fff; }
.btn-teal:hover { background-color: var(--teal-hover); }

.btn-secondary { background-color: #e2e8f0; color: #334155; }
.btn-secondary:hover { background-color: #cbd5e1; }

.btn-danger { background-color: var(--danger); color: #fff; }
.btn-danger:hover { background-color: #dc2626; }

.btn-success { background-color: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background-color: #fff;
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2064748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  text-transform: capitalize;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-purple  { background: #f3e8ff; color: #6b21a8; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border-radius: 10px;
  padding: 14px 20px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  min-width: 300px;
  border-left: 5px solid var(--primary);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #94a3b8;
}

@keyframes slideIn {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Bed Grid Matrix */
.bed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.bed-box {
  background: #fff;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.bed-box.available { border-color: var(--success); background: #f0fdf4; }
.bed-box.occupied { border-color: var(--danger); background: #fef2f2; }
.bed-box.maintenance { border-color: var(--warning); background: #fffbeb; }

.bed-box h4 { font-size: 16px; font-weight: 700; }
.bed-box span { font-size: 11px; font-weight: 600; text-transform: uppercase; }

/* Prescription & EMR Print Box */
.medical-timeline {
  border-left: 2px solid var(--border-color);
  padding-left: 20px;
  margin-left: 10px;
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -27px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
}

/* ========================================================
   SaaS Multi-Tenant, Omni-Search & OPD Receipt Styles
   ======================================================== */
.search-autocomplete-wrap {
  position: relative;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 4px;
}

.search-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s ease;
}

.search-result-item:hover, .search-result-item.active {
  background: #eff6ff;
}

.search-result-name {
  font-weight: 600;
  color: #0f172a;
  font-size: 14px;
}

.search-result-meta {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.search-result-badge {
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Follow-up Validity Alert Banner */
.validity-alert-box {
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  line-height: 1.4;
  animation: fadeIn 0.2s ease;
}

.validity-alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.validity-alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.validity-alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* Patient History Drawer / Card */
.patient-history-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.history-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.history-stat-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.history-stat-val {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.history-stat-lbl {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
}

/* Thermal Token Slip (80mm) */
.thermal-slip {
  width: 80mm;
  max-width: 100%;
  background: #fff;
  padding: 14px;
  margin: 0 auto;
  font-family: 'Courier New', Courier, monospace;
  color: #000;
  border: 1px dashed #94a3b8;
  border-radius: 6px;
}

.thermal-slip .header {
  text-align: center;
  border-bottom: 1px dashed #000;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.thermal-slip .token-number-large {
  font-size: 38px;
  font-weight: 900;
  text-align: center;
  margin: 6px 0;
  border: 2px solid #000;
  border-radius: 8px;
  padding: 4px;
}

.thermal-slip .slip-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.thermal-slip .footer {
  text-align: center;
  border-top: 1px dashed #000;
  padding-top: 8px;
  margin-top: 8px;
  font-size: 11px;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-container {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  animation: scaleUp 0.25s ease;
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  border-radius: 0 0 16px 16px;
}

/* Password Health Line Widget (Minimalist & Sleek) */
.pw-widget-box {
  margin-top: 5px;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 11px;
}

.pw-strength-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.pw-strength-bar {
  flex: 1;
  height: 5px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.pw-strength-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  background: #e2e8f0;
  border-radius: 999px;
}

.pw-strength-label {
  font-weight: 700;
  font-size: 11px;
  min-width: 55px;
  text-align: right;
  color: #64748b;
  letter-spacing: 0.2px;
}

.pw-rules-chips {
  display: none !important;
}

.btn-generate-pw {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-generate-pw:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Universal Clean Modal System (Prevents modals from ever leaking into normal page flow) */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99999;
  padding: 16px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.modal.show, .modal.active {
  display: flex !important;
}

.modal-dialog {
  margin: auto;
  max-width: 580px;
  width: 100%;
}

.modal-dialog.modal-xl {
  max-width: 1100px;
}

.modal-content {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid #e2e8f0;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
}

/* Modern Form Controls & Select Elements */
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: #1e293b;
  background-color: #ffffff;
  background-clip: padding-box;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  font-family: inherit;
  box-sizing: border-box;
}

.form-control:hover,
.form-select:hover {
  border-color: #94a3b8;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary, #2563eb);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background-color: #ffffff;
}

.form-select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 10px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
}

.form-control-sm,
.form-select-sm {
  height: 33px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.form-select-sm {
  padding-right: 24px;
}

/* ==========================================================================
   ADVANCED MOBILE & TABLET RESPONSIVE SYSTEM (Phones <= 768px & Small Devices <= 420px)
   ========================================================================== */
@media (max-width: 992px) {
  .app-sidebar {
    width: 270px !important;
  }
}

@media (max-width: 768px) {
  /* 1. App Shell & Containers */
  .app-container {
    overflow-x: hidden;
    width: 100%;
  }

  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden;
  }

  /* 2. Top Navbar Mobile Optimization */
  .top-navbar {
    height: 56px !important;
    padding: 0 12px !important;
    gap: 8px;
  }

  .page-title {
    gap: 10px !important;
    min-width: 0 !important;
    flex: 1 !important;
  }

  .sidebar-toggle-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 15px !important;
    border-radius: 8px !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    flex-shrink: 0 !important;
  }

  .navbar-title-wrap {
    min-width: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
  }

  .navbar-brand-title {
    font-size: 14.5px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .navbar-brand-subtitle {
    display: none !important; /* Hide secondary tagline on mobile navbar to keep top bar 1-line clean */
  }

  .navbar-actions {
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  .hide-on-mobile {
    display: none !important; /* Hides desktop-only Auto-Close toggle and date pill */
  }

  .display-screen-badge {
    padding: 6px 10px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .display-screen-badge i {
    font-size: 14px;
    margin: 0 !important;
  }

  /* 3. Content Body Padding */
  .content-body {
    padding: 14px 12px !important;
    min-height: calc(100vh - 56px) !important;
  }

  /* 4. OPD Dashboard Command Center Banner */
  .dashboard-banner-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .dashboard-title {
    font-size: 18px !important;
    display: flex;
    align-items: center;
  }

  .dashboard-subtitle {
    font-size: 12px !important;
    margin-top: 2px !important;
  }

  .dashboard-action-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .btn-action-opd {
    width: 100% !important;
    padding: 10px 6px !important;
    font-size: 12.5px !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
  }

  /* 5. Stat Metric Cards */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .stat-card {
    padding: 14px 14px !important;
    border-radius: 12px !important;
    gap: 12px !important;
    margin-bottom: 0 !important;
  }

  .stat-icon {
    width: 44px !important;
    height: 44px !important;
    font-size: 18px !important;
    border-radius: 10px !important;
    flex-shrink: 0 !important;
  }

  .stat-label {
    font-size: 10.5px !important;
    letter-spacing: 0.3px !important;
    margin-bottom: 2px !important;
  }

  .stat-value {
    font-size: 20px !important;
  }

  .stat-subtext {
    font-size: 11px !important;
    margin-top: 3px !important;
  }

  /* 6. Standard Cards & Tables */
  .card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
    margin-bottom: 14px !important;
  }

  .card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    padding-bottom: 10px !important;
  }

  .card-title {
    font-size: 15px !important;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
  }

  .table th {
    padding: 10px 10px !important;
    font-size: 11.5px !important;
    white-space: nowrap;
  }

  .table td {
    padding: 10px 10px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }

  /* 7. General Mobile Elements & Touch Targets */
  .btn {
    min-height: 38px;
  }

  .form-control, .form-select {
    font-size: 14.5px !important;
  }
}

@media (max-width: 420px) {
  .navbar-brand-title {
    font-size: 13.5px !important;
    max-width: 170px !important;
  }

  .dashboard-action-buttons {
    grid-template-columns: 1fr !important;
  }

  .btn-action-opd {
    padding: 10px 12px !important;
    font-size: 13px !important;
  }
}




