/* ── ED Dietary Software — Clinical Design System ── */
/* iOS tap delay fix */
* { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button, a, select, input { touch-action: manipulation; cursor: pointer; }

:root {
  /* ── Color palette — softer, more modern, healthcare-warm ── */
  --bg:          #f7f9fc;
  --bg-elev:     #ffffff;
  --sidebar-bg:  #0b2545;
  --sidebar-sec: #163a60;
  --card-bg:     #ffffff;
  --border:      #e6edf5;
  --border-soft: #eef2f7;
  --btn-bg:      #1a4480;
  --btn-hover:   #0f3366;
  --btn-accent:  #4f8cff;
  --btn-success: #1a6b35;
  --btn-danger:  #c0392b;
  --btn-warning: #b45309;
  --btn-neutral: #475569;
  --text-dark:   #0b2545;
  --text-med:    #1e3a5f;
  --text-muted:  #6b7280;
  --row-alt:     #f9fbfd;
  --flash-yellow:#fef3c7;
  /* ── Soft shadows for modern depth ── */
  --shadow-sm:   0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow:      0 2px 10px rgba(15, 23, 42, 0.05);
  --shadow-md:   0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-hover:0 6px 18px rgba(15, 23, 42, 0.08);
  --font:        'Segoe UI', system-ui, sans-serif;
  --font-mono:   'Consolas', monospace;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-sm:   8px;
  /* ── Smooth, calm transitions ── */
  --transition:  all 0.2s ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-dark);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Gentle entrance animation for the main content area — calm, not flashy */
@keyframes calmFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Layout ── */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 230px; min-width: 230px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  animation: calmFadeIn 0.28s ease-out;
}

/* ── Sidebar ── */
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid #1a3a5c;
}
.brand-icon { font-size: 24px; }
.brand-logo-img {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: 8px;
  background: #0a1e3d;
  padding: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.brand-name { color: #fff; font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.brand-sub  { color: #7fa8d0; font-size: 10px; letter-spacing: 0.02em; }

.nav-section-label {
  color: #4a7fa8; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 16px 14px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  color: #a8c4df; font-size: 13px; text-decoration: none;
  border-radius: 8px; margin: 2px 8px;
  position: relative;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e8f0fa;
  transform: translateX(2px);
}
.nav-item.active {
  background: var(--sidebar-sec);
  color: #ffffff;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--btn-accent);
}

/* Session bar */
.session-bar {
  margin-top: auto;
  border-top: 1px solid #1a3a5c;
  padding: 10px 12px;
  background: #0a1f3d;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.session-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #1e5ba8; color: #7ec8ff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.session-info { flex: 1; min-width: 0; }
.session-name { color: #e2eaf3; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-role { color: #4a7fa8; font-size: 10px; }
.session-actions { display: flex; gap: 4px; }
.btn-session {
  background: #1e5ba8; color: white; border: none;
  border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 12px;
}
.btn-session.btn-danger { background: #c0392b; }
.btn-session:hover { opacity: 0.85; }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-hover);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text-dark); letter-spacing: -0.01em; }

/* ── Page header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.page-title { font-size: 24px; font-weight: 700; color: var(--text-dark); letter-spacing: -0.015em; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: var(--transition);
  font-family: var(--font);
  box-shadow: var(--shadow-sm);
}
.btn:hover { opacity: 0.92; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--btn-bg);      color: #fff; }
.btn-success   { background: var(--btn-success);  color: #fff; }
.btn-danger    { background: var(--btn-danger);   color: #fff; }
.btn-warning   { background: var(--btn-warning);  color: #fff; }
.btn-neutral   { background: var(--btn-neutral);  color: #fff; }
.btn-outline   { background: transparent; color: var(--btn-bg); border: 1px solid var(--btn-bg); box-shadow: none; }
.btn-outline:hover { background: rgba(26, 68, 128, 0.04); box-shadow: none; }
.btn-sm        { padding: 5px 12px; font-size: 12px; }
.btn-lg        { padding: 11px 26px; font-size: 15px; }
.btn-close     { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); box-shadow: none; }
.btn-close:hover { box-shadow: none; transform: none; opacity: 0.7; }

/* ── Filter bar ── */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.filter-label { font-weight: 600; font-size: 12px; color: var(--text-muted); }
.filter-btn {
  padding: 6px 14px; border: none; border-radius: 20px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  background: #e8eff9; color: var(--btn-bg);
  transition: background 0.15s, color 0.15s;
}
.filter-btn.active, .filter-btn:hover { background: var(--btn-bg); color: #fff; }

/* ── Search ── */
.search-box {
  display: flex; align-items: center; gap: 6px;
  background: #f1f5f9; border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 12px;
}
.search-box input {
  border: none; background: none; outline: none;
  font-size: 13px; width: 200px; color: var(--text-dark);
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f0f4f8; color: var(--text-dark);
  font-weight: 700; font-size: 12px;
  padding: 10px 14px; text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: pointer;
}
tbody tr:hover { background: #f0f6ff; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:nth-child(even):hover { background: #f0f6ff; }
td { padding: 10px 14px; font-size: 13px; }
.td-center { text-align: center; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.badge-rtc     { background: #dbeafe; color: #1e40af; }
.badge-php     { background: #ede9fe; color: #5b21b6; }
.badge-iop     { background: #d1fae5; color: #065f46; }
.badge-rest    { background: #dcfce7; color: #166534; }
.badge-maint   { background: #fef9c3; color: #854d0e; }
.badge-allergy { background: #fee2e2; color: #991b1b; }
.badge-ok      { background: #d1fae5; color: #065f46; }
.badge-warn    { background: #fef9c3; color: #854d0e; }
.badge-alert   { background: #fee2e2; color: #991b1b; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 13px; font-family: var(--font);
  color: var(--text-dark); background: var(--card-bg);
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--btn-bg);
  box-shadow: 0 0 0 3px rgba(26,68,128,0.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* ── Percentage buttons (meal doc) ── */
.pct-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.pct-btn {
  padding: 5px 10px; border: none; border-radius: 4px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--btn-bg); color: white;
  transition: background 0.12s;
}
.pct-btn.selected  { background: #fff; color: var(--text-dark); border: 2px solid var(--btn-bg); }
.pct-btn.pct-0     { background: #c62828; }
.pct-btn.pct-0.selected { background: #fff; color: #c62828; border: 2px solid #c62828; }
.pct-btn.pct-100   { background: var(--btn-success); }
.pct-btn.pct-100.selected { background: #fff; color: var(--btn-success); border: 2px solid var(--btn-success); }

/* ── HP/MP style bars ── */
.progress-bar { height: 14px; background: #e2e8f0; border-radius: 7px; overflow: hidden; margin: 3px 0; }
.progress-fill { height: 100%; border-radius: 7px; transition: width 0.3s; }
.bar-hp   { background: #e74c3c; }
.bar-mp   { background: #3498db; }
.bar-xp   { background: #f39c12; }
.bar-good { background: var(--btn-success); }
.bar-warn { background: #d97706; }
.bar-bad  { background: var(--btn-danger); }

/* ── Stat cards (dashboard) ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  border-left: 4px solid var(--btn-bg);
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.stat-card .stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 30px; font-weight: 700; color: var(--text-dark); margin: 6px 0; letter-spacing: -0.02em; }
.stat-card .stat-sub   { font-size: 12px; color: var(--text-muted); }
.stat-card.green  { border-left-color: var(--btn-success); }
.stat-card.red    { border-left-color: var(--btn-danger); }
.stat-card.yellow { border-left-color: #d97706; }
.stat-card.purple { border-left-color: #7c3aed; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: 6px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.alert-warning  { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.alert-danger   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success  { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info     { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 100; display: flex; align-items: center; justify-content: center;
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  z-index: 101; width: 92%; max-width: 780px;
  max-height: 92vh; overflow: hidden; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--btn-bg); color: white;
}
.modal-header h3 { color: white; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.hidden { display: none !important; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #0b2545; color: white;
  padding: 12px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 9600; max-width: 360px;
}
.toast.info    { background: #0e7490; }
.toast.success { background: var(--btn-success); }
.toast.error   { background: var(--btn-danger); }

/* ── Login ── */
.login-page {
  min-height: 100vh; background: #07192e;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #0b2545; border-radius: 12px;
  padding: 40px; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-kairos-logo {
  display: block;
  width: 90px; height: 90px;
  margin: 0 auto 14px;
  object-fit: contain;
  border-radius: 16px;
  background: #0a1e3d;
  padding: 6px;
  box-shadow: 0 4px 18px rgba(127, 168, 208, 0.18);
}
.login-title {
  color: #fff; font-size: 30px; font-weight: 700;
  text-align: center; margin-bottom: 6px;
  letter-spacing: 0.18em;
  font-family: Georgia, 'Times New Roman', serif;
}
.login-sub {
  color: #7fa8d0; font-size: 12px; text-align: center;
  margin-bottom: 28px; font-style: italic; letter-spacing: 0.02em;
}
.login-field { margin-bottom: 16px; }
.login-field label { display: block; color: #8ab8d8; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.login-field input {
  width: 100%; background: #0e2a4a; color: white; border: 1px solid #1a4480;
  border-radius: 8px; padding: 12px 14px; font-size: 14px;
}
.login-field input:focus { outline: none; border-color: #4d8fd4; }
.login-error { color: #f87171; font-size: 12px; margin-bottom: 12px; text-align: center; min-height: 18px; }
.login-footer { color: #3d6a8a; font-size: 11px; text-align: center; margin-top: 20px; }

/* ── Weight table row colors ── */
tr.wt-green { background: #f0fdf4; }
tr.wt-yellow { background: #fefce8; }
tr.wt-red { background: #fff1f2; }

/* ── Flag severity colors ── */
.flag-red    { border-left: 3px solid #e74c3c; }
.flag-orange { border-left: 3px solid #f39c12; }
.flag-yellow { border-left: 3px solid #ecc94b; }
.flag-blue   { border-left: 3px solid #3498db; }
.flag-gray   { border-left: 3px solid #94a3b8; }

/* ── Exchange grid ── */
.exchange-grid-wrap {
  overflow-x: auto;
  margin: 12px 0;
}
.exchange-grid {
  display: grid;
  grid-template-columns: 110px repeat(6, 1fr);
  gap: 4px;
  min-width: 520px;
  align-items: center;
}
.exchange-grid .ex-header {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-align: center; padding: 4px;
  background: #f0f4f8; border-radius: 4px;
}

.exchange-grid input[type="number"] {
  width: 100%; text-align: center; border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 2px; font-size: 12px;
  background: white; box-sizing: border-box;
}
.exchange-grid input[type="number"]:focus {
  outline: none; border-color: var(--btn-bg);
  background: #f0f7ff;
}
.exchange-grid .ex-meal-label {
  font-size: 12px; font-weight: 600; color: var(--text-dark);
  padding: 4px 6px; white-space: nowrap;
}
.ex-section-header {
  font-size: 12px; font-weight: 700; color: var(--text-dark);
  margin: 12px 0 6px; padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}

/* ── Tab strip ── */
.tabs {
  display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tab-btn {
  padding: 10px 20px; border: none; background: none;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  flex: 0 0 auto; white-space: nowrap;
}
.tab-btn.active { color: var(--btn-bg); border-bottom-color: var(--btn-bg); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {

  /* ── Hide sidebar on mobile — use bottom nav instead ── */
  .sidebar {
    display: none !important;
  }

  /* ── Main content fills full screen ── */
  .layout {
    flex-direction: column;
  }
  .main-content {
    padding: 12px 12px 80px 12px; /* bottom padding for mobile nav */
    min-height: 100vh;
  }

  /* ── Stats grid 2 cols on mobile ── */
  .stat-grid { grid-template-columns: repeat(2,1fr); }

  /* ── Modals full width ── */
  .modal { width: 98%; }

  /* ── Page header stack on mobile ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* ── Tables scroll horizontally ── */
  .table-wrap { overflow-x: auto; }

  /* ── Tab bar: tighter on mobile, scrolls if it overflows ── */
  .tabs { gap: 0; }
  .tab-btn { padding: 10px 14px; font-size: 12px; }

  /* ── Cards full width ── */
  .card { border-radius: 10px; }

  /* ── Filter buttons wrap ── */
  .filter-row { flex-wrap: wrap; }

  /* ── Mobile top bar ── */
  .mobile-topbar {
    display: flex !important;
  }

  /* ── Mobile bottom nav ── */
  .mobile-bottom-nav {
    display: flex !important;
  }
}

/* Hide mobile elements on desktop */
.mobile-topbar { display: none; }
.mobile-bottom-nav { display: none; }

/* Mobile top bar styles */
.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--sidebar-bg, #0c2340);
  color: white;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.mobile-topbar-logo {
  font-size: 15px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-menu-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 18px;
}

/* Mobile sidebar drawer */
.mobile-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
}
.mobile-drawer.open { display: block; }
.mobile-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.mobile-drawer-panel {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 280px;
  background: var(--sidebar-bg, #0c2340);
  overflow-y: auto;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

/* Mobile bottom nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: white;
  border-top: 1px solid #e5e7eb;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bottom-nav-inner {
  display: flex;
}
.mbn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  font-size: 9px;
  color: #94a3b8;
  text-decoration: none;
  gap: 3px;
  min-height: 52px;
  border: none;
  background: none;
  cursor: pointer;
}
.mbn-item.active { color: #1d4ed8; }
.mbn-item svg {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* ─── Collapsible nav categories (v50) ──────────────────────────── */
.nav-cat-btn {
  display: flex; align-items: center; gap: 10px;
  width: calc(100% - 16px);
  padding: 10px 12px; margin: 4px 8px 0;
  background: transparent; color: #a8c4df; border: none;
  border-radius: 8px; font-size: 13px; font-weight: 600;
  text-align: left; cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  font-family: inherit;
}
.nav-cat-btn:hover {
  background: rgba(255,255,255,0.05);
  color: #e8f0fa;
}
.nav-cat-btn .cat-icon { font-size: 14px; flex-shrink: 0; }
.nav-cat-btn .cat-label { flex: 1; }
.nav-cat-btn .cat-chevron {
  font-size: 10px; color: #4a7fa8;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.nav-cat-btn.cat-open .cat-chevron { transform: rotate(90deg); color: #7ec8ff; }
.nav-cat-btn.cat-open { color: #e8f0fa; }

.nav-cat-children { padding: 2px 0 6px; }
.nav-item.nav-sub {
  padding-left: 32px;
  font-size: 12.5px;
  margin: 1px 8px;
}
.nav-item.nav-sub-deep {
  padding-left: 44px;
  font-size: 12px;
  margin: 1px 8px;
}
.nav-subheader {
  color: #3a5a7c; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 14px 2px 28px;
}

/* ─── Top-right user area (bell + account chip) ───────────────────
   Both sit in a flex row, pinned to top-right of the main content.
   z-index above content but below any modal. .main-content has
   matching right-padding so page-action buttons (Add Patient,
   Refresh, etc) don't get visually clipped beneath this area. */
.user-area-wrap {
  position: absolute;
  top: 14px; right: 22px;
  display: flex; align-items: center; gap: 10px;
  z-index: 100;
}

/* ─── Notification bell ───────────────────────────────────────── */
.notif-bell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: white; border: 1px solid var(--border, #e2e8f0);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  font-size: 17px;
  user-select: none;
}
.notif-bell:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}
.notif-bell.has-unread {
  background: #fff7ed;
  border-color: #fed7aa;
}
.notif-bell-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  background: #dc2626; color: white;
  border: 2px solid white;
  border-radius: 10px;
  font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  box-sizing: content-box;
}
.notif-bell-badge.hidden { display: none; }

/* Notification panel — slide-down from the bell */
.notif-panel {
  position: absolute;
  top: 50px; right: 0;
  width: 380px; max-width: calc(100vw - 32px);
  max-height: 560px;
  background: white;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  overflow: hidden;
  display: flex; flex-direction: column;
  z-index: 200;
}
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: linear-gradient(180deg,#f8fafc,#fff);
}
.notif-panel-title {
  font-size: 14px; font-weight: 700; color: #0f172a;
  display: flex; align-items: center; gap: 8px;
}
.notif-panel-actions {
  font-size: 11px; color: #4f46e5;
  cursor: pointer; font-weight: 600;
  background: transparent; border: none; padding: 4px 8px;
  border-radius: 6px;
}
.notif-panel-actions:hover { background: #eef2ff; }
.notif-panel-body {
  flex: 1; overflow-y: auto; padding: 4px 0;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.12s ease;
  position: relative;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #f0f9ff; }
.notif-item.unread:hover { background: #e0f2fe; }
.notif-item-title {
  font-size: 13px; font-weight: 700; color: #0f172a;
  margin-bottom: 3px; line-height: 1.3;
  padding-right: 22px;
}
.notif-item-body {
  font-size: 12px; color: #475569; line-height: 1.5;
}
.notif-item-meta {
  font-size: 10px; color: #94a3b8;
  margin-top: 5px;
  display: flex; align-items: center; gap: 8px;
}
.notif-item-sev {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 1px 6px; border-radius: 4px;
}
.notif-item-sev.info     { background: #e2e8f0; color: #475569; }
.notif-item-sev.low      { background: #dbeafe; color: #1d4ed8; }
.notif-item-sev.medium   { background: #fef3c7; color: #92400e; }
.notif-item-sev.high     { background: #fed7aa; color: #9a3412; }
.notif-item-sev.urgent   { background: #fecaca; color: #b91c1c; }
.notif-item-dismiss {
  position: absolute;
  top: 12px; right: 14px;
  background: transparent; border: none;
  color: #94a3b8; font-size: 16px;
  cursor: pointer; padding: 0; line-height: 1;
}
.notif-item-dismiss:hover { color: #dc2626; }
.notif-empty {
  text-align: center; padding: 36px 20px;
  color: #94a3b8; font-size: 12px;
  font-style: italic;
}
.notif-panel-footer {
  padding: 8px 16px; border-top: 1px solid var(--border, #e2e8f0);
  background: #f8fafc;
  font-size: 11px; color: #64748b;
  text-align: center;
}

/* Toast notifications — slide-in from top-right, stack downward */
.toast-stack {
  position: fixed;
  top: 70px; right: 22px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1500;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: white;
  border-left: 4px solid #4f46e5;
  border: 1px solid var(--border, #e2e8f0);
  border-left: 4px solid #4f46e5;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  animation: toast-in 0.32s ease-out;
  cursor: pointer;
  max-width: 360px;
}
.toast.urgent  { border-left-color: #b91c1c; }
.toast.high    { border-left-color: #9a3412; }
.toast.medium  { border-left-color: #d97706; }
.toast.low     { border-left-color: #1d4ed8; }
.toast.info    { border-left-color: #475569; }
.toast-title { font-size: 13px; font-weight: 700; color: #0f172a; margin-bottom: 3px; }
.toast-body  { font-size: 12px; color: #475569; line-height: 1.5; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Account Settings dropdown (top-right) ─────────────────────── */
.account-settings-wrap {
  position: relative;
  /* No longer absolute-positioned — lives inside .user-area-wrap */
}
.account-chip {
  display: flex; align-items: center; gap: 8px;
  background: white; border: 1px solid var(--border, #e2e8f0);
  border-radius: 22px; padding: 4px 12px 4px 4px;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}
.account-chip:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}
.account-chip-circle {
  width: 30px; height: 30px; border-radius: 50%;
  background: #1e5ba8; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.account-chip-name {
  font-size: 13px; font-weight: 600; color: #1e293b;
  max-width: 160px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.account-chip-caret { font-size: 10px; color: #64748b; }

.account-menu {
  position: absolute; top: 48px; right: 0;
  min-width: 220px; background: white;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
}
.account-menu-header {
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.account-menu-item {
  display: block; padding: 10px 14px;
  color: #1e293b; text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background 0.15s ease;
}
.account-menu-item:hover { background: #f1f5f9; }
.account-menu-divider {
  height: 1px; background: var(--border, #e2e8f0); margin: 4px 0;
}
.account-menu-danger { color: #dc2626; }
.account-menu-danger:hover { background: #fef2f2; }

/* Make sure main content has room for the user area on the right.
   Reserved zone = bell (38px) + gap (10px) + chip (varies, allow ~200px) + 22px margin.
   Page-action buttons (Add Patient, Refresh, etc) should sit clear of this zone. */
.main-content {
  padding-right: 22px;
  position: relative;
}
.page-header,
.page-header-row,
.header-row {
  padding-right: 280px;   /* clear zone for bell + chip */
  min-height: 56px;
}
@media (max-width: 1100px) {
  .page-header, .page-header-row, .header-row { padding-right: 220px; }
}
@media (max-width: 768px) {
  .page-header, .page-header-row, .header-row { padding-right: 0; }
}

/* Mobile — hide account area from main content, since mobile top-bar
   handles user identity separately */
@media (max-width: 768px) {
  .user-area-wrap { display: none; }
}

/* ─── Dashboard LOC stat cards (Kairos v12) ───────────────────────
   Color-blind-safe distinguishing cues. Each card uses MULTIPLE
   redundant signals so no single failure mode (color blindness,
   monochrome printing, screen glare) breaks the at-a-glance read:
     1. Icon — different glyph per card type
     2. ADULT / ADOLESCENT text tag pill
     3. Border style — Adult cards = solid left border, Adolescent
        cards = dashed (works even in pure black/white)
     4. Background tint — subtle, supports the icon/tag
     5. Color — Okabe-Ito palette, safe for deuteranopia / protanopia
        / tritanopia
*/
.stat-card-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.stat-icon {
  font-size: 18px; flex-shrink: 0;
}
.stat-tag {
  display: inline-block;
  background: #1e293b; color: #fff;
  font-size: 9px; font-weight: 800;
  padding: 1px 6px; border-radius: 4px;
  margin-left: 4px; letter-spacing: 0.5px;
  vertical-align: middle;
}
.stat-tag-adol {
  background: #fff;
  color: #1e293b;
  border: 1.5px solid #1e293b;
}

/* Overall totals — neutral blue (Okabe-Ito blue #0072B2) */
.stat-card-ovr {
  border-left: 5px solid #0072B2;
  background: linear-gradient(to right, #f0f7fc 0%, #fff 30%);
}

/* RTC — Okabe-Ito vermillion #D55E00 (distinct from any PHP/IOP color) */
.stat-card-rtc {
  border-left: 5px solid #D55E00;
  background: linear-gradient(to right, #fdf3ed 0%, #fff 30%);
}

/* PHP Adult — Okabe-Ito bluish-green #009E73, solid border */
.stat-card-adult-php {
  border-left: 5px solid #009E73;
  background: linear-gradient(to right, #ecf8f4 0%, #fff 30%);
}

/* IOP Adult — Okabe-Ito yellow #E69F00 (more orange-yellow, distinct
   from RTC vermillion and PHP green), solid border */
.stat-card-adult-iop {
  border-left: 5px solid #E69F00;
  background: linear-gradient(to right, #fdf6e7 0%, #fff 30%);
}

/* PHP Adolescent — Okabe-Ito reddish-purple #CC79A7, DASHED border */
.stat-card-adol-php {
  border-left: 5px dashed #CC79A7;
  background: linear-gradient(to right, #fbf2f7 0%, #fff 30%);
}

/* IOP Adolescent — Okabe-Ito sky-blue #56B4E9, DASHED border */
.stat-card-adol-iop {
  border-left: 5px dashed #56B4E9;
  background: linear-gradient(to right, #eff8fd 0%, #fff 30%);
}

/* On mobile, drop the gradients (less helpful at narrow widths) */
@media (max-width: 600px) {
  .stat-card-ovr, .stat-card-rtc,
  .stat-card-adult-php, .stat-card-adult-iop,
  .stat-card-adol-php, .stat-card-adol-iop {
    background: #fff;
  }
}

/* ─── Owner's Portal nav entry ────────────────────────────────────
   Gold-on-dark distinctive treatment to match the Atlas/globe brand
   imagery. Visually signals "different class of access" without being
   loud. Only Admin and Owner roles see this entry — UI-invisible to
   everyone else via Jinja perms gate. */
.nav-item.nav-owner-portal {
  margin: 8px 12px;
  padding: 9px 12px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fde68a;
  border: 1px solid #b45309;
  border-radius: 7px;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 8px;
}
.nav-item.nav-owner-portal:hover {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fef3c7;
  border-color: #d97706;
}
.nav-item.nav-owner-portal.active {
  background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
  color: #fef3c7;
  border-color: #fde68a;
}
.nav-item.nav-owner-portal.active::before {
  content: none !important;   /* override default active::before bar */
}
