/* ============================================================
   HEALTH MONITORING SYSTEM — UNIFIED DESIGN SYSTEM
   Palette: Deep Navy #00416A + Clinical White + Alert Red
   Font: Inter (all weights)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --navy:       #00416A;
  --navy-dark:  #002D4A;
  --navy-mid:   #005C96;
  --navy-light: #E8F4FD;
  --blue:       #0078B4;
  --blue-soft:  #60B4F5;

  --red:        #E74C3C;
  --red-soft:   #FDEEEC;
  --amber:      #F59E0B;
  --amber-soft: #FFFBEB;
  --green:      #10B981;
  --green-soft: #ECFDF5;
  --purple:     #8B5CF6;
  --purple-soft:#F5F3FF;

  --bg:         #F0F5F9;
  --surface:    #FFFFFF;
  --border:     #E2EAF0;
  --border-mid: #C8D8E8;

  --text-primary:   #0A1628;
  --text-secondary: #4A6080;
  --text-muted:     #8A9AB0;

  --sidebar-w:  260px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 3px rgba(0,65,106,.06);
  --shadow-md:  0 4px 12px rgba(0,65,106,.10);
  --shadow-lg:  0 12px 32px rgba(0,65,106,.12);
  --shadow-xl:  0 24px 64px rgba(0,65,106,.14);

  --transition: .2s ease;
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-shell { display:flex; min-height:100vh; }
.main { flex:1; margin-left: var(--sidebar-w); display:flex; flex-direction:column; }
.page-content { flex:1; padding:28px 32px; max-width:1280px; width:100%; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  position: fixed;
  top:0; left:0; bottom:0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display:none; }

.sb-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sb-logo {
  width: 36px; height: 36px;
  background: var(--red);
  border-radius: var(--radius-sm);
  display: flex; align-items:center; justify-content:center;
  flex-shrink: 0;
}
.sb-logo svg { width:20px; height:20px; stroke:#fff; fill:none; stroke-width:2; stroke-linecap:round; }
.sb-name { color:#fff; font-size:.95rem; font-weight:700; line-height:1.2; }
.sb-name small { display:block; color:rgba(255,255,255,.4); font-size:.68rem; font-weight:400; letter-spacing:.5px; margin-top:1px; }

.sb-section-label {
  padding: 20px 20px 8px;
  color: rgba(255,255,255,.3);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sb-nav { flex:1; padding: 8px 12px; }
.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.sb-link svg { width:17px; height:17px; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; flex-shrink:0; }
.sb-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-link.active { background: rgba(255,255,255,.12); color: #fff; }
.sb-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--blue-soft);
  border-radius: 0 3px 3px 0;
}
.sb-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex; align-items:center; justify-content:center;
  padding: 0 5px;
}
.sb-badge.warn { background: var(--amber); }

.sb-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sb-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,100,100,.7);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 500;
  transition: all var(--transition);
}
.sb-logout:hover { background: rgba(255,80,80,.08); color: #ff6b6b; }
.sb-logout svg { width:17px; height:17px; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; flex-shrink:0; }

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display:flex; align-items:center; gap:16px; }
.topbar-title { font-size:1rem; font-weight:700; color: var(--text-primary); }
.topbar-subtitle { font-size:.8rem; color: var(--text-muted); }
.topbar-right { display:flex; align-items:center; gap:12px; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-secondary);
}
.menu-toggle svg { width:22px; height:22px; stroke:currentColor; fill:none; stroke-width:2; }

.avatar-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 700;
  display: flex; align-items:center; justify-content:center;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 20px;
}
.card-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { width:16px; height:16px; stroke: var(--navy); fill:none; stroke-width:2; stroke-linecap:round; }

/* ── STAT CARDS ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
}
.stat-card:hover { transform:translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-mid); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items:center; justify-content:center;
  flex-shrink: 0;
}
.stat-icon svg { width:22px; height:22px; stroke:#fff; fill:none; stroke-width:2; stroke-linecap:round; }
.stat-icon.blue   { background: var(--navy); }
.stat-icon.green  { background: var(--green); }
.stat-icon.amber  { background: var(--amber); }
.stat-icon.red    { background: var(--red); }
.stat-icon.purple { background: var(--purple); }
.stat-body {}
.stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-top: 3px;
}
.stat-trend {
  font-size: .75rem;
  font-weight: 600;
  margin-top: 4px;
}
.trend-up   { color: var(--green); }
.trend-warn { color: var(--amber); }
.trend-down { color: var(--red);   }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; flex-shrink:0; }
.btn-primary { background: var(--navy); color:#fff; }
.btn-primary:hover { background: var(--navy-dark); transform:translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline { background:transparent; color: var(--navy); border:1.5px solid var(--border-mid); }
.btn-outline:hover { border-color: var(--navy); background: var(--navy-light); }
.btn-danger  { background: var(--red); color:#fff; }
.btn-danger:hover  { background: #c0392b; }
.btn-success { background: var(--green); color:#fff; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-lg { padding: 13px 28px; font-size: .95rem; border-radius: var(--radius-lg); }
.btn-block { width:100%; justify-content:center; }

/* ── BADGES / PILLS ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.badge-red    { background: var(--red-soft);    color: #C0392B; }
.badge-amber  { background: var(--amber-soft);  color: #92400E; }
.badge-green  { background: var(--green-soft);  color: #065F46; }
.badge-blue   { background: var(--navy-light);  color: var(--navy); }
.badge-purple { background: var(--purple-soft); color: #5B21B6; }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: .84rem;
  border-left: 3px solid transparent;
}
.alert-critical { background: var(--red-soft);   border-color: var(--red);   color: #7F1D1D; }
.alert-warning  { background: var(--amber-soft); border-color: var(--amber); color: #78350F; }
.alert-success  { background: var(--green-soft); border-color: var(--green); color: #064E3B; }
.alert-info     { background: var(--navy-light); border-color: var(--navy);  color: var(--navy-dark); }
.alert-strip svg { width:16px; height:16px; stroke:currentColor; fill:none; stroke-width:2; flex-shrink:0; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display:block; font-size:.82rem; font-weight:600; color: var(--text-secondary); margin-bottom:6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0,65,106,.08);
}
.form-control::placeholder { color: var(--text-muted); }
.input-wrap { position:relative; }
.input-icon {
  position:absolute; left:12px; top:50%; transform:translateY(-50%);
  color: var(--text-muted);
}
.input-icon svg { width:16px; height:16px; stroke:currentColor; fill:none; stroke-width:1.8; }
.input-wrap .form-control { padding-left:40px; }

/* ── TABLES ─────────────────────────────────────────────── */
.data-table { width:100%; border-collapse:collapse; }
.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  border-bottom: 1px solid var(--border);
  background: #FAFCFF;
}
.data-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
.data-table tbody tr {
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #F7FAFD; }
.data-table td { padding: 13px 14px; font-size: .87rem; vertical-align: middle; }

/* ── VITALS ─────────────────────────────────────────────── */
.vital-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.vital-row:last-child { border-bottom:none; }
.vital-icon {
  width: 40px; height:40px;
  border-radius: var(--radius-sm);
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.vital-icon svg { width:18px; height:18px; stroke:#fff; fill:none; stroke-width:2; stroke-linecap:round; }
.vital-info { flex:1; min-width:0; }
.vital-name  { font-size:.82rem; color: var(--text-muted); }
.vital-value { font-size:1.05rem; font-weight:700; color: var(--text-primary); }
.vital-bar-wrap { width:80px; }
.vital-bar {
  height:4px;
  background: var(--border);
  border-radius:2px;
  overflow:hidden;
}
.vital-bar-fill { height:100%; border-radius:2px; transition:width .5s ease; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 1.35rem; font-weight: 800; color: var(--text-primary); }
.page-subtitle { font-size: .83rem; color: var(--text-muted); margin-top:3px; }

/* ── GRID HELPERS ────────────────────────────────────────── */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:20px; }
.grid-auto { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:20px; }

/* ── PATIENT CARD ─────────────────────────────────────────── */
.patient-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.patient-row:last-child { border-bottom:none; }
.avatar {
  width: 38px; height:38px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:.78rem; font-weight:700;
  color:#fff;
  flex-shrink:0;
}

/* ── ACTIVITY FEED ───────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom:none; }
.activity-dot {
  width: 32px; height:32px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  margin-top:2px;
}
.activity-dot svg { width:14px; height:14px; stroke:#fff; fill:none; stroke-width:2.2; }
.activity-text { flex:1; }
.activity-text p { font-size:.84rem; color: var(--text-primary); margin-bottom:2px; }
.activity-text span { font-size:.75rem; color: var(--text-muted); }

/* ── ECG LINE ────────────────────────────────────────────── */
.ecg-line {
  position: absolute;
  top: 50%; left:0; right:0;
  transform: translateY(-50%);
  height: 60px;
  overflow: hidden;
  pointer-events: none;
}
.ecg-svg path {
  stroke: rgba(255,255,255,.15);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: ecgDraw 3s ease forwards;
}
@keyframes ecgDraw { to { stroke-dashoffset:0; } }

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(20px); }
  to   { opacity:1; transform:translateY(0); }
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideRight { from{opacity:0;transform:translateX(-20px)} to{opacity:1;transform:translateX(0)} }
@keyframes countUp { from { opacity:0; } to { opacity:1; } }
@keyframes heartPulse {
  0%,100% { transform:scale(1); }
  14%     { transform:scale(1.3); }
  28%     { transform:scale(1); }
  42%     { transform:scale(1.15); }
  56%     { transform:scale(1); }
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

.anim-fade-up { animation: fadeUp .6s ease both; }
.anim-fade-up-2 { animation: fadeUp .6s .1s ease both; }
.anim-fade-up-3 { animation: fadeUp .6s .2s ease both; }
.anim-fade-up-4 { animation: fadeUp .6s .3s ease both; }
.anim-slide-r { animation: slideRight .5s ease both; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width:900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .main { margin-left:0; }
  .menu-toggle { display:flex; }
  .page-content { padding:20px 16px; }
  .topbar { padding:0 16px; }
  .grid-2, .grid-3 { grid-template-columns:1fr; }
}

/* ── MISC UTILITY ────────────────────────────────────────── */
.mb-0{margin-bottom:0} .mb-1{margin-bottom:6px} .mb-2{margin-bottom:12px} .mb-3{margin-bottom:20px} .mb-4{margin-bottom:28px}
.mt-auto{margin-top:auto}
.flex{display:flex} .flex-col{flex-direction:column} .items-center{align-items:center} .justify-between{justify-content:space-between}
.gap-1{gap:6px} .gap-2{gap:12px} .gap-3{gap:18px}
.text-sm{font-size:.8rem} .text-xs{font-size:.72rem}
.fw-600{font-weight:600} .fw-700{font-weight:700}
.text-muted{color:var(--text-muted)}
.text-danger{color:var(--red)} .text-success{color:var(--green)} .text-warn{color:var(--amber)}
.divider{height:1px;background:var(--border);margin:20px 0}
.overlay {position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:150;display:none;}
.overlay.show{display:block;}
.search-bar {
  display:flex; align-items:center; gap:8px;
  background: var(--bg);
  border:1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--navy); }
.search-bar svg { width:15px; height:15px; stroke: var(--text-muted); fill:none; stroke-width:2; flex-shrink:0; }
.search-bar input { border:none; background:transparent; font-family:inherit; font-size:.87rem; color: var(--text-primary); outline:none; width:100%; }
.search-bar input::placeholder { color:var(--text-muted); }

/* ── LOGIN PAGE SPECIFIC ─────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  position: relative;
  overflow: hidden;
}
.auth-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  z-index: 2;
}
.auth-right {
  width: 440px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.auth-form { width:100%; max-width:360px; }
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}
.auth-logo-icon {
  width:42px; height:42px;
  background: var(--red);
  border-radius: 10px;
  display:flex; align-items:center; justify-content:center;
}
.auth-logo-icon svg { width:22px; height:22px; stroke:#fff; fill:none; stroke-width:2; stroke-linecap:round; }
.auth-logo-name { color:#fff; font-size:1.1rem; font-weight:700; }
.auth-tagline { color:rgba(255,255,255,.45); font-size:.72rem; font-weight:400; margin-top:1px; }
.auth-headline { font-size:clamp(1.6rem,3vw,2.4rem); font-weight:800; color:#fff; line-height:1.2; margin-bottom:16px; }
.auth-sub { color:rgba(255,255,255,.55); font-size:.95rem; line-height:1.7; max-width:400px; margin-bottom:48px; }
.auth-features { display:flex; flex-direction:column; gap:14px; }
.auth-feature {
  display:flex; align-items:center; gap:12px;
  color:rgba(255,255,255,.7); font-size:.87rem;
}
.auth-feature-icon {
  width:32px; height:32px;
  background: rgba(255,255,255,.1);
  border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.auth-feature-icon svg { width:16px; height:16px; stroke:#fff; fill:none; stroke-width:2; stroke-linecap:round; }
.auth-form h2 { font-size:1.4rem; font-weight:800; color: var(--text-primary); margin-bottom:6px; }
.auth-form .sub { font-size:.84rem; color: var(--text-muted); margin-bottom:32px; }
.form-error {
  background: var(--red-soft);
  border: 1px solid #FECACA;
  color: #991B1B;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size:.84rem;
  margin-bottom:18px;
  display:flex; align-items:center; gap:8px;
  animation: shakeX .4s ease;
}
.form-error svg { width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2.2; flex-shrink:0; }
@keyframes shakeX {
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-6px)}
  75%{transform:translateX(6px)}
}
.auth-link { color: var(--navy); font-weight:600; text-decoration:none; }
.auth-link:hover { text-decoration:underline; }

/* Auth background decor */
.auth-bg-ecg {
  position:absolute;
  bottom:80px; left:0; right:0;
  height:120px;
  opacity:.08;
}
.auth-bg-circles {
  position:absolute;
  top:-100px; right:400px;
  width:500px; height:500px;
  border:1px solid rgba(255,255,255,.05);
  border-radius:50%;
}
.auth-bg-circles::before {
  content:'';
  position:absolute;
  inset:60px;
  border:1px solid rgba(255,255,255,.05);
  border-radius:50%;
}

@media (max-width:768px) {
  .auth-left { display:none; }
  .auth-right { width:100%; min-height:100vh; }
}
