/* frontend/css/app.css — Mobile-first VetCRM */

/* ═══════════════════════════════════════════════════
   AUTH SCREEN
════════════════════════════════════════════════════ */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--green-800) 0%, var(--green-900) 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-primary);
  border-radius: var(--r-xl);
  padding: 36px 28px 32px;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-logo { font-size: 40px; text-align: center; margin-bottom: 10px; }
.auth-title { font-size: 26px; font-weight: 600; text-align: center; color: var(--green-700); letter-spacing: -0.5px; }
.auth-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin: 4px 0 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-error { font-size: 13px; color: var(--red-700); background: var(--red-50); border: 1px solid var(--red-100); border-radius: var(--r-sm); padding: 10px 12px; }
.auth-hint { font-size: 11px; color: var(--text-tertiary); text-align: center; margin-top: 16px; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════
   APP SHELL
════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--green-800);
  display: flex;
  align-items: center;
  padding: 0 12px 0 8px;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}
.topbar-menu {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.85);
  transition: background var(--t-fast);
}
.topbar-menu:hover, .topbar-menu:active { background: rgba(255,255,255,0.12); }
.topbar-menu svg { width: 22px; height: 22px; }
.topbar-brand { display: flex; align-items: center; gap: 8px; flex: 1; }
.topbar-paw { font-size: 22px; }
.topbar-name { font-size: 18px; font-weight: 600; color: #fff; letter-spacing: -0.3px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.85);
  position: relative;
  transition: background var(--t-fast);
}
.topbar-btn:hover { background: rgba(255,255,255,0.12); }
.topbar-btn svg { width: 20px; height: 20px; }
.notif-badge {
  position: absolute; top: 6px; right: 6px;
  width: 16px; height: 16px;
  background: var(--red-500);
  color: #fff; font-size: 9px; font-weight: 600;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--green-800);
}
.user-avatar-sm {
  width: 30px; height: 30px;
  border-radius: var(--r-full);
  background: var(--green-500);
  color: #fff;
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.3);
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100dvh;
  background: var(--bg-primary);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform var(--t-normal);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}
.sidebar.open { transform: translateX(0); }
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0); }
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 18px 20px;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-avatar {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  background: var(--green-500);
  color: #fff;
  font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.sidebar-user-role { font-size: 11px; color: var(--text-secondary); text-transform: capitalize; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  transition: all var(--t-fast);
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--green-50); color: var(--green-700); }
.nav-item.active { background: var(--green-50); color: var(--green-700); }
.nav-item.active svg { stroke: var(--green-600); }
.nav-badge {
  margin-left: auto;
  background: var(--green-500);
  color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.nav-divider { height: 1px; background: var(--border-light); margin: 8px 4px; }
.sidebar-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px;
  font-size: 13px; color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  width: 100%;
  transition: color var(--t-fast);
}
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover { color: var(--red-500); }

/* ── Main content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  height: var(--bottomnav-h);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  flex-shrink: 0;
  z-index: 50;
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text-tertiary);
  font-size: 10px; font-weight: 500;
  transition: color var(--t-fast);
  position: relative;
}
.bnav-item svg { width: 22px; height: 22px; }
.bnav-item.active { color: var(--green-600); }
.bnav-item.active::after {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 3px;
  background: var(--green-500);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}

/* ═══════════════════════════════════════════════════
   SHARED COMPONENTS
════════════════════════════════════════════════════ */

/* Fields */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.2px; }
.field-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
  -webkit-appearance: none;
}
.field-input:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(29,158,117,0.15);
  background: var(--bg-primary);
}
.field-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field-textarea:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(29,158,117,0.15);
  background: var(--bg-primary);
}
.field-select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888780' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* Buttons */
.btn-primary {
  height: 46px;
  padding: 0 20px;
  background: var(--green-600);
  color: #fff;
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--t-fast), transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { background: var(--green-700); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.loading { opacity: 0.7; pointer-events: none; }
.btn-full { width: 100%; }

.btn-secondary {
  height: 40px;
  padding: 0 16px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--t-fast);
}
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-secondary:active { transform: scale(0.97); }

.btn-ghost {
  height: 36px;
  padding: 0 12px;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-ghost svg { width: 15px; height: 15px; }

.btn-danger {
  height: 40px;
  padding: 0 16px;
  background: var(--red-50);
  color: var(--red-700);
  border: 1.5px solid var(--red-100);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast);
}
.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-icon svg { width: 16px; height: 16px; }

/* Cards */
.card {
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

/* Badges / Pills */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-green  { background: var(--green-50);  color: var(--green-700);  }
.badge-amber  { background: var(--amber-50);  color: var(--amber-700);  }
.badge-red    { background: var(--red-50);    color: var(--red-700);    }
.badge-blue   { background: var(--blue-50);   color: var(--blue-700);   }
.badge-purple { background: var(--purple-50); color: var(--purple-700); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-600);   }

/* Avatar */
.avatar {
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.av-green  { background: var(--green-100);  color: var(--green-700); }
.av-blue   { background: var(--blue-100);   color: var(--blue-700);  }
.av-amber  { background: var(--amber-100);  color: var(--amber-700); }
.av-purple { background: var(--purple-100); color: var(--purple-700);}
.av-teal   { background: var(--teal-100);   color: var(--teal-600);  }
.av-gray   { background: var(--gray-200);   color: var(--gray-600);  }

/* Page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 0;
}
.page-title { font-size: 20px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.3px; }
.page-sub   { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px 16px;
}
.kpi-card {
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-light);
  padding: 14px 14px 12px;
}
.kpi-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.2px; }
.kpi-value { font-size: 28px; font-weight: 600; color: var(--text-primary); letter-spacing: -1px; margin: 4px 0 2px; }
.kpi-trend { font-size: 11px; display: flex; align-items: center; gap: 3px; }
.kpi-trend.up   { color: var(--green-600); }
.kpi-trend.down { color: var(--red-500); }
.kpi-trend.neutral { color: var(--text-tertiary); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
}
.toast.success { background: var(--green-700); }
.toast.error   { background: var(--red-700); }
.toast.warning { background: var(--amber-700); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* Modal / Bottom sheet */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.bottom-sheet {
  width: 100%;
  background: var(--bg-primary);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 0 0 env(safe-area-inset-bottom,16px);
  max-height: 90dvh;
  overflow-y: auto;
  animation: sheetUp 0.3s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--gray-300);
  border-radius: var(--r-full);
  margin: 12px auto 16px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border-light);
}
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-close {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.sheet-close svg { width: 16px; height: 16px; }

/* Loader */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 24px;
  flex-direction: column; gap: 12px;
  color: var(--text-secondary); font-size: 13px;
}
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--green-100);
  border-top-color: var(--green-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 24px;
  gap: 12px; text-align: center;
}
.empty-icon { font-size: 48px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.empty-sub   { font-size: 13px; color: var(--text-secondary); max-width: 260px; }

/* Search bar */
.search-wrap {
  padding: 10px 16px;
  position: relative;
}
.search-icon {
  position: absolute; left: 28px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  stroke: var(--text-tertiary); fill: none; stroke-width: 1.8;
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--r-full);
  background: var(--bg-secondary);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-fast);
}
.search-input:focus { border-color: var(--green-400); background: var(--bg-primary); }

/* Segment control */
.segment {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segment-btn {
  flex: 1;
  height: 32px;
  border-radius: calc(var(--r-md) - 2px);
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.segment-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════
   INBOX VIEW
════════════════════════════════════════════════════ */
.inbox-filters {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.inbox-filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 500;
  border: 1.5px solid var(--border-medium);
  color: var(--text-secondary);
  background: var(--bg-primary);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.filter-chip.active {
  background: var(--green-700);
  color: #fff;
  border-color: var(--green-700);
}

.conv-list { display: flex; flex-direction: column; }
.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.conv-item:active { background: var(--green-50); }
.conv-item.unread { background: var(--green-50); }
.conv-item.unread .conv-name { font-weight: 600; }
.conv-avatar { position: relative; flex-shrink: 0; }
.conv-channel-badge {
  position: absolute; bottom: -2px; right: -2px;
  width: 16px; height: 16px;
  border-radius: var(--r-full);
  border: 2px solid var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 8px;
}
.ch-whatsapp { background: #25D366; }
.ch-facebook { background: #0866FF; }
.ch-email    { background: var(--blue-500); }
.conv-body { flex: 1; min-width: 0; }
.conv-row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.conv-name { font-size: 14px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.conv-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-tags { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.conv-unread-dot {
  position: absolute; top: 50%; right: 14px;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  background: var(--green-500);
  border-radius: var(--r-full);
}

/* ═══════════════════════════════════════════════════
   CHAT VIEW
════════════════════════════════════════════════════ */
.chat-view {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h) - var(--bottomnav-h));
  background: #E8F5E9;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%231D9E75' fill-opacity='0.04'%3E%3Cpath d='M20 20c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10zm10 0c0-5.5-4.5-10-10-10S10 14.5 10 20s4.5 10 10 10 10-4.5 10-10z'/%3E%3C/g%3E%3C/svg%3E");
}
.chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--green-800);
  flex-shrink: 0;
}
.chat-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.chat-back svg { width: 20px; height: 20px; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-contact-name { font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-sub { font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 1px; }
.chat-actions { display: flex; gap: 2px; }
.chat-action-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85);
  border-radius: var(--r-md);
}
.chat-action-btn svg { width: 18px; height: 18px; }

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.msg-group-date {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.7);
  border-radius: var(--r-full);
  padding: 3px 10px;
  align-self: center;
  margin: 8px 0;
}
.msg-row { display: flex; gap: 8px; max-width: 85%; }
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.in  { align-self: flex-start; }
.msg-row.full-width { max-width: 95%; align-self: center; }
.msg-bubble {
  padding: 9px 12px;
  border-radius: 4px 16px 16px 16px;
  font-size: 14px; line-height: 1.5;
  word-break: break-word;
  position: relative;
}
.msg-row.in  .msg-bubble { background: #fff; color: var(--text-primary); box-shadow: var(--shadow-sm); }
.msg-row.out .msg-bubble { background: var(--green-600); color: #fff; border-radius: 16px 4px 16px 16px; }
.msg-row.note .msg-bubble { background: var(--amber-50); color: var(--amber-700); border: 1px solid var(--amber-100); border-radius: 8px; font-size: 13px; align-self: center; }
.msg-meta { font-size: 10px; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.msg-row.in  .msg-meta { color: var(--text-tertiary); }
.msg-row.out .msg-meta { color: rgba(255,255,255,0.65); justify-content: flex-end; }
.msg-note-label { font-size: 10px; font-weight: 600; color: var(--amber-700); margin-bottom: 3px; }

.chat-input-area {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}
.input-type-tabs {
  display: flex; gap: 0;
  margin-bottom: 8px;
}
.input-type-tab {
  padding: 4px 10px;
  font-size: 12px; font-weight: 500;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
}
.input-type-tab.active { color: var(--green-600); border-bottom-color: var(--green-600); }
.input-row { display: flex; align-items: flex-end; gap: 8px; }
.input-box {
  flex: 1;
  min-height: 42px; max-height: 120px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--r-xl);
  font-size: 15px;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.4;
  overflow-y: auto;
  transition: border-color var(--t-fast);
}
.input-box:focus { border-color: var(--green-400); background: var(--bg-primary); }
.send-btn {
  width: 42px; height: 42px;
  border-radius: var(--r-full);
  background: var(--green-600);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}
.send-btn:hover  { background: var(--green-700); }
.send-btn:active { transform: scale(0.92); }
.send-btn svg { width: 18px; height: 18px; }
.attach-btn {
  width: 42px; height: 42px;
  border-radius: var(--r-full);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.attach-btn svg { width: 18px; height: 18px; }

/* Conversation info panel */
.conv-info-panel { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.info-section { background: var(--bg-primary); border-radius: var(--r-lg); border: 1px solid var(--border-light); overflow: hidden; }
.info-section-header { padding: 12px 14px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.info-section-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--border-light); }
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 12px; color: var(--text-secondary); }
.info-val { font-size: 13px; color: var(--text-primary); font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }

/* Pet card in conv panel */
.pet-mini-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--t-fast);
}
.pet-mini-card:hover { background: var(--green-50); }
.pet-mini-card:last-child { border-bottom: none; }
.pet-emoji { width: 36px; height: 36px; background: var(--amber-50); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.pet-mini-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.pet-mini-sub  { font-size: 11px; color: var(--text-secondary); }

/* Vaccine indicator */
.vac-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border-light); }
.vac-row:last-child { border-bottom: none; }
.vac-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.vac-ok   { background: var(--green-500); }
.vac-soon { background: var(--amber-500); }
.vac-due  { background: var(--red-500); }
.vac-name { font-size: 12px; color: var(--text-primary); flex: 1; }
.vac-date { font-size: 11px; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════
   MEDICAL VIEW
════════════════════════════════════════════════════ */
.pet-list { display: flex; flex-direction: column; gap: 0; }
.pet-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.pet-card:active { background: var(--green-50); }
.pet-card-emoji { width: 48px; height: 48px; background: var(--amber-50); border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.pet-card-body { flex: 1; min-width: 0; }
.pet-card-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.pet-card-breed { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.pet-card-tags { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.pet-card-arrow { color: var(--text-tertiary); }
.pet-card-arrow svg { width: 16px; height: 16px; }

.record-list { display: flex; flex-direction: column; gap: 0; }
.record-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}
.record-icon { width: 36px; height: 36px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; background: var(--bg-secondary); }
.record-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.record-sub   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.record-date  { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* ═══════════════════════════════════════════════════
   REPORTS VIEW
════════════════════════════════════════════════════ */
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}
.alert-icon { font-size: 22px; flex-shrink: 0; }
.alert-body { flex: 1; min-width: 0; }
.alert-pet  { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.alert-vac  { font-size: 12px; color: var(--text-secondary); }
.alert-days { font-size: 11px; margin-top: 2px; }
.agent-stat-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.agent-conv-count { font-size: 20px; font-weight: 600; color: var(--green-600); min-width: 36px; text-align: right; margin-left: auto; }

/* ═══════════════════════════════════════════════════
   TABLET / DESKTOP (>= 768px)
════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .topbar-menu { display: none; }

  .app-shell { flex-direction: row; }
  .topbar { display: none; }

  /* Always-visible sidebar on tablet+ */
  .sidebar {
    position: relative;
    transform: none !important;
    height: 100dvh;
    box-shadow: none;
    border-right: 1px solid var(--border-light);
    flex-shrink: 0;
  }
  .sidebar-overlay { display: none !important; }

  .main-content { flex: 1; }

  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .chat-view { height: calc(100dvh - 56px); }

  /* Two-column layout for inbox on tablet */
  .inbox-two-col {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100dvh;
  }
  .inbox-panel { border-right: 1px solid var(--border-light); overflow-y: auto; height: 100dvh; }
  .chat-panel  { overflow: hidden; }
}

@media (min-width: 1024px) {
  .sidebar { width: 240px; }
  .kpi-grid { gap: 14px; padding: 18px; }
}
