/* ===================================================================
   MEDLAB CLINICAL ADMIN DESIGN SYSTEM & STYLESHEET (NO BS5)
   Inspired by: MedLab Medical Admin Template (dashboard2.html)
   Adapted for: eSoft EMR - Smart Clinic & Lab Information System
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css');

:root {
  /* MedLab Primary Sapphire & Medical Brand Accents */
  --primary: #116aef;
  --primary-rgb: 17, 106, 239;
  --primary-hover: #0e55bf;
  --primary-subtle: #e3eefd;
  --primary-border-subtle: #a0c3f9;
  --primary-text-emphasis: #072a60;

  --secondary: #d8e2eb;
  --secondary-rgb: 216, 226, 235;
  --secondary-subtle: #f3f6f9;
  --secondary-border-subtle: #cdd6dc;

  --success: #0ebb13;
  --success-rgb: 14, 187, 19;
  --success-hover: #0ca310;
  --success-subtle: #e9fdea;
  --success-border-subtle: #9fe4a1;
  --success-text-emphasis: #064b08;

  --danger: #ff5a39;
  --danger-rgb: 255, 90, 57;
  --danger-hover: #e04424;
  --danger-subtle: #ffefec;
  --danger-border-subtle: #ffbdb0;
  --danger-text-emphasis: #662417;

  --warning: #eebb30;
  --warning-rgb: 238, 187, 48;
  --warning-hover: #d1a324;
  --warning-subtle: #fefaf1;
  --warning-border-subtle: #f8e4ac;
  --warning-text-emphasis: #5f4b13;

  --info: #039ce0;
  --info-rgb: 3, 156, 224;
  --info-hover: #0283bd;
  --info-subtle: #e8f8ff;
  --info-border-subtle: #9ad7f3;
  --info-text-emphasis: #013e5a;

  /* MedLab Dashboard 2 Palette */
  --lime: #79d874;
  --lime-rgb: 121, 216, 116;
  --arctic: #1ec5f9;
  --arctic-rgb: 30, 197, 249;
  --peach: #fea95f;
  --pine-green: #02b86f;
  --dark: #151516;
  --black: #0f1115;

  /* Backgrounds & Neutrals */
  --bg-app: #f6f9fb;
  --bg-surface: #ffffff;
  --bg-subtle: #f0f1f4;
  --bg-header: #116aef;
  --bg-sidebar: #ffffff;

  /* Typography Colors */
  --text-main: #0f1115;
  --text-body: #272727;
  --text-muted: #58626d;
  --text-light: #7b8590;
  --text-white: #ffffff;

  /* Borders & Dividers */
  --border-color: #dde2ee;
  --border-light: #f0f1f4;
  --border-gray: #cdd6dc;

  /* MedLab Shadows & Inset Depth */
  --card-shadow: 0px 2px 6px rgba(40, 90, 185, 0.08);
  --header-shadow: 0 2px 5px rgba(40, 90, 185, 0.12);
  --sidebar-shadow: 0 2px 8px rgba(40, 90, 185, 0.1);
  --dropdown-shadow: 0 10px 25px rgba(40, 90, 185, 0.15);
  --inset-bevel: inset 1.5px 1.5px 0px rgba(255, 255, 255, 0.25), inset -1.5px -1.5px 0px rgba(0, 0, 0, 0.1);

  /* Geometry */
  --header-height: 52px;
  --hero-header-height: 48px;
  --tabbar-height: 42px;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 74px;
  --radius: 8px;
  --radius-sm: 5px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 50px;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-size-base: 0.9rem;
  --font-size-sm: 0.7875rem;
  --font-size-xs: 0.75rem;
  --font-size-md: 0.875rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.35rem;
  --font-size-2xl: 1.8rem;
  --font-size-3xl: 2.25rem;
}

/* ==================== RESET & CORE ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-body);
  background-color: var(--bg-app);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* MedLab Standard Heading Scale */
h1, .h1 { font-size: 2.25rem; font-weight: 600; line-height: 1.2; color: var(--text-main); margin-bottom: 0.5rem; }
h2, .h2 { font-size: 1.8rem; font-weight: 600; line-height: 1.2; color: var(--text-main); margin-bottom: 0.5rem; }
h3, .h3 { font-size: 1.575rem; font-weight: 600; line-height: 1.2; color: var(--text-main); margin-bottom: 0.5rem; }
h4, .h4 { font-size: 1.35rem; font-weight: 600; line-height: 1.2; color: var(--text-main); margin-bottom: 0.5rem; }
h5, .h5 { font-size: 1.125rem; font-weight: 600; line-height: 1.2; color: var(--text-main); margin-bottom: 0.5rem; }
h6, .h6 { font-size: 0.9rem; font-weight: 600; line-height: 1.2; color: var(--text-main); margin-bottom: 0.5rem; }
p { margin-top: 0; margin-bottom: 0.5rem; }

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-hover);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd6dc;
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: #a8b3bb;
}

/* ==================== MEDLAB APP SHELL ==================== */
.page-wrapper, .app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-app);
}

/* ==================== TOP APP HEADER (#116aef) ==================== */
.app-header, .top-navbar {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-header);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: var(--header-shadow);
  z-index: 110;
  position: relative;
  flex-shrink: 0;
}

/* Toggle Sidebar Button (MedLab Signature: 32x32 white box with rounded corners & blue icon) */
.toggle-sidebar, .btn-sidebar-toggle {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  color: var(--primary);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.toggle-sidebar:hover, .btn-sidebar-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  background: #f8fafc;
}
.toggle-sidebar svg, .toggle-sidebar i, .btn-sidebar-toggle svg {
  color: var(--primary);
  stroke: var(--primary);
}

/* App Brand / Logo */
.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  text-decoration: none;
}
.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo-icon {
  width: 32px;
  height: 32px;
  background: #ffffff;
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  line-height: 1;
}
.brand-title {
  font-size: 1.125rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
  line-height: 1.15;
}
.brand-title span {
  color: #a0c3f9;
}
.brand-subtitle {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

/* Clinic Branch Indicator Pill */
.clinic-branch-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  color: #ffffff;
  font-weight: 600;
  margin-left: 14px;
}
.branch-indicator {
  width: 8px;
  height: 8px;
  background: #0ebb13;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(14, 187, 19, 0.35);
  animation: pulseGreen 2s infinite;
}
@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(14, 187, 19, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 5px rgba(14, 187, 19, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(14, 187, 19, 0); }
}

/* Search Container (MedLab Style) */
.search-container, .top-search-box {
  position: relative;
  width: 300px;
  margin: 0 16px;
}
.search-container input, .top-search-box input {
  width: 100%;
  height: 36px;
  padding: 0 14px 0 36px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #ffffff;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}
.search-container input:focus, .top-search-box input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.search-container input::placeholder, .top-search-box input::placeholder {
  color: #7b8590;
}
.search-container i, .top-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 1.125rem;
  pointer-events: none;
}

/* Header Actions */
.header-actions, .top-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.btn-icon-nav, .header-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
  font-size: 1.125rem;
}
.btn-icon-nav:hover, .header-icon:hover {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
}
.btn-icon-nav:hover svg {
  stroke: var(--primary);
}
.btn-icon-nav svg {
  stroke: #ffffff;
}
.badge-dot, .count-label {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-header);
}

.btn-quick-patient-portal {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: var(--primary);
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}
.btn-quick-patient-portal:hover {
  background: #f0f4ff;
  transform: translateY(-1px);
}
.btn-quick-patient-portal svg {
  stroke: var(--primary);
}

/* User Settings Avatar Box (MedLab Signature) */
.avatar-box {
  width: 36px;
  height: 36px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px;
}
.avatar-box:hover {
  background: #ffffff;
  color: var(--primary);
}
.avatar-box .status {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #0ebb13;
}
.avatar-box .status.online { background: #0ebb13; }
.avatar-box .status.busy { background: #ff5a39; }
.avatar-box .status.away { background: #eebb30; }

/* ==================== MAIN WORKSPACE CONTAINER ==================== */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-app);
}

/* ==================== MEDLAB SIDEBAR (#ffffff) ==================== */
.sidebar, .sidebar-wrapper {
  width: var(--sidebar-width);
  background: #ffffff;
  color: var(--text-body);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--sidebar-shadow);
  z-index: 100;
  user-select: none;
  height: 100%;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Top Profile Box in Sidebar */
.sidebar-profile {
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 16px 14px;
  border-bottom: 1px solid #f1f1f1;
  margin-bottom: 6px;
  background: #ffffff;
}
.sidebar.collapsed .sidebar-profile .profile-name,
.sidebar.collapsed .sidebar-profile .profile-role,
.sidebar.collapsed .sidebar-profile .user-info {
  display: none !important;
}
.sidebar-profile-avatar, .user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(40, 90, 185, 0.15);
  border: 1px solid #ffffff;
  flex-shrink: 0;
  margin-right: 10px;
}
.profile-name, .user-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.profile-role, .user-role {
  font-size: 0.7875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Scrollable Nav */
.sidebarMenuScroll, .sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 0.8125rem;
  font-weight: 400;
  text-transform: uppercase;
  color: #116aef;
  letter-spacing: 0.4px;
  padding: 10px 18px 4px 18px;
}
.sidebar.collapsed .nav-section-title {
  display: none;
}

/* Nav Item (MedLab Signature: 36x36 rounded-10 icon container + hover/active styles) */
.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 18px 8px 14px;
  color: #272727;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  font-size: 0.95rem;
  font-weight: 400;
  text-decoration: none;
  position: relative;
  white-space: nowrap;
}

.nav-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: #e9f2ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  margin-right: 12px;
  transition: all 0.2s ease;
}
.nav-icon svg {
  stroke: var(--primary);
  transition: stroke 0.2s ease;
}
.nav-icon i {
  font-size: 1.15rem;
}

.nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-badge {
  display: none !important;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 7px 0;
}
.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

/* Hover State */
.nav-item:hover {
  color: var(--primary);
  background: #e9f2ff;
  border-left-color: var(--primary);
}
.nav-item:hover .nav-icon {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(40, 90, 185, 0.12);
}

/* Active State (MedLab Signature: Active icon turns solid primary blue with white glyph) */
.nav-item.active {
  color: var(--primary);
  background: #e9f2ff;
  font-weight: 400;
  border-left: 3px solid var(--primary);
}
.nav-item.active .nav-icon {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 3px 6px rgba(17, 106, 239, 0.25);
}
.nav-item.active .nav-icon svg {
  stroke: #ffffff;
}

/* Badges on Nav */
.nav-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  margin-left: auto;
}
.nav-badge.primary { background: var(--primary); color: #ffffff; }
.nav-badge.danger { background: var(--danger); color: #ffffff; }
.nav-badge.warning { background: var(--warning); color: #ffffff; }
.nav-badge.success { background: var(--success); color: #ffffff; }

/* Sidebar Emergency Contact Card (MedLab Signature Green Card) */
.sidebar-contact {
  padding: 10px 14px 10px 48px;
  background: #0ebb13;
  color: #ffffff;
  margin: 14px 14px 12px 14px;
  border-radius: 6px;
  position: relative;
  box-shadow: 0 3px 8px rgba(14, 187, 19, 0.2);
}
.sidebar-contact i, .sidebar-contact svg {
  font-size: 1.5rem;
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: #ffffff;
  stroke: #ffffff;
}
.sidebar-contact p {
  font-size: 0.7875rem;
  margin: 0;
  opacity: 0.9;
  text-transform: uppercase;
  font-weight: 400;
}
.sidebar-contact h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.sidebar.collapsed .sidebar-contact {
  display: none !important;
}

/* ==================== MAIN WORKSPACE AREA ==================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
}

/* ==================== APP HERO HEADER (BREADCRUMB & FILTERS) ==================== */
.app-hero-header {
  background: #f6f9fb;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 90;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb-item i {
  color: var(--primary);
  font-size: 1.25rem;
  margin-right: 0.25rem;
}
.breadcrumb-item a {
  color: var(--text-muted);
}
.breadcrumb-item a:hover {
  color: var(--primary);
}
.breadcrumb-item.active, .breadcrumb-item.text-primary, #heroBreadcrumbCurrent {
  color: var(--primary);
  font-weight: 600;
}
.breadcrumb-separator {
  color: #a8b3bb;
  font-size: 12px;
}

.day-sorting {
  display: flex;
  align-items: center;
  gap: 4px;
}
.day-sorting .btn {
  height: 28px;
  padding: 0 10px;
  font-size: 0.7875rem;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-body);
  border: 1px solid var(--border-color);
}
.day-sorting .btn.active, .day-sorting .btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.day-sorting .btn:hover:not(.active):not(.btn-primary) {
  background: #f0f4f9;
}

/* ==================== WORKSPACE MULTI-TAB BAR ==================== */
.tab-bar-container {
  height: var(--tabbar-height);
  background: #eef3f8;
  padding: 4px 14px 0;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
  flex-shrink: 0;
}

.workspace-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  background: #e2e8f0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  max-width: 220px;
  border: 1px solid transparent;
  border-bottom: none;
  position: relative;
}
.workspace-tab:hover {
  background: #ffffff;
  color: var(--primary);
}
.workspace-tab.active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 700;
  border-color: var(--border-color);
  box-shadow: 0 -2px 6px rgba(40, 90, 185, 0.05);
}
.workspace-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}
.tab-icon {
  width: 14px;
  height: 14px;
  opacity: 0.85;
}
.workspace-tab.active .tab-icon {
  color: var(--primary);
  stroke: var(--primary);
}
.tab-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-close {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s;
}
.tab-close:hover {
  background: rgba(255, 90, 57, 0.15);
  color: var(--danger);
}

/* ==================== WORKSPACE VIEWPORT / APP BODY ==================== */
.workspace-viewport, .app-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: var(--bg-app);
}

.view-pane {
  display: none;
  animation: fadeIn 0.18s ease-in-out;
}
.view-pane.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== MEDLAB CARDS & WIDGETS ==================== */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  padding: 16px;
  margin-bottom: 18px;
  position: relative;
}

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

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.card-title i {
  font-size: 1.25rem;
}

.card-body {
  padding: 0;
}

/* MedLab Hero Banner .card.bg-3 (Clinical Wave Banner) */
.card.bg-3 {
  background: linear-gradient(135deg, #116aef 0%, #039ce0 100%),
              radial-gradient(circle at right center, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
  background-size: cover;
  border: none;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(17, 106, 239, 0.25);
  position: relative;
  overflow: hidden;
}
.card.bg-3::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* MedLab Lime & Arctic & Accents */
.card.bg-lime, .bg-lime {
  background: var(--lime);
  color: #ffffff;
}
.bg-arctic { background: var(--arctic); color: #ffffff; }
.bg-peach { background: var(--peach); color: #ffffff; }
.bg-pine-green { background: var(--pine-green); color: #ffffff; }

/* Inset Bevel Icon Boxes */
.icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
  border-radius: 10px;
  box-shadow: var(--inset-bevel);
}
.icon-box.sm { width: 30px; height: 30px; font-size: 14px; }
.icon-box.md { width: 40px; height: 40px; font-size: 18px; }
.icon-box.lg { width: 54px; height: 54px; font-size: 24px; }
.icon-box.xl { width: 68px; height: 68px; font-size: 30px; }

.bg-primary-subtle { background: var(--primary-subtle); color: var(--primary); }
.bg-success-subtle { background: var(--success-subtle); color: var(--success); }
.bg-danger-subtle { background: var(--danger-subtle); color: var(--danger); }
.bg-warning-subtle { background: var(--warning-subtle); color: var(--warning); }
.bg-info-subtle { background: var(--info-subtle); color: var(--info); }

/* MedLab Layout Grids */
.medlab-row, .medflex-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}
.medlab-col-12, .medflex-col-12 { flex: 0 0 100%; width: 100%; }
.medlab-col-8, .medflex-col-8 { flex: 0 0 calc(66.666% - 8px); width: calc(66.666% - 8px); }
.medlab-col-6, .medflex-col-6 { flex: 0 0 calc(50% - 8px); width: calc(50% - 8px); }
.medlab-col-4, .medflex-col-4 { flex: 0 0 calc(33.333% - 8px); width: calc(33.333% - 8px); }
.medlab-col-3, .medflex-col-3 { flex: 0 0 calc(25% - 12px); width: calc(25% - 12px); }

@media (max-width: 992px) {
  .medlab-col-8, .medflex-col-8,
  .medlab-col-4, .medflex-col-4,
  .medlab-col-6, .medflex-col-6,
  .medlab-col-3, .medflex-col-3 {
    flex: 0 0 100%;
    width: 100%;
  }
}

/* Banner Content Formatting */
.banner-doctor-name {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.banner-stats-row {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.banner-stat-item {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.banner-stat-item .stat-text h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0;
  line-height: 1;
}
.banner-stat-item .stat-text p {
  font-size: 0.8125rem;
  margin: 2px 0 0 0;
  opacity: 0.9;
}

/* Activity Gauge Card */
.activity-chart-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
}
.activity-circle-progress {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}
.circular-chart {
  display: block;
  margin: 0 auto;
  max-width: 80%;
  max-height: 250px;
}
.circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 3.8;
}
.circle {
  fill: none;
  stroke-width: 3.8;
  stroke: #ffffff;
  stroke-linecap: round;
  animation: progress 1s ease-out forwards;
}
.percentage {
  fill: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.5em;
  font-weight: 700;
  text-anchor: middle;
}
.activity-info-text {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Doctor Cards Grid */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.doc-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  transition: all 0.2s ease;
}
.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
  border-color: var(--primary-border-subtle);
}
.doc-card h6 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 2px 0;
  line-height: 1.3;
}
.doc-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 4px 0;
  line-height: 1.4;
}
.avatar-doc-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.avatar-doc-circle.bg-info { background: var(--info-subtle); color: var(--info); }
.avatar-doc-circle.bg-success { background: var(--success-subtle); color: var(--success); }
.avatar-doc-circle.bg-primary { background: var(--primary-subtle); color: var(--primary); }

/* Timeline Grid & Cards */
.timeline-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.timeline-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}
.timeline-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
  border-color: var(--primary-border-subtle);
}
.timeline-date-box {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
}
.timeline-date-box p {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}
.timeline-date-box h3 {
  margin: 0;
  font-size: 1.575rem;
  font-weight: 800;
  line-height: 1;
}
.timeline-info {
  margin-left: 12px;
  flex: 1;
}
.timeline-info h6 {
  margin: 0 0 2px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}
.timeline-info p {
  margin: 0 0 4px 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==================== MEDLAB KPI GRID ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(40, 90, 185, 0.12);
  border-color: var(--primary-border-subtle);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
}
.kpi-title {
  font-size: 0.7875rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
  letter-spacing: 0.4px;
}
.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  font-family: var(--font-sans);
}
.kpi-sub {
  font-size: 0.7875rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ==================== MEDLAB TABLES & TABLE-OUTER ==================== */
.table-outer {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #ffffff;
}

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

.table, .table-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: left;
}

.table th, .table-custom th {
  background: #f8fafc;
  color: #31373d;
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.table td, .table-custom td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
  vertical-align: middle;
  font-size: 0.9rem;
}

.table tbody tr:hover, .table-custom tbody tr:hover {
  background-color: #f3f7fd;
}
.table tbody tr.selected, .table-custom tbody tr.selected {
  background-color: var(--primary-subtle);
}

.avatar-initials {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 700;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==================== MEDLAB BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0.375rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  font-family: inherit;
  box-shadow: var(--inset-bevel);
  line-height: 1.5;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}

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

.btn-success {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}
.btn-success:hover {
  background: var(--success-hover);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-hover);
  color: #ffffff;
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
  border-color: var(--warning);
}
.btn-warning:hover {
  background: var(--warning-hover);
  color: #ffffff;
}

.btn-info {
  background: var(--info);
  color: #ffffff;
  border-color: var(--info);
}
.btn-info:hover {
  background: var(--info-hover);
  color: #ffffff;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-body);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #f8fafc;
  color: var(--text-main);
  border-color: var(--border-gray);
}

.btn-outline-primary {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  color: #ffffff;
}

.btn-outline-success {
  background: #ffffff;
  color: var(--success);
  border-color: var(--success);
}
.btn-outline-success:hover {
  background: var(--success);
  color: #ffffff;
}

.btn-outline-danger {
  background: #ffffff;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  height: 28px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7875rem;
}
.btn-lg {
  height: 44px;
  padding: 0.5rem 1.25rem;
  font-size: 1.125rem;
}

/* ==================== MEDLAB BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.35em 0.65em;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge-primary, .badge.bg-primary { background: var(--primary); color: #ffffff; }
.badge-success, .badge.bg-success { background: var(--success); color: #ffffff; }
.badge-warning, .badge.bg-warning { background: var(--warning); color: #ffffff; }
.badge-danger, .badge.bg-danger { background: var(--danger); color: #ffffff; }
.badge-info, .badge.bg-info { background: var(--info); color: #ffffff; }
.badge-neutral { background: #eef3f8; color: #475569; }

/* Subtle pill badges */
.badge-subtle-primary { background: var(--primary-subtle); color: var(--primary); }
.badge-subtle-success { background: var(--success-subtle); color: var(--success); }
.badge-subtle-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-subtle-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-subtle-info { background: var(--info-subtle); color: var(--info); }

/* ==================== FORMS & INPUTS ==================== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #31373d;
  margin-bottom: 0.375rem;
}

.form-control, .form-select {
  width: 100%;
  height: 38px;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-gray);
  background: #ffffff;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
  line-height: 1.5;
}

.form-control:focus, .form-select:focus {
  border-color: #88b5f7;
  box-shadow: 0 0 0 0.25rem rgba(17, 106, 239, 0.15);
}

textarea.form-control {
  height: auto;
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* ==================== SPLIT LAYOUTS ==================== */
.split-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: calc(100vh - var(--header-height) - var(--hero-header-height) - var(--tabbar-height) - 60px);
  height: auto;
  align-items: start;
}
@media (max-width: 992px) {
  .split-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }
}

.split-left {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  max-height: calc(100vh - var(--header-height) - var(--hero-header-height) - var(--tabbar-height) - 40px);
}

.split-right {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  overflow: visible;
  height: auto;
  min-height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* View Header */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.view-header-title-box {
  display: flex;
  flex-direction: column;
}
.view-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.view-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.view-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==================== MODAL SYSTEM ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}
.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  max-width: 680px;
  width: 92%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
  animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-card.modal-lg { max-width: 900px; }
.modal-card.modal-xl { max-width: 1100px; }

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

.modal-header {
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.btn-close-modal {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-close-modal:hover {
  background: #e2e8f0;
  color: var(--danger);
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  background: #ffffff;
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(40, 90, 185, 0.15);
  border-left: 4px solid var(--primary);
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 290px;
  max-width: 440px;
  animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--primary); }

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

/* ==================== CLINICAL COMPONENTS ==================== */
/* Levey-Jennings QC */
.qc-chart-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.qc-canvas {
  width: 100%;
  height: 260px;
  display: block;
}

/* Cryogenic Rack Matrix */
.tray-grid-container {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  background: #f1f5f9;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}
.tray-cell {
  aspect-ratio: 1;
  background: #ffffff;
  border: 1px solid var(--border-gray);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}
.tray-cell:hover {
  border-color: var(--primary);
  transform: scale(1.08);
  z-index: 5;
  box-shadow: var(--card-shadow);
}
.tray-cell.occupied {
  background: var(--primary-subtle);
  border-color: var(--primary-border-subtle);
  color: var(--primary);
}
.tray-cell.occupied::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 2px;
}

/* Phone Mockup Modal */
.phone-mockup-wrapper {
  display: flex;
  justify-content: center;
  padding: 10px;
}
.phone-device {
  width: 360px;
  height: 640px;
  border: 12px solid #1e293b;
  border-radius: 36px;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  position: relative;
}
.phone-notch {
  width: 140px;
  height: 18px;
  background: #1e293b;
  border-radius: 0 0 12px 12px;
  align-self: center;
  z-index: 10;
}
.phone-screen {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Raw code block for machine logs & HL7/ASTM */
.raw-code-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  border: 1px solid #1e293b;
}

/* Kinetic Trend Canvas */
.kinetics-canvas {
  width: 100%;
  height: 220px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  display: block;
}

/* ==================== MEDLAB FOOTER ==================== */
.app-footer {
  font-size: 0.7875rem;
  margin: 14px 0 6px 0;
  padding: 12px 18px;
  color: var(--text-muted);
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===================================================================
   RESPONSIVE DESIGN SYSTEM & ADAPTIVE BREAKPOINTS (NO BS5)
   Optimized for Tablets (iPad, Galaxy Tab) & Mobile Phones (iOS / Android)
   =================================================================== */

/* --- Responsive Utility Grid Classes --- */
.dashboard-analytics-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.responsive-2col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Sidebar Drawer Overlay */
.sidebar-overlay {
  display: none;
}

/* Base table scrolling touch optimization */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}
.table, .table-custom {
  min-width: 680px;
}

/* ==================== 1. TABLET BREAKPOINT (max-width: 992px) ==================== */
@media (max-width: 992px) {
  /* App Shell & Containers */
  .page-wrapper, .app-container {
    overflow-x: hidden;
    width: 100vw;
    max-width: 100vw;
    position: relative;
  }

  .main-container {
    position: relative;
    overflow-x: hidden;
    width: 100%;
  }

  .main-wrapper {
    width: 100%;
    min-width: 0;
    flex: 1;
  }

  /* Sidebar transforms into offcanvas drawer */
  .sidebar, .sidebar-wrapper {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px !important;
    height: 100vh !important;
    max-height: 100vh;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    display: flex !important;
    flex-direction: column;
    background: #ffffff;
  }

  /* When drawer is open on tablet/mobile */
  .sidebar.show-mobile {
    transform: translateX(0) !important;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.25) !important;
  }
  .sidebar.show-mobile .nav-text,
  .sidebar.show-mobile .nav-badge,
  .sidebar.show-mobile .sidebar-profile .profile-name,
  .sidebar.show-mobile .sidebar-profile .profile-role,
  .sidebar.show-mobile .sidebar-contact {
    display: block !important;
  }
  .sidebar.show-mobile .nav-item {
    justify-content: flex-start;
    padding: 7px 18px 7px 14px;
  }
  .sidebar.show-mobile .nav-icon {
    margin-right: 12px;
  }

  /* Sidebar Backdrop Overlay */
  .sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Header adjustments for Tablet */
  .clinic-branch-pill {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
    padding: 4px 10px;
    margin-left: 8px;
  }
  .search-container {
    width: 220px;
    margin: 0 10px;
  }
  .btn-quick-patient-portal span {
    display: none;
  }
  .btn-quick-patient-portal {
    padding: 6px 10px;
  }

  /* Viewport spacing */
  .workspace-viewport, .app-body {
    padding: 14px;
  }

  /* Dashboard grids */
  .medlab-col-8, .medflex-col-8,
  .medlab-col-4, .medflex-col-4,
  .medlab-col-6, .medflex-col-6,
  .medlab-col-3, .medflex-col-3 {
    flex: 0 0 100% !important;
    width: 100% !important;
  }
  .dashboard-analytics-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .responsive-2col-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Split layout */
  .split-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
    gap: 14px;
  }
  .split-left {
    max-height: 280px;
    overflow-y: auto;
  }
  .split-right {
    overflow: visible;
    height: auto;
  }
}

/* ==================== 2. MOBILE BREAKPOINT (max-width: 768px) ==================== */
@media (max-width: 768px) {
  /* Header in Mobile */
  .app-header {
    height: 50px;
    padding: 0 10px;
  }
  .search-container {
    display: none !important;
  }
  .clinic-branch-pill {
    display: none !important;
  }
  .brand-subtitle {
    display: none !important;
  }
  .brand-title {
    font-size: 14px;
  }
  .brand-logo-icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
  .app-brand {
    margin-left: 6px;
    gap: 6px;
  }
  .header-actions {
    gap: 6px;
    margin-left: auto;
  }
  .btn-icon-nav {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }
  .avatar-box {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  /* App Hero Header */
  .app-hero-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
    height: auto;
  }
  .breadcrumb {
    font-size: 11.5px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    width: 100%;
  }
  .day-sorting {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    width: 100%;
    gap: 4px;
  }
  .day-sorting .btn {
    flex-shrink: 0;
    height: 24px;
    padding: 0 8px;
    font-size: 11px;
  }

  /* Multi-tab Bar */
  .tab-bar-container {
    height: 36px;
    padding: 2px 8px 0;
    -webkit-overflow-scrolling: touch;
  }
  .workspace-tab {
    height: 30px;
    padding: 0 10px;
    font-size: 11.5px;
    max-width: 150px;
  }

  /* Workspace Viewport */
  .workspace-viewport, .app-body {
    padding: 10px;
  }

  /* View Header */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }
  .view-title {
    font-size: 16px;
  }
  .view-subtitle {
    font-size: 11.5px;
  }
  .view-header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .view-header-actions .btn {
    height: 30px;
    font-size: 11.5px;
    padding: 0 10px;
  }

  /* Doctor Welcome Banner */
  .card.bg-3 .card-body > div {
    min-height: auto !important;
    padding: 16px 12px !important;
  }
  .banner-doctor-name {
    font-size: 18px !important;
  }
  .banner-stats-row {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
    gap: 8px !important;
    margin-top: 14px !important;
  }
  .banner-stat-item {
    padding: 8px 10px;
    gap: 8px;
  }
  .banner-stat-item .icon-box.lg {
    width: 38px;
    height: 38px;
    font-size: 18px;
    margin-right: 8px !important;
  }
  .banner-stat-item .stat-text h2 {
    font-size: 18px;
  }

  /* Activity Progress Card */
  .card.bg-lime .card-body > div {
    min-height: auto !important;
    padding: 14px 12px !important;
  }
  .activity-chart-box {
    gap: 10px;
    padding: 10px 0;
  }
  .activity-circle-progress {
    width: 58px;
    height: 58px;
  }
  .activity-info-text {
    font-size: 12px;
  }

  /* Available Doctors & Timeline */
  .doc-grid, .timeline-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .doc-card {
    padding: 10px;
  }

  /* KPI Grid */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    margin-bottom: 14px;
  }
  .kpi-card {
    padding: 10px 12px;
  }
  .kpi-title {
    font-size: 0.75rem;
  }
  .kpi-value {
    font-size: 1.5rem;
  }
  .kpi-sub {
    font-size: 0.75rem;
  }

  /* Tables in Mobile */
  .table-outer {
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
  }
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .table, .table-custom {
    min-width: 680px;
    font-size: 0.875rem;
  }
  .table th {
    padding: 8px 10px;
    font-size: 0.7875rem;
  }
  .table td {
    padding: 8px 10px;
    font-size: 0.875rem;
  }

  /* Forms & Inputs in Mobile */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .form-group {
    margin-bottom: 10px;
  }
  .form-control, .form-select {
    height: 36px;
    font-size: 0.875rem;
  }

  /* Modals in Mobile */
  .modal-card {
    width: 95% !important;
    max-height: 94vh;
    margin: 8px;
    border-radius: var(--radius-md);
  }
  .modal-header {
    padding: 10px 14px;
  }
  .modal-title {
    font-size: 1rem;
  }
  .modal-body {
    padding: 12px;
  }
  .modal-footer {
    padding: 10px 14px;
    gap: 6px;
  }
  .phone-device {
    width: 100% !important;
    max-width: 320px;
    height: 480px;
    border-width: 8px;
    border-radius: 26px;
  }

  /* Clinical Canvas and Rack */
  .tray-grid-container {
    min-width: 480px;
    gap: 4px;
    padding: 8px;
  }
  .qc-canvas, .kinetics-canvas {
    height: 220px;
  }

  /* Footer */
  .app-footer {
    flex-direction: column;
    text-align: center;
    gap: 4px;
    font-size: 10.5px;
    padding: 8px 12px;
  }
}

/* ==================== 3. EXTRA SMALL MOBILE (max-width: 420px) ==================== */
@media (max-width: 420px) {
  .brand-title {
    font-size: 13px;
  }
  .brand-logo-icon {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }
  .toggle-sidebar {
    width: 30px;
    height: 30px;
  }
  .btn-icon-nav {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .avatar-box {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
  }
  .banner-stats-row {
    grid-template-columns: 1fr !important;
  }
}

/* ===================================================================
   HEMODIALYSIS & NEPHROLOGY UNIT DESIGN SYSTEM (MODULES 2, 3, 4, 5, 6, 7, 13, 14, 15)
   =================================================================== */

/* Ma trận 30 máy lọc máu (Sẵn sàng mở rộng 60 máy) */
.dialysis-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.machine-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  transition: all 0.25s ease;
  position: relative;
}

.machine-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.09);
}

.machine-card.running { border-left: 5px solid #10b981; }
.machine-card.ready { border-left: 5px solid #0284c7; }
.machine-card.disinfecting { border-left: 5px solid #f59e0b; }
.machine-card.alarm { 
  border-left: 5px solid #ef4444;
  animation: alarmPulse 1.8s infinite;
}
.machine-card.maintenance { border-left: 5px solid #64748b; background: #f8fafc; }

@keyframes alarmPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.machine-card-header {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.machine-card.running .machine-card-header { background: #ecfdf5; border-bottom-color: #d1fae5; }
.machine-card.alarm .machine-card-header { background: #fef2f2; border-bottom-color: #fee2e2; }
.machine-card.ready .machine-card-header { background: #f0f9ff; border-bottom-color: #e0f2fe; }
.machine-card.disinfecting .machine-card-header { background: #fffbeb; border-bottom-color: #fef3c7; }

.machine-badge-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.machine-card.running .machine-badge-status { background: #10b981; color: #fff; }
.machine-card.ready .machine-badge-status { background: #0284c7; color: #fff; }
.machine-card.disinfecting .machine-badge-status { background: #f59e0b; color: #fff; }
.machine-card.alarm .machine-badge-status { background: #ef4444; color: #fff; }
.machine-card.maintenance .machine-badge-status { background: #64748b; color: #fff; }

.machine-card-body {
  padding: 12px 14px;
}

.telemetry-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 8px;
  margin: 10px 0;
  text-align: center;
}

.telemetry-item-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13.5px;
  color: #0f172a;
}
.telemetry-item-lbl {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
}

/* TV Wall Fullscreen buồng thận */
.tv-wall-mode {
  background: #090d16 !important;
  color: #e2e8f0;
  padding: 16px;
  min-height: 100vh;
}
.tv-wall-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 16px;
}
.tv-wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.tv-wall-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px 12px;
  color: #f3f4f6;
  position: relative;
}
.tv-wall-card.running { border-left: 4px solid #10b981; }
.tv-wall-card.alarm { 
  border-left: 4px solid #ef4444;
  background: #271418;
  animation: alarmPulse 1.5s infinite;
}
.tv-wall-card.ready { border-left: 4px solid #0284c7; }
.tv-wall-card.disinfecting { border-left: 4px solid #f59e0b; }
.tv-wall-card.maintenance { border-left: 4px solid #4b5563; opacity: 0.7; }

/* Trạm RO P&ID Flowchart */
.ro-pipeline-diagram {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.ro-node {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
  min-width: 140px;
  flex: 1;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ro-node.active-pass {
  border-color: #0284c7;
  background: #f0f9ff;
}
.ro-node.safe-ok {
  border-color: #10b981;
  background: #ecfdf5;
}
.ro-arrow {
  color: #0284c7;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
}

/* Phiếu lọc máu điện tử 3 pha */
.phase-step-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}
.phase-step-pill.active {
  background: #0284c7;
  color: #ffffff;
}

/* Hide footer in TV Wall dark-mode */
#pane-tv-wall-buong-than.active ~ .app-footer {
  display: none !important;
}



