@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;600;700;800&display=swap');

:root {
  --navy: #0B1F3A;
  --navy-mid: #122949;
  --teal: #0D7A6B;
  --teal-light: #12A08E;
  --teal-pale: #E6F5F3;
  --sky: #2196C4;
  --sky-pale: #EAF5FB;
  --red: #C0392B;
  --red-pale: #FDECEA;
  --amber: #D4820A;
  --amber-pale: #FEF6E4;
  --green: #1A7D4F;
  --green-pale: #E8F5EE;
  --purple: #6B4FB5;
  --purple-pale: #F0EDFB;
  --white: #FFFFFF;
  --bg: #F2F5F9;
  --sidebar-width: 260px;
  --text-dark: #0B1F3A;
  --text-mid: #3D5068;
  --text-light: #7A90A8;
  --border: #DDE4ED;
  --shadow-sm: 0 1px 4px rgba(11,31,58,0.08);
  --shadow-md: 0 4px 16px rgba(11,31,58,0.10);
  --shadow-lg: 0 8px 32px rgba(11,31,58,0.13);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--teal-light), var(--sky));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.logo-icon svg { width: 22px; height: 22px; fill: white; }

.logo-text { display: flex; flex-direction: column; }
.logo-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px; font-weight: 700;
  color: white; line-height: 1.2;
}
.logo-sub {
  font-size: 10px; color: rgba(255,255,255,0.45);
  letter-spacing: 0.08em; text-transform: uppercase;
}

.sidebar-section {
  padding: 12px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  margin-top: 8px;
}

.sidebar nav { flex: 1; padding: 8px 12px; overflow-y: auto; overflow-x: hidden; min-height: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.07); color: white; }
.nav-item.active { background: var(--teal); color: white; }

.nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--teal), var(--sky));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
}
.user-info { flex: 1; }
.user-name { font-size: 12.5px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.4); }

/* ── MAIN CONTENT ── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 17px; font-weight: 700; color: var(--navy);
}
.page-breadcrumb { font-size: 12px; color: var(--text-light); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-btn {
  width: 36px; height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  color: var(--text-mid);
  transition: all 0.15s ease;
}
.topbar-btn:hover { background: var(--teal-pale); color: var(--teal); border-color: var(--teal-light); }

.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid white;
}

.date-chip {
  font-size: 12px; color: var(--text-mid);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
}

.content { padding: 28px; flex: 1; }

/* ── MODULE PAGES ── */
.module-page { display: none; }
.module-page.active { display: block; }

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; gap: 14px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }

.stat-info { flex: 1; }
.stat-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 26px; font-weight: 800;
  color: var(--navy); line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 12px; color: var(--text-light); font-weight: 500; }
.stat-delta {
  font-size: 11px; font-weight: 600;
  margin-top: 4px;
}
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── TABLES ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px; font-weight: 700; color: var(--navy);
}
.card-subtitle { font-size: 12px; color: var(--text-light); margin-top: 1px; }

.card-actions { display: flex; gap: 8px; }

.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-light); }
.btn-outline {
  background: white; color: var(--text-mid);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: var(--amber); color: white; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--teal-pale); }
tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-dark);
}

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: var(--green-pale); color: var(--green); }
.badge-red { background: var(--red-pale); color: var(--red); }
.badge-amber { background: var(--amber-pale); color: var(--amber); }
.badge-blue { background: var(--sky-pale); color: var(--sky); }
.badge-teal { background: var(--teal-pale); color: var(--teal); }
.badge-purple { background: var(--purple-pale); color: var(--purple); }
.badge-navy { background: rgba(11,31,58,0.08); color: var(--navy); }
.badge-sky { background: var(--sky-pale); color: var(--sky); }

/* ── TWO-COL GRID ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── FORM ELEMENTS ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-mid); }
.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dark);
  background: var(--white);
  transition: border-color 0.15s;
  font-family: 'Inter', sans-serif;
}
.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,122,107,0.1);
}
select.form-control { cursor: pointer; }

/* ── PROGRESS BARS ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(11,31,58,0.5);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 520px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px; font-weight: 700; color: var(--navy);
}
.modal-close {
  width: 28px; height: 28px;
  border: none; background: var(--bg);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
  font-size: 16px;
}
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── DASHBOARD WELCOME ── */
.welcome-banner {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-mid) 50%, #1a4a6b 100%);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  overflow: hidden;
  position: relative;
}
.welcome-banner::before {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(13,122,107,0.3) 0%, transparent 70%);
  border-radius: 50%;
}
.welcome-banner::after {
  content: '';
  position: absolute;
  right: 100px; bottom: -60px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(33,150,196,0.2) 0%, transparent 70%);
  border-radius: 50%;
}
.welcome-text h2 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 22px; font-weight: 800;
  color: white; margin-bottom: 6px;
}
.welcome-text p { font-size: 13.5px; color: rgba(255,255,255,0.6); }
.welcome-stats { display: flex; gap: 28px; z-index: 1; }
.w-stat { text-align: center; }
.w-stat-val {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 28px; font-weight: 800; color: white;
}
.w-stat-lbl { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 2px; }

/* ── MODULE HEADER ── */
.module-hero {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px;
}
.module-hero-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.module-hero h1 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 20px; font-weight: 800; color: var(--navy);
}
.module-hero p { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ── QUICK ACTIONS ── */
.quick-actions {
  display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── DEDICATED SYSTEM OVERLAY ── */
.dedicated-system {
  position: fixed;
  inset: 0;
  display: flex;
  z-index: 500;
  background: var(--bg);
}

.ded-sidebar {
  width: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.ded-logo {
  padding: 20px 16px;
}

.ded-section {
  padding: 12px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  margin-top: 6px;
}

.ded-nav {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.ded-nav:hover { background: rgba(255,255,255,0.08); color: white; }
.ded-nav.active { color: white; }

.ded-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.ded-topbar {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ded-content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
}

.ded-panel { display: none; }
.ded-panel.active { display: block; }

/* Lab active nav */
#lab-system .ded-nav.active { background: rgba(123,63,190,0.35); }
/* Pharmacy active nav */
#pharmacy-system .ded-nav.active { background: rgba(217,119,6,0.35); }

@media (max-width: 1024px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .welcome-stats { display: none; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── ALERT STRIP ── */
.alert-strip {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.alert-strip.danger { background: var(--red-pale); color: var(--red); border-left: 3px solid var(--red); }
.alert-strip.warning { background: var(--amber-pale); color: var(--amber); border-left: 3px solid var(--amber); }
.alert-strip.success { background: var(--green-pale); color: var(--green); border-left: 3px solid var(--green); }

/* ── MINI CHART PLACEHOLDER ── */
.chart-placeholder {
  height: 160px;
  background: linear-gradient(180deg, var(--teal-pale) 0%, var(--white) 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
  font-size: 12px;
  position: relative;
  overflow: hidden;
}
.chart-bars {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: flex-end; gap: 4px;
  padding: 0 16px;
  height: 80%;
}
.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--teal-light), var(--teal));
  border-radius: 4px 4px 0 0;
  opacity: 0.7;
}

.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-light);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }
.tab-btn:hover { color: var(--teal); }
