.dashboard-body {
  background-color: var(--bg-canvas);
  overflow-x: hidden;
}
.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: 0;
  line-height: 1;
}
.brand-logo {
  width: 34px;
  height: 28px;
  object-fit: contain;
}
.sidebar-nav {
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s;
}
.nav-item:hover,
.nav-item.active {
  background-color: rgba(2, 132, 199, 0.08);
  color: var(--primary-color);
}
.sidebar-footer {
  margin-top: auto;
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
}
.doc-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.doc-info {
  display: flex;
  flex-direction: column;
}
.doc-info strong {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 700;
}
.doc-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--success-color);
  background: rgba(22, 163, 74, 0.1);
  padding: 6px 14px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--success-color);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(22, 163, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px;
  align-items: start;
  max-width: 1440px;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.section-header h2 {
  font-size: 18px;
  color: var(--text-main);
  font-weight: 700;
}
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.queue-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.queue-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 6px 14px -2px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.queue-card.active {
  border-color: var(--primary-color);
  background: #f0f9ff;
  box-shadow: 0 6px 18px -2px rgba(2, 132, 199, 0.2);
}
.queue-card.active .token-number {
  background: var(--primary-color);
  color: white;
}
.token-number {
  font-size: 20px;
  font-weight: 800;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  min-width: 58px;
  text-align: center;
  letter-spacing: -0.02em;
}
.patient-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.patient-details strong {
  font-size: 15px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patient-details span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.consultation-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  min-width: 0;
  box-sizing: border-box;
}
.consultation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}
.consultation-header .eyebrow {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 6px;
}
.consultation-header h2 {
  font-size: 26px;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin: 0;
}

.visit-history-preview {
  margin-bottom: 20px;
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
}
.visit-history-preview summary {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-color);
  cursor: pointer;
}
.history-data {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}

.rx-table-wrap {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.prescription-builder {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.rx-table-header {
  display: grid !important;
  grid-template-columns:
    22px 64px minmax(100px, 2fr)
    44px 86px 82px 60px minmax(80px, 1.2fr) 26px !important;
  gap: 5px !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  align-items: center !important;
  background: #f8fafc;
  border-bottom: 1.5px solid #e2e8f0;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prescription-row {
  display: grid !important;
  grid-template-columns:
    22px 64px minmax(100px, 2fr)
    44px 86px 82px 60px minmax(80px, 1.2fr) 26px !important;
  gap: 5px !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  align-items: center !important;
  padding: 5px 6px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  transition: background-color 0.15s ease;
}
.prescription-row:last-child {
  border-bottom: none;
}
.prescription-row:hover {
  background-color: #f8fafc;
}
.rx-table-header > div,
.prescription-row > div,
.rx-dropdown-wrap,
.rx-custom-container {
  min-width: 0 !important;
  box-sizing: border-box !important;
}
.prescription-row .input,
.prescription-row select,
.prescription-row input {
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  min-width: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 4px 6px !important;
  font-size: 12px !important;
  border-radius: 5px !important;
  border: 1px solid #e2e8f0 !important;
  background: #ffffff !important;
  color: #0f172a !important;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.prescription-row .input:focus,
.prescription-row select:focus,
.prescription-row input:focus {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.12) !important;
  outline: none !important;
}
.prescription-row .rx-med {
  font-weight: 600 !important;
}
.prescription-row .btn-ghost {
  color: #94a3b8 !important;
  transition: all 0.15s ease;
}
.prescription-row .btn-ghost:hover {
  color: #ef4444 !important;
  background: #fee2e2 !important;
}

@media (max-width: 768px) {
  .prescription-row {
    grid-template-columns: 1fr; /* Stacks vertically on mobile so it doesn't get crushed */
  }
}
.add-medicine-btn {
  margin-top: 10px;
  border: 1px dashed #cbd5e1;
  color: var(--primary-color);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
  transition: all 0.2s ease;
}
.add-medicine-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(2, 132, 199, 0.08);
}
.consultation-actions {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 20px;
}

/* EXPANDED LAB FLOWSHEET STYLES */
.labs-modal-container {
  background: white;
  width: 100%;
  max-width: 1000px;
  max-height: 92vh;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.2);
}
.labs-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}
.labs-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.labs-entry-section {
  flex: 1.2;
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--color-border);
}
.labs-chart-section {
  flex: 0.8;
  padding: 24px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
}
.lab-category-title {
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
  margin-bottom: 12px;
  margin-top: 20px;
  font-size: 15px;
  font-weight: 700;
}
.lab-category-title:first-of-type {
  margin-top: 0;
}
.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.lab-input-group label {
  font-size: 12px;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}
.lab-input-abnormal {
  background-color: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #b91c1c !important;
  font-weight: 700;
}
.chart-container {
  flex: 1;
  min-height: 320px;
  position: relative;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
}

@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .queue-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 10px;
  }
  .queue-card {
    min-width: 250px;
  }
}
@media (max-width: 640px) {
  .prescription-row {
    grid-template-columns: 1fr;
  }
  .dashboard-layout {
    padding: 16px;
    gap: 20px;
  }
  .consultation-card {
    padding: 20px;
  }
  .labs-modal-body {
    flex-direction: column;
  }
  .labs-entry-section {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
}

/* PRINT ISOLATION RULES (Fixes Blank Second Page) */
.print-only,
#print-rx-layout,
#print-qr-layout,
#print-bill-layout {
  display: none;
}

@media print {
  /* Completely remove non-print elements from the document flow */
  body > :not(.print-only) {
    display: none !important;
  }
  html,
  body {
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: white !important;
  }

  /* Show only the active print layout */
  body.mode-rx #print-rx-layout {
    display: block !important;
    width: 100% !important;
    padding: 20px !important;
  }
  body.mode-qr #print-qr-layout {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    height: 100vh !important;
    padding: 40px !important;
  }
  body.mode-bill #print-bill-layout {
    display: block !important;
    width: 100% !important;
    padding: 20px !important;
  }

  @page {
    margin: 1cm;
    size: auto;
  }
}

/* LAB ABNORMAL HIGHLIGHTING */
.lab-input-abnormal {
  background-color: #ffcdd2 !important;
  color: #b71c1c !important;
  border-color: #ef4444 !important;
  font-weight: 700;
}

.lab-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-bottom: 20px;
}
.lab-input-group {
  display: grid;
  grid-template-columns: 2fr 1fr;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border-bottom: 1px solid #f1f5f9;
}
.lab-input-group label {
  font-size: 13px;
  color: #334155;
  font-weight: 500;
  text-align: right;
  padding-right: 10px;
}
.lab-input-group input {
  width: 100%;
  max-width: 150px;
}
