/* ===========================================================================
   LEAD THE WAY — Application Stylesheet
   Dark theme, mobile-first, designed for field use
   =========================================================================== */

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

/* ── Reset & Variables ── */
:root {
  --bg: #0c0e14;
  --surface: #12151e;
  --surface2: #181c28;
  --surface3: #1e2436;
  --border: #252a3e;
  --text: #c8cdd8;
  --text2: #6b7490;
  --text3: #4a5268;
  --blue: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  /* iOS safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* ── Loading screen ── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; gap: 12px; color: var(--text2);
}
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App Layout ── */
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ── Top Bar (mobile) ── */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  padding-top: var(--safe-top);
  background: rgba(12,14,20,0.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding-left: 16px; padding-right: 16px;
  gap: 12px; z-index: 90;
}
.menu-btn {
  background: none; border: none; color: var(--text); font-size: 22px;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
}
.menu-btn:hover { background: var(--surface2); }
.top-title { font-size: 15px; font-weight: 700; color: #f0f2f5; }
.conn-badge {
  margin-left: auto; font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 20px;
}
.conn-badge.offline { background: rgba(239,68,68,0.15); color: #f87171; }
.conn-badge.syncing { background: rgba(59,130,246,0.15); color: #60a5fa; }

@media (min-width: 769px) {
  .top-bar { display: none; }
  .menu-btn { display: none; }
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 100;
  transform: translateX(-100%); transition: transform 0.25s ease;
  padding-top: var(--safe-top);
}
.sidebar.open { transform: translateX(0); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
}

@media (min-width: 769px) {
  .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: none; }
}

.sidebar-brand {
  padding: 20px 16px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; }
.brand-text { font-family: var(--mono); font-size: 16px; font-weight: 700; color: #f0f2f5; }

.nav-list { list-style: none; padding: 12px 8px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--text2); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: all 0.15s;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: rgba(59,130,246,0.12); color: var(--blue); font-weight: 600; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.logout-btn {
  width: 100%; background: none; border: none; color: var(--text2);
  padding: 10px 12px; text-align: left; font-size: 13px; cursor: pointer;
  border-radius: var(--radius-sm);
}
.logout-btn:hover { background: var(--surface2); color: var(--red); }

/* ── Main Content ── */
.main-content {
  flex: 1; padding: calc(var(--topbar-h) + var(--safe-top) + 16px) 16px calc(16px + var(--safe-bottom));
  max-width: 1200px;
}
@media (min-width: 769px) {
  .main-content { margin-left: var(--sidebar-w); padding: 24px 32px; }
}

/* ── Page ── */
.page { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: #f0f2f5; }
.page-sub { color: var(--text2); font-size: 14px; }
.header-actions { display: flex; gap: 8px; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 700; color: #f0f2f5; }
.card-title { font-size: 14px; font-weight: 700; color: #f0f2f5; margin-bottom: 12px; }

/* ── Stat Grid ── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--surface3); transform: translateY(-1px); }
.stat-icon { width: 36px; height: 36px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center; font-size: 18px; margin-bottom: 10px; }
.stat-value { font-family: var(--mono); font-size: 28px; font-weight: 700; color: #f0f2f5; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── Buttons ── */
.btn {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: all 0.15s; display: inline-flex;
  align-items: center; gap: 6px; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: #2563eb; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface2); border-color: var(--text2); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-full { width: 100%; justify-content: center; padding: 12px; }

/* ── Inputs ── */
.input {
  font-family: var(--font); font-size: 14px; width: 100%;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--blue); }
.input::placeholder { color: var(--text3); }
.textarea { min-height: 80px; resize: vertical; }
select.input { appearance: auto; }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-input { max-width: 300px; }
.filter-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pill {
  font-family: var(--font); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; transition: all 0.15s;
}
.pill:hover { background: var(--surface2); color: var(--text); }
.pill.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ── Dog Grid ── */
.dog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.dog-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.dog-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.dog-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dog-avatar {
  width: 40px; height: 40px; border-radius: 10px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.dog-name { font-size: 15px; font-weight: 700; color: #f0f2f5; }
.dog-breed { font-size: 12px; color: var(--text2); }
.handling-dot {
  width: 12px; height: 12px; border-radius: 50%; margin-left: auto; flex-shrink: 0;
}
.dog-card-body { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Status Badges ── */
.status-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 20px; text-transform: capitalize;
}
.status-prospect    { background: rgba(107,114,128,0.15); color: #9ca3af; }
.status-new         { background: rgba(59,130,246,0.15); color: #60a5fa; }
.status-active, .status-enrolled { background: rgba(34,197,94,0.15); color: #4ade80; }
.status-graduated, .status-alumni { background: rgba(139,92,246,0.15); color: #a78bfa; }
.status-contacted   { background: rgba(245,158,11,0.15); color: #fbbf24; }
.status-consultation_booked { background: rgba(139,92,246,0.15); color: #a78bfa; }
.status-consultation_done   { background: rgba(6,182,212,0.15); color: #22d3ee; }
.status-proposal_sent { background: rgba(236,72,153,0.15); color: #f472b6; }
.status-scheduled   { background: rgba(59,130,246,0.12); color: #60a5fa; }
.status-confirmed   { background: rgba(34,197,94,0.12); color: #4ade80; }
.status-completed   { background: rgba(107,114,128,0.12); color: #9ca3af; }
.status-cancelled   { background: rgba(239,68,68,0.12); color: #f87171; }
.status-paused      { background: rgba(245,158,11,0.12); color: #fbbf24; }

.program-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 20px; background: rgba(6,182,212,0.12); color: #22d3ee;
}

/* ── Pipeline (Kanban) ── */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.pipeline-col { min-width: 200px; flex: 1; }
.pipeline-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border-top: 3px solid; font-size: 13px;
  font-weight: 700; color: #f0f2f5; margin-bottom: 8px;
}
.pipeline-count {
  font-family: var(--mono); font-size: 12px; background: var(--surface2);
  padding: 2px 8px; border-radius: 10px; color: var(--text2);
}
.pipeline-cards { display: flex; flex-direction: column; gap: 8px; }
.pipeline-empty {
  text-align: center; padding: 20px; color: var(--text3); font-size: 12px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.lead-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; cursor: pointer;
  transition: border-color 0.2s;
}
.lead-card:hover { border-color: var(--blue); }
.lead-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.lead-dog-name { font-size: 13px; font-weight: 700; color: #f0f2f5; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lead-challenges { font-size: 12px; color: var(--text2); margin-bottom: 6px; line-height: 1.4; }
.lead-meta { display: flex; gap: 8px; font-size: 11px; color: var(--text3); }
.lead-source { text-transform: capitalize; }

/* ── Appointment List ── */
.appt-list { display: flex; flex-direction: column; gap: 4px; }
.appt-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); transition: background 0.15s;
}
.appt-row:hover { background: var(--surface2); }
.appt-time { font-family: var(--mono); font-size: 13px; color: var(--blue); min-width: 65px; }
.appt-type { font-size: 13px; flex: 1; }
.appt-status { font-size: 11px; }

/* ── Lead Row ── */
.lead-list { display: flex; flex-direction: column; gap: 2px; }
.lead-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s;
}
.lead-row:hover { background: var(--surface2); }

/* ── Profile / Detail ── */
.profile-header { }
.profile-top { display: flex; align-items: center; gap: 16px; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 16px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center; font-size: 32px; flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.profile-name { font-size: 22px; font-weight: 700; color: #f0f2f5; }
.profile-sub { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.profile-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Field Rows ── */
.field-group { display: flex; flex-direction: column; gap: 2px; }
.field-row {
  display: flex; padding: 8px 0; border-bottom: 1px solid var(--border);
  gap: 12px; font-size: 13px;
}
.field-row:last-child { border-bottom: none; }
.field-label { color: var(--text2); min-width: 120px; flex-shrink: 0; font-weight: 500; }
.field-value { color: var(--text); }

/* ── Forms ── */
.form { max-width: 560px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Data Table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 8px 12px; font-weight: 600; color: var(--text2);
  border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--surface2); }

/* ── Link ── */
.link { color: var(--blue); text-decoration: none; font-size: 13px; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ── Empty / Loading states ── */
.empty-state { text-align: center; padding: 32px; color: var(--text3); font-size: 14px; }
.loading-state { text-align: center; padding: 32px; color: var(--text2); }
.error-text { color: var(--red); font-size: 13px; margin: 8px 0; }

/* ── Placeholder page ── */
.placeholder-page {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 64px 24px; text-align: center;
}
.placeholder-icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-page h2 { font-size: 22px; margin-bottom: 8px; color: #f0f2f5; }
.placeholder-page p { color: var(--text2); max-width: 360px; }

/* ── Login ── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 24px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; width: 100%; max-width: 380px;
  text-align: center;
}
.login-brand { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; font-weight: 700; color: #f0f2f5; margin-bottom: 4px; }
.login-sub { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }

/* ── Mobile optimizations ── */
@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline { flex-direction: column; }
  .pipeline-col { min-width: unset; }
  .form-row { grid-template-columns: 1fr; }
  .dog-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; gap: 2px; }
  .field-label { min-width: unset; }
}

/* ── Touch targets ── */
@media (hover: none) {
  .btn { min-height: 44px; }
  .input { min-height: 44px; }
  .nav-link { min-height: 44px; }
}

/* ===========================================================================
   SCHEDULE SCREEN
   =========================================================================== */

.schedule-nav {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.schedule-date { font-size: 15px; font-weight: 600; color: #f0f2f5; margin-left: 4px; }
.schedule-today { font-size: 12px; }
.view-toggle { display: flex; gap: 4px; margin-left: auto; }

.schedule-timeline { }
.timeline-hour {
  display: flex; gap: 12px; min-height: 48px;
  border-bottom: 1px solid var(--border); padding: 4px 0;
}
.hour-label {
  font-family: var(--mono); font-size: 12px; color: var(--text3);
  min-width: 50px; padding-top: 4px; text-align: right;
}
.hour-slots { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.appt-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid; border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; transition: border-color 0.2s, transform 0.15s;
}
.appt-card:hover { transform: translateX(2px); border-color: var(--blue); }
.appt-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.appt-card-time { font-family: var(--mono); font-size: 12px; color: var(--blue); }
.appt-card-title { font-size: 13px; font-weight: 600; color: #f0f2f5; }
.appt-card-location { font-size: 11px; color: var(--text2); margin-top: 4px; }
.appt-card-zoom { font-size: 11px; margin-top: 4px; display: inline-block; }

.week-day-group { margin-bottom: 16px; }
.week-day-label {
  font-size: 13px; font-weight: 700; color: var(--blue);
  padding: 8px 0 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.week-day-group .appt-card { margin-bottom: 6px; }

/* ===========================================================================
   DOG FORM
   =========================================================================== */

.dog-form { max-width: 680px; }
.form-section-title {
  font-size: 15px; font-weight: 700; color: var(--blue);
  margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid var(--border);
}
.form-section-title:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

.handling-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.handling-btn {
  font-family: var(--font); font-size: 12px; font-weight: 600;
  padding: 8px 14px; border-radius: 20px; border: 2px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; transition: all 0.15s;
}
.handling-btn.active { color: white; }
.handling-btn.handling-green { border-color: #22c55e40; }
.handling-btn.handling-green.active { background: #22c55e; border-color: #22c55e; color: #0a0c12; }
.handling-btn.handling-yellow { border-color: #eab30840; }
.handling-btn.handling-yellow.active { background: #eab308; border-color: #eab308; color: #0a0c12; }
.handling-btn.handling-purple { border-color: #a855f740; }
.handling-btn.handling-purple.active { background: #a855f7; border-color: #a855f7; }
.handling-btn.handling-black { border-color: #37415140; }
.handling-btn.handling-black.active { background: #374151; border-color: #374151; }

.trigger-input-row { display: flex; gap: 8px; }
.trigger-input-row .input { flex: 1; }
.trigger-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.trigger-tag {
  display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500;
  padding: 4px 10px; background: rgba(239,68,68,0.12); color: #f87171;
  border-radius: 20px;
}
.trigger-remove {
  background: none; border: none; color: #f87171; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px;
}
.trigger-remove:hover { color: #ef4444; }

.reactivity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.reactivity-item { display: flex; align-items: center; gap: 8px; }
.reactivity-label { font-size: 12px; color: var(--text2); min-width: 80px; text-transform: capitalize; }
.reactivity-select { max-width: 120px; font-size: 12px; padding: 6px 8px; }

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

/* ===========================================================================
   MESSAGES / CHAT
   =========================================================================== */

.messages-page .page-header { margin-bottom: 12px; }
.messages-layout { display: flex; gap: 0; height: calc(100vh - 140px); min-height: 400px; }

.msg-sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius); overflow-y: auto;
}
.msg-sidebar-header {
  padding: 12px 14px; font-size: 12px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
}
.msg-enrollment {
  padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.msg-enrollment:hover { background: var(--surface2); }
.msg-enrollment.active { background: rgba(59,130,246,0.1); border-left: 3px solid var(--blue); }
.msg-enrollment-name { font-size: 13px; font-weight: 600; color: #f0f2f5; }
.msg-enrollment-status { font-size: 11px; color: var(--text2); text-transform: capitalize; }
.msg-empty { padding: 20px; text-align: center; color: var(--text3); font-size: 12px; }

.msg-chat {
  flex: 1; display: flex; flex-direction: column; background: var(--bg);
  border: 1px solid var(--border); border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.msg-chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.msg-chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 14px;
}

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

.msg-bubble {
  max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 13px;
}
.msg-bubble.sent {
  align-self: flex-end; background: rgba(59,130,246,0.15); border-bottom-right-radius: 4px;
}
.msg-bubble.received {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-bubble-header { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 11px; }
.msg-type-icon { font-size: 12px; }
.msg-sender { font-weight: 600; color: var(--text2); text-transform: capitalize; }
.msg-time { color: var(--text3); margin-left: auto; }
.msg-body { line-height: 1.5; color: var(--text); white-space: pre-wrap; }
.msg-tag {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 6px;
  border-radius: 4px; margin-top: 6px;
}
.homework-tag { background: rgba(245,158,11,0.15); color: #fbbf24; }
.progress-tag { background: rgba(34,197,94,0.15); color: #4ade80; }
.msg-pin { font-size: 10px; color: var(--text3); margin-top: 4px; }

.msg-compose {
  display: flex; align-items: center; gap: 8px; padding: 12px;
  border-top: 1px solid var(--border); background: var(--surface);
  border-radius: 0 0 var(--radius) 0;
}
.msg-type-selector { display: flex; gap: 2px; }
.msg-type-btn {
  background: none; border: 1px solid transparent; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: 16px; transition: all 0.15s;
}
.msg-type-btn:hover { background: var(--surface2); }
.msg-type-btn.active { background: var(--surface2); border-color: var(--blue); }
.msg-input { flex: 1; }
.msg-send { padding: 10px 16px; font-size: 18px; }

@media (max-width: 768px) {
  .messages-layout { flex-direction: column; height: auto; }
  .msg-sidebar { width: 100%; max-height: 150px; border-radius: var(--radius) var(--radius) 0 0; }
  .msg-chat { border-left: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); min-height: 400px; }
}

/* ── Follow-up Alerts ── */
.alert-card { border-left: 3px solid var(--amber); }
.alert-count {
  background: var(--amber); color: #000; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; min-width: 20px; text-align: center;
}
.followup-list { display: flex; flex-direction: column; gap: 2px; }
.followup-row {
  display: grid; grid-template-columns: 1fr 2fr auto;
  gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer;
  border-radius: 6px; transition: background 0.15s;
}
.followup-row:hover { background: var(--surface2); }
.followup-info { display: flex; align-items: center; gap: 8px; }
.followup-dog { font-weight: 600; color: var(--text); }
.followup-detail { color: var(--text2); font-size: 13px; }
.followup-challenge { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.followup-meta { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.followup-date { font-size: 12px; font-weight: 600; color: var(--amber); font-family: var(--mono); }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.priority-urgent { background: var(--red); }
.priority-high { background: var(--amber); }
.priority-normal { background: var(--text3); }
.priority-low { background: var(--text3); opacity: 0.5; }

@media (max-width: 768px) {
  .followup-row { grid-template-columns: 1fr; gap: 4px; }
  .followup-meta { justify-content: flex-start; }
}

/* ── Connection Bar ── */
.connection-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.conn-offline { background: var(--red); color: white; }
.conn-syncing { background: var(--amber); color: #000; }
.conn-icon { font-size: 16px; }
.conn-text { flex: 1; }
.conn-sync-btn {
  background: rgba(0,0,0,0.2); color: inherit; border: none; padding: 4px 12px;
  border-radius: 4px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.conn-sync-btn:hover { background: rgba(0,0,0,0.3); }

/* ── Install Banner ── */
.install-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border);
  font-size: 14px; color: var(--text);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.install-banner span { flex: 1; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Offline Save Banner ── */
.offline-save-banner {
  background: var(--amber); color: #000; padding: 10px 16px;
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
  margin-bottom: 12px; text-align: center;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.offline-hint { font-size: 12px; color: var(--amber); margin-left: 8px; }
.success-text { color: var(--green); font-size: 13px; font-weight: 600; }
.error-text { color: var(--red); font-size: 13px; font-weight: 600; }

/* ── Lead Pipeline Progress ── */
.lead-pipeline-progress {
  display: flex; gap: 4px; align-items: center; overflow-x: auto; padding: 4px 0;
}
.pipeline-step {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text3);
  text-transform: capitalize; white-space: nowrap; padding: 4px 8px; border-radius: 4px;
}
.pipeline-step.active { color: var(--text2); }
.pipeline-step.current {
  color: var(--blue); font-weight: 700; background: rgba(59,130,246,0.1);
}
.pipeline-step-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0;
}
.pipeline-step.active .pipeline-step-dot { background: var(--blue); }
.pipeline-step.current .pipeline-step-dot {
  background: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ── Lead Card Inline Edit ── */
.lead-card-editing {
  background: var(--surface2); border: 1px solid var(--blue); cursor: default;
}
.lead-card-editing .input-sm {
  font-size: 12px; padding: 5px 8px; background: var(--surface); border: 1px solid var(--border);
}
.lead-card-editing textarea.input-sm { resize: vertical; }
.lead-card-editing select.input-sm { font-size: 11px; padding: 4px 6px; }
.pipeline-overall { font-size: 13px; color: var(--green); font-weight: 600; font-family: var(--mono); }
.pipeline-rate { font-size: 10px; color: var(--text3); font-family: var(--mono); margin-left: auto; }

/* ── Reports ── */
.report-bars { display: flex; flex-direction: column; gap: 10px; }
.report-bar-row { display: flex; align-items: center; gap: 12px; }
.report-bar-label { width: 140px; font-size: 13px; color: var(--text2); text-transform: capitalize; flex-shrink: 0; }
.report-bar-track { flex: 1; height: 20px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.report-bar-fill { height: 100%; background: var(--blue); border-radius: 4px; transition: width 0.3s ease; min-width: 2px; }
.report-bar-value { width: 80px; text-align: right; font-size: 13px; font-family: var(--mono); color: var(--text); font-weight: 600; }

/* ── Chat media ── */
.msg-media { margin-bottom: 6px; }
.msg-img { max-width: 200px; border-radius: 8px; cursor: pointer; }
.msg-video { max-width: 280px; border-radius: 8px; }
.msg-attach { font-size: 20px; padding: 8px; }

@media (max-width: 768px) {
  .report-bar-label { width: 100px; font-size: 11px; }
  .report-bar-value { width: 60px; font-size: 11px; }
}

/* ── Data Browser ── */
.data-browser-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.data-browser-tab {
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text2);
  cursor: pointer; transition: all 0.15s;
}
.data-browser-tab:hover { background: var(--surface2); color: var(--text); border-color: var(--text3); }
.data-browser-tab.active {
  background: var(--blue); color: #fff; border-color: var(--blue);
}
.data-browser-table select.input-sm {
  min-width: 100px; font-size: 12px; padding: 4px 8px;
  background: var(--surface); border: 1px solid var(--border);
}
.row-saving { opacity: 0.5; pointer-events: none; }

/* ── Message History ── */
.msg-history { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.msg-history-item {
  padding: 10px 12px; background: var(--surface2); border-radius: 8px;
}
.msg-history-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px;
}
.msg-history-time { color: var(--text3); font-family: var(--mono); margin-left: auto; }
.msg-history-body { color: var(--text); font-size: 13px; line-height: 1.5; margin: 0; }

/* ── Schedule Page ── */
.schedule-nav {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  padding: 12px; background: var(--surface); border-radius: var(--radius);
}
.schedule-date { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: center; }
.schedule-date input[type="date"] { background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px; border-radius: 6px; font-family: var(--mono); }
.schedule-date-label { color: var(--text2); font-size: 13px; }
.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.schedule-item {
  display: flex; gap: 16px; align-items: flex-start; padding: 16px !important;
}
.schedule-item-time {
  display: flex; flex-direction: column; align-items: flex-end; min-width: 70px;
  font-family: var(--mono); font-size: 14px; font-weight: 600;
}
.schedule-time-start { color: var(--text); }
.schedule-time-end { color: var(--text3); font-size: 12px; }
.schedule-item-body { flex: 1; }
.schedule-item-title { font-weight: 600; color: var(--text); text-transform: capitalize; margin-bottom: 4px; }
.schedule-item-loc { color: var(--text2); font-size: 13px; }
.schedule-item-status { margin-left: auto; }

/* ── Messages Page ── */
.messages-layout {
  display: flex; height: calc(100vh - 140px); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
.msg-sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0;
}
.msg-thread {
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.msg-thread:hover { background: var(--surface2); }
.msg-thread.active { background: var(--surface2); border-left: 3px solid var(--blue); }
.msg-thread-name { font-weight: 600; color: var(--text); font-size: 14px; }
.msg-thread-sub { color: var(--text3); font-size: 12px; margin-top: 2px; text-transform: capitalize; }
.msg-chat {
  flex: 1; display: flex; flex-direction: column; background: var(--bg);
}
.msg-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.msg-bubble {
  max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5;
}
.msg-sent {
  align-self: flex-end; background: var(--blue); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-received {
  align-self: flex-start; background: var(--surface); color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg-bubble .msg-time { font-size: 11px; opacity: 0.6; margin-top: 4px; }
.msg-compose {
  display: flex; align-items: center; gap: 8px; padding: 12px;
  border-top: 1px solid var(--border); background: var(--surface);
}
.msg-input { flex: 1; }
.msg-send { padding: 10px 16px; font-size: 18px; }

@media (max-width: 768px) {
  .messages-layout { flex-direction: column; height: auto; }
  .msg-sidebar { width: 100%; max-height: 150px; }
  .msg-chat { min-height: 400px; }
  .schedule-nav { flex-wrap: wrap; }
  .schedule-date-label { display: none; }
  .schedule-item { flex-direction: column; gap: 8px; }
  .schedule-item-time { flex-direction: row; gap: 8px; }
}
