/* =========================================================
   IRCA MEDICAL DISPENSING SOFTWARE - DESIGN SYSTEM
   ========================================================= */

:root {
  --bg-primary: #090D16;
  --bg-secondary: #0F172A;
  --bg-card: rgba(30, 41, 59, 0.65);
  --bg-card-hover: rgba(51, 65, 85, 0.75);
  --bg-card-solid: #1E293B;
  --bg-glass: rgba(15, 23, 42, 0.85);

  --border-subtle: rgba(148, 163, 184, 0.12);
  --border-medium: rgba(148, 163, 184, 0.22);
  --border-glow: rgba(59, 130, 246, 0.35);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-white: #FFFFFF;

  --accent-blue: #3B82F6;
  --accent-blue-glow: rgba(59, 130, 246, 0.25);
  --accent-emerald: #10B981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06B6D4;
  --accent-purple: #8B5CF6;
  --accent-amber: #F59E0B;
  --accent-rose: #F43F5E;
  --accent-red: #EF4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px -3px rgba(59, 130, 246, 0.3);

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

/* ================= Layout Structure ================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.brand-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10B981, #06B6D4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
}

.brand-icon {
  width: 24px;
  height: 24px;
  color: #FFFFFF;
}

.brand-text h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-white);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Navigation Links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  width: 100%;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-blue);
}

.nav-item.active svg {
  color: var(--accent-blue);
  filter: drop-shadow(0 0 6px var(--accent-blue));
}

.badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.badge-emerald { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #A78BFA; }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.badge-rose { background: rgba(244, 63, 94, 0.15); color: #FB7185; }

/* Status Box */
.sidebar-status-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #34D399;
  margin-bottom: 4px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10B981;
  box-shadow: 0 0 8px #10B981;
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; filter: drop-shadow(0 0 6px #10B981); }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ================= Main Content ================= */
.main-content {
  flex: 1;
  padding: 28px 36px;
  overflow-y: auto;
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
}

/* Top Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.header-search-wrap {
  position: relative;
  flex: 1;
  max-width: 580px;
}

.header-search-wrap input {
  width: 100%;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 18px 12px 44px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

.header-search-wrap input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #192231;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #60A5FA, #3B82F6);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-emerald {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-emerald:hover {
  background: linear-gradient(135deg, #34D399, #10B981);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: #FFFFFF;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #F87171, #EF4444);
}

.btn-outline {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(148, 163, 184, 0.4);
}

.btn-outline-glass {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  width: 100%;
}
.btn-outline-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-glow {
  box-shadow: 0 0 18px var(--accent-blue-glow);
}

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

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
}

.kpi-emerald::before { background: linear-gradient(90deg, #10B981, transparent); }
.kpi-blue::before { background: linear-gradient(90deg, #3B82F6, transparent); }
.kpi-amber::before { background: linear-gradient(90deg, #F59E0B, transparent); }
.kpi-purple::before { background: linear-gradient(90deg, #8B5CF6, transparent); }

.kpi-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  border-color: var(--border-medium);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.kpi-card:active {
  transform: translateY(-1px);
}

.kpi-icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-emerald .kpi-icon-wrap { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.kpi-blue .kpi-icon-wrap { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.kpi-amber .kpi-icon-wrap { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.kpi-purple .kpi-icon-wrap { background: rgba(139, 92, 246, 0.15); color: #A78BFA; }

.kpi-icon-wrap svg {
  width: 22px;
  height: 22px;
}

.kpi-body {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
  margin: 4px 0 2px 0;
  font-family: var(--font-mono);
}

.kpi-hint {
  font-size: 0.72rem;
  font-weight: 500;
}
.text-emerald { color: #34D399; }
.text-blue { color: #60A5FA; }
.text-amber { color: #FBBF24; }
.text-purple { color: #A78BFA; }

/* ================= Tab Controls & Sections ================= */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.01em;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ================= Active Patient Cards Grid ================= */
.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.patient-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.patient-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.35);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.12);
}

.patient-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.patient-reg-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.25);
  letter-spacing: 0.05em;
}

.patient-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #34D399;
  background: rgba(16, 185, 129, 0.1);
  padding: 3px 8px;
  border-radius: 20px;
}

.patient-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 4px;
}

.patient-name-link {
  color: var(--text-white);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, text-decoration 0.15s ease;
  cursor: pointer;
}
.patient-name-link:hover {
  color: #60A5FA !important;
  text-decoration: underline !important;
}

.patient-substance-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.substance-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}
.substance-opioids { background: rgba(139, 92, 246, 0.2); color: #C4B5FD; border: 1px solid rgba(139, 92, 246, 0.3); }
.substance-alcohol { background: rgba(245, 158, 11, 0.2); color: #FCD34D; border: 1px solid rgba(245, 158, 11, 0.3); }
.substance-cannabis { background: rgba(16, 185, 129, 0.2); color: #6EE7B7; border: 1px solid rgba(16, 185, 129, 0.3); }
.substance-sedatives { background: rgba(59, 130, 246, 0.2); color: #93C5FD; border: 1px solid rgba(59, 130, 246, 0.3); }
.substance-inhalants { background: rgba(244, 63, 94, 0.2); color: #FDA4AF; border: 1px solid rgba(244, 63, 94, 0.3); }
.substance-default { background: rgba(148, 163, 184, 0.2); color: #CBD5E1; border: 1px solid rgba(148, 163, 184, 0.3); }

.patient-details-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 18px;
  background: rgba(15, 23, 42, 0.4);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.08);
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-val {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-card-actions {
  display: flex;
  gap: 10px;
}

.patient-card-actions .btn {
  flex: 1;
}

/* ================= Tables ================= */
.inventory-table-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-sm {
  max-width: 280px;
}

.inventory-status-pills {
  display: flex;
  gap: 8px;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn:hover, .pill-btn.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  border-color: var(--accent-blue);
}

.table-responsive {
  overflow-x: auto;
}

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

.data-table th {
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-medium);
  background: rgba(15, 23, 42, 0.4);
}

.data-table td {
  padding: 14px;
  font-size: 0.88rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Stock Progress Bars */
.stock-cell-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-meter {
  width: 80px;
  height: 6px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.stock-meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.meter-ok { background: #10B981; }
.meter-low { background: #F59E0B; }
.meter-out { background: #EF4444; }

.status-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-block;
}
.status-pill.ok { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.status-pill.low { background: rgba(245, 158, 11, 0.15); color: #FBBF24; animation: pulseAmber 2s infinite; }
.status-pill.out { background: rgba(239, 68, 68, 0.15); color: #F87171; }

@keyframes pulseAmber {
  0% { opacity: 0.8; }
  50% { opacity: 1; filter: drop-shadow(0 0 4px #F59E0B); }
  100% { opacity: 0.8; }
}

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

.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-textarea {
  resize: vertical;
}

/* ================= Workbench & Drag-Drop Studio ================= */
.modal-dialog.modal-xl.workbench-dialog {
  max-width: 1240px;
  width: 95vw;
  height: 90vh;
  max-height: 900px;
  background: #0D1322;
  display: flex;
  flex-direction: column;
}

.workbench-header {
  padding: 16px 24px;
  background: #111A2E;
  border-bottom: 1px solid var(--border-medium);
}

.workbench-badge {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  color: #34D399;
}

.workbench-patient-quickinfo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  margin-right: 16px;
}

.patient-header-chip {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.patient-header-chip strong {
  color: var(--text-white);
}

/* Recommended Protocol Bar */
.protocol-bar {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.protocol-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #60A5FA;
}

.protocol-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.protocol-quick-btn {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93C5FD;
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.protocol-quick-btn:hover {
  background: #3B82F6;
  color: #FFFFFF;
  transform: translateY(-1px);
}

/* Main Workbench Layout */
.workbench-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Drawer: Medicine Catalog */
.workbench-drawer {
  width: 330px;
  background: #0F172A;
  border-right: 1px solid var(--border-medium);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.8);
}

.drawer-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.drawer-title-wrap h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-white);
}

.drawer-search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.drawer-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-xs {
  padding: 6px 10px 6px 30px !important;
  font-size: 0.8rem !important;
  border-radius: var(--radius-md) !important;
  height: 32px;
}

.drawer-filters {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.drawer-filter-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.drawer-filter-btn:hover, .drawer-filter-btn.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  border-color: var(--accent-blue);
}

.drawer-meds-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Draggable Medicine Card */
.drag-med-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: grab;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.drag-med-card:hover {
  background: #243248;
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.drag-med-card:active {
  cursor: grabbing;
}

.drag-med-card.is-dragging {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--accent-blue);
}

.drag-med-card.is-out-of-stock {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.drag-med-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.drag-grip {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
}

.drag-med-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-white);
  flex: 1;
}

.drag-med-type {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.drag-med-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drag-med-stock {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: #34D399;
}
.drag-med-stock.stock-low { color: #FBBF24; }
.drag-med-stock.stock-out { color: #F87171; }

.drag-quick-slots {
  display: flex;
  gap: 4px;
}

.slot-quick-add {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.68rem;
  padding: 2px 5px;
  cursor: pointer;
  transition: all 0.1s ease;
}
.slot-quick-add:hover {
  background: var(--accent-blue);
  color: #FFFFFF;
}

/* Right Side: Schedule & 3 Slots */
.workbench-schedule {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #090D16;
  padding: 16px;
  overflow-y: auto;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  flex: 1;
  margin-bottom: 14px;
}

.schedule-slot-card {
  background: #11192C;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
}

.slot-morning { border-top: 3px solid #F59E0B; }
.slot-lunch { border-top: 3px solid #06B6D4; }
.slot-dinner { border-top: 3px solid #8B5CF6; }

.slot-header {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slot-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-icon {
  font-size: 1.25rem;
}

.slot-title-wrap h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
}

.slot-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.slot-item-count {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-secondary);
}

/* Dropzone Area */
.slot-dropzone {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  transition: all 0.2s ease;
  background: rgba(13, 19, 34, 0.4);
}

.slot-dropzone.drag-over {
  background: rgba(59, 130, 246, 0.12);
  border: 2px dashed #3B82F6;
  box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.2);
}

.dropzone-empty-hint {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  border: 2px dashed rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  padding: 24px 12px;
}

.dropzone-empty-hint svg {
  width: 28px;
  height: 28px;
  margin-bottom: 6px;
  opacity: 0.4;
}

/* Item Card inside Slot Dropzone */
.slot-med-item {
  background: #1B263B;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.slot-med-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.slot-med-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-white);
}

.slot-med-type-badge {
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.btn-remove-slot-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.btn-remove-slot-item:hover {
  color: #EF4444;
}

.slot-med-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.stepper-wrap {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  overflow: hidden;
}

.stepper-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
}
.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.stepper-val {
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #60A5FA;
  min-width: 22px;
  text-align: center;
}

.meal-timing-toggle {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34D399;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.meal-timing-toggle.before-meal {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #FBBF24;
}

/* ================= Log Modes & Navigation ================= */
.log-mode-switcher {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
}

.mode-tab-btn, .mode-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-tab-btn:hover, .mode-btn:hover {
  color: var(--text-white);
}

.mode-tab-btn.active, .mode-btn.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.logs-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  flex-wrap: wrap;
}

.date-navigator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input-sm {
  max-width: 155px;
  padding: 5px 10px !important;
  font-size: 0.82rem !important;
  height: 30px;
}

.slot-filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.slot-filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.slot-filter-btn:hover, .slot-filter-btn.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  border-color: var(--accent-blue);
}

.patient-select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.patient-log-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* Phase Navigation Tabs inside Workbench */
.phase-tabs-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  width: 100%;
}

.phase-tabs-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  flex: 1;
  scrollbar-width: thin;
}

.phase-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}

.phase-tab:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--text-primary);
}

.phase-tab.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
  border-color: #10B981;
  color: #FFFFFF;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.phase-tab-num {
  font-weight: 700;
  color: #34D399;
}

.phase-tab.active .phase-tab-num {
  color: #6EE7B7;
}

.phase-tab-details {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.phase-tab.active .phase-tab-details {
  color: #A7F3D0;
}

.phase-tab-count {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.phase-tab.active .phase-tab-count {
  background: rgba(16, 185, 129, 0.3);
  color: #FFFFFF;
}

.btn-add-phase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-add-phase:hover {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

/* Active Phase Configuration Bar inside Workbench */
.phase-config-bar {
  width: 100%;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 12px;
}

.phase-config-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.phase-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phase-field-label {
  font-size: 0.75rem !important;
  margin-bottom: 0 !important;
  white-space: nowrap;
  color: #94A3B8;
}

.phase-date-input {
  padding: 4px 8px !important;
  font-size: 0.8rem !important;
  width: 135px !important;
  height: 30px !important;
  border-radius: var(--radius-sm) !important;
}

.phase-duration-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.duration-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.duration-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #60A5FA;
}

.duration-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.2);
  color: #93C5FD;
  padding: 2px 8px;
  border-radius: 10px;
}

.duration-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.duration-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.duration-chip:hover, .duration-chip.active {
  background: #10B981;
  color: #FFFFFF;
  border-color: #10B981;
}

.custom-days-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.custom-days-input {
  width: 55px !important;
  height: 26px !important;
  padding: 2px 6px !important;
  font-size: 0.75rem !important;
  text-align: center;
}

.phase-quick-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-phase-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-phase-action:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93C5FD;
}

.btn-phase-delete {
  color: #F87171;
}

.btn-phase-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
}

.phase-frequency-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.frequency-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.frequency-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #F59E0B;
}

.frequency-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.2);
  color: #FCD34D;
  padding: 2px 8px;
  border-radius: 10px;
}

.frequency-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.frequency-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.frequency-chip:hover, .frequency-chip.active {
  background: #F59E0B;
  color: #0F172A;
  font-weight: 700;
  border-color: #F59E0B;
}

/* Scheduled Calendar Dates Preview Strip */
.phase-schedule-strip {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}

.schedule-strip-info {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.strip-icon {
  font-size: 0.95rem;
}

.strip-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.phase-dates-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.schedule-date-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #BFDBFE;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.schedule-date-pill .pill-day {
  color: #60A5FA;
  font-size: 0.68rem;
  opacity: 0.85;
}

.schedule-date-pill.is-today {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6EE7B7;
}

/* Item cadence pill */
.item-cadence-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: #93C5FD;
  border: 1px solid rgba(59, 130, 246, 0.35);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.item-cadence-badge:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.item-cadence-badge.cadence-daily {
  background: rgba(59, 130, 246, 0.15);
  color: #93C5FD;
  border-color: rgba(59, 130, 246, 0.35);
}

.item-cadence-badge.cadence-alternate {
  background: rgba(245, 158, 11, 0.18);
  color: #FCD34D;
  border-color: rgba(245, 158, 11, 0.45);
}

.item-cadence-badge.cadence-weekly {
  background: rgba(168, 85, 247, 0.2);
  color: #D8B4FE;
  border-color: rgba(168, 85, 247, 0.45);
}

/* Stock Calibration Grid */
.calibrate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.calibrate-item {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calibrate-item-info {
  display: flex;
  flex-direction: column;
}

.calibrate-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-white);
}

.calibrate-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.calibrate-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calibrate-stock-input {
  width: 75px !important;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 5px !important;
  height: 32px !important;
}

/* ================= Patient Timeline View (By Patient Mode) ================= */
.patient-timeline-header {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.85));
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.timeline-patient-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.timeline-patient-info {
  flex: 1;
  min-width: 200px;
}

.timeline-patient-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-white);
  margin: 0 0 4px 0;
}

.timeline-patient-substance {
  font-size: 0.88rem;
  font-weight: 600;
  color: #FBBF24;
}

.timeline-stat-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.timeline-stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.timeline-stat-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-white);
  font-family: var(--font-mono);
}

.timeline-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.slot-time-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Date column in timeline */
.timeline-date-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-date-main {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-white);
  font-family: var(--font-mono);
}

.timeline-date-day {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.timeline-date-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 2px;
  width: fit-content;
}

.timeline-date-badge.today {
  background: rgba(16, 185, 129, 0.2);
  color: #34D399;
}

.timeline-date-badge.future {
  background: rgba(59, 130, 246, 0.15);
  color: #93C5FD;
}

.timeline-date-badge.past {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

/* Medicine cell inside a slot column */
.timeline-med-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-med-item {
  background: rgba(15, 23, 42, 0.45);
  border-left: 3px solid var(--border-subtle);
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-med-item.slot-morning {
  border-left-color: #F59E0B;
}
.timeline-med-item.slot-lunch {
  border-left-color: #06B6D4;
}
.timeline-med-item.slot-dinner {
  border-left-color: #8B5CF6;
}

.timeline-med-name {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text-white);
}

.timeline-med-detail {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-med-qty {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #34D399;
  background: rgba(16, 185, 129, 0.1);
  padding: 0 5px;
  border-radius: 4px;
}

.timeline-meal-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: #A78BFA;
  background: rgba(139, 92, 250, 0.1);
  padding: 0 5px;
  border-radius: 4px;
}

.timeline-empty-slot {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
  padding: 8px 0;
}

/* ================= Sidebar Section Divider & Title ================= */
.sidebar-section-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 10px 10px 10px;
}

.sidebar-section-title {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 14px;
  margin-bottom: 6px;
}

/* ================= Pharmacy Issue Register (Form XVIII Ledger) ================= */
.issue-register-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.issue-register-table th, 
.issue-register-table td {
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: center;
  font-size: 0.82rem;
  padding: 6px 8px;
}

.issue-register-table th:first-child,
.issue-register-table td:first-child {
  text-align: center;
  width: 36px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.issue-register-table th:nth-child(2),
.issue-register-table td:nth-child(2) {
  text-align: left;
  font-weight: 700;
  color: var(--text-white);
  min-width: 170px;
  background: rgba(15, 23, 42, 0.7);
  position: sticky;
  left: 0;
  z-index: 5;
}

.issue-date-header {
  background: rgba(30, 41, 59, 0.9) !important;
  font-family: var(--font-mono);
  font-weight: 800;
  color: #60A5FA;
  border-bottom: 1px solid var(--border-medium) !important;
}

.issue-sub-header {
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  padding: 4px 6px !important;
}

.sub-rec {
  color: #34D399 !important;
  background: rgba(16, 185, 129, 0.08) !important;
}

.sub-iss {
  color: #F87171 !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

.sub-bal {
  color: #FBBF24 !important;
  background: rgba(245, 158, 11, 0.08) !important;
}

.val-rec {
  color: #34D399;
  font-weight: 700;
  font-family: var(--font-mono);
}

.val-iss {
  color: #F87171;
  font-weight: 700;
  font-family: var(--font-mono);
}

.val-bal {
  color: var(--text-white);
  font-weight: 800;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.03);
}

.val-empty {
  color: var(--text-muted);
  opacity: 0.3;
}

/* Print Styles for Form XVIII Register */
@media print {
  body * {
    visibility: hidden;
  }
  .print-section, .print-section * {
    visibility: visible;
  }
  .print-section {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: #fff !important;
    color: #000 !important;
  }
  .issue-register-table th, .issue-register-table td {
    color: #000 !important;
    border-color: #ccc !important;
  }
}


@media (max-width: 960px) {
  .workbench-body {
    flex-direction: column;
    overflow-y: auto;
  }
  .workbench-drawer {
    width: 100%;
    height: 240px;
  }
  .slots-grid {
    grid-template-columns: 1fr;
  }
}


/* ================= Modals ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background: #131D31;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-dialog.modal-lg {
  max-width: 780px;
}
.modal-dialog.modal-sm {
  max-width: 420px;
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-icon-badge svg {
  width: 22px;
  height: 22px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-white);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.btn-close:hover {
  color: var(--text-white);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 10px;
}

/* Quick Refill Box */
.refill-current-box {
  display: flex;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.5);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.refill-current-box strong {
  font-family: var(--font-mono);
  color: #34D399;
}

.quick-refill-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.btn-chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-chip:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent-blue);
  color: #60A5FA;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1E293B;
  border-left: 4px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--text-white);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  font-size: 0.88rem;
  animation: slideInRight 0.25s ease;
}

.toast-success { border-left-color: #10B981; }
.toast-error { border-left-color: #EF4444; }
.toast-warning { border-left-color: #F59E0B; }

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

/* Loading Spinner */
.loading-spinner-wrap {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(148, 163, 184, 0.15);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================= Enhanced Purchase Register Visual System ================= */
.physical-register-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.physical-register-table th {
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  color: #94A3B8;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  padding: 14px 16px;
  border-bottom: 2px solid rgba(245, 158, 11, 0.35);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.physical-register-table th:last-child {
  border-right: none;
}

.date-group-cell {
  background: rgba(15, 23, 42, 0.85) !important;
  border-right: 2px solid rgba(245, 158, 11, 0.4) !important;
  vertical-align: middle !important;
  text-align: center !important;
  padding: 16px 12px !important;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(99, 102, 241, 0.15));
  color: #93C5FD;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.88rem;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.sl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.1));
  color: #FBBF24;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.95rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
  margin: 0 auto;
}

/* Dosage Type Tags */
.dosage-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
  text-transform: uppercase;
}

.dosage-tag-tab { background: rgba(6, 182, 212, 0.15); color: #22D3EE; border: 1px solid rgba(6, 182, 212, 0.3); }
.dosage-tag-cap { background: rgba(168, 85, 247, 0.15); color: #C084FC; border: 1px solid rgba(168, 85, 247, 0.3); }
.dosage-tag-syp { background: rgba(245, 158, 11, 0.15); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.3); }
.dosage-tag-ont { background: rgba(16, 185, 129, 0.15); color: #34D399; border: 1px solid rgba(16, 185, 129, 0.3); }
.dosage-tag-gen { background: rgba(148, 163, 184, 0.15); color: #CBD5E1; border: 1px solid rgba(148, 163, 184, 0.3); }

/* Quantity & Pack Chips */
.pack-format-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.05);
  color: #FDE68A;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(253, 230, 138, 0.2);
  margin-right: 6px;
}

.units-intake-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.purchase-amount-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.05));
  color: #FBBF24;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.05rem;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Verification Signature Box */
.verified-seal-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.verified-stamp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ================= Modern Challan Cards ================= */
.challan-card-modern {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  margin-bottom: 20px;
}

.challan-card-modern:hover {
  transform: translateY(-3px);
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.challan-header-modern {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.45) 0%, rgba(15, 23, 42, 0.95) 100%);
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.challan-icon-tile {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.1));
  border: 1.5px solid rgba(96, 165, 250, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: #60A5FA;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  flex-shrink: 0;
}

.challan-val-display {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 900;
  background: linear-gradient(135deg, #6EE7B7, #10B981);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(16, 185, 129, 0.2);
}

.challan-footer-modern {
  background: rgba(15, 23, 42, 0.65);
  padding: 12px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ================= Redesigned Purchase KPI Cards ================= */
.purchase-kpi-card {
  position: relative;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 22px 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
}

.purchase-kpi-card:hover {
  transform: translateY(-4px);
}

/* Blue Variant */
.purchase-kpi-blue {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.35) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 8px 24px -6px rgba(30, 58, 138, 0.3);
}

.purchase-kpi-blue:hover {
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow: 0 12px 32px -6px rgba(59, 130, 246, 0.45);
}

/* Emerald Variant */
.purchase-kpi-emerald {
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.38) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 8px 24px -6px rgba(6, 78, 59, 0.35);
}

.purchase-kpi-emerald:hover {
  border-color: rgba(52, 211, 153, 0.65);
  box-shadow: 0 12px 32px -6px rgba(16, 185, 129, 0.45);
}

.purchase-kpi-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.purchase-kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.blue-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.emerald-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.purchase-kpi-meta {
  display: flex;
  flex-direction: column;
}

.purchase-kpi-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.purchase-kpi-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-white);
  margin: 2px 0 0 0;
}

.purchase-kpi-body {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.purchase-kpi-val {
  font-family: var(--font-mono);
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.1;
  color: #F8FAFC;
}

.emerald-text {
  background: linear-gradient(135deg, #6EE7B7, #10B981, #34D399);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.purchase-kpi-unit {
  font-size: 0.88rem;
  color: #93C5FD;
  font-weight: 600;
}

.purchase-kpi-pill {
  font-size: 0.75rem;
  background: rgba(16, 185, 129, 0.18);
  color: #34D399;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  font-weight: 600;
}

.purchase-kpi-footer {
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-item {
    width: auto;
  }
  .main-content {
    padding: 20px 16px;
  }
}

/* ================= Medicine Purchase View ================= */
.med-view-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 4px;
}

.med-view-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.med-view-summary-card:hover {
  transform: translateY(-2px);
  border-color: rgba(96, 165, 250, 0.4);
}

.med-view-summary-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.med-view-summary-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 900;
  color: #FFFFFF;
  line-height: 1.1;
}

.med-view-summary-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  margin-top: 4px;
}

/* Controls Toolbar */
.med-view-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 18px;
  backdrop-filter: blur(8px);
}

.med-view-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.med-scope-switcher {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.med-scope-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.med-scope-btn:hover {
  color: #FFFFFF;
}

.med-scope-btn.active {
  background: rgba(59, 130, 246, 0.25);
  color: #93C5FD;
  border: 1px solid rgba(96, 165, 250, 0.35);
}

/* Individual Medicine Cards */
.med-purchase-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  transition: all 0.25s ease;
}

.med-purchase-card:hover {
  border-color: rgba(96, 165, 250, 0.4);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

.med-purchase-header {
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.45) 0%, rgba(15, 23, 42, 0.85) 100%);
  user-select: none;
  transition: background 0.2s ease;
}

.med-purchase-header:hover {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.25) 0%, rgba(15, 23, 42, 0.95) 100%);
}

.med-rank-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  flex-shrink: 0;
}

.med-rank-badge.rank-gold {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(217, 119, 6, 0.15));
  border-color: rgba(245, 158, 11, 0.55);
  color: #FBBF24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.med-rank-badge.rank-silver {
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.3), rgba(100, 116, 139, 0.15));
  border-color: rgba(148, 163, 184, 0.5);
  color: #E2E8F0;
  box-shadow: 0 0 12px rgba(148, 163, 184, 0.2);
}

.med-rank-badge.rank-bronze {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.3), rgba(180, 83, 9, 0.15));
  border-color: rgba(217, 119, 6, 0.5);
  color: #F59E0B;
}

.med-count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.1));
  color: #93C5FD;
  border: 1px solid rgba(96, 165, 250, 0.35);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
  white-space: nowrap;
}

.med-count-pill.high-frequency {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.15));
  color: #FDE68A;
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.25);
}

.med-count-pill.zero-purchases {
  background: rgba(255, 255, 255, 0.05);
  color: #94A3B8;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.med-date-span-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #94A3B8;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 12px;
  border-radius: 8px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.med-date-chips-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 22px;
  background: rgba(15, 23, 42, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

.med-date-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #CBD5E1;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: 12px;
  transition: all 0.15s ease;
}

.med-date-chip:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(96, 165, 250, 0.35);
  color: #93C5FD;
}

.med-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.med-purchase-card.expanded .med-chevron {
  transform: rotate(180deg);
  color: #60A5FA;
}

.med-detail-drawer {
  display: none;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.65);
}

.med-purchase-card.expanded .med-detail-drawer {
  display: block;
}

/* Visual Pulse Cue for Patient Select Dropdown */
@keyframes pulseHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    border-color: #3B82F6;
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    border-color: #60A5FA;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    border-color: #3B82F6;
  }
}

.pulse-highlight {
  animation: pulseHighlight 0.9s ease-in-out infinite alternate !important;
  border-color: #3B82F6 !important;
  outline: none !important;
}

/* ================= Theme Toggle Switch ================= */
.theme-toggle-wrap {
  padding: 8px 8px 12px 8px;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.theme-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-icon-sun {
  color: #FBBF24;
  display: none;
}

.theme-icon-moon {
  color: #818CF8;
}

.theme-label {
  flex: 1;
  text-align: left;
}

.theme-switch-track {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 2px;
  transition: background 0.3s ease;
  flex-shrink: 0;
  position: relative;
}

.theme-switch-thumb {
  width: 16px;
  height: 16px;
  background: #818CF8;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transform: translateX(0);
}

/* Light theme active state for the toggle */
[data-theme="light"] .theme-icon-sun {
  display: block;
}
[data-theme="light"] .theme-icon-moon {
  display: none;
}
[data-theme="light"] .theme-switch-track {
  background: rgba(245, 158, 11, 0.25);
}
[data-theme="light"] .theme-switch-thumb {
  transform: translateX(16px);
  background: #F59E0B;
  box-shadow: 0 1px 6px rgba(245, 158, 11, 0.4);
}

/* ================= LIGHT THEME ================= */
[data-theme="light"] {
  --bg-primary: #F1F5F9;
  --bg-secondary: #FFFFFF;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-card-solid: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.92);

  --border-subtle: rgba(148, 163, 184, 0.22);
  --border-medium: rgba(148, 163, 184, 0.35);
  --border-glow: rgba(59, 130, 246, 0.3);
  --border-color: rgba(148, 163, 184, 0.25);

  --text-primary: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-white: #0F172A;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 20px -3px rgba(59, 130, 246, 0.15);
}

/* Body & scrollbar overrides for light */
[data-theme="light"] body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

[data-theme="light"] ::-webkit-scrollbar-track {
  background: #F1F5F9;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}

/* Sidebar */
[data-theme="light"] .sidebar {
  background: #FFFFFF;
  border-right: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .sidebar-brand {
  border-bottom-color: rgba(226, 232, 240, 0.6);
}

[data-theme="light"] .brand-text h2 {
  color: #0F172A;
}

[data-theme="light"] .nav-item {
  color: #475569;
}
[data-theme="light"] .nav-item:hover {
  background: rgba(59, 130, 246, 0.06);
  color: #1E293B;
}
[data-theme="light"] .nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.03));
  border-color: rgba(59, 130, 246, 0.25);
  color: #2563EB;
}
[data-theme="light"] .nav-item.active svg {
  color: #2563EB;
  filter: none;
}

[data-theme="light"] .sidebar-status-card {
  background: rgba(241, 245, 249, 0.7);
  border-color: rgba(226, 232, 240, 0.8);
}

[data-theme="light"] .sidebar-section-divider {
  background: rgba(226, 232, 240, 0.6);
}

[data-theme="light"] .theme-toggle-btn {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(226, 232, 240, 0.8);
  color: #475569;
}
[data-theme="light"] .theme-toggle-btn:hover {
  background: rgba(241, 245, 249, 1);
  border-color: rgba(203, 213, 225, 0.8);
  color: #1E293B;
}

/* Top Header & Search */
[data-theme="light"] .header-search-wrap input {
  background: #FFFFFF;
  border-color: rgba(203, 213, 225, 0.6);
  color: #1E293B;
}
[data-theme="light"] .header-search-wrap input:focus {
  background: #FFFFFF;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
[data-theme="light"] .header-search-wrap input::placeholder {
  color: #94A3B8;
}

/* KPI Cards */
[data-theme="light"] .kpi-card {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .kpi-card:hover {
  background: #FFFFFF;
  border-color: rgba(203, 213, 225, 0.8);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .kpi-value {
  color: #0F172A;
}

/* Section titles */
[data-theme="light"] .section-title {
  color: #0F172A;
}

/* Patient Cards */
[data-theme="light"] .patient-card {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .patient-card:hover {
  background: #FFFFFF;
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .patient-name {
  color: #0F172A;
}
[data-theme="light"] .patient-name-link {
  color: #0F172A;
}
[data-theme="light"] .patient-details-list {
  background: rgba(241, 245, 249, 0.6);
  border-color: rgba(226, 232, 240, 0.5);
}

/* Tables */
[data-theme="light"] .inventory-table-card {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .data-table th {
  background: rgba(241, 245, 249, 0.8);
  color: #475569;
  border-bottom-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .data-table td {
  color: #1E293B;
  border-bottom-color: rgba(241, 245, 249, 0.8);
}
[data-theme="light"] .data-table tbody tr:hover {
  background: rgba(241, 245, 249, 0.5);
}

/* Buttons */
[data-theme="light"] .btn-outline {
  background: #FFFFFF;
  border-color: rgba(203, 213, 225, 0.6);
  color: #1E293B;
}
[data-theme="light"] .btn-outline:hover {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(148, 163, 184, 0.5);
}
[data-theme="light"] .btn-outline-glass {
  background: rgba(241, 245, 249, 0.7);
  border-color: rgba(226, 232, 240, 0.8);
  color: #475569;
}
[data-theme="light"] .btn-outline-glass:hover {
  background: rgba(241, 245, 249, 1);
  color: #1E293B;
}

/* Form inputs */
[data-theme="light"] .form-input,
[data-theme="light"] .form-select,
[data-theme="light"] .form-textarea {
  background: #FFFFFF;
  border-color: rgba(203, 213, 225, 0.6);
  color: #1E293B;
}
[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-select:focus,
[data-theme="light"] .form-textarea:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Pill Buttons */
[data-theme="light"] .pill-btn {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(203, 213, 225, 0.5);
  color: #475569;
}

/* Filter bars */
[data-theme="light"] .logs-filter-bar {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .slot-filter-btn {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(203, 213, 225, 0.5);
  color: #475569;
}

/* Log mode switcher */
[data-theme="light"] .log-mode-switcher {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .mode-tab-btn,
[data-theme="light"] .mode-btn {
  color: #475569;
}
[data-theme="light"] .mode-tab-btn:hover,
[data-theme="light"] .mode-btn:hover {
  color: #1E293B;
}

/* Duration chips */
[data-theme="light"] .duration-chip {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(203, 213, 225, 0.5);
  color: #475569;
}

/* Patient Log Summary */
[data-theme="light"] .patient-log-summary {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(226, 232, 240, 0.8);
}

/* Modals */
[data-theme="light"] .modal-dialog {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .modal-header {
  background: rgba(241, 245, 249, 0.9);
  border-bottom-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .modal-title {
  color: #0F172A;
}
[data-theme="light"] .modal-body {
  background: #FFFFFF;
}
[data-theme="light"] .modal-footer {
  background: rgba(241, 245, 249, 0.6);
  border-top-color: rgba(226, 232, 240, 0.8);
}

/* Workbench Light Overrides */
[data-theme="light"] .modal-dialog.modal-xl.workbench-dialog {
  background: #F8FAFC;
}
[data-theme="light"] .workbench-header {
  background: #FFFFFF;
  border-bottom-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .workbench-drawer {
  background: #FFFFFF;
  border-right-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .drawer-header {
  background: rgba(248, 250, 252, 0.95);
  border-bottom-color: rgba(226, 232, 240, 0.6);
}
[data-theme="light"] .drawer-title-wrap h4 {
  color: #0F172A;
}
[data-theme="light"] .drag-med-card {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .drag-med-card:hover {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(59, 130, 246, 0.3);
}
[data-theme="light"] .drag-med-name {
  color: #0F172A;
}
[data-theme="light"] .drag-med-type {
  background: rgba(241, 245, 249, 0.8);
  color: #475569;
}
[data-theme="light"] .workbench-schedule {
  background: #F1F5F9;
}
[data-theme="light"] .schedule-slot-card {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .slot-header {
  background: rgba(248, 250, 252, 0.9);
  border-bottom-color: rgba(226, 232, 240, 0.6);
}
[data-theme="light"] .slot-dropzone {
  background: rgba(241, 245, 249, 0.4);
}
[data-theme="light"] .slot-med-item {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .slot-med-name {
  color: #0F172A;
}

/* Issue Register & Physical Register */
[data-theme="light"] .issue-register-table th,
[data-theme="light"] .issue-register-table td {
  border-right-color: rgba(226, 232, 240, 0.5);
  border-bottom-color: rgba(226, 232, 240, 0.5);
}

[data-theme="light"] .physical-register-table th {
  background: rgba(241, 245, 249, 0.95);
  color: #1E293B;
  border-bottom-color: rgba(203, 213, 225, 0.6);
}
[data-theme="light"] .physical-register-table td {
  color: #1E293B;
  border-bottom-color: rgba(241, 245, 249, 0.8);
}

/* Purchase KPI Cards */
[data-theme="light"] .purchase-kpi-card {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Patient Timeline Header */
[data-theme="light"] .patient-timeline-header {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
}

/* Toast notifications */
[data-theme="light"] .toast {
  background: #FFFFFF;
  border-color: rgba(226, 232, 240, 0.8);
  color: #1E293B;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Inline-style overriders (for elements with hardcoded dark backgrounds) */
[data-theme="light"] [style*="background: rgba(15, 23, 42"] {
  background: rgba(241, 245, 249, 0.8) !important;
}
[data-theme="light"] [style*="background: rgba(30, 41, 59"] {
  background: rgba(248, 250, 252, 0.9) !important;
}
[data-theme="light"] [style*="color: #FFFFFF"] {
  color: #0F172A !important;
}
[data-theme="light"] [style*="color: #FBBF24"] {
  color: #B45309 !important;
}
[data-theme="light"] [style*="color: #34D399"] {
  color: #059669 !important;
}

/* Badges in light mode */
[data-theme="light"] .badge-emerald { background: rgba(16, 185, 129, 0.12); color: #059669; }
[data-theme="light"] .badge-blue { background: rgba(59, 130, 246, 0.12); color: #2563EB; }
[data-theme="light"] .badge-purple { background: rgba(139, 92, 246, 0.12); color: #7C3AED; }
[data-theme="light"] .badge-amber { background: rgba(245, 158, 11, 0.12); color: #B45309; }
[data-theme="light"] .badge-rose { background: rgba(244, 63, 94, 0.12); color: #E11D48; }

/* KPI hint colors in light */
[data-theme="light"] .text-emerald { color: #059669; }
[data-theme="light"] .text-blue { color: #2563EB; }
[data-theme="light"] .text-amber { color: #B45309; }
[data-theme="light"] .text-purple { color: #7C3AED; }

/* Patient header chips */
[data-theme="light"] .patient-header-chip {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(226, 232, 240, 0.8);
}
[data-theme="light"] .patient-header-chip strong {
  color: #0F172A;
}

/* Stepper in workbench */
[data-theme="light"] .stepper-wrap {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(203, 213, 225, 0.5);
}
[data-theme="light"] .stepper-btn {
  color: #475569;
}
[data-theme="light"] .stepper-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #2563EB;
}

/* Protocol bar */
[data-theme="light"] .protocol-bar {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.06), rgba(139, 92, 246, 0.04));
  border-bottom-color: rgba(59, 130, 246, 0.12);
}
[data-theme="light"] .protocol-quick-btn {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
  color: #2563EB;
}
[data-theme="light"] .protocol-quick-btn:hover {
  background: #3B82F6;
  color: #FFFFFF;
}

/* Search input in purchase view */
[data-theme="light"] #purchase-search-input {
  background: #FFFFFF !important;
  border-color: rgba(203, 213, 225, 0.6) !important;
  color: #1E293B !important;
}

/* Smooth theme transition */
[data-theme="light"],
[data-theme="light"] body,
[data-theme="light"] .sidebar,
[data-theme="light"] .main-content,
[data-theme="light"] .kpi-card,
[data-theme="light"] .patient-card,
[data-theme="light"] .inventory-table-card,
[data-theme="light"] .modal-dialog,
[data-theme="light"] .data-table th,
[data-theme="light"] .data-table td,
[data-theme="light"] .btn-outline,
[data-theme="light"] .btn-outline-glass,
[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
