/* ============================================================
   GlucoSentry — style.css
   Light theme default · Dark theme via [data-theme="dark"]
   Palette: Navy #0A3D62 · Teal #1A6B8A · Mist #E6F5FA
   Traffic light: #E74C3C / #F39C12 / #27AE60 / #C0392B
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

/* ── Design tokens — Light theme ─────────────────────────── */
:root {
  /* Page */
  --bg:        #F5F8FA;
  --bg-mid:    #E6F5FA;
  --surface:   #FFFFFF;
  --surface2:  #F5F8FA;
  --border:    #C8DCE4;
  --border-mid:#A8C4D0;
  --shadow:    0 1px 4px rgba(10,61,98,0.08);
  --shadow-md: 0 4px 16px rgba(10,61,98,0.10);
  --shadow-lg: 0 8px 32px rgba(10,61,98,0.12);

  /* Text */
  --text1:  #1C2B35;
  --text2:  #3D5462;
  --text3:  #7A9BA8;
  --text4:  #A8C4D0;

  /* Brand */
  --navy:        #0A3D62;
  --navy-dark:   #072D48;
  --teal:        #1A6B8A;
  --sky:         #2E9EC4;
  --mist:        #E6F5FA;
  --accent:      #1A6B8A;
  --accent-hover:#2E9EC4;
  --accent-light:#E6F5FA;

  /* Traffic light */
  --color-critical-low:  #E74C3C;
  --color-caution:       #F39C12;
  --color-in-range:      #27AE60;
  --color-critical-high: #C0392B;

  /* Sidebar (stays navy in both themes) */
  --sidebar-bg:     #0A3D62;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-text:   rgba(255,255,255,0.75);
  --sidebar-text2:  rgba(255,255,255,0.45);
  --sidebar-active: rgba(255,255,255,0.12);
  --sidebar-hover:  rgba(255,255,255,0.07);
  --sidebar-label:  rgba(255,255,255,0.35);

  /* Header */
  --header-bg:     #0A3D62;
  --header-border: rgba(255,255,255,0.1);
  --header-text:   rgba(255,255,255,0.9);
  --header-text2:  rgba(255,255,255,0.55);

  /* Components */


  /* Legacy aliases — keeps existing pages working */

  --text:    var(--text1);

  --text2:   var(--text2);

  --bg-card: var(--surface);

  --bg-dark: var(--navy);

  --radius:    8px;
  --radius-sm: 4px;
  --radius-lg: 12px;

  /* Typography */
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'DM Mono', 'JetBrains Mono', monospace;
}

/* ── Dark theme overrides ─────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #07111a;
  --bg-mid:    #0b1c2c;
  --surface:   #0f2336;
  --surface2:  #0b1c2c;
  --border:    #1e3a52;
  --border-mid:#2a5070;
  --shadow:    0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);

  --text1:  #e8f4ff;
  --text2:  #b0cfe0;
  --text3:  #5a8aaa;
  --text4:  #2a5070;

  --accent:       #2E9EC4;
  --accent-hover: #4ab8d8;
  --accent-light: rgba(46,158,196,0.12);

  --header-bg:    #061524;
  --header-border:rgba(255,255,255,0.07);
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text1);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.mono, code { font-family: var(--mono); }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  height: 60px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  padding: 0 16px 0 12px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 8px rgba(0,0,0,0.15);
}

.header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-dark-img  { display: none; }
.logo-light-img { display: block; }
[data-theme="dark"] .logo-dark-img  { display: block; }
[data-theme="dark"] .logo-light-img { display: none; }

.header-spacer { flex: 1; }

.hdr-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--header-text);
}

.hdr-role {
  font-size: 11px;
  color: var(--header-text2);
  display: block;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user-info { text-align: right; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: none;
  transition: background 0.15s;
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--mono);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.18);
  color: white;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-label);
  padding: 18px 16px 8px;
}

.patient-list { display: flex; flex-direction: column; }

.patient-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}

.patient-item:hover { background: var(--sidebar-hover); }

.patient-item.active {
  background: var(--sidebar-active);
  border-left-color: var(--sky);
}

.patient-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-item-meta {
  font-size: 11px;
  color: var(--sidebar-text2);
  margin-top: 1px;
}

.badge-glucose {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-empty {
  font-size: 13px;
  color: var(--sidebar-text2);
  padding: 16px;
}

.sidebar-admin-links {
  display: flex;
  flex-direction: column;
  padding: 4px 8px 16px;
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 12px;
}

.sidebar-admin-links a {
  font-size: 13px;
  color: var(--sidebar-text2);
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s;
}

.sidebar-admin-links a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--bg);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-primary {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
.btn-primary:hover { background: var(--sky); border-color: var(--sky); color: white; }

.btn-secondary {
  background: var(--surface);
  color: var(--text2);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-mid); color: var(--text1); }

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.65);
  border-color: rgba(255,255,255,0.15);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: white; border-color: rgba(255,255,255,0.25); }

.btn-green {
  background: var(--color-in-range);
  color: white;
  border-color: var(--color-in-range);
}
.btn-green:hover { background: #219150; border-color: #219150; color: white; }

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
  color: var(--text2);
  transition: all 0.15s;
  user-select: none;
}

.btn-toggle input[type="radio"] { display: none; }

.btn-toggle:has(input:checked),
.btn-toggle.selected {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  margin: 0;
}

.card-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
}

/* ── Patient header ───────────────────────────────────────── */
.patient-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.patient-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text1);
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

.patient-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text2);
}

.mono-tag {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--text2);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text2);
}

.pill-blue {
  background: rgba(26,107,138,0.1);
  border-color: rgba(26,107,138,0.2);
  color: var(--teal);
}

.pill-dark {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text3);
}

.patient-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Stat grid ────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text1);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-value.mono { font-family: var(--mono); }

.stat-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.stat-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-top: 4px;
}

/* ── Range filter bar ─────────────────────────────────────── */
.range-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.range-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  margin-right: 4px;
}

.range-btn {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  text-decoration: none;
  color: var(--text2);
  background: var(--surface);
  transition: all 0.15s;
}

.range-btn:hover { border-color: var(--teal); color: var(--teal); }
.range-btn.active { background: var(--navy); border-color: var(--navy); color: white; }

/* ── Tab bar ──────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text1); }

.tab-btn.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Chart ────────────────────────────────────────────────── */
.chart-wrap {
  padding: 20px;
  height: 340px;
  position: relative;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}

.legend-item::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
}

/* ── Log list ─────────────────────────────────────────────── */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s;
}

.log-item:hover { box-shadow: var(--shadow); }

.log-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--bg-mid);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--mono);
}

.dose-icon::after { content: '💉'; font-size: 18px; }
.reading-icon { font-size: 13px; }

.log-body { flex: 1; min-width: 0; }

.log-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text1);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.log-notes {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.log-meta { text-align: right; flex-shrink: 0; }

.log-time {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}

.log-by {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--text3);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}

.optional { font-weight: 400; color: var(--text3); }

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
select,
textarea {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(46,158,196,0.12);
}

textarea { resize: vertical; }

.glucose-preview {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  min-height: 20px;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,61,98,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text1);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.modal-close:hover { background: var(--bg-mid); color: var(--text1); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Alert banner ─────────────────────────────────────────── */
.alert-banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-banner.critical {
  background: rgba(231,76,60,0.08);
  border-color: var(--color-critical-low);
  color: #922b21;
}

.alert-banner.warning {
  background: rgba(243,156,18,0.08);
  border-color: var(--color-caution);
  color: #784212;
}

[data-theme="dark"] .alert-banner.critical { color: #f1948a; }
[data-theme="dark"] .alert-banner.warning  { color: #f8c471; }

/* ── Print ────────────────────────────────────────────────── */
.print-header, .print-footer { display: none; }
.print-legend { display: flex; }

.print-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.print-stat { font-size: 13px; color: var(--text2); }
.print-title { font-size: 18px; font-weight: 700; color: var(--text1); }
.print-sub   { font-size: 13px; color: var(--text3); margin-top: 4px; }

@media print {
  .app-header, .sidebar, .patient-actions, .range-bar, .tab-bar,
  .btn, .modal-overlay { display: none !important; }
  .main-content { padding: 0; overflow: visible; }
  .app-layout { height: auto; overflow: visible; }
  .print-header, .print-footer { display: block !important; }
  .tab-panel { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 16px; }
  .patient-header { flex-direction: column; }
  .patient-actions { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .header-user-info { display: none; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
}

/* ============================================================
   SERVICESENTRY-STYLE SIDEBAR — appended patch
   ============================================================ */

/* Hide old header (no longer used) */
.app-header { display: none !important; }

/* Full-height layout — sidebar + main fill viewport */
html, body { height: 100%; margin: 0; }
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar base overrides */
.sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  position: relative;
  transform: none !important; /* override mobile transform on desktop */
}

/* Scrollbar thin */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Logo area */
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo img { display: block; max-width: 160px; }

/* Facility row */
.sidebar-facility {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px 4px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar-facility svg { flex-shrink: 0; opacity: 0.6; }

/* Section labels */
.sidebar-section-label {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sidebar-label);
  margin-top: 0;
}

/* Nav links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.95);
}
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-link.active svg { opacity: 1; }

/* Patient list tweaks (inside new sidebar) */
.patient-list {
  padding: 0 8px;
  flex: 0 1 auto;
  overflow-y: auto;
  max-height: 300px;
}
.patient-list::-webkit-scrollbar { width: 3px; }
.patient-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }

/* User block at bottom */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10.5px;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
  white-space: nowrap;
}
.sidebar-user-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.sidebar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  padding: 0;
}
.sidebar-icon-btn:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
}

/* Main content area fills remaining width */
.main-content {
  flex: 1;
  overflow-y: auto;
  height: 100vh;
  background: var(--bg);
}

/* Mobile sidebar toggle — floating button */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Dark theme icon swap */
[data-theme="dark"] .icon-sun  { display: none !important; }
[data-theme="dark"] .icon-moon { display: block !important; }
[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none !important; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 150;
    transform: translateX(-100%) !important;
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar-mobile-toggle { display: flex; }
  .main-content { padding-top: 60px; }
}

/* ── Print — hide sidebar ────────────────────────────────── */
@media print {
  .sidebar, .sidebar-mobile-toggle { display: none !important; }
  .app-layout { display: block; }
  .main-content { height: auto; overflow: visible; }
}

/* ── Admin pages inside sidebar layout ──────────────────── */
.main-content .admin-wrap {
  padding: 32px 36px;
  max-width: 1300px;
  margin: 0 auto;
}
.admin-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

/* ── Admin pages inside sidebar layout ──────────────────── */
.main-content .admin-wrap {
  padding: 32px 36px;
  max-width: 1300px;
  margin: 0 auto;
}
.admin-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}



/* ── Admin table padding fix ────────────────────────────── */

.admin-table th,

.admin-table td {

  padding: 10px 14px;

}

.admin-table th:first-child,

.admin-table td:first-child { padding-left: 18px; }

.admin-table th:last-child,

.admin-table td:last-child  { padding-right: 18px; }


/* ============================================================
   SERVICESENTRY-STYLE SIDEBAR — appended patch
   ============================================================ */

/* Hide old header (no longer used) */
.app-header { display: none !important; }

/* Full-height layout — sidebar + main fill viewport */
html, body { height: 100%; margin: 0; }
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar base overrides */
.sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  position: relative;
  transform: none !important; /* override mobile transform on desktop */
}

/* Scrollbar thin */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Logo area */
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo img { display: block; max-width: 160px; }

/* Facility row */
.sidebar-facility {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px 4px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar-facility svg { flex-shrink: 0; opacity: 0.6; }

/* Section labels */
.sidebar-section-label {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sidebar-label);
  margin-top: 0;
}

/* Nav links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.95);
}
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-link.active svg { opacity: 1; }

/* Patient list tweaks (inside new sidebar) */
.patient-list {
  padding: 0 8px;
  flex: 0 1 auto;
  overflow-y: auto;
  max-height: 300px;
}
.patient-list::-webkit-scrollbar { width: 3px; }
.patient-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }

/* User block at bottom */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10.5px;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
  white-space: nowrap;
}
.sidebar-user-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.sidebar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  padding: 0;
}
.sidebar-icon-btn:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
}

/* Main content area fills remaining width */
.main-content {
  flex: 1;
  overflow-y: auto;
  height: 100vh;
  background: var(--bg);
}

/* Mobile sidebar toggle — floating button */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Dark theme icon swap */
[data-theme="dark"] .icon-sun  { display: none !important; }
[data-theme="dark"] .icon-moon { display: block !important; }
[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none !important; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 150;
    transform: translateX(-100%) !important;
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar-mobile-toggle { display: flex; }
  .main-content { padding-top: 60px; }
}

/* ── Print — hide sidebar ────────────────────────────────── */
@media print {
  .sidebar, .sidebar-mobile-toggle { display: none !important; }
  .app-layout { display: block; }
  .main-content { height: auto; overflow: visible; }
}



/* ── Admin layout final override ────────────────────────── */

.main-content .admin-wrap {

  padding: 32px 36px !important;

  max-width: 1300px;

  margin: 0 auto;

}

.admin-table {

  width: 100%;

  border-collapse: collapse;

}

.admin-table th,

.admin-table td {

  padding: 10px 14px !important;

  text-align: left;

}

.admin-table th:first-child,

.admin-table td:first-child { padding-left: 20px !important; }

.admin-table th:last-child,

.admin-table td:last-child  { padding-right: 20px !important; }




/* ── Admin form card inner padding ──────────────────────── */

.admin-form {

  padding: 20px 20px 16px;

}

.card > .admin-form {

  padding: 20px 20px 16px;

}

.admin-form .form-row {

  margin-bottom: 12px;

}

.admin-form .form-group label {

  margin-bottom: 4px;

  display: block;

}




/* ── Login page ─────────────────────────────────────────── */

.login-body {

  min-height: 100vh;

  height: auto;

  display: flex;

  align-items: center;

  justify-content: center;

  background: var(--bg);

  padding: 24px;

}

.login-wrap {

  width: 100%;

  max-width: 420px;

}

.login-card {

  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: 14px;

  padding: 40px 36px 32px;

  box-shadow: 0 4px 24px rgba(0,0,0,0.08);

}

.login-logo {

  display: flex;

  justify-content: center;

  margin-bottom: 8px;

}

.login-logo-img {

  height: 52px;

  width: auto;

}

.login-sub {

  text-align: center;

  margin-bottom: 24px;

}

.login-card .form-group {

  margin-bottom: 16px;

}

.login-card .btn-block {

  width: 100%;

  margin-top: 8px;

}

.login-hint {

  text-align: center;

  font-size: 12px;

  color: var(--text3);

  margin-top: 16px;

}

/* Override app-layout height for login page */

.login-body.login-body {

  height: auto;

  min-height: 100vh;

}




/* ── Login logo — dark background so white logo is visible ── */

.login-logo {

  background: #0A3D62;

  border-radius: 12px;

  padding: 14px 24px;

  display: inline-flex;

  justify-content: center;

  margin: 0 auto 16px;

  width: fit-content;

}

.login-card {

  display: flex;

  flex-direction: column;

  align-items: center;

}

.login-card form,

.login-card .alert,

.login-card .login-sub,

.login-card .login-hint {

  width: 100%;

}




/* ── Admin card form padding (vnccamp fix) ───────────────── */

.card .admin-form,

.card > form {

  padding: 20px 24px 20px;

}

.card .form-group {

  margin-bottom: 16px;

}

.card .form-group input,

.card .form-group select,

.card .form-group textarea {

  padding: 8px 12px;

  width: 100%;

  box-sizing: border-box;

}

