/* =====================================================
   REACHPT — Provider Portal Styles
   Clinical: Navy + Slate + Green accents
   ===================================================== */

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

:root {
  /* Brand */
  --green-800: #1B4332;
  --green-700: #2D6A4F;
  --green-600: #40916C;
  --green-500: #52B788;
  --green-400: #74C69D;
  --green-300: #95D5B2;
  --green-100: #D8F3DC;
  --green-50:  #F0FAF3;

  --amber-500: #F59E0B;
  --amber-400: #FBBF24;
  --amber-100: #FEF3C7;

  --red-600: #DC2626;
  --red-500: #EF4444;
  --red-100: #FEE2E2;
  --red-50:  #FFF5F5;

  --blue-700: #1D4ED8;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-100: #DBEAFE;
  --blue-50:  #EFF6FF;

  /* Clinical slate palette — more neutral/corporate than patient portal */
  --navy-900: #0F172A;
  --navy-800: #1E293B;
  --navy-700: #334155;
  --navy-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;

  --white: #FFFFFF;
  --off-white: #F5F7FA;

  --sidebar-width: 268px;
  --topbar-height: 64px;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.16);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--navy-900);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: inherit; background: none; }
textarea, input, select { font-family: inherit; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform 0.3s var(--ease-out);
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--white);
}

.sidebar-logo em { font-style: normal; color: var(--green-400); }

.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-close {
  display: none;
  background: rgba(255,255,255,0.08);
  color: var(--white);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.provider-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 14px 8px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.06);
}

.provider-avatar-img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.provider-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--white);
}

.provider-detail {
  font-size: 0.72rem;
  color: var(--slate-400);
  margin-top: 2px;
}

.provider-org {
  font-size: 0.7rem;
  color: var(--green-400);
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 8px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--slate-400);
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--white); }

.nav-item.active {
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(37,99,235,0.15));
  color: #93C5FD;
  border: 1px solid rgba(59,130,246,0.2);
}

.nav-icon { font-size: 1.1rem; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--navy-700);
  color: var(--slate-300);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
}

.nav-badge.unread { background: var(--blue-600); color: var(--white); }
.nav-badge.danger {
  background: var(--red-600);
  color: var(--white);
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
  50% { box-shadow: 0 0 0 4px rgba(220,38,38,0); }
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.ehr-status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.06);
}

.ehr-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ehr-dot.active {
  background: var(--green-400);
  box-shadow: 0 0 8px rgba(116,198,157,0.5);
  animation: ehr-pulse 2s ease-in-out infinite;
}

@keyframes ehr-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(116,198,157,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(116,198,157,0); }
}

.ehr-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--white);
}

.ehr-sub { font-size: 0.7rem; color: var(--green-400); margin-top: 2px; }
.ehr-icon { margin-left: auto; font-size: 1rem; }

/* ── Main Wrap ───────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245,247,250,0.94);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--slate-200);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-menu-btn {
  display: none;
  background: var(--slate-100);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 1rem;
  color: var(--navy-700);
  transition: background 0.2s;
}

.topbar-menu-btn:hover { background: var(--slate-200); }

.breadcrumb-page {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--navy-900);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hipaa-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green-700);
  font-family: var(--font-display);
  white-space: nowrap;
}

.date-chip {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-500);
  white-space: nowrap;
}

.topbar-notif {
  position: relative;
  background: var(--slate-100);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 1rem;
  transition: background 0.2s;
}

.topbar-notif:hover { background: var(--slate-200); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red-500);
  border-radius: 50%;
  border: 2px solid var(--off-white);
}

.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; cursor: pointer; border: 2px solid var(--green-200); }

/* ── Sections ────────────────────────────────────── */
.dash-section { display: none; flex: 1; }
.dash-section.active { display: block; }

.section-content {
  padding: 28px 28px 60px;
  max-width: 1200px;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--navy-900);
  margin-bottom: 6px;
}

.section-sub {
  font-size: 0.95rem;
  color: var(--slate-500);
  margin-bottom: 28px;
  line-height: 1.65;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* ── Welcome Bar ─────────────────────────────────── */
.welcome-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.welcome-bar h1 { margin-bottom: 4px; }
.welcome-bar p { font-size: 0.9rem; color: var(--slate-500); }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-900);
}

.card-link {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--blue-600);
  cursor: pointer;
  transition: color 0.2s;
}

.card-link:hover { color: var(--blue-700); }
.card-link.danger-link { color: var(--red-500); }

/* ── KPI Cards ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  border: 1px solid var(--slate-200);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.kpi-icon.blue   { background: var(--blue-50);   border: 1px solid #BFDBFE; }
.kpi-icon.green  { background: var(--green-50);  border: 1px solid var(--green-100); }
.kpi-icon.amber  { background: var(--amber-100); border: 1px solid #FDE68A; }
.kpi-icon.red    { background: var(--red-50);    border: 1px solid #FECACA; }

.kpi-body { flex: 1; }

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--navy-900);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-delta {
  font-size: 0.75rem;
  font-weight: 600;
}

.kpi-delta.up   { color: var(--green-600); }
.kpi-delta.warn { color: var(--amber-500); }
.kpi-delta.down { color: var(--red-500); }

.kpi-spark {
  position: absolute;
  bottom: 0; right: 0;
  width: 80px; height: 40px;
  opacity: 0.35;
}

.kpi-alert-link {
  margin-top: auto;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--red-500);
  cursor: pointer;
  transition: color 0.2s;
  display: block;
  margin-top: 8px;
}

.kpi-alert-link:hover { color: var(--red-600); }

/* ── Overview Grid ───────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-bottom: 16px;
}

.right-col { display: flex; flex-direction: column; gap: 16px; }

/* ── Patient Table ───────────────────────────────── */
.patient-table-wrap { width: 100%; overflow-x: auto; }

.pt-table-header {
  display: grid;
  grid-template-columns: 160px 140px 60px 90px 80px 60px 100px;
  padding: 8px 12px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  gap: 8px;
}

.pt-table-header span {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--slate-400);
}

.pt-table-row {
  display: grid;
  grid-template-columns: 160px 140px 60px 90px 80px 60px 100px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--slate-50);
  align-items: center;
  transition: background 0.15s;
  border-radius: var(--radius-sm);
  cursor: pointer;
  gap: 8px;
}

.pt-table-row:hover { background: var(--blue-50); }

.pt-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pt-mini-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--white);
  flex-shrink: 0;
}

.pt-mini-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pt-table-row span {
  font-size: 0.84rem;
  color: var(--navy-700);
}

.adh-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.adh-bar-track {
  flex: 1;
  height: 6px;
  background: var(--slate-100);
  border-radius: 3px;
  overflow: hidden;
}

.adh-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.adh-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--navy-700);
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-display);
  white-space: nowrap;
}

.status-badge.on-track  { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-200); }
.status-badge.at-risk   { background: var(--red-50); color: var(--red-600); border: 1px solid #FECACA; }
.status-badge.completed { background: var(--blue-50); color: var(--blue-600); border: 1px solid #BFDBFE; }
.status-badge.new       { background: var(--amber-100); color: #92400E; border: 1px solid #FDE68A; }

/* ── Alert Card ──────────────────────────────────── */
.alert-card {}

.alert-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--red-50);
  border: 1px solid #FECACA;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.alert-preview-item:hover { background: #FEE2E2; transform: translateX(3px); }
.alert-preview-item:last-child { margin-bottom: 0; }

.alert-icon { font-size: 1.3rem; flex-shrink: 0; }

.alert-patient-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--red-600);
  margin-bottom: 3px;
}

.alert-desc {
  font-size: 0.78rem;
  color: var(--navy-700);
  line-height: 1.5;
}

.alert-time {
  font-size: 0.7rem;
  color: var(--slate-400);
  margin-top: 4px;
}

/* ── Quick Ref Form ──────────────────────────────── */
.quick-ref-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Charts Row ──────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--slate-500);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

.legend-dot.green { background: var(--green-500); }
.legend-dot.slate { background: var(--slate-400); }
.legend-dot.blue  { background: var(--blue-500); }
.legend-dot.red   { background: var(--red-500); }
.legend-dot.amber { background: var(--amber-500); }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 12px 22px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  transition: all 0.2s var(--ease-spring);
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(37,99,235,0.45);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--white);
  color: var(--navy-700);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--slate-200);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--slate-50);
  border-color: var(--blue-300);
  color: var(--blue-700);
  transform: translateY(-1px);
}

.full-width { width: 100%; }

/* ── Patient Cards Grid ──────────────────────────── */
.patient-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.patient-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--slate-200);
  overflow: hidden;
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.patient-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--blue-300); }
.patient-card.at-risk { border-color: #FECACA; }
.patient-card.at-risk:hover { border-color: var(--red-400); }

.pc-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-100);
}

.patient-card.at-risk .pc-header { background: var(--red-50); border-color: #FECACA; }

.pc-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--white);
  flex-shrink: 0;
}

.pc-name-block { flex: 1; }

.pc-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy-900);
}

.pc-surgery {
  font-size: 0.78rem;
  color: var(--slate-500);
  margin-top: 2px;
}

.pc-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pc-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pc-metric {
  text-align: center;
  padding: 8px 4px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
}

.pc-metric-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--navy-900);
  line-height: 1;
}

.pc-metric-label {
  font-size: 0.65rem;
  color: var(--slate-400);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

.pc-adherence-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pc-adh-label {
  font-size: 0.75rem;
  color: var(--slate-500);
  white-space: nowrap;
}

.pc-adh-track {
  flex: 1;
  height: 8px;
  background: var(--slate-100);
  border-radius: 4px;
  overflow: hidden;
}

.pc-adh-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s var(--ease-out);
}

.pc-adh-pct {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.pc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--slate-100);
}

.pc-last-log {
  font-size: 0.75rem;
  color: var(--slate-400);
}

/* ── Filter Bar ──────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  flex: 1;
  min-width: 200px;
  transition: border-color 0.2s;
}

.search-wrap:focus-within { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.search-input {
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--navy-900);
  background: transparent;
  flex: 1;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  border: 1.5px solid var(--slate-200);
  color: var(--slate-500);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip:hover { border-color: var(--blue-300); color: var(--blue-600); }
.filter-chip.active { background: var(--blue-600); color: var(--white); border-color: var(--blue-600); }

/* ── Form Controls ───────────────────────────────── */
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--navy-900);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: var(--font-body);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-textarea { resize: vertical; line-height: 1.6; }

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy-700);
  margin-bottom: 6px;
}

.required { color: var(--red-500); }

.form-group { display: flex; flex-direction: column; }

.form-row { display: flex; gap: 14px; }
.form-row.two-col > * { flex: 1; }

.form-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--slate-400);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: var(--font-display);
  margin: 8px 0;
}

.form-divider::before, .form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--slate-200);
}

/* ── Referral Form Layout ────────────────────────── */
.referral-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.referral-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pain-threshold-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pain-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--amber-400) 0%, var(--red-500) 100%);
  outline: none;
  cursor: pointer;
}

.pain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  border: 3px solid var(--amber-500);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.pain-threshold-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--amber-600);
  min-width: 40px;
}

.form-checks { display: flex; flex-direction: column; gap: 10px; }

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--navy-700);
  cursor: pointer;
  line-height: 1.5;
}

.check-label input[type="checkbox"] {
  width: 16px; height: 16px;
  border-radius: 4px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--blue-600);
}

.form-submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}

/* ── Referral Info Col ───────────────────────────── */
.timeline-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ts-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.ts-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
}

.ts-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--navy-900);
  margin-bottom: 3px;
}

.ts-sub { font-size: 0.78rem; color: var(--slate-500); line-height: 1.55; }

.protocol-list { display: flex; flex-direction: column; gap: 8px; }

.protocol-btn {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy-700);
  background: var(--white);
  cursor: pointer;
  transition: all 0.15s;
}

.protocol-btn:hover { background: var(--blue-50); border-color: var(--blue-300); color: var(--blue-700); }

.liability-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #FFFBEB;
  border-color: #FDE68A;
}

.liability-icon { font-size: 1.3rem; flex-shrink: 0; }

.liability-text {
  font-size: 0.82rem;
  color: #78350F;
  line-height: 1.65;
}

.liability-link { color: var(--blue-600); text-decoration: underline; }

/* ── Alerts Section ──────────────────────────────── */
.alerts-list { display: flex; flex-direction: column; gap: 14px; }

.alert-full-item {
  background: var(--white);
  border: 1.5px solid #FECACA;
  border-left: 5px solid var(--red-500);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.alert-full-item:hover { box-shadow: var(--shadow-md); transform: translateX(3px); }

.alert-full-icon { font-size: 2rem; flex-shrink: 0; }

.alert-full-body { flex: 1; }

.alert-full-patient {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--red-600);
  margin-bottom: 4px;
}

.alert-full-meta {
  font-size: 0.8rem;
  color: var(--slate-500);
  margin-bottom: 8px;
}

.alert-full-desc {
  font-size: 0.9rem;
  color: var(--navy-700);
  line-height: 1.65;
  margin-bottom: 12px;
}

.alert-rule-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

.alert-rule-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--navy-900);
  color: var(--white);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.detection-rules-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}

.detection-rule-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--slate-50);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.detection-rule-icon { font-size: 1.25rem; flex-shrink: 0; }

.detection-rule-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--navy-900);
  margin-bottom: 2px;
}

.detection-rule-desc {
  font-size: 0.78rem;
  color: var(--slate-500);
  line-height: 1.5;
}

.alert-full-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.alert-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.alert-btn.primary { background: var(--red-500); color: var(--white); border: none; }
.alert-btn.primary:hover { background: var(--red-600); transform: translateY(-1px); }
.alert-btn.secondary { background: var(--white); color: var(--navy-700); border: 1.5px solid var(--slate-200); }
.alert-btn.secondary:hover { background: var(--slate-50); border-color: var(--slate-300); }

/* ── Reports ─────────────────────────────────────── */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.report-kpi {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--slate-200);
  text-align: center;
}

.report-kpi-val {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--navy-900);
  line-height: 1;
  margin-bottom: 6px;
}

.report-kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.report-kpi-bench {
  font-size: 0.7rem;
  color: var(--green-600);
  font-weight: 600;
  margin-top: 4px;
}

.report-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.clinical-summary {
  background: var(--slate-50);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 0.88rem;
  color: var(--navy-700);
  line-height: 1.75;
}

.clinical-summary ul { padding-left: 18px; margin-top: 4px; }
.clinical-summary li { margin-bottom: 4px; }

/* ── Billing & Documentation ─────────────────────── */
.cpt-table-wrap { overflow-x: auto; }

.cpt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.cpt-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--slate-50);
  color: var(--slate-500);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--slate-100);
  white-space: nowrap;
}

.cpt-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--navy-700);
  vertical-align: top;
}

.cpt-code-cell {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--green-700);
  white-space: nowrap;
}

.cpt-pay-cell {
  font-weight: 700;
  white-space: nowrap;
}

.cpt-table-footnote {
  font-size: 0.75rem;
  color: var(--slate-400);
  margin: 12px 2px 2px;
}

.billing-select-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--navy-700);
  margin-bottom: 6px;
}

.billing-select {
  width: 100%;
  max-width: 420px;
  padding: 10px 14px;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--navy-900);
  background: var(--white);
  margin-bottom: 18px;
}

.billing-select:focus { outline: none; border-color: var(--green-400); }

.channel-hint {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--slate-400);
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: normal;
}

.channel-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.channel-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 2px solid var(--slate-100);
  border-radius: var(--radius-full);
  padding: 9px 16px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--navy-700);
  transition: all 0.2s ease;
}

.channel-chip:hover { border-color: var(--green-300); }

.channel-chip.active {
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  border-color: transparent;
  color: var(--white);
}

.channel-chip-min {
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: 500;
}

.channel-total {
  font-size: 0.8rem;
  color: var(--slate-500);
  margin-bottom: 18px;
}

.channel-total.ready { color: var(--green-700); font-weight: 600; }

.doc-prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.doc-prompt-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--slate-50);
  border: 2px solid var(--slate-100);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.doc-prompt-btn:hover { border-color: var(--green-300); background: var(--green-50); }

.doc-prompt-btn.active {
  border-color: var(--green-500);
  background: var(--green-50);
}

.doc-prompt-icon { font-size: 1.3rem; flex-shrink: 0; }

.doc-prompt-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy-700);
  line-height: 1.35;
}

.doc-note-output {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--slate-100);
}

.doc-note-textarea {
  width: 100%;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--navy-800);
  background: var(--slate-50);
  resize: vertical;
}

.doc-note-textarea:focus { outline: none; border-color: var(--green-400); }

/* ── Patient Detail Panel ────────────────────────── */
.patient-detail-panel {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  backdrop-filter: blur(8px);
  z-index: 400;
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
}

.pdp-inner {
  width: 780px;
  max-width: 95vw;
  background: var(--white);
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.35s var(--ease-out);
}

@keyframes slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.pdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--slate-100);
  flex-wrap: wrap;
  gap: 12px;
  background: var(--slate-50);
}

.pdp-patient-info { display: flex; align-items: center; gap: 14px; }

.pdp-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--white);
  flex-shrink: 0;
}

.pdp-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--navy-900);
  margin-bottom: 3px;
}

.pdp-meta { font-size: 0.82rem; color: var(--slate-500); }

.pdp-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-top: 4px;
}

.pdp-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pdp-close {
  width: 36px; height: 36px;
  background: var(--slate-100);
  border-radius: 50%;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.pdp-close:hover { background: var(--slate-200); }

.pdp-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--slate-100);
}

.pdp-kpi-item {
  padding: 16px 20px;
  border-right: 1px solid var(--slate-100);
  text-align: center;
}

.pdp-kpi-item:last-child { border-right: none; }

.pdp-kpi-val {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--navy-900);
  line-height: 1;
  margin-bottom: 4px;
}

.pdp-kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-400);
}

.pdp-kpi-delta {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 3px;
}

.pdp-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  flex: 1;
}

.pdp-col { display: flex; flex-direction: column; }

.adherence-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.acal-day {
  aspect-ratio: 1;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: default;
}

.acal-day.done    { background: var(--green-100); color: var(--green-700); }
.acal-day.missed  { background: var(--red-100);   color: var(--red-500); }
.acal-day.partial { background: var(--amber-100); color: #92400E; }
.acal-day.future  { background: var(--slate-50);  color: var(--slate-300); }
.acal-day.today   { background: var(--blue-100);  color: var(--blue-700); outline: 2px solid var(--blue-400); }

.pt-notes-list { display: flex; flex-direction: column; gap: 10px; }

.pt-note-item {
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  border-left: 3px solid var(--green-400);
}

.pt-note-date { font-size: 0.7rem; color: var(--slate-400); font-weight: 600; margin-bottom: 4px; }
.pt-note-text { font-size: 0.84rem; color: var(--navy-700); line-height: 1.6; }

/* ── Clinical Inbox ──────────────────────────────── */
.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  height: calc(100vh - var(--topbar-height) - 120px);
  min-height: 400px;
}

.inbox-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  overflow: hidden;
}

.inbox-tabs {
  display: flex;
  border-bottom: 1px solid var(--slate-200);
  padding: 10px 10px 0;
  gap: 4px;
}

.inbox-tab {
  flex: 1;
  padding: 8px 10px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--slate-500);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 6px 6px 0 0;
}

.inbox-tab:hover { color: var(--blue-600); }
.inbox-tab.active { color: var(--blue-600); border-bottom-color: var(--blue-600); background: var(--blue-50); }

.inbox-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }

.inbox-item {
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.inbox-item:hover { background: var(--slate-50); }
.inbox-item.active { background: var(--blue-50); border-color: var(--blue-200); }
.inbox-item.unread .inbox-subject { font-weight: 700; color: var(--navy-900); }

.inbox-from {
  font-family: var(--font-display);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--navy-800);
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.inbox-time { font-size: 0.7rem; color: var(--slate-400); font-weight: 500; }

.inbox-subject {
  font-size: 0.8rem;
  color: var(--navy-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.inbox-preview {
  font-size: 0.74rem;
  color: var(--slate-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  margin-right: 4px;
}

.msg-detail-pane {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-detail-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--slate-100);
  background: var(--slate-50);
}

.msg-detail-body {
  flex: 1;
  padding: 22px;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--navy-700);
  line-height: 1.8;
}

.msg-reply-bar {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--slate-100);
  align-items: flex-end;
}

.msg-reply-bar .form-textarea {
  flex: 1;
  border-radius: var(--radius-md);
  resize: none;
}

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--navy-900);
  color: var(--white);
  border-radius: var(--radius-full);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-lg);
  z-index: 600;
  transition: transform 0.4s var(--ease-spring);
  white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1200px) {
  .overview-grid { grid-template-columns: 1fr; }
  .referral-layout { grid-template-columns: 1fr; }
  .pdp-body { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .main-wrap { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .report-charts-grid { grid-template-columns: 1fr; }
  .report-kpis { grid-template-columns: repeat(3, 1fr); }
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .inbox-sidebar { max-height: 280px; }
}

@media (max-width: 640px) {
  .section-content { padding: 16px 16px 48px; }
  .patient-cards-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .report-kpis { grid-template-columns: repeat(2, 1fr); }
  .hipaa-badge { display: none; }
  .date-chip { display: none; }
  .pdp-inner { width: 100%; }
  .pdp-kpis { grid-template-columns: repeat(2, 1fr); }
  .form-row.two-col { flex-direction: column; }
}
