/* ===== DESIGN SYSTEM ===== */
:root {
  --bg:        #080d14;
  --surface:   #0e1620;
  --surface2:  #131d2a;
  --border:    rgba(255,255,255,0.06);
  --border2:   rgba(255,255,255,0.10);

  --cyan:      #00e5c8;
  --cyan-dim:  rgba(0,229,200,0.12);
  --cyan-glow: rgba(0,229,200,0.25);

  --amber:     #ffb340;
  --amber-dim: rgba(255,179,64,0.12);

  --rose:      #ff4f6d;
  --rose-dim:  rgba(255,79,109,0.12);

  --violet:    #9b7cff;
  --violet-dim:rgba(155,124,255,0.12);

  --sky:       #3db8f5;
  --sky-dim:   rgba(61,184,245,0.12);

  --text:      #e8eef5;
  --text-muted:#6b7d8f;
  --text-dim:  #3a4a5a;

  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --radius:    12px;
  --radius-lg: 18px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background grid */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 20px 16px;
  z-index: 100;
  gap: 6px;
}

.sidebar-logo {
  width: auto; height: 40px;
  background: transparent;
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: 12px;
  margin-bottom: 28px;
  font-family: var(--font-head);
  font-size: 22px; font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
}
.sidebar-logo span { color: var(--cyan); }

.nav-item {
  width: 100%; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: flex-start;
  padding: 0 12px;
  gap: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all .18s ease;
  position: relative;
}
.nav-text {
  font-size: 13.5px;
  font-weight: 500;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--cyan-dim); color: var(--cyan); }
.nav-item .badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  background: var(--rose);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}
.nav-item i { font-size: 17px; width: 20px; text-align: center; }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed; top: 0; left: 240px; right: 0; height: 60px;
  background: rgba(8,13,20,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  z-index: 99;
  gap: 16px;
}

.topbar-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text);
}
.topbar-title span { color: var(--cyan); }

.topbar-search {
  margin-left: 24px;
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
  height: 34px;
}
.topbar-search input {
  background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-body);
  font-size: 13px; width: 200px;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search i { color: var(--text-muted); font-size: 13px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.topbar-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer;
  position: relative; transition: all .15s;
}
.topbar-btn:hover { color: var(--text); border-color: var(--border2); }
.topbar-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 6px; height: 6px;
  background: var(--rose); border-radius: 50%;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--cyan-dim);
  border: 1.5px solid var(--cyan);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: 13px; font-weight: 700;
  color: var(--cyan);
}

.live-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-family: var(--font-mono);
  color: var(--cyan);
  background: var(--cyan-dim);
  border: 1px solid rgba(0,229,200,0.2);
  border-radius: 6px;
  padding: 4px 10px;
}
.live-indicator::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:.4; transform:scale(0.7); }
}

/* ===== MAIN LAYOUT ===== */
.main {
  margin-left: 240px;
  padding-top: 60px;
  min-height: 100vh;
  position: relative; z-index: 1;
}

.content {
  padding: 28px;
  max-width: 1400px;
}

/* ===== SECTION HEADERS ===== */
.section-header {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 16px;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.section-title {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.section-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease;
  cursor: default;
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border2);
}
.kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-color);
  opacity: .7;
}

.kpi-card[data-accent="cyan"]  { --accent-color: var(--cyan); }
.kpi-card[data-accent="amber"] { --accent-color: var(--amber); }
.kpi-card[data-accent="rose"]  { --accent-color: var(--rose); }
.kpi-card[data-accent="violet"]{ --accent-color: var(--violet); }
.kpi-card[data-accent="sky"]   { --accent-color: var(--sky); }

.kpi-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px;
}
.kpi-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: var(--accent-color);
}

.kpi-card[data-accent="cyan"]   .kpi-icon { background: var(--cyan-dim); }
.kpi-card[data-accent="amber"]  .kpi-icon { background: var(--amber-dim); }
.kpi-card[data-accent="rose"]   .kpi-icon { background: var(--rose-dim); }
.kpi-card[data-accent="violet"] .kpi-icon { background: var(--violet-dim); }
.kpi-card[data-accent="sky"]    .kpi-icon { background: var(--sky-dim); }

.kpi-trend {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 7px;
  border-radius: 5px;
}
.kpi-trend.up   { background: rgba(0,229,200,.1); color: var(--cyan); }
.kpi-trend.down { background: rgba(255,79,109,.1); color: var(--rose); }
.kpi-trend.neu  { background: rgba(107,125,143,.1); color: var(--text-muted); }

.kpi-value {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-color);
  margin-bottom: 4px;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.kpi-link {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 14px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.kpi-link:hover { color: var(--accent-color); }

/* ===== MINI SPARKLINE ===== */
.sparkline {
  height: 30px;
  margin-top: 10px;
}
.sparkline svg { width: 100%; height: 100%; }

/* ===== TWO-COLUMN PANELS ===== */
.panels-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  margin-bottom: 28px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.panel-head-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.panel-head-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  font-family: var(--font-mono);
}
.panel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
}

/* ===== DONUT CHART ===== */
.donut-wrap {
  padding: 24px;
  display: flex; align-items: center; gap: 28px;
}
.donut-svg { width: 140px; height: 140px; flex-shrink: 0; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 10px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { font-size: 12px; color: var(--text-muted); flex: 1; }
.legend-val { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }

/* ===== BAR CHART ===== */
.bar-chart-wrap { padding: 20px 20px 8px; }
.bar-group { display: flex; align-items: flex-end; gap: 5px; height: 120px; margin-bottom: 6px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar-fill {
  width: 100%;
  border-radius: 5px 5px 0 0;
  transition: height .6s cubic-bezier(.16,1,.3,1);
  min-height: 4px;
}
.bar-xlabel { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }

/* ===== RECENT REQUESTS TABLE ===== */
.req-table { width: 100%; border-collapse: collapse; }
.req-table thead th {
  padding: 10px 20px;
  text-align: left;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.req-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.req-table tbody tr:last-child { border-bottom: none; }
.req-table tbody tr:hover { background: var(--surface2); }
.req-table td {
  padding: 12px 20px;
  font-size: 13px;
}

.patient-cell { display: flex; align-items: center; gap: 10px; }
.patient-avatar {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  font-family: var(--font-head);
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.status-pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill.completed { background: rgba(0,229,200,.1); color: var(--cyan); }
.status-pill.pending   { background: rgba(255,179,64,.1); color: var(--amber); }
.status-pill.cancelled { background: rgba(255,79,109,.1); color: var(--rose); }
.status-pill.new       { background: rgba(61,184,245,.1); color: var(--sky); }

/* ===== BOTTOM GRID ===== */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 320px;
  gap: 18px;
  margin-bottom: 28px;
}

/* ===== ACTIVITY FEED ===== */
.activity-feed { padding: 8px 0; }
.activity-item {
  display: flex; gap: 14px;
  padding: 11px 20px;
  transition: background .12s;
}
.activity-item:hover { background: var(--surface2); }
.activity-line { display: flex; flex-direction: column; align-items: center; gap: 0; }
.activity-dot-wrap {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.activity-connector {
  width: 1px; flex: 1; min-height: 12px;
  background: var(--border);
  margin-top: 4px;
}
.activity-item:last-child .activity-connector { display: none; }
.activity-body { padding-top: 4px; flex: 1; }
.activity-text { font-size: 12.5px; color: var(--text); line-height: 1.4; margin-bottom: 3px; }
.activity-text strong { color: var(--cyan); font-weight: 500; }
.activity-time { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }

/* ===== UPCOMING TESTS ===== */
.test-list { padding: 6px 0; }
.test-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.test-item:last-child { border-bottom: none; }
.test-item:hover { background: var(--surface2); }
.test-type-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid;
  flex-shrink: 0;
}
.test-info { flex: 1; }
.test-name { font-size: 12.5px; font-weight: 500; margin-bottom: 2px; }
.test-patient { font-size: 11px; color: var(--text-muted); }
.test-time { font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); }

/* ===== EQUIPMENT STATUS ===== */
.equipment-list { padding: 10px 0; }
.equip-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.equip-item:last-child { border-bottom: none; }
.equip-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.equip-info { flex: 1; }
.equip-name { font-size: 12.5px; font-weight: 500; margin-bottom: 2px; }
.equip-model { font-size: 11px; color: var(--text-muted); }
.equip-status {
  font-size: 10px; font-family: var(--font-mono);
  padding: 3px 8px; border-radius: 5px;
}
.equip-status.online   { background: rgba(0,229,200,.1); color: var(--cyan); }
.equip-status.busy     { background: rgba(255,179,64,.1); color: var(--amber); }
.equip-status.offline  { background: rgba(255,79,109,.1); color: var(--rose); }
.equip-status.standby  { background: rgba(155,124,255,.1); color: var(--violet); }

/* ===== REAGENT STOCK ===== */
.reagent-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px; margin-bottom: 28px;
}
.stock-item { padding: 6px 0; }
.stock-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.stock-row:last-child { border-bottom: none; }
.stock-row:hover { background: var(--surface2); }
.stock-name { font-size: 12.5px; color: var(--text); }
.stock-qty { font-family: var(--font-mono); font-size: 11px; margin-bottom: 5px; }
.stock-bar-wrap { height: 4px; background: var(--surface2); border-radius: 99px; width: 80px; margin-top: 4px; }
.stock-bar { height: 100%; border-radius: 99px; transition: width .5s ease; }
.stock-bar.high   { background: var(--cyan); }
.stock-bar.medium { background: var(--amber); }
.stock-bar.low    { background: var(--rose); }

/* ===== ALERT BANNER ===== */
.alert-strip {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px;
  background: rgba(255,179,64,.07);
  border: 1px solid rgba(255,179,64,.2);
  border-radius: var(--radius);
  margin-bottom: 22px;
}
.alert-icon { color: var(--amber); font-size: 15px; }
.alert-text { font-size: 12.5px; color: var(--text); flex: 1; }
.alert-text strong { color: var(--amber); }
.alert-action {
  font-size: 11px; font-family: var(--font-mono);
  color: var(--amber); text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(255,179,64,.3);
  border-radius: 6px;
  transition: all .15s;
}
.alert-action:hover { background: rgba(255,179,64,.1); }

/* ===== SELECT2 overrides ===== */
.select2-container--default .select2-selection--single {
  background: var(--surface2);
  border: 1px solid var(--border, #1e2a35);
  border-radius: 8px;
  height: 38px;
  outline: none;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text);
  line-height: 36px;
  font-family: var(--font-sans);
  font-size: 13px;
  padding-left: 12px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
}
.select2-dropdown {
  background-color: var(--surface);
  border: 1px solid var(--border, #1e2a35);
  border-radius: 8px;
}
.select2-search--dropdown .select2-search__field {
  background: var(--surface2);
  border: 1px solid var(--border, #1e2a35);
  border-radius: 6px;
  color: var(--text);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--cyan);
  color: #0a1520;
}

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn .5s ease both; }
.fade-in:nth-child(1) { animation-delay: .05s; }
.fade-in:nth-child(2) { animation-delay: .1s; }
.fade-in:nth-child(3) { animation-delay: .15s; }
.fade-in:nth-child(4) { animation-delay: .2s; }
.fade-in:nth-child(5) { animation-delay: .25s; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .panels-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; padding: 20px 10px; }
  .sidebar-logo { padding-left: 0; justify-content: center; font-size: 18px; }
  .sidebar-logo span { display: none; }
  .nav-item { padding: 0; justify-content: center; }
  .nav-text { display: none; }
  .nav-item .badge { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; padding: 0; min-width: 0; color: transparent; border: 1.5px solid var(--surface); }
  .topbar { left: 64px; }
  .main { margin-left: 64px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
