/* ==========================================================================
   LOGI FINTECH - Modern CRM Design System
   Brand Color: #0A4D8C | Responsive, Premium, Ultra-clean
   ========================================================================== */

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

:root {
  /* Brand Core */
  --brand-primary: #0A4D8C;
  --brand-primary-hover: #083c6d;
  --brand-primary-light: #eaf2fa;
  --brand-primary-subtle: #f0f6fc;
  --brand-accent: #00A3E0;
  
  /* Status Colors */
  --status-active-bg: #dcfce7;
  --status-active-text: #15803d;
  --status-prospect-bg: #fef3c7;
  --status-prospect-text: #b45309;
  --status-inactive-bg: #f1f5f9;
  --status-inactive-text: #64748b;
  
  /* Priority Colors */
  --priority-high: #ef4444;
  --priority-med: #f59e0b;
  --priority-low: #10b981;
  
  /* Channels */
  --whatsapp-color: #25D366;
  --whatsapp-hover: #20bd5a;
  --whatsapp-light: #e8fbf0;

  /* Surfaces & Backgrounds */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;
  
  /* Borders */
  --border-light: #e2e8f0;
  --border-focus: #0A4D8C;
  
  /* Typography */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 12px 20px -3px rgba(10, 77, 140, 0.12);
  
  /* Geometry */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  
  --sidebar-width: 260px;
  --header-height: 70px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--brand-primary-hover);
}

/* ==========================================================================
   Layout Structure
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  height: 70px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
}

.sidebar-brand picture {
  display: flex;
  align-items: center;
  max-width: 100%;
}

.sidebar-brand img {
  max-height: 48px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-brand:hover img {
  opacity: 0.95;
  transform: scale(1.02);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--brand-primary), #1e6bb8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(10, 77, 140, 0.25);
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--brand-primary);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-subtle);
  padding: 12px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform 0.2s;
}

.nav-link:hover {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
}

.nav-link:hover svg {
  transform: translateX(2px);
}

.nav-link.active {
  background-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(10, 77, 140, 0.25);
}

.nav-link.active svg {
  stroke: #ffffff;
}

.nav-badge {
  margin-left: auto;
  background: rgba(10, 77, 140, 0.12);
  color: var(--brand-primary);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.nav-link.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  background-color: #fafbfc;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.user-info {
  line-height: 1.2;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-search {
  position: relative;
  width: 380px;
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 16px 0 42px;
  background-color: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(10, 77, 140, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Content Container */
.app-content {
  padding: 28px 32px;
  flex: 1;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(10, 77, 140, 0.2);
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(10, 77, 140, 0.25);
}

.btn-outline {
  background-color: #ffffff;
  border-color: var(--border-light);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--bg-body);
  border-color: #cbd5e1;
  color: var(--text-main);
}

.btn-whatsapp {
  background-color: var(--whatsapp-color);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.25);
}

.btn-whatsapp:hover {
  background-color: var(--whatsapp-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-email {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid rgba(10, 77, 140, 0.15);
}

.btn-email:hover {
  background-color: #dbeaf9;
  color: var(--brand-primary-hover);
}

.btn-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background-color: #fca5a5;
  color: #991b1b;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.text-danger {
  color: #ef4444 !important;
}

.btn-outline.text-danger:hover {
  background-color: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626 !important;
}

.w-3\.5, svg.w-3\.5 {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Cards & Grid
   ========================================================================== */

.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

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

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  background-color: #fafbfc;
  border-top: 1px solid var(--border-light);
}

/* KPI Dashboard Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card, a.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.kpi-card:hover, a.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(10, 77, 140, 0.4);
  color: inherit;
  text-decoration: none;
}

/* Filter Navigation Tabs */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-tab {
  padding: 8px 16px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-tab:hover {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
  text-decoration: none;
}

.filter-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 6px rgba(10, 77, 140, 0.25);
}

.filter-tab .badge-count {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #475569;
}

.filter-tab.active .badge-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon svg {
  width: 26px;
  height: 26px;
}

.kpi-content {
  flex: 1;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-trend {
  font-size: 11.5px;
  margin-top: 4px;
  font-weight: 600;
}

/* Color Themes for KPI */
.kpi-blue .kpi-icon { background: var(--brand-primary-light); color: var(--brand-primary); }
.kpi-green .kpi-icon { background: #dcfce7; color: #16a34a; }
.kpi-amber .kpi-icon { background: #fef3c7; color: #d97706; }
.kpi-purple .kpi-icon { background: #ede9fe; color: #7c3aed; }
.kpi-red .kpi-icon { background: #fee2e2; color: #dc2626; }
.kpi-cyan .kpi-icon { background: #e0f2fe; color: #0284c7; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background-color: #fafbfc;
  padding: 13px 18px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13.5px;
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color 0.15s ease;
}

.table tbody tr:hover {
  background-color: var(--brand-primary-subtle);
}

/* ==========================================================================
   Badges & Tags
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.badge-active {
  background-color: var(--status-active-bg);
  color: var(--status-active-text);
}

.badge-prospect {
  background-color: var(--status-prospect-bg);
  color: var(--status-prospect-text);
}

.badge-inactive {
  background-color: var(--status-inactive-bg);
  color: var(--status-inactive-text);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  margin-right: 4px;
  margin-bottom: 4px;
}

.client-code-badge {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--brand-primary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.form-col-full {
  grid-column: 1 / -1;
}

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

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-label .required {
  color: #ef4444;
}

.form-hint {
  font-size: 12px;
  color: var(--text-subtle);
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(10, 77, 140, 0.12);
}

.form-control.is-invalid {
  border-color: #ef4444;
  background-color: #fff8f8;
}

.invalid-feedback {
  font-size: 12px;
  color: #ef4444;
  display: none;
}

.form-control.is-invalid + .invalid-feedback {
  display: block;
}

textarea.form-control {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
}

/* Input with Prefix */
.input-group {
  display: flex;
  align-items: center;
}

.input-group-addon {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background-color: #f1f5f9;
  border: 1px solid var(--border-light);
  border-right: none;
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group .form-control {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Multi-select Tags Container */
.tag-selector-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  min-height: 48px;
}

.tag-checkbox-pill {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.tag-checkbox-pill input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.tag-checkbox-pill .pill-text {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background-color: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
}

.tag-checkbox-pill input:checked + .pill-text {
  background-color: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 4px rgba(10, 77, 140, 0.2);
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */

.alert-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-icon {
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

.alert-close {
  background: none;
  border: none;
  font-size: 20px;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}

.alert-close:hover { opacity: 1; }

.alert-success {
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-danger {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-warning {
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-info {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* ==========================================================================
   Client Profile Specifics
   ========================================================================== */

.profile-header-card {
  background: linear-gradient(135deg, #0A4D8C 0%, #06325C 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.profile-header-card::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
}

.profile-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile-avatar-lg {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 3px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
}

.profile-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.profile-meta-chips {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
}

.profile-actions-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Profile Grid */
.profile-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

/* Info List Items */
.info-list {
  display: flex;
  flex-direction: column;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-light);
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
}

/* Family Primary Contact Banner */
.family-contact-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.family-contact-banner .contact-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.family-contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Tree Structure for Referrals */
.referral-tree-container {
  padding: 16px 0;
}

.tree-node {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.tree-node.highlight {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.tree-branch {
  position: relative;
  padding-left: 28px;
  margin-top: 14px;
  border-left: 2px dashed #cbd5e1;
}

/* ==========================================================================
   Filter Bar
   ========================================================================== */

.filter-bar {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-item {
  flex: 1;
  min-width: 150px;
}

.filter-item-search {
  flex: 2;
  min-width: 240px;
}

/* ==========================================================================
   Modal Dialogs
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-subtle);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  background: #fafbfc;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   Mobile Responsive Cards (Table to Cards switch)
   ========================================================================== */

.mobile-client-cards {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.mobile-client-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.mobile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mobile-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
}

.mobile-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 868px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  
  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .app-content {
    padding: 20px 16px;
  }

  .app-header {
    padding: 0 16px;
  }

  .header-search {
    display: none;
  }

  .form-grid, .form-grid-3 {
    grid-template-columns: 1fr;
  }

  /* Switch desktop table to card view on mobile as required */
  .desktop-table-view {
    display: none;
  }

  .mobile-client-cards {
    display: flex;
  }
}
