:root {
  --navy: #1a1f3d;
  --navy-light: #252b4a;
  --navy-lighter: #2f3657;
  --nav-active: #3b5bdb;
  --nav-active-bg: rgba(59, 91, 219, .15);
  --primary: #3b5bdb;
  --primary-light: #e7ecfd;
  --primary-dark: #2b4ac7;
  --accent: #845ef7;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --orange: #f97316;
  --orange-light: #ffedd5;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 180ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════ Sidebar ═══════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 20px;
  flex-shrink: 0;
}
.brand-logo {
  width: 38px; height: 38px;
  background: var(--nav-active);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; letter-spacing: .5px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 14px; }
.brand-sub { font-weight: 400; font-size: 12px; opacity: .7; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 10px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 18px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  white-space: nowrap;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: var(--nav-active); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px 10px;
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--nav-active);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.sidebar-user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.45); }
.sidebar-footer-actions { display: flex; gap: 4px; }
.sidebar-footer-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.6);
  border: none; cursor: pointer;
  font-size: 12px; font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
}
.sidebar-footer-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ═══════ Main Content ═══════ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ═══════ Top Bar ═══════ */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--gray-600); padding: 4px; }
.topbar-welcome { font-size: 15px; font-weight: 600; color: var(--gray-800); white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-search { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.topbar-search input {
  width: 200px;
  padding: 7px 12px 7px 36px;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  font-size: 13px;
  background: var(--gray-50);
  transition: all var(--transition);
  outline: none;
  font-family: inherit;
}
.topbar-search input:focus { width: 280px; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.topbar-icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: none; border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-500);
  transition: all var(--transition);
}
.topbar-icon-btn:hover { background: var(--gray-50); color: var(--gray-700); }
.notification-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.topbar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  border: 2px solid var(--gray-200);
  transition: border-color var(--transition);
}
.topbar-avatar:hover { border-color: var(--primary); }

/* ═══════ Page Content ═══════ */
.page-content { flex: 1; padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-subtitle { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ═══════ KPI Register ═══════ */
.kpi-register {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi-register-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  border-bottom: 1px solid var(--gray-100);
}
.kpi-register-header svg { color: var(--gray-500); }
.kpi-register-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.kpi-reg-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  border-right: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background var(--transition);
}
.kpi-reg-item:last-child { border-right: none; }
.kpi-reg-item:hover { background: var(--gray-50); }
.kpi-reg-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-reg-icon svg { width: 20px; height: 20px; }
.kpi-green { background: #dcfce7; color: #16a34a; }
.kpi-teal { background: #ccfbf1; color: #0d9488; }
.kpi-blue { background: #dbeafe; color: #2563eb; }
.kpi-red { background: #fee2e2; color: #dc2626; }
.kpi-purple { background: #ede9fe; color: #7c3aed; }
.kpi-reg-body { flex: 1; min-width: 0; }
.kpi-reg-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.kpi-reg-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
  margin-bottom: 2px;
}
.kpi-reg-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-bottom: 6px;
}
.kpi-reg-action {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
}
.kpi-reg-action:hover { text-decoration: underline; }

/* Legacy KPI support (therapist dashboard) */
.kpi-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.kpi-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}
.kpi-card-title { font-size: 14px; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.kpi-card-title svg { width: 18px; height: 18px; color: var(--gray-500); }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
}
.kpi-item {
  padding: 8px 16px;
  border-right: 1px solid var(--gray-100);
}
.kpi-item:last-child { border-right: none; }
.kpi-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.kpi-label svg { width: 14px; height: 14px; }
.kpi-label.green { color: var(--success); }
.kpi-label.blue { color: var(--primary); }
.kpi-label.teal { color: var(--teal); }
.kpi-label.orange { color: var(--orange); }
.kpi-label.purple { color: var(--accent); }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.kpi-sub { font-size: 12px; color: var(--primary); cursor: pointer; margin-top: 2px; }
.kpi-sub:hover { text-decoration: underline; }
.kpi-progress { margin-top: 4px; }
.kpi-progress-bar {
  height: 4px; background: var(--gray-100); border-radius: 2px; overflow: hidden; margin-top: 4px;
}
.kpi-progress-fill { height: 100%; border-radius: 2px; transition: width .3s ease; }

/* ═══════ Stat Cards (bottom row) ═══════ */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-card-mini {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.stat-card-mini:hover { box-shadow: var(--shadow-md); }
.stat-mini-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-mini-icon svg { width: 22px; height: 22px; }
.stat-mini-icon.green { background: var(--success-light); color: var(--success); }
.stat-mini-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-mini-icon.orange { background: var(--orange-light); color: var(--orange); }
.stat-mini-icon.teal { background: var(--teal-light); color: var(--teal); }
.stat-mini-label { font-size: 13px; color: var(--gray-500); margin-bottom: 2px; }
.stat-mini-value { font-size: 26px; font-weight: 700; color: var(--gray-900); line-height: 1.1; }

/* ═══════ Cards ═══════ */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.card-header-title { font-size: 14px; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.card-header-title svg { width: 18px; height: 18px; color: var(--gray-400); }
.card-body { padding: 20px; }

/* ═══════ Data Table ═══════ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--gray-500); padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px; font-size: 13.5px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ═══════ Caseload Table Specific ═══════ */
.caseload-name {
  display: flex; align-items: center; gap: 10px;
}
.caseload-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500); flex-shrink: 0;
}
.caseload-avatar svg { width: 16px; height: 16px; }
.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-warning { color: var(--warning); font-weight: 600; }
.text-muted { color: var(--gray-400); }
.rebooking-indicator {
  display: flex; align-items: center; gap: 4px;
  color: var(--danger); font-weight: 600;
}
.rebooking-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.muted-row { font-size: 13px; color: var(--gray-400); padding: 12px 16px; }

/* ═══════ Badges ═══════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-amber { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-teal { background: var(--teal-light); color: var(--teal); }
.badge-sm { font-size: 11px; padding: 1px 8px; }
.discipline-tag {
  display: inline-flex; padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 700;
  background: var(--primary-light); color: var(--primary);
}

/* ═══════ Buttons ═══════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: none; cursor: pointer;
  transition: all var(--transition);
  font-family: inherit; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { padding: 6px; }

/* ═══════ Forms ═══════ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit;
  transition: all var(--transition); outline: none; background: #fff;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ═══════ Schedule / Calendar ═══════ */
/* ═══════ Halaxy-style Schedule ═══════ */
.hx-cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.hx-cal-title {
  font-size: 18px; font-weight: 700; color: var(--navy);
}
.hx-cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.hx-cal-toolbar-left { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.hx-cal-toolbar-right { display: flex; align-items: center; gap: 10px; }
.hx-therapist-select {
  min-width: 200px; font-weight: 600; color: var(--navy);
  border: 2px solid var(--navy); border-radius: var(--radius-sm);
}
.hx-therapist-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--navy); color: #fff;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
}
.hx-therapist-badge svg { width: 16px; height: 16px; }

.cal-nav { display: flex; align-items: center; gap: 0; }
.cal-nav-btn {
  padding: 6px 14px; border: 1px solid var(--gray-200);
  background: #fff; cursor: pointer;
  font-size: 12px; font-family: inherit; font-weight: 600;
  color: var(--gray-600); text-transform: uppercase;
  letter-spacing: 0.3px; transition: all var(--transition);
}
.cal-nav-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.cal-nav-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.cal-nav-btn:not(:first-child) { border-left: none; }
.cal-nav-btn:hover { background: var(--gray-50); color: var(--gray-800); }
.cal-nav-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.hx-cal-grid {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); overflow: hidden;
}
.hx-cal-grid-header {
  display: grid; grid-template-columns: 80px repeat(7, 1fr);
  border-bottom: 2px solid var(--navy);
}
.hx-time-col-header {
  padding: 10px; border-right: 1px solid var(--gray-200);
}
.hx-day-header {
  padding: 10px 8px; font-size: 13px; font-weight: 700;
  color: var(--navy); text-align: center;
  border-right: 1px solid var(--gray-200);
}
.hx-day-header:last-child { border-right: none; }
.hx-day-header.hx-today { background: var(--primary-light); color: var(--primary); }

.hx-cal-grid-body {
  display: grid; grid-template-columns: 80px repeat(7, 1fr);
  position: relative; overflow-y: auto; max-height: 70vh;
}
.hx-time-col { border-right: 1px solid var(--gray-200); }
.hx-time-label {
  font-size: 11px; color: var(--gray-400); text-align: right;
  padding: 0 8px; display: flex; align-items: flex-start;
  justify-content: flex-end; line-height: 1;
}
.hx-day-col {
  position: relative; border-right: 1px solid var(--gray-200);
  cursor: pointer;
}
.hx-day-col:last-child { border-right: none; }
.hx-today-col { background: rgba(59, 91, 219, 0.03); }
.hx-slot { box-sizing: border-box; }

.hx-appt {
  position: absolute; left: 2px; right: 2px;
  border-radius: 4px; padding: 3px 6px;
  overflow: hidden; cursor: pointer;
  z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: box-shadow 0.15s, transform 0.15s;
}
.hx-appt:hover { box-shadow: 0 3px 8px rgba(0,0,0,.25); transform: scale(1.01); z-index: 5; }
.hx-appt-time { font-size: 10px; font-weight: 700; opacity: 0.95; line-height: 1.3; }
.hx-appt-type { font-size: 9px; font-weight: 600; opacity: 0.85; line-height: 1.3; }
.hx-appt-name { font-size: 10px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hx-appt-phone { font-size: 9px; opacity: 0.8; line-height: 1.3; }
.hx-appt-actions {
  position: absolute; bottom: 2px; right: 4px;
  display: flex; gap: 2px;
}
.hx-appt-icon {
  font-size: 11px; opacity: 0.7; cursor: pointer;
}
.hx-appt-icon:hover { opacity: 1; }

/* Legacy calendar support */
.schedule-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.schedule-legend { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--gray-500); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.legend-ncp { background: var(--success); }
.legend-halaxy { background: var(--primary); }
.cal-period { font-size: 16px; font-weight: 600; color: var(--gray-800); min-width: 220px; text-align: center; }

.cal-week { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.cal-week-header { display: grid; grid-template-columns: 80px repeat(7, 1fr); border-bottom: 1px solid var(--gray-200); }
.cal-week-header div { padding: 10px 8px; font-size: 13px; font-weight: 600; color: var(--gray-500); text-align: center; border-right: 1px solid var(--gray-100); }
.cal-week-header div:first-child { border-right: 1px solid var(--gray-200); }
.cal-week-header div:last-child { border-right: none; }
.cal-week-header .today-col { color: var(--primary); background: var(--primary-light); }
.cal-week-body { position: relative; }
.cal-time-row { display: grid; grid-template-columns: 80px repeat(7, 1fr); min-height: 60px; border-bottom: 1px solid var(--gray-100); }
.cal-time-row:last-child { border-bottom: none; }
.cal-time-label { padding: 4px 10px; font-size: 12px; color: var(--gray-400); text-align: right; border-right: 1px solid var(--gray-200); }
.cal-time-cell { border-right: 1px solid var(--gray-100); position: relative; cursor: pointer; transition: background var(--transition); }
.cal-time-cell:hover { background: var(--gray-50); }
.cal-time-cell:last-child { border-right: none; }
.cal-event { position: absolute; left: 2px; right: 2px; border-radius: var(--radius-xs); padding: 2px 6px; font-size: 11px; font-weight: 500; overflow: hidden; cursor: pointer; z-index: 2; }
.cal-event.ncp { background: var(--success); color: #fff; }
.cal-event.halaxy { background: var(--primary); color: #fff; }

/* ═══════ Tabs ═══════ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 16px; }
.tab {
  padding: 9px 18px; font-size: 13px; font-weight: 500;
  color: var(--gray-500); cursor: pointer;
  border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition); font-family: inherit;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ═══════ SOP / Document Cards ═══════ */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.doc-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 18px;
  cursor: pointer; transition: all var(--transition);
  display: flex; flex-direction: column;
}
.doc-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); transform: translateY(-1px); }
.doc-card-cat { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 6px; }
.doc-card-title { font-size: 15px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.doc-card-desc { font-size: 12.5px; color: var(--gray-500); flex: 1; margin-bottom: 10px; }
.doc-card-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--gray-400);
  padding-top: 10px; border-top: 1px solid var(--gray-100);
}

/* ═══════ Document Detail ═══════ */
.doc-detail-body {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 28px;
  line-height: 1.8; font-size: 14px;
}
.doc-detail-body h3 { margin: 20px 0 6px; font-size: 16px; }
.doc-detail-body h3:first-child { margin-top: 0; }
.doc-detail-body ol, .doc-detail-body ul { margin: 6px 0 6px 22px; }
.doc-detail-body li { margin-bottom: 3px; }
.doc-detail-body p { margin-bottom: 10px; }

/* ═══════ Profile ═══════ */
.profile-header { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.profile-name { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.profile-meta { font-size: 13px; color: var(--gray-500); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.detail-section {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 18px;
}
.detail-section-title {
  font-size: 13px; font-weight: 600; color: var(--gray-900);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}
.detail-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.detail-row .label { color: var(--gray-500); }
.detail-row .value { color: var(--gray-900); font-weight: 500; text-align: right; }

/* ═══════ Client Detail (tabbed) ═══════ */
.cd-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 0; flex-wrap: wrap;
}
.cd-header-left { display: flex; align-items: center; gap: 12px; }
.cd-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.cd-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--gray-200);
  margin: 16px 0 20px; overflow-x: auto;
}
.cd-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  color: var(--gray-500); background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.cd-tab:hover { color: var(--primary); }
.cd-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.cd-tab-content { min-height: 200px; }

.cd-overview-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.cd-overview-left {}
.cd-overview-right {}

.cd-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.cd-info-item {}
.cd-info-label {
  font-size: 11px; font-weight: 600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px;
}
.cd-info-value { font-size: 14px; color: var(--gray-900); word-break: break-word; }

.cd-appt-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.cd-appt-stat {
  flex: 1; min-width: 80px; text-align: center;
  padding: 10px 8px; background: var(--gray-50);
  border-radius: var(--radius-sm);
}
.cd-appt-stat-icon { display: flex; justify-content: center; margin-bottom: 4px; color: var(--primary); }
.cd-appt-stat-label { font-size: 11px; color: var(--gray-400); text-transform: uppercase; font-weight: 600; }
.cd-appt-stat-value { font-size: 20px; font-weight: 700; color: var(--gray-900); }

@media (max-width: 768px) {
  .cd-overview-grid { grid-template-columns: 1fr; }
  .cd-header { flex-direction: column; align-items: flex-start; }
  .cd-info-grid { grid-template-columns: 1fr; }
}

/* ═══════ Notes ═══════ */
.notes-timeline { display: flex; flex-direction: column; gap: 10px; }
.note-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 14px 18px; }
.note-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.note-card-participant { font-weight: 600; font-size: 13.5px; color: var(--gray-900); }
.note-card-date { font-size: 12px; color: var(--gray-400); }
.note-card-body { font-size: 13.5px; color: var(--gray-600); line-height: 1.7; }
.note-card-actions { display: flex; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--gray-100); }

/* ═══════ Filter Bar ═══════ */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar .form-input, .filter-bar .form-select { width: auto; min-width: 160px; }

/* ═══════ Settings ═══════ */
.settings-section { max-width: 600px; }
.settings-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--gray-200); }

/* ═══════ Modal ═══════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.95);
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 201;
  width: 90%; max-width: 800px; max-height: 85vh;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: all var(--transition);
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal.modal-lg { max-width: 640px; }
.modal.modal-xl { max-width: 900px; }

tr.clickable { cursor: pointer; transition: background .15s; }
tr.clickable:hover { background: var(--gray-50); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--gray-400); line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px; overflow-y: auto; }

/* ═══════ Toast ═══════ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column-reverse; gap: 8px; }
.toast {
  background: var(--gray-900); color: #fff; padding: 10px 18px;
  border-radius: var(--radius-sm); font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toast-in .3s ease forwards; max-width: 340px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══════ Empty State ═══════ */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; margin-bottom: 14px; }

/* ═══════ Utility ═══════ */
.clickable { cursor: pointer; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }

/* ═══════ Dashboard Filter Dropdown ═══════ */
.dash-filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-period-select {
  width: auto;
  min-width: 170px;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.dash-period-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.dash-period-range {
  font-size: 12px;
  color: var(--gray-400);
  white-space: nowrap;
}
.dash-custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

/* ═══════ Dashboard Widgets Grid ═══════ */
.dash-widgets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ═══════ Today's Session Row ═══════ */
.today-session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
  cursor: pointer;
}
.today-session-row:hover { background: var(--gray-50); }
.today-session-row:last-of-type { border-bottom: none; }
.today-session-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  min-width: 100px;
}
.today-session-info { flex: 1; }

/* ═══════ Lead Funnel ═══════ */
.funnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.funnel-row:last-child { margin-bottom: 0; }
.funnel-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  width: 80px;
  flex-shrink: 0;
}
.funnel-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--gray-100);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.funnel-bar {
  height: 100%;
  border-radius: var(--radius-xs);
  transition: width 0.4s ease;
  min-width: 4px;
}
.funnel-count {
  font-size: 14px;
  font-weight: 700;
  min-width: 30px;
  text-align: right;
}

/* ═══════ Compliance Rows ═══════ */
.compliance-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.compliance-row:last-of-type { border-bottom: none; }
.compliance-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.compliance-icon svg { width: 18px; height: 18px; }
.ci-warning { background: var(--warning-light); color: var(--warning); }
.ci-danger { background: var(--danger-light); color: var(--danger); }
.ci-primary { background: var(--primary-light); color: var(--primary); }
.ci-teal { background: var(--teal-light); color: var(--teal); }
.compliance-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
  margin-left: auto;
}

/* ═══════ Responsive ═══════ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .topbar-welcome { display: none; }
  .topbar-search input { width: 140px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-item { border-bottom: 1px solid var(--gray-100); }
  .kpi-register-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-reg-item { border-bottom: 1px solid var(--gray-100); }
  .kpi-reg-item:nth-child(2n) { border-right: none; }
  .stat-cards-grid { grid-template-columns: 1fr 1fr; }
  .dash-widgets-grid { grid-template-columns: 1fr; }
  .cal-week-header, .cal-time-row { grid-template-columns: 60px repeat(7, 1fr); }
  .hx-cal-grid-header, .hx-cal-grid-body { grid-template-columns: 60px repeat(7, 1fr); }
  .hx-cal-title { font-size: 14px; }
  .hx-cal-toolbar { gap: 8px; }
  .hx-therapist-select { min-width: 150px; }
}
@media (max-width: 480px) {
  .stat-cards-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-register-grid { grid-template-columns: 1fr; }
  .kpi-reg-item { border-right: none; }
}
