/* ==========================================================================
   DESIGN SYSTEM — ĐÔNG Y GIA TRUYỀN ĐỨC NGUYÊN ĐƯỜNG ERP (v3.0 UI/UX)
   Phong cách: Heritage Oriental Medicine × Modern Enterprise ERP
   Hướng dẫn tùy chỉnh thương hiệu nhanh:
   - Đổi bảng màu chủ đạo tại khối :root bên dưới (--forest-900, --gold, ...)
   - Đổi font chữ toàn hệ thống tại biến --font-sans
   ========================================================================== */

:root {
  /* 1. Brand Color Tokens */
  --forest-900: #0D3B2E;       /* Primary Forest Green (Sidebar, Brand Anchor) */
  --forest-800: #14532D;       /* Primary Hover / Deep Accent */
  --emerald-700: #166534;      /* Primary CTA Button / Active Stepper / Totals */
  --primary: #14532D;          /* Alias tương thích ngược cho 11 phân hệ hiện có */
  --primary-hover: #0D3B2E;
  --primary-soft: #EAF4EE;

  --gold: #C6A667;             /* Gold Heritage */
  --gold-dark: #A47A36;        /* Gold Dark */
  --gold-soft: #FAF3E3;        /* Active Sidebar Pill / Heritage Highlight */
  --ivory: #FAF8F3;            /* Warm Ivory Surface */

  /* 2. Neutral & Surface Tokens */
  --bg: #F7F8F5;               /* App Background */
  --card: #FFFFFF;             /* Card Background */
  --border: #E5E9E2;           /* Hairline Card & Table Border */
  --border-strong: #CFD8CC;    /* Input Border */
  --text: #172B24;             /* Main Text (WCAG AA > 12:1 on white) */
  --muted: #64746B;            /* Secondary Text (WCAG AA > 4.7:1 on white) */

  /* 3. Semantic Status Tokens */
  --success: #15803D;
  --success-soft: #DCFCE7;
  --warning: #B7791F;
  --accent: #B7791F;
  --accent-soft: #FEF3C7;
  --danger: #DC3545;
  --danger-soft: #FEE2E2;
  --info: #2563EB;
  --info-soft: #DBEAFE;

  /* 4. Typography, Spacing & Elevation */
  --font-sans: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-card: 14px;
  --radius: 14px;
  --radius-input: 9px;
  --shadow-xs: 0 1px 2px rgba(13, 59, 46, 0.04);
  --shadow: 0 2px 10px rgba(13, 59, 46, 0.05), 0 1px 2px rgba(13, 59, 46, 0.03);
  --shadow-lg: 0 14px 34px rgba(13, 59, 46, 0.14);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.ui-icon {
  flex-shrink: 0;
  vertical-align: middle;
}

/* ================= APP SHELL: SIDEBAR + 64PX HEADER ================= */
.erp-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 35, 27, 0.45);
  backdrop-filter: blur(2px);
  z-index: 55;
}

.erp-sidebar {
  width: 252px;
  background: linear-gradient(180deg, #0D3B2E 0%, #0A2E24 68%, #08241C 100%);
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(198, 166, 103, 0.28);
  z-index: 60;
  transition: width 0.2s ease, transform 0.22s ease;
}

.erp-sidebar::-webkit-scrollbar {
  width: 5px;
}
.erp-sidebar::-webkit-scrollbar-thumb {
  background: rgba(198, 166, 103, 0.25);
  border-radius: 99px;
}

/* Brand Crest (Top of Sidebar — Matching Heritage Reference) */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(198, 166, 103, 0.22);
  position: relative;
}

.brand-seal {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #215E46 0%, #0D3B2E 75%);
  color: #F5E3B8;
  font-weight: 800;
  font-size: 14.5px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 166, 103, 0.16), 0 4px 10px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
  margin-bottom: 8px;
}

.brand-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #FAF8F3;
  line-height: 1.32;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--gold);
  font-weight: 500;
  margin-top: 3px;
}

.brand-ornament {
  width: 96px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 166, 103, 0.7), transparent);
  margin-top: 8px;
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 10px 10px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.65px;
  color: var(--gold);
  padding: 12px 10px 4px;
  text-transform: uppercase;
  opacity: 0.92;
}

.nav-btn {
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(250, 248, 243, 0.88);
  padding: 8px 11px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-btn-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-btn-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover {
  background: rgba(250, 248, 243, 0.09);
  color: #FFFFFF;
}

.nav-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.nav-btn.active {
  background: linear-gradient(90deg, #FAF3E3 0%, #F5E9CE 100%);
  color: var(--forest-900);
  border-color: rgba(198, 166, 103, 0.75);
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.nav-btn.active .ui-icon {
  color: var(--emerald-700);
}

/* Sidebar Heritage Bottom Artwork */
.sidebar-footer {
  padding: 4px 12px 12px;
  margin-top: auto;
  position: relative;
}

.sidebar-heritage-svg {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0.92;
}

.sidebar-footer-caption {
  text-align: center;
  font-size: 11px;
  color: rgba(250, 248, 243, 0.66);
  margin-top: -4px;
}

/* Desktop Collapsed Rail Mode (74px) */
.erp-sidebar.collapsed {
  width: 74px;
}
.erp-sidebar.collapsed .brand-text-wrap,
.erp-sidebar.collapsed .brand-ornament,
.erp-sidebar.collapsed .nav-group-label,
.erp-sidebar.collapsed .nav-btn-label,
.erp-sidebar.collapsed .sidebar-footer {
  display: none;
}
.erp-sidebar.collapsed .sidebar-brand {
  padding: 14px 8px;
}
.erp-sidebar.collapsed .brand-seal {
  width: 42px;
  height: 42px;
  margin-bottom: 0;
}
.erp-sidebar.collapsed .nav-btn {
  justify-content: center;
  padding: 10px 0;
  position: relative;
}
.erp-sidebar.collapsed .badge-count {
  position: absolute;
  top: 4px;
  right: 6px;
  padding: 0 5px;
  font-size: 10px;
}

/* ================= TOP HEADER (64PX) ================= */
.erp-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.erp-header {
  height: 64px;
  background: linear-gradient(90deg, #FAF8F3 0%, #F7F5EC 55%, #FAF8F3 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: visible;
}

.header-oriental-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.header-oriental-svg {
  height: 64px;
  width: 560px;
  max-width: 60vw;
  margin-left: 120px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.hdr-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--forest-900);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.hdr-icon-btn:hover {
  background: var(--ivory);
  border-color: var(--gold);
}

.global-search-wrap {
  position: relative;
  flex: 1;
  max-width: 490px;
}

.global-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.global-search-box .search-prefix {
  position: absolute;
  left: 13px;
  color: var(--muted);
  display: inline-flex;
  pointer-events: none;
}

.global-search-box input {
  height: 40px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1px solid #DCE2D8;
  padding: 0 68px 0 38px;
  font-size: 13px;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.global-search-box input:focus {
  border-color: var(--emerald-700);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}

.ds-kbd {
  position: absolute;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #F3F5F1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: inherit;
  pointer-events: none;
}

.global-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 390px;
  overflow-y: auto;
  padding: 8px;
  z-index: 80;
}

.search-hit-item {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.search-hit-item:hover {
  background: var(--primary-soft);
}

/* Header Right Controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.facility-pill {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: #EEF5F0;
  border: 1px solid #CBE0D1;
  color: var(--forest-800);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.notif-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FAF8F3;
}

.hdr-dropdown-wrap {
  position: relative;
}

.hdr-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.hdr-user-trigger:hover {
  border-color: var(--gold);
  background: var(--ivory);
}

.hdr-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #166534 0%, #0D3B2E 100%);
  color: #FAF3E3;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--gold);
  flex-shrink: 0;
}

.hdr-user-meta {
  line-height: 1.22;
}
.hdr-user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}
.hdr-user-role {
  font-size: 11px;
  color: var(--muted);
}

.hdr-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 85;
}

.popover-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 11px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  text-align: left;
}
.popover-item:hover {
  background: var(--bg);
}
.popover-item.danger {
  color: var(--danger);
}
.popover-item.danger:hover {
  background: var(--danger-soft);
}

.badge-count {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  line-height: 1.45;
}
.badge-count.amber {
  background: var(--gold);
  color: var(--forest-900);
}

/* ================= MAIN CONTENT CONTAINER & GRIDS ================= */
.container {
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.grid-doctor {
  display: grid;
  grid-template-columns: minmax(0, 1.44fr) minmax(380px, 1fr);
  gap: 20px;
  align-items: start;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr);
  gap: 18px;
  align-items: start;
}

.grid-equal {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.grid-cashier {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.grid-doctor > *,
.grid-2 > *,
.grid-equal > *,
.grid-cashier > *,
.grid-3 > *,
.rx-patient-grid-top > *,
.rx-patient-grid-bottom > *,
.rx-summary-grid > *,
.form-row > * {
  min-width: 0;
}

input, select, textarea {
  max-width: 100%;
}

select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================= PAGE HEADER & 6-STEP CLINICAL STEPPER ================= */
.ds-page-header {
  margin-bottom: 14px;
}

.ds-page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ds-page-title-group {
  display: flex;
  align-items: center;
  gap: 13px;
}

.ds-page-emblem {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #FAF3E3 0%, #EFE2C2 100%);
  border: 1px solid rgba(198, 166, 103, 0.65);
  color: var(--forest-900);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.ds-page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--forest-900);
  letter-spacing: -0.25px;
  line-height: 1.25;
}

.ds-page-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.ds-breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.ds-bc-current {
  color: var(--forest-800);
  font-weight: 600;
}

/* 6-Step Real-Status Process Bar (Matching Heritage Mockup) */
.ds-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ivory);
  border: 1px solid #E8E4D8;
  border-radius: 14px;
  padding: 8px 12px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.ds-step-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid #E4DFD2;
  background: #FFFFFF;
  color: #495850;
  flex: 1;
  min-width: fit-content;
  transition: all 0.16s ease;
}

.ds-step-pill .ds-step-icon {
  color: var(--gold-dark);
  display: inline-flex;
}

.ds-step-pill.is-current {
  background: linear-gradient(135deg, #166534 0%, #0D3B2E 100%);
  color: #FFFFFF;
  border-color: #0D3B2E;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(13, 59, 46, 0.22);
}
.ds-step-pill.is-current .ds-step-icon {
  color: #F5E3B8;
}

.ds-step-pill.is-completed {
  background: #ECF8F0;
  border-color: #9ED5B0;
  color: var(--emerald-700);
}
.ds-step-pill.is-completed .ds-step-icon {
  color: var(--success);
}

.ds-step-arrow {
  color: #9CA8A0;
  display: inline-flex;
  flex-shrink: 0;
}

/* ================= SECTION CARDS & KPI STAT CARDS ================= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.ds-card-summary {
  border: 1.5px solid #C8DDD0;
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFDFB 100%);
}

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

.ds-card-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ds-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--ivory);
  border: 1px solid #E8DFC8;
  color: var(--gold-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--forest-900);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.ds-card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.ds-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--emerald-700);
  border-radius: var(--radius-card);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.kpi-card.gold { border-left-color: var(--gold); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-card.highlight {
  background: linear-gradient(135deg, #0D3B2E 0%, #166534 100%);
  color: #fff;
  border-color: #0D3B2E;
  border-left: 4px solid var(--gold);
}
.kpi-card.highlight .kpi-label,
.kpi-card.highlight .kpi-sub {
  color: #D7F3E2;
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.kpi-val {
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0 3px;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ================= UNIFIED FORMS, ICON INPUTS & STEPPERS ================= */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.rx-patient-grid-top {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(135px, 0.95fr) 105px 108px;
  gap: 12px;
  margin-bottom: 12px;
  align-items: end;
}

.rx-patient-grid-bottom {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(190px, 1.15fr) minmax(210px, 1.25fr);
  gap: 12px;
  margin-bottom: 6px;
}

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #2A3B33;
  margin-bottom: 5px;
}

.req-star {
  color: var(--danger);
  font-weight: 700;
}

input, select {
  width: 100%;
  min-height: 40px;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-input);
  font-size: 13.5px;
  font-family: inherit;
  background: #FFFFFF;
  color: var(--text);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-input);
  font-size: 13.5px;
  font-family: inherit;
  background: #FFFFFF;
  color: var(--text);
  line-height: 1.5;
  resize: vertical;
}

input[type="checkbox"], input[type="radio"] {
  height: 16px;
  min-height: 16px;
  width: 16px;
  accent-color: var(--emerald-700);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--emerald-700);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.13);
}

.ds-input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.ds-input-prefix {
  position: absolute;
  left: 11px;
  color: var(--muted);
  display: inline-flex;
  pointer-events: none;
}
.ds-input-icon-wrap input,
.ds-input-icon-wrap select {
  padding-left: 34px;
}

.ds-field.has-error input,
.input-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.12) !important;
}
.ds-field-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  font-weight: 500;
}

/* Quantity Stepper [-][input][+] */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #FFFFFF;
  overflow: hidden;
  height: 34px;
}

.qty-step-btn {
  width: 30px;
  height: 32px;
  border: none;
  background: #F6F8F5;
  color: var(--forest-900);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s ease;
}
.qty-step-btn:hover {
  background: var(--primary-soft);
}

.qty-stepper input {
  width: 52px;
  height: 32px;
  min-height: 32px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.qty-stepper input:focus {
  box-shadow: none;
}
/* Hide number spin arrows inside compact stepper */
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ================= BUTTONS & SUBTABS ================= */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  min-height: 40px;
  height: 40px;
  padding: 0 15px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--emerald-700);
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(13, 59, 46, 0.18);
}
.btn-primary:hover:not(:disabled) {
  background: var(--forest-900);
}

.btn-gold {
  background: linear-gradient(180deg, #D3B577 0%, #C6A667 100%);
  color: var(--forest-900);
  border-color: #B69352;
  font-weight: 700;
}
.btn-gold:hover:not(:disabled) {
  background: #B89554;
}

.btn-amber {
  background: var(--warning);
  color: #FFFFFF;
}
.btn-amber:hover:not(:disabled) {
  background: #976115;
}

.btn-outline {
  background: #FFFFFF;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) {
  background: var(--ivory);
  border-color: var(--gold);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--emerald-700);
  border-color: #C3DFCC;
}
.btn-soft:hover:not(:disabled) {
  background: #D9EDE0;
}

.btn-danger {
  background: #FFF5F5;
  color: var(--danger);
  border-color: #F8C9CE;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-lg {
  min-height: 44px;
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
}

.btn-sm {
  min-height: 32px;
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-icon-ghost {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-ghost:hover {
  background: var(--danger-soft);
  border-color: #F8C9CE;
}

.subnav-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #EDEFE9;
  padding: 5px;
  border-radius: 11px;
  margin-bottom: 16px;
}

.subnav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.subnav-btn.active {
  background: #FFFFFF;
  color: var(--forest-900);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ================= SEMANTIC STATUS BADGES ================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
.pill-amber { background: var(--accent-soft); color: #92560C; border: 1px solid #F7DC9C; }
.pill-gold { background: var(--gold-soft); color: #7C5A20; border: 1px solid #E6D5B0; }
.pill-green { background: var(--success-soft); color: #14532D; border: 1px solid #B7ECC8; }
.pill-blue { background: var(--info-soft); color: #1E40AF; border: 1px solid #BFDBFE; }
.pill-red { background: var(--danger-soft); color: #991B1B; border: 1px solid #FECACA; }
.pill-gray { background: #F1F3EF; color: #4B5563; border: 1px solid #E2E6DF; }

/* ================= TRADITIONAL FORMULA CARDS (4-COL MOCKUP STYLE) ================= */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tpl-card {
  position: relative;
  border: 1px solid #DFE5DC;
  background: var(--ivory);
  border-radius: 12px;
  padding: 11px 12px 26px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.tpl-card:hover {
  border-color: var(--emerald-700);
  background: #F4FAF6;
}

.tpl-card.is-selected {
  border: 2px solid var(--emerald-700);
  background: #EAF6EE;
  box-shadow: 0 3px 10px rgba(22, 101, 52, 0.1);
}

.tpl-card-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--forest-900);
  line-height: 1.35;
  padding-right: 22px;
  position: relative;
  z-index: 2;
}

.tpl-card-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  position: relative;
  z-index: 2;
}

.tpl-card-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--emerald-700);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tpl-herb-art {
  position: absolute;
  right: 4px;
  bottom: 2px;
  width: 54px;
  height: 38px;
  pointer-events: none;
  z-index: 1;
}

/* ================= DATA TABLES & PAGINATION ================= */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #FFFFFF;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  background: #F4F6F2;
  color: #36473E;
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #EEF1EC;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #FAFBF9;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.center {
  text-align: center;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 8px;
}

/* ================= SUMMARY TOTALS BOX (DOCTOR RIGHT CARD) ================= */
.rx-summary-grid {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-top: 6px;
}

.rx-totals-card {
  background: var(--ivory);
  border: 1px solid #E5DFD0;
  border-radius: 10px;
  padding: 10px 13px;
  min-width: 0;
}

.rx-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #46574E;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}

.rx-totals-grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 7px;
  border-top: 1px dashed #CBD5CB;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--forest-900);
}

.rx-totals-grand .grand-money {
  font-size: 19px;
  color: var(--emerald-700);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ================= SMART SEARCH COMBOBOX & DOCTOR EDIT BANNER ================= */
.smart-combo-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.smart-combo-prefix {
  position: absolute;
  left: 11px;
  color: var(--emerald-700);
  display: inline-flex;
  pointer-events: none;
  z-index: 2;
}

.smart-combo-input {
  width: 100%;
  height: 40px;
  padding: 8px 32px 8px 35px !important;
  border: 1.5px solid #C2D4C6;
  border-radius: var(--radius-input);
  background: #FFFFFF;
  font-size: 13.5px;
  color: var(--text);
}

.smart-combo-input:focus {
  border-color: var(--emerald-700);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.14);
}

.smart-combo-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #EFF2EC;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.smart-combo-clear:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.smart-combo-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: min(520px, 90vw);
  max-height: 320px;
  overflow-y: auto;
  background: #FFFFFF;
  border: 1px solid #CFD8CC;
  border-radius: 12px;
  box-shadow: 0 16px 38px rgba(13, 59, 46, 0.18);
  padding: 6px;
  z-index: 92;
}

.smart-combo-item {
  padding: 8px 11px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #F3F5F1;
  transition: background 0.1s ease;
}
.smart-combo-item:last-child {
  border-bottom: none;
}
.smart-combo-item:hover,
.smart-combo-item.is-active {
  background: #EAF6EE;
}

.smart-combo-empty {
  padding: 14px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.rx-edit-mode-banner {
  background: linear-gradient(90deg, #FAF3E3 0%, #EFF8F2 100%);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.recent-order-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-order-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.recent-order-row:hover {
  border-color: #BDD4C4;
  background: #FBFDFB;
}
.recent-order-row.is-editing {
  border: 2px solid var(--emerald-700);
  background: #EAF6EE;
}

.price-inline-input {
  width: 84px;
  height: 32px !important;
  min-height: 32px !important;
  padding: 4px 6px !important;
  text-align: right;
  font-weight: 600;
  font-size: 12.5px !important;
  font-variant-numeric: tabular-nums;
  border: 1px solid #CFD8CC;
  border-radius: 7px;
  background: #FFFFFF;
}

.price-inline-input.linetotal-input {
  width: 92px;
  font-weight: 700;
  color: var(--forest-900);
  background: #FAFDFB;
  border-color: #B9D4C2;
}

.price-inline-input::-webkit-outer-spin-button,
.price-inline-input::-webkit-inner-spin-button,
.summary-money-input::-webkit-outer-spin-button,
.summary-money-input::-webkit-inner-spin-button,
.summary-grand-input::-webkit-outer-spin-button,
.summary-grand-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.summary-money-input {
  width: 122px;
  height: 30px !important;
  min-height: 30px !important;
  padding: 3px 8px !important;
  text-align: right;
  font-weight: 700;
  font-size: 13px !important;
  font-variant-numeric: tabular-nums;
  border: 1px solid #D8D4C7;
  border-radius: 7px;
  background: #FFFFFF;
}

.summary-grand-input {
  width: 146px;
  height: 36px !important;
  min-height: 36px !important;
  padding: 4px 10px !important;
  text-align: right;
  font-weight: 800;
  font-size: 18px !important;
  color: var(--emerald-700) !important;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--emerald-700);
  border-radius: 8px;
  background: #FFFFFF;
}

/* Allow dropdown inside SectionCard to overflow cleanly */
.ds-section-card {
  overflow: visible !important;
}

/* ================= EMPTY, SKELETON, ERROR & DRAWER ================= */
.ds-empty-state {
  padding: 26px 16px;
  text-align: center;
  background: var(--ivory);
  border: 1px dashed #D8D4C7;
  border-radius: 12px;
  color: var(--muted);
}
.ds-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1px solid #E5DFD0;
  color: var(--gold-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.ds-empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--forest-900);
}
.ds-empty-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.ds-skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ds-skeleton-line {
  background: linear-gradient(90deg, #EEF1EC 25%, #F7F8F5 50%, #EEF1EC 75%);
  background-size: 200% 100%;
  animation: dsShimmer 1.4s infinite;
  border-radius: 9px;
}
@keyframes dsShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ds-error-state {
  background: var(--danger-soft);
  border: 1px solid #F8B4BC;
  color: #842029;
  padding: 12px 14px;
  border-radius: 10px;
}

/* Slide-over Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 35, 27, 0.42);
  backdrop-filter: blur(2px);
  z-index: 88;
  display: flex;
  justify-content: flex-end;
}

.ds-drawer-panel {
  width: 100%;
  max-width: 560px;
  height: 100vh;
  background: #FFFFFF;
  box-shadow: -12px 0 36px rgba(13, 35, 27, 0.22);
  display: flex;
  flex-direction: column;
  animation: drawerSlideIn 0.18s ease-out;
}
@keyframes drawerSlideIn {
  from { transform: translateX(28px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

.ds-drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--ivory);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ds-drawer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--forest-900);
}
.ds-drawer-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.ds-drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.ds-drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #FAFBF9;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ================= QUEUE, KANBAN & VIETQR (COMPATIBILITY) ================= */
.queue-item {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.queue-item:hover { border-color: var(--emerald-700); }
.queue-item.selected {
  border: 2px solid var(--emerald-700);
  background: #F2F9F4;
}

.kanban-col {
  background: #EFF2EC;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  min-height: 440px;
}
.kanban-header {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dispense-card {
  background: #fff;
  border-radius: 11px;
  padding: 13px;
  margin-bottom: 12px;
  border: 1px solid #DCE2D9;
  box-shadow: var(--shadow-xs);
}
.herb-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  border-bottom: 1px dashed #E5E7EB;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.herb-check-row:hover {
  background: #F4F8F5;
}
.herb-check-row.checked {
  background: #ECFDF5;
  border: 1px solid #86EFAC;
  color: #065F46;
  text-decoration: none;
  margin-bottom: 3px;
}

/* ================= 1-SCREEN EXECUTIVE COCKPIT & QUICK WORKFLOW BARS ================= */
.cockpit-ai-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #0D3B2E 0%, #166534 100%);
  color: #FAF3E3;
  border: 1px solid rgba(198, 166, 103, 0.55);
  border-radius: 13px;
  padding: 11px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.cockpit-kpi-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.cockpit-pipeline-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.cockpit-pipe-step {
  background: #FFFFFF;
  border: 1.5px solid #DCE4DC;
  border-radius: 12px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.cockpit-pipe-step:hover {
  border-color: var(--emerald-700);
  background: #FAFDFB;
  transform: translateY(-1px);
}
.cockpit-pipe-step.is-active {
  background: linear-gradient(135deg, #FAF3E3 0%, #EFF8F2 100%);
  border: 2px solid var(--emerald-700);
  box-shadow: 0 6px 16px rgba(13, 59, 46, 0.1);
}
.cockpit-pipe-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.cockpit-pipe-count {
  font-size: 21px;
  font-weight: 800;
  color: var(--forest-900);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.cockpit-pipe-sub {
  font-size: 11px;
  color: #5C6B62;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-service-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.quick-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 31px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid #C6D8CB;
  background: #F6FAF7;
  color: var(--forest-900);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.quick-chip-btn:hover {
  border-color: var(--emerald-700);
  background: #E8F5EC;
}
.quick-chip-btn.is-selected {
  background: var(--emerald-700);
  border-color: var(--emerald-700);
  color: #FFFFFF;
}

.fast-checkin-bar {
  background: linear-gradient(135deg, #FAF8F3 0%, #F2F8F4 100%);
  border: 1.5px solid #D5DFD5;
  border-radius: 13px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

@media (max-width: 1279px) {
  .cockpit-kpi-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cockpit-pipeline-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 767px) {
  .cockpit-kpi-5 {
    grid-template-columns: minmax(0, 1fr);
  }
  .cockpit-pipeline-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.vietqr-box {
  border: 2px dashed var(--emerald-700);
  background: #F7FBF8;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.vietqr-box img {
  max-width: 225px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #D1D5DB;
  background: #fff;
}

/* ================= LOGIN, WARNING BANNER, MODAL & TOAST ================= */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #166534 0%, #0D3B2E 58%, #07221A 100%);
}
.login-card {
  background: #FFFFFF;
  border-radius: 18px;
  max-width: 448px;
  width: 100%;
  padding: 30px 28px;
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.34);
  border: 1.5px solid var(--gold);
}

.pw-warning-banner {
  background: var(--gold-soft);
  border-bottom: 1px solid var(--gold);
  color: #78350F;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toast-box {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--forest-900);
  color: #FFFFFF;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(13, 35, 27, 0.24);
  border-left: 4px solid var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toast.error {
  background: #991B1B;
  border-left-color: #FCA5A5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 35, 27, 0.5);
  backdrop-filter: blur(2px);
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: #FFFFFF;
  border-radius: 16px;
  max-width: 740px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.26);
  border: 1px solid var(--border);
}
.modal-card.modal-xl {
  max-width: 1160px;
}

/* ================= RESPONSIVE BREAKPOINTS (DESKTOP / TABLET / MOBILE) ================= */
/* Compact Desktop / Large Tablet: 1025px – 1340px */
@media (max-width: 1340px) {
  .grid-doctor {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Tablet: 768px – 1279px */
@media (max-width: 1279px) {
  .erp-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px !important;
    transform: translateX(-100%);
  }
  .erp-sidebar.open {
    transform: translateX(0);
  }
  .grid-doctor,
  .grid-2,
  .grid-cashier {
    grid-template-columns: minmax(0, 1fr);
  }
  .tpl-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rx-patient-grid-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rx-patient-grid-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile: < 768px */
@media (max-width: 767px) {
  html, body, .erp-layout, .erp-main {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .erp-header {
    padding: 0 12px;
    gap: 8px;
  }
  .facility-pill,
  .hdr-user-meta,
  .ds-kbd,
  .header-oriental-art {
    display: none;
  }
  .container {
    padding: 14px 12px 40px;
    max-width: 100%;
  }
  .card {
    padding: 14px;
    max-width: 100%;
    overflow: hidden;
  }
  .ds-page-title {
    font-size: 20px;
  }
  .tpl-grid,
  .grid-equal,
  .grid-3,
  .rx-patient-grid-top,
  .rx-patient-grid-bottom,
  .rx-summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ================= PRINT STYLESHEET (A4 / K80 CLEAN PRINT) ================= */
#print-area {
  display: none;
}

/* ================= PREMIUM RECEPTION & APPOINTMENT MODULE (v3.4 — 3-COLUMN) ================= */
.rec-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.rec-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rec-kpi-card:hover {
  border-color: #CBD6C9;
  box-shadow: var(--shadow);
}
.rec-kpi-ic {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #EAF4EE;
  color: var(--emerald-700);
}
.rec-kpi-ic.amber {
  background: #FEF3C7;
  color: #B7791F;
}
.rec-kpi-ic.gold {
  background: #FAF3E3;
  color: #A47A36;
}
.rec-kpi-body {
  min-width: 0;
  flex: 1;
}
.rec-kpi-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-kpi-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.rec-kpi-trend {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--emerald-700);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-kpi-trend.down {
  color: #B7791F;
}
.rec-kpi-trend.muted {
  color: var(--muted);
  font-weight: 500;
}

/* 3-Column Desktop Layout (21.5% / 50% / 28.5%) */
.rec-3col-grid {
  display: grid;
  grid-template-columns: minmax(236px, 21.5fr) minmax(0, 50fr) minmax(305px, 28.5fr);
  gap: 16px;
  align-items: start;
}

.rec-panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

/* Left Column: Month Calendar & Filters */
.rec-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
}
.rec-cal-nav-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rec-cal-nav-btn:hover {
  background: var(--ivory);
  border-color: var(--emerald-700);
}
.rec-cal-month-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--forest-900);
}
.rec-cal-weekdays,
.rec-cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  gap: 2px;
}
.rec-cal-weekdays span {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 5px 0;
}
.rec-cal-day {
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto;
  width: 36px;
  transition: background 0.14s ease, color 0.14s ease;
}
.rec-cal-day:hover:not(.is-selected):not(.is-outside) {
  background: #EAF4EE;
  color: var(--forest-900);
}
.rec-cal-day.is-outside {
  color: #B8C2B9;
  cursor: default;
}
.rec-cal-day.is-today:not(.is-selected) {
  border: 1.5px solid var(--emerald-700);
  font-weight: 700;
  color: var(--emerald-700);
}
.rec-cal-day.is-selected {
  background: var(--forest-900);
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(13, 59, 46, 0.24);
}
.rec-cal-dot {
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--emerald-700);
  position: absolute;
  bottom: 3px;
}
.rec-cal-day.is-selected .rec-cal-dot {
  background: var(--gold);
}

.rec-filter-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.rec-filter-stack select {
  height: 40px;
  font-size: 13.5px;
}

/* Middle Column: Tabs, Table, 3-Dot Menu, Bottom Split */
.rec-stage-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.rec-stage-tab {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #F7F8F5;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.rec-stage-tab:hover {
  border-color: var(--emerald-700);
  color: var(--forest-900);
}
.rec-stage-tab.is-active {
  background: var(--emerald-700);
  border-color: var(--emerald-700);
  color: #FFFFFF;
}

.rec-appt-row-waiting {
  background: #FFFBEB !important;
}
.rec-appt-row-examining {
  background: #F0F9FF !important;
}

/* 3-Dot Action Dropdown Menu */
.rec-menu-wrap {
  position: relative;
  display: inline-flex;
}
.rec-dots-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rec-dots-btn:hover {
  background: var(--ivory);
  color: var(--forest-900);
  border-color: #C7D2C5;
}
.rec-dots-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  min-width: 215px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 75;
}
.rec-dots-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.rec-dots-item:hover {
  background: var(--primary-soft);
  color: var(--forest-900);
}
.rec-dots-item.danger {
  color: var(--danger);
}
.rec-dots-item.danger:hover {
  background: var(--danger-soft);
}

/* Middle Bottom Split: Waiting Queue + Quick Utilities */
.rec-mid-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(230px, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.rec-util-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.rec-util-tile {
  border: 1px solid var(--border);
  background: #FAFBF9;
  border-radius: 12px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.14s ease;
}
.rec-util-tile:hover:not(.is-disabled-honest) {
  background: #EAF4EE;
  border-color: var(--emerald-700);
  color: var(--forest-900);
  transform: translateY(-1px);
}
.rec-util-tile.is-disabled-honest {
  opacity: 0.78;
  background: #F5F6F4;
}
.rec-util-ic {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--emerald-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rec-util-label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}
.rec-util-sub {
  font-size: 10.5px;
  color: var(--muted);
}

/* Right Column: Segmented Booking / Walk-in Form */
.rec-form-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #F1F4EF;
  padding: 4px;
  border-radius: 11px;
  margin-bottom: 14px;
  gap: 4px;
}
.rec-form-tab {
  height: 38px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.rec-form-tab.is-active {
  background: var(--forest-900);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(13, 59, 46, 0.18);
}

.rec-form-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--forest-900);
  margin: 12px 0 8px;
}

.rec-switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ivory);
  border: 1px solid #E5DFD0;
  margin-top: 10px;
}
.rec-toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.rec-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.rec-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #CBD5CE;
  transition: 0.2s;
  border-radius: 999px;
}
.rec-toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}
.rec-toggle input:checked + .rec-toggle-slider {
  background-color: var(--emerald-700);
}
.rec-toggle input:checked + .rec-toggle-slider::before {
  transform: translateX(18px);
}

/* Numbered Page Buttons matching Reference Image */
.rec-page-num {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rec-page-num:hover:not(:disabled):not(.is-active) {
  background: #EAF4EE;
  border-color: var(--emerald-700);
}
.rec-page-num.is-active {
  background: var(--forest-900);
  border-color: var(--forest-900);
  color: #FFFFFF;
}
.rec-page-num:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 1380px) {
  .rec-3col-grid {
    grid-template-columns: 235px minmax(0, 1fr);
  }
  .rec-col-right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1024px) {
  .rec-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rec-3col-grid,
  .rec-mid-bottom-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .rec-kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .rec-panel-card {
    padding: 13px;
  }
}

/* ================= PREMIUM MINI CRM (v3.5 — 2 MENUS + MASTER-DETAIL) ================= */
.mcrm-menu-switch {
  display: inline-flex;
  background: #ECEFE9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  border: 1px solid var(--border);
}
.mcrm-menu-btn {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}
.mcrm-menu-btn:hover {
  color: var(--forest-900);
}
.mcrm-menu-btn.is-active {
  background: var(--forest-900);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(13, 59, 46, 0.18);
}

.mcrm-kpi-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.mcrm-split-layout {
  display: grid;
  grid-template-columns: minmax(310px, 37fr) minmax(0, 63fr);
  gap: 16px;
  align-items: start;
}

.mcrm-cust-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 2px;
}

.mcrm-cust-item {
  width: 100%;
  border: 1px solid var(--border);
  background: #FFFFFF;
  border-radius: 12px;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}
.mcrm-cust-item:hover {
  border-color: var(--emerald-700);
  background: #FAFDFB;
}
.mcrm-cust-item.is-selected {
  border: 1.5px solid var(--emerald-700);
  background: #EFF8F2;
  box-shadow: 0 3px 10px rgba(22, 101, 52, 0.08);
}

.mcrm-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0D3B2E 0%, #166534 100%);
  color: #FAF3E3;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(198, 166, 103, 0.6);
}
.mcrm-avatar.lg {
  width: 54px;
  height: 54px;
  font-size: 18px;
}

.mcrm-profile-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 14px 0 16px;
  flex-wrap: wrap;
}
.mcrm-ptab-btn {
  border: none;
  background: transparent;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.mcrm-ptab-btn:hover {
  color: var(--forest-900);
}
.mcrm-ptab-btn.is-active {
  color: var(--forest-900);
  border-bottom-color: var(--emerald-700);
}

.mcrm-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}
.mcrm-info-box {
  padding: 10px 12px;
  background: #FAFBF9;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.mcrm-info-lbl {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}
.mcrm-info-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.mcrm-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mcrm-tl-row {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #FFFFFF;
  align-items: flex-start;
}
.mcrm-tl-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #EAF4EE;
  color: var(--emerald-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 1120px) {
  .mcrm-split-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 767px) {
  .mcrm-kpi-3,
  .mcrm-info-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #print-area,
  #print-area * {
    visibility: visible;
  }
  #print-area {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 12px;
    color: #000;
    background: #fff;
    font-size: 13px;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
  }
  .print-table th,
  .print-table td {
    border: 1px solid #333;
    padding: 6px 8px;
  }
}
