
/* ============ Reset & Base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1e40af;
  --primary-light: #e8edfb;
  --primary-dark: #16308a;
  --blue: #1d6fa4;
  --blue-light: #e8f3fb;
  --green: #1a7f4f;
  --green-light: #e6f4ee;
  --orange: #c2740a;
  --orange-light: #fff3e0;
  --red: #b91c1c;
  --red-light: #fef2f2;
  --purple: #6d28d9;
  --purple-light: #f5f3ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  /* clinic identity colors (validated categorical order) */
  --clinic-1: #2a78d6;
  --clinic-2: #eb6834;
  --clinic-3: #1baf7a;
  --clinic-4: #eda100;
  --clinic-5: #e87ba4;
  --clinic-6: #008300;
  --clinic-7: #4a3aa7;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============ Demo Banner ============ */
.demo-banner {
  background: var(--gray-800);
  color: #fff;
  text-align: center;
  font-size: 12px;
  padding: 6px 12px;
  letter-spacing: 0.3px;
}
.demo-banner strong { color: #fbbf24; }

/* ============ Buttons ============ */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ============ Login ============ */
.login-page {
  min-height: calc(100vh - 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 20% -10%, var(--primary-light), transparent),
    var(--gray-50);
  padding: 24px;
}
.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 44px 40px;
  box-shadow: var(--shadow-md);
  text-align: center;
  width: 380px;
  max-width: 94vw;
}
.login-box h2 { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.login-box .subtitle { color: var(--gray-600); margin-bottom: 26px; }
.login-box label { display: block; text-align: left; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--primary); }
.login-box .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--gray-400);
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.error-msg {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  text-align: left;
}
.brand-mark {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

/* ============ Header ============ */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-title { line-height: 1.2; }
.header-title .t1 { font-weight: 700; font-size: 16px; }
.header-title .t2 { font-size: 12px; color: var(--gray-600); }
.brand-mark-sm {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.staff-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
}

.header-menu { position: relative; }
.header-dropdown {
  position: absolute; right: 0; top: 115%;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 8px; box-shadow: var(--shadow-md);
  min-width: 170px; z-index: 60; overflow: hidden;
}
.header-dropdown a {
  display: block; padding: 9px 14px; font-size: 13px;
  color: var(--gray-700); text-decoration: none; font-weight: 600;
}
.header-dropdown a:hover { background: var(--gray-100); }

/* ============ Metrics Bar ============ */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  padding: 16px 24px 6px;
  max-width: 1280px;
  margin: 0 auto;
}
.metric {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.metric:hover { box-shadow: var(--shadow-sm); }
.metric.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-label { font-size: 11.5px; color: var(--gray-600); margin-top: 2px; }
.metric-warning .metric-value { color: var(--orange); }
.metric-success .metric-value { color: var(--green); }
.metric-ti .metric-value { color: var(--red); }

/* ============ Search & Filters ============ */
.search-bar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 24px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.search-input-wrapper { position: relative; flex: 1 1 320px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.55; }
.search-input {
  width: 100%;
  padding: 11px 38px 11px 36px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  background: var(--white);
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--primary); }
.search-clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: var(--gray-100); color: var(--gray-600);
  width: 22px; height: 22px; border-radius: 50%; font-size: 14px; line-height: 1;
}
.search-results-badge {
  font-size: 12px; color: var(--gray-600);
  background: var(--gray-100); padding: 4px 10px; border-radius: 20px;
}
.clinic-chips {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 24px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.clinic-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-700);
  transition: border-color 0.15s, background 0.15s;
}
.clinic-chip:hover { background: var(--gray-100); }
.clinic-chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.clinic-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ============ Cards ============ */
.main-content { max-width: 1280px; margin: 0 auto; padding: 16px 24px 60px; }
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.patient-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.patient-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.patient-card.ti { background: var(--red-light); border-color: #fecaca; }
.pc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pc-name { font-size: 15px; font-weight: 700; }
.pc-sub { font-size: 12px; color: var(--gray-600); margin-top: 1px; }
.pc-clinic {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--gray-700);
  background: var(--gray-100); border-radius: 20px; padding: 3px 10px;
  white-space: nowrap;
}
.patient-card.ti .pc-clinic { background: #fee2e2; }
.pc-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.stage-chip {
  font-size: 11.5px; font-weight: 700;
  border-radius: 20px; padding: 3px 10px;
}
.pc-stats { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.pc-stat { font-size: 12px; color: var(--gray-600); }
.pc-stat b { color: var(--gray-800); font-size: 13px; }
.milestone-dots { display: flex; align-items: center; gap: 3px; margin-top: 12px; }
.mdot {
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; letter-spacing: 0.2px;
  background: var(--gray-100); color: var(--gray-400);
  border: 1.5px solid var(--gray-200);
}
.patient-card.ti .mdot { background: #fff; }
.mdot.done { background: var(--green-light); color: var(--green); border-color: var(--green); }
.mdot.sched { background: var(--orange-light); color: var(--orange); border-color: var(--orange); }
/* the step that's up next — same orange family as the chart's "Up next" highlight */
.mdot.next { background: #fff7ed; color: var(--orange); border: 1.5px dashed var(--orange); font-weight: 700; }
.mconnect { flex: 1; height: 2px; background: var(--gray-200); min-width: 3px; }
.empty-state { text-align: center; color: var(--gray-600); padding: 60px 20px; }
.empty-icon { font-size: 34px; margin-bottom: 8px; }

.touch-badge {
  position: absolute; top: -9px; right: -9px;
  background: var(--red); color: #fff;
  border-radius: 20px; padding: 2px 9px;
  font-size: 10.5px; font-weight: 700;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

/* ============ Analytics ============ */
.an-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.an-tile { border: 1px solid var(--gray-200); background: var(--gray-50); border-radius: var(--radius-sm); padding: 10px 14px; }
.an-tile .l { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-600); font-weight: 600; }
.an-tile .v { font-size: 24px; font-weight: 700; margin-top: 2px; }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.bar-label { flex: 0 0 190px; font-weight: 600; text-align: right; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; display: flex; align-items: center; gap: 8px; }
.bar-fill { height: 14px; border-radius: 0 4px 4px 0; background: var(--primary); min-width: 3px; }
.bar-val { font-weight: 700; font-size: 12.5px; }
.an-select { padding: 8px 12px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 13.5px; background: #fff; outline: none; font-weight: 600; }

.mini-input, .mini-select {
  padding: 6px 9px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 12.5px; outline: none; background: #fff;
}
.mini-input:focus, .mini-select:focus { border-color: var(--primary); }
.ms-editor { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.tl-edit {
  border: 1px solid var(--gray-200); background: #fff; color: var(--gray-600);
  border-radius: 6px; font-size: 11px; padding: 2px 8px; font-weight: 600; white-space: nowrap;
}
.tl-edit:hover { background: var(--gray-100); }
.cm-chip {
  display: inline-block; background: var(--gray-100); border-radius: 16px;
  padding: 3px 10px; font-size: 12px; margin: 2px 4px 2px 0; font-weight: 600; color: var(--gray-700);
}

.memo-item {
  padding: 9px 12px; border-left: 3px solid var(--orange);
  background: var(--gray-50); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 8px 0; font-size: 13px;
}
.memo-item.critical { border-left-color: var(--red); background: var(--red-light); }
.ask-chip {
  display: inline-block; background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 16px; padding: 4px 12px; font-size: 12px; font-weight: 600;
  color: var(--gray-700); margin: 4px 6px 0 0; cursor: pointer;
}
.ask-chip:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.rt-chip {
  border: 1px solid var(--gray-200); background: #fff; border-radius: 16px;
  padding: 4px 12px; font-size: 12px; font-weight: 700; color: var(--gray-600); cursor: pointer;
}
.rt-chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.ac-list {
  position: absolute; background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 8px; box-shadow: var(--shadow-md); max-height: 220px; overflow-y: auto; z-index: 300;
}
.ac-item { padding: 7px 12px; font-size: 13px; cursor: pointer; }
.ac-item:hover { background: var(--primary-light); }
.ans-hero { font-size: 40px; font-weight: 700; line-height: 1.1; }

/* ============ Reports ============ */
.an-tabs { display: flex; gap: 6px; margin-top: 14px; border-bottom: 1px solid var(--gray-200); }
.an-tab {
  border: none; background: none; padding: 8px 14px;
  font-size: 13px; font-weight: 600; color: var(--gray-600);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.an-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.rpt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 12px; }
.rpt-table th { background: var(--gray-100); font-weight: 700; padding: 6px 8px; text-align: right; border: 1px solid var(--gray-200); }
.rpt-table th:first-child { text-align: left; }
.rpt-table td { padding: 5px 8px; border: 1px solid var(--gray-200); text-align: right; font-variant-numeric: tabular-nums; }
.rpt-table td:first-child { text-align: left; font-weight: 600; }
.rpt-table tr.total td { font-weight: 700; background: var(--gray-50); }
.diff-pos { color: #006300; font-weight: 700; }
.diff-neg { color: var(--red); font-weight: 700; }
.chart-wrap { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px; margin-top: 16px; background: #fff; }
.chart-title { text-align: center; font-weight: 700; color: var(--primary-dark); margin-bottom: 14px; }
.chart-cols { display: flex; align-items: flex-end; gap: 8px; height: 200px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 72%; background: var(--primary); border-radius: 4px 4px 0 0; }
.chart-v { font-size: 10.5px; color: var(--gray-600); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.chart-m { font-size: 10.5px; color: var(--gray-600); margin-top: 5px; }
.rpt-scroll { max-height: 400px; overflow-y: auto; margin-top: 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); }
.rpt-scroll .rpt-table { margin-top: 0; border: none; }
.email-preview { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); margin-top: 14px; font-size: 13px; overflow: hidden; }
.email-head { background: var(--gray-50); padding: 12px 16px; border-bottom: 1px solid var(--gray-200); color: var(--gray-700); }
.email-head b { color: var(--gray-800); }
.email-body { padding: 16px; }
.email-clinic { font-weight: 700; margin: 12px 0 4px; }
.email-clinic:first-child { margin-top: 0; }
.email-item { padding: 4px 0 4px 12px; border-left: 3px solid var(--orange); margin: 5px 0; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal-box {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  width: 860px;
  max-width: 100%;
  padding: 26px 28px;
  position: relative;
}
.modal-box.narrow { width: 560px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  border: none; background: var(--gray-100); color: var(--gray-600);
  width: 30px; height: 30px; border-radius: 50%; font-size: 16px;
}
.md-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-right: 40px; }
.md-name { font-size: 20px; font-weight: 700; }
.tstat-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tstat {
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-width: 118px;
}
.tstat .l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-600); font-weight: 600; }
.tstat .v { font-size: 14.5px; font-weight: 700; margin-top: 1px; }
.md-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 760px) { .md-grid { grid-template-columns: 1fr; } }
.panel {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--gray-50);
}
.panel h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--gray-600); margin-bottom: 10px;
}
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; }
.kv .k { color: var(--gray-600); }
.kv .v { font-weight: 600; text-align: right; }
.timeline { list-style: none; }
.timeline li { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.timeline li:last-child { padding-bottom: 0; }
.tl-marker {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: var(--gray-100); color: var(--gray-400);
  border: 2px solid var(--gray-200);
  z-index: 1;
}
.timeline li::before {
  content: ""; position: absolute; left: 10px; top: 22px; bottom: 0;
  width: 2px; background: var(--gray-200);
}
.timeline li:last-child::before { display: none; }
.tl-marker.done { background: var(--green-light); color: var(--green); border-color: var(--green); }
.tl-marker.sched { background: var(--orange-light); color: var(--orange); border-color: var(--orange); }
.tl-body { flex: 1; }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-meta { font-size: 12px; color: var(--gray-600); }
.ref-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ref-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--gray-600); padding: 4px 6px; border-bottom: 1px solid var(--gray-200);
}
.ref-table td { padding: 7px 6px; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
.ref-status {
  display: inline-block; font-size: 11px; font-weight: 700;
  border-radius: 20px; padding: 2px 9px; white-space: nowrap;
}
.ref-status.done { background: var(--green-light); color: var(--green); }
.ref-status.pend { background: var(--blue-light); color: var(--blue); }
.ref-status.sched { background: var(--orange-light); color: var(--orange); }
.ref-status.other { background: var(--gray-100); color: var(--gray-600); }
.note-item { border-bottom: 1px solid var(--gray-200); padding: 8px 0; font-size: 13px; }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 11.5px; color: var(--gray-400); margin-top: 2px; }
.note-input-row { display: flex; gap: 8px; margin-top: 10px; }
.note-input-row input {
  flex: 1; padding: 9px 12px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); outline: none; font-size: 13px;
}
.note-input-row input:focus { border-color: var(--primary); }
.hist-item { padding: 5px 0; border-bottom: 1px dashed var(--gray-200); font-size: 12px; color: var(--gray-600); }
.hist-item:last-child { border-bottom: none; }
.hist-item b { color: var(--gray-700); }
.note-del {
  position: absolute; right: 0; top: 8px;
  border: none; background: var(--gray-100); color: var(--gray-600);
  width: 20px; height: 20px; border-radius: 50%; font-size: 13px; line-height: 1; cursor: pointer;
}
.note-del:hover { background: var(--red-light); color: var(--red); }
.task-item { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--gray-200); align-items: flex-start; }
.task-item:last-child { border-bottom: none; }
.task-item.done { opacity: 0.55; }
.task-check {
  border: 1.5px solid var(--gray-400); background: #fff; border-radius: 5px;
  width: 20px; height: 20px; cursor: pointer; font-size: 12px; line-height: 1; flex: none; margin-top: 1px;
}
.task-check:hover { border-color: var(--green); background: var(--green-light); }

/* ============ Forms ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--gray-700); }
.form-field input, .form-field select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 13.5px; outline: none; background: #fff;
}
.form-field input:focus, .form-field select:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-800); color: #fff;
  padding: 11px 20px; border-radius: 30px; font-size: 13.5px;
  box-shadow: var(--shadow-md); z-index: 200;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 640px) {
  .header { padding: 10px 14px; }
  .metrics-bar, .search-bar, .clinic-chips { padding-left: 14px; padding-right: 14px; }
  .main-content { padding: 14px 14px 60px; }
  .modal-box { padding: 20px 16px; }
}
/* ============ Sidebar layout ============ */
.layout { display: flex; min-height: calc(100vh - 30px); }
.sidebar {
  width: 216px; flex: none;
  background: linear-gradient(180deg, #14275e, #1e40af);
  color: #dde5fb; padding: 16px 12px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  box-sizing: border-box;
}
.sb-brand { display: flex; gap: 10px; align-items: center; padding: 2px 6px 10px; }
.sb-brand .t1 { font-weight: 700; font-size: 15px; color: #fff; line-height: 1.1; }
.sb-brand .t2 { font-size: 11px; color: #aebfee; }
.sb-item {
  display: flex; gap: 9px; align-items: center;
  padding: 9px 12px; border-radius: 8px;
  color: #d5defa; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; user-select: none;
}
.sb-item:hover { background: rgba(255,255,255,0.09); color: #fff; }
.sb-count { margin-left: auto; background: rgba(255,255,255,0.16); border-radius: 10px; padding: 1px 8px; font-size: 10.5px; }
.sb-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #93a8e8; margin: 14px 12px 4px; }
.sb-footer { margin-top: auto; padding: 10px 6px 2px; }
.sidebar .staff-badge { display: block; text-align: center; background: rgba(255,255,255,0.12); color: #fff; }
.mainarea { flex: 1; min-width: 0; padding-bottom: 40px; }
.cm-del { margin-left: 5px; color: var(--gray-400); cursor: pointer; font-weight: 700; text-decoration: none; }
.cm-del:hover { color: var(--red); }
