/* ══════════════════════════════════════════════════════════════════════
   Salud Familiar — Unified Design System
   Purple-first dark theme, responsive mobile + desktop
   Mobile: bottom nav, full-width, safe-area aware
   Desktop (>=768px): fixed sidebar 240px + center content (max 720px)
                      + right panel 400px (slide-in)
   ══════════════════════════════════════════════════════════════════════ */

/* ─── Iconos Lucide (migración desde Material Icons/Symbols) ────────── */
.material-symbols-outlined,
.material-icons-round {
  font-family: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.material-symbols-outlined > svg,
.material-icons-round > svg {
  width: 1em;
  height: 1em;
  display: inline-block;
  flex-shrink: 0;
}
.material-symbols-outlined:not(:has(svg)),
.material-icons-round:not(:has(svg)) {
  color: transparent;
}
/* SVG Lucide inline (de window.icon) */
.lucide {
  vertical-align: -0.15em;
  flex-shrink: 0;
}
/* Inicial + color (reemplaza emojis de avatar) */
.init-avatar {
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.02em;
  user-select: none;
}


/* ═══════════════════════════════════════════
   1. CSS VARIABLES
   ═══════════════════════════════════════════ */
:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface2: #1c1c1f;
  --surface3: #242428;
  --border: #2a2a2e;
  --text: #e8e8ec;
  --text2: #9898a0;
  --text3: #68686e;

  --primary: #14b8a6;
  --primary-dim: rgba(20, 184, 166, 0.12);

  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --teal: #2dd4bf;
  --teal-dim: rgba(45, 212, 191, 0.12);
  --pink: #f472b6;
  --pink-dim: rgba(244, 114, 182, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-full: 999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --nav-height: 64px;
  --sidebar-w: 240px;
  --panel-w: 400px;
  --bar-bg: rgba(10, 10, 11, 0.85);
  --backdrop: rgba(0, 0, 0, 0.6);

  /* Legacy aliases (for existing app.js compatibility) */
  --surface-1: var(--surface);
  --surface-3: var(--surface3);
  --surface-card: var(--surface);
  --surface-elevated: var(--surface2);
  --surface-highest: var(--surface3);
  --on-surface: var(--text);
  --on-surface-variant: var(--text2);
  --on-surface-dim: var(--text3);
  --text-secondary: var(--text2);
  --text-tertiary: var(--text3);
  --outline: var(--border);
  --outline-variant: rgba(255, 255, 255, 0.04);
  --error: var(--red);
  --secondary: var(--green);
  --tertiary: var(--yellow);
  --radius-card: var(--radius);
  --radius-md: var(--radius);
  --radius-lg: var(--radius);
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --font-head: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --primary-glow: rgba(20, 184, 166, 0.06);

  /* Letra de inicial dentro de avatares (J, C, M...). Sigue el fondo de la app. */
  --avatar-text: #0a0a0b;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f0f0f2;
  --surface3: #e8e8ec;
  --border: #d1d1d6;
  --text: #1c1c1e;
  --text2: #636366;
  --text3: #aeaeb2;

  --primary: #0d9488;
  --primary-dim: rgba(13, 148, 136, 0.10);

  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --yellow: #d97706;
  --yellow-dim: rgba(217, 119, 6, 0.08);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.08);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --teal: #0d9488;
  --teal-dim: rgba(13, 148, 136, 0.08);
  --pink: #db2777;
  --pink-dim: rgba(219, 39, 119, 0.08);
  --orange: #ea580c;
  --orange-dim: rgba(234, 88, 12, 0.08);

  --bar-bg: rgba(245, 245, 247, 0.85);
  --backdrop: rgba(0, 0, 0, 0.3);
  --primary-glow: rgba(13, 148, 136, 0.06);

  /* Letra de inicial en modo claro: blanca para mimetizar con el fondo de la app. */
  --avatar-text: #ffffff;

  /* Legacy aliases */
  --surface-1: var(--surface);
  --surface-3: var(--surface3);
  --surface-card: var(--surface);
  --surface-elevated: var(--surface2);
  --surface-highest: var(--surface3);
  --on-surface: var(--text);
  --on-surface-variant: var(--text2);
  --on-surface-dim: var(--text3);
  --text-secondary: var(--text2);
  --text-tertiary: var(--text3);
  --outline: var(--border);
  --outline-variant: rgba(0, 0, 0, 0.04);
  --error: var(--red);
  --secondary: var(--green);
  --tertiary: var(--yellow);
  --radius-card: var(--radius);
}

/* ── Cuaderno Familiar — Dark (default) ── */
[data-style="cuaderno"] {
  --bg: #0E0D0C;
  --surface: #181614;
  --surface2: #211E1B;
  --surface3: #2A2622;
  --border: rgba(237, 233, 227, 0.06);
  --text: #EDE9E3;
  --text2: #C4BFB7;
  --text3: #9B9590;

  --primary: #C8875A;
  --primary-dim: rgba(200, 135, 90, 0.12);

  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --teal: #2dd4bf;
  --teal-dim: rgba(45, 212, 191, 0.12);
  --pink: #f472b6;
  --pink-dim: rgba(244, 114, 182, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);

  --bar-bg: rgba(14, 13, 12, 0.85);
  --primary-glow: rgba(200, 135, 90, 0.06);
  --avatar-text: #0E0D0C;

  --font-head: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-body: 'Instrument Serif', Georgia, 'Times New Roman', serif;

  /* Legacy aliases */
  --surface-1: var(--surface);
  --surface-3: var(--surface3);
  --surface-card: var(--surface);
  --surface-elevated: var(--surface2);
  --surface-highest: var(--surface3);
  --on-surface: var(--text);
  --on-surface-variant: var(--text2);
  --on-surface-dim: var(--text3);
  --text-secondary: var(--text2);
  --text-tertiary: var(--text3);
  --outline: var(--border);
  --outline-variant: rgba(237, 233, 227, 0.04);
  --error: var(--red);
  --secondary: var(--green);
  --tertiary: var(--yellow);
  --radius-card: var(--radius);
}

/* ── Cuaderno Familiar — Light ── */
[data-style="cuaderno"][data-theme="light"] {
  --bg: #F5F2ED;
  --surface: #FFFFFF;
  --surface2: #F0EDE7;
  --surface3: #E8E4DD;
  --border: rgba(14, 13, 12, 0.08);
  --text: #1A1816;
  --text2: #3D3833;
  --text3: #7A756E;

  --primary: #B4752E;
  --primary-dim: rgba(180, 117, 46, 0.10);

  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --yellow: #d97706;
  --yellow-dim: rgba(217, 119, 6, 0.08);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.08);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --teal: #0d9488;
  --teal-dim: rgba(13, 148, 136, 0.08);
  --pink: #db2777;
  --pink-dim: rgba(219, 39, 119, 0.08);
  --orange: #ea580c;
  --orange-dim: rgba(234, 88, 12, 0.08);

  --bar-bg: rgba(245, 242, 237, 0.85);
  --backdrop: rgba(0, 0, 0, 0.3);
  --primary-glow: rgba(180, 117, 46, 0.05);
  --avatar-text: #ffffff;

  /* Legacy aliases */
  --surface-1: var(--surface);
  --surface-3: var(--surface3);
  --surface-card: var(--surface);
  --surface-elevated: var(--surface2);
  --surface-highest: var(--surface3);
  --on-surface: var(--text);
  --on-surface-variant: var(--text2);
  --on-surface-dim: var(--text3);
  --text-secondary: var(--text2);
  --text-tertiary: var(--text3);
  --outline: var(--border);
  --outline-variant: rgba(14, 13, 12, 0.04);
  --error: var(--red);
  --secondary: var(--green);
  --tertiary: var(--yellow);
  --radius-card: var(--radius);
}

/* ── Smooth style/theme transition ── */
html.style-transition,
html.style-transition *,
html.style-transition *::before,
html.style-transition *::after {
  transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease !important;
}


/* ═══════════════════════════════════════════
   2. RESET & BASE
   ═══════════════════════════════════════════ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
  height: 100%;
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100%;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}

textarea { resize: vertical; }
a { color: var(--primary); text-decoration: none; }

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


/* ═══════════════════════════════════════════
   3. TYPOGRAPHY
   ═══════════════════════════════════════════ */
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; }

.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-secondary, .text2 { color: var(--text2); }
.text-tertiary, .text3 { color: var(--text3); }


/* ═══════════════════════════════════════════
   4. KEYFRAME ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.96); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes slideRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes pulse-voice {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.animate-in { animation: fadeIn 0.3s ease-out forwards; }
.animate-in-delay-1 { animation-delay: 0.05s; opacity: 0; }
.animate-in-delay-2 { animation-delay: 0.1s;  opacity: 0; }
.animate-in-delay-3 { animation-delay: 0.15s; opacity: 0; }
.animate-in-delay-4 { animation-delay: 0.2s;  opacity: 0; }
.animate-in-delay-5 { animation-delay: 0.25s; opacity: 0; }


/* ═══════════════════════════════════════════
   5. APP LAYOUT
   ═══════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
  overflow-x: clip;
}

.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}


/* ═══════════════════════════════════════════
   6. SIDEBAR (desktop: always visible, mobile: off-canvas drawer)
   ═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
}

.sidebar-brand {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tagline {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-brand .logo {
  font-size: 22px;
}

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

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
}

.sidebar-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.sidebar-item.active {
  background: var(--primary-dim);
  color: var(--primary);
}

.sidebar-item .material-symbols-outlined,
.sidebar-item .material-icons-round {
  font-size: 20px;
}

.sidebar-divider,
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 14px;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.sidebar-upload,
.btn-upload {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sidebar-upload:hover,
.btn-upload:hover {
  opacity: 0.9;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 0 2px;
}

.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal-dim);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user .email {
  font-size: 11px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.sidebar-logout {
  color: var(--red) !important;
}

.sidebar-logout:hover {
  color: var(--red) !important;
  background: var(--red-dim);
}

/* Nav badge in sidebar */
.nav-badge {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Mobile sidebar: off-canvas drawer */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

.nav-overlay.open {
  display: block;
}

@media (max-width: 767px) {
  .sidebar {
    display: none;
    border: none;
    width: 280px;
    min-width: 280px;
    background: var(--surface);
  }

  .sidebar.open {
    display: flex;
    animation: slideInLeft 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }

  /* Hamburguer fuera de mobile: redundante con bottom-nav + avatarMenu + FAB. */
  .topbar-menu { display: none !important; }
  /* Recuperar el padding-left del título para no quedar pegado al borde. */
  .topbar > div:first-of-type { padding-left: 4px; }
}

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

@media (min-width: 768px) {
  .sidebar {
    display: flex !important;
    animation: none !important;
  }

  .main {
    margin-left: var(--sidebar-w);
  }

  .topbar {
    display: none !important;
  }

  .bottom-tabs {
    display: none !important;
  }
}


/* ═══════════════════════════════════════════
   7. MAIN CONTENT AREA
   ═══════════════════════════════════════════ */
.main {
  flex: 1;
  min-height: 100vh;
  min-width: 0;
  overflow-x: clip; /* clip instead of hidden — doesn't break sticky in Safari */
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);
}

/* Desktop center layout */
.center-content {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  padding: 32px;
}

.center-inner {
  width: 100%;
}


/* ═══════════════════════════════════════════
   8. TOPBAR (mobile)
   ═══════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  min-height: calc(44px + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  z-index: 50;
  border-bottom: 0.5px solid var(--border);
}

.topbar-menu {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
}

.topbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
}

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

.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}


/* ═══════════════════════════════════════════
   9. BOTTOM NAV / TABS (mobile)
   ═══════════════════════════════════════════ */
.bottom-nav,
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

/* Nav buttons (bottom nav items) */
.nav-btn,
.nav-item,
.btab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 8px 16px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
  position: relative;
  background: none;
  border: none;
  font-family: inherit;
}

.nav-btn:active,
.nav-item:active,
.btab:active {
  opacity: 0.6;
}

.nav-btn .material-icons-round,
.nav-btn .material-symbols-outlined,
.nav-item .material-icons-round,
.nav-item .material-symbols-outlined,
.btab .material-icons-round,
.btab .material-symbols-outlined {
  font-size: 24px;
  color: var(--text3);
  transition: color 0.2s;
}

.nav-btn span:last-child,
.nav-item span:last-child,
.btab span:last-child {
  font-size: 10px;
  color: var(--text3);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-btn.active .material-icons-round,
.nav-btn.active .material-symbols-outlined,
.nav-btn.active span:last-child,
.nav-item.active .material-icons-round,
.nav-item.active .material-symbols-outlined,
.nav-item.active span:last-child,
.btab.active,
.btab.active .material-symbols-outlined {
  color: var(--primary);
}

/* Center "add" button in nav */
.nav-item.nav-add .material-icons-round {
  font-size: 34px;
  color: var(--primary);
  margin-top: -4px;
}
.nav-item.nav-add span:last-child { display: none; }


/* ═══════════════════════════════════════════
   10. PAGES
   ═══════════════════════════════════════════ */
.page {
  display: none;
  padding: 16px;
  overflow-x: hidden;
  max-width: 100%;
}

.page.active {
  display: block;
}

.page-content {
  padding: 0 16px 24px;
}

.page::-webkit-scrollbar { width: 0; }


/* ═══════════════════════════════════════════
   11. PAGE HEADER
   ═══════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 0;
}

.page-header h1,
.page-title,
.page-large-title {
  font-size: 22px;
  font-weight: 700;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header .back-btn,
.back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: none;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.back-btn:active { opacity: 0.6; }

.header-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-top: 1px;
}

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

/* Icon button (notifications, settings, etc.) */
.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.icon-btn:hover { background: var(--surface3); }
.icon-btn:active { opacity: 0.6; }
.icon-btn .material-icons-round,
.icon-btn .material-symbols-outlined { font-size: 20px; color: var(--text2); }

.icon-btn .badge,
.notification-badge,
.bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Bell button alias */
.notification-btn,
.bell-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s;
  cursor: pointer;
  border: none;
}

.bell-btn:hover { background: var(--surface3); }
.bell-btn .material-icons-round { font-size: 20px; color: var(--text2); }


/* ═══════════════════════════════════════════
   12. CARDS
   ═══════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  overflow: hidden;
  word-break: break-word;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header,
.section-title,
.section-label,
.list-section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 16px 0 8px;
}


/* ═══════════════════════════════════════════
   13. QUESTION CARD
   ═══════════════════════════════════════════ */
.question-card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

/* Gradient border effect */
.question-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, var(--primary), var(--teal), var(--pink));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.q-icon,
.question-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.q-icon .material-icons-round,
.question-icon .material-icons-round {
  font-size: 16px;
  color: var(--primary);
}

.q-text,
.question-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}

.q-context,
.question-context {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 12px;
  line-height: 1.5;
}

.q-input,
.question-textarea {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  min-height: 60px;
  outline: none;
  transition: border-color 0.2s;
}

.q-input::placeholder,
.question-textarea::placeholder { color: var(--text3); }
.q-input:focus,
.question-textarea:focus { border-color: var(--primary); }

.q-submit { margin-top: 10px; }

.q-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.q-actions,
.question-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Desktop question card variant */
.question-content { flex: 1; }
.question-content .label {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.question-content p { font-size: 14px; margin-bottom: 4px; }
.question-content .context { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
.question-content textarea { width: 100%; min-height: 56px; margin-bottom: 10px; }


/* ═══════════════════════════════════════════
   14. TODAY ITEMS
   ═══════════════════════════════════════════ */
.today-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 0;
  font-size: 13px;
}

.today-item.highlighted {
  background: var(--primary-dim);
  margin: 0 -12px;
  padding: 8px 12px;
  border-radius: 8px;
}

.today-time,
.today-item .time {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  min-width: 42px;
  padding-top: 1px;
}

.today-info h4 { font-size: 14px; font-weight: 600; }
.today-info p { font-size: 12px; color: var(--text2); margin-top: 2px; }

.today-item .specialty-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--teal-dim);
  color: var(--teal);
}


/* ═══════════════════════════════════════════
   15. ACTION ITEMS
   ═══════════════════════════════════════════ */
.actions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.urgency-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  background: var(--red-dim);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.action-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.4s ease, transform 0.4s ease, max-height 0.4s ease, padding 0.4s ease;
  max-height: 200px;
  overflow: hidden;
}

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

.action-item.done {
  opacity: 0;
  transform: translateX(-30px);
  max-height: 0;
  padding: 0;
  border-bottom: none;
}

.action-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.action-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.action-dot.alta,
.action-dot.red,
.dot-red { background: var(--red); }

.action-dot.media,
.action-dot.yellow,
.dot-yellow { background: var(--yellow); }

.action-dot.baja,
.action-dot.blue,
.dot-blue { background: var(--blue); }

.action-body { flex: 1; min-width: 0; }

.action-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.action-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text3);
}

.action-meta-icon { font-size: 12px; }

.action-btns,
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  margin-left: 18px;
}

.action-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}

.action-btn:active { opacity: 0.6; }

.action-btn.done,
.action-btn.hecho:hover,
.action-btn.hecho:active {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.action-btn.dismiss:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

/* Desktop urgent items */
.urgent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.3s;
}

.urgent-item:last-child { border-bottom: none; }
.urgent-item .dot { width: 6px; height: 6px; border-radius: 50%; min-width: 6px; }
.urgent-item .label { flex: 1; }
.urgent-item .actions { display: flex; gap: 4px; }
.urgent-item .actions button {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s;
}
.urgent-item .actions .btn-check { background: var(--green-dim); color: var(--green); }
.urgent-item .actions .btn-check:hover { background: var(--green); color: #fff; }
.urgent-item .actions .btn-dismiss { background: var(--surface3); color: var(--text3); }
.urgent-item .actions .btn-dismiss:hover { background: var(--red-dim); color: var(--red); }
.urgent-item.done { opacity: 0.3; pointer-events: none; }

/* Desktop action card variant */
.action-card {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity 0.3s;
}
.action-card.done { opacity: 0.3; pointer-events: none; }
.action-card .action-text { flex: 1; font-size: 13px; }
.action-card .action-btns { display: flex; gap: 4px; margin: 0; }
.action-card .action-btns button {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-hecho { background: var(--green-dim); color: var(--green); }
.btn-hecho:hover { background: var(--green); color: #fff; }
.btn-na { background: var(--surface3); color: var(--text3); }
.btn-na:hover { background: var(--red-dim); color: var(--red); }


/* ═══════════════════════════════════════════
   16. FAMILY AVATARS (mobile scroll row)
   ═══════════════════════════════════════════ */
.family-row,
.family-scroll {
  display: flex;
  gap: 12px;
  padding: 8px 16px 16px;
  overflow-x: auto;

}

.family-row::-webkit-scrollbar,
.family-scroll::-webkit-scrollbar { display: none; }

.family-member,
.avatar-item,
.fam {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.avatar-item:active,
.fam:active { opacity: 0.7; }

.family-avatar,
.avatar-circle,
.fam-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  position: relative;
  transition: box-shadow 0.2s;
}

/* Color variants */
.avatar-circle.teal,
.family-avatar.teal { background: var(--teal-dim); color: var(--teal); }
.avatar-circle.pink,
.family-avatar.pink { background: var(--pink-dim); color: var(--pink); }
.avatar-circle.purple,
.family-avatar.purple { background: var(--primary-dim); color: var(--primary); }
.avatar-circle.orange,
.family-avatar.orange { background: var(--orange-dim); color: var(--orange); }
.avatar-circle.yellow,
.family-avatar.yellow { background: var(--yellow-dim); color: var(--yellow); }
.avatar-circle.blue,
.family-avatar.blue { background: var(--blue-dim); color: var(--blue); }

.family-avatar.selected,
.avatar-item.selected .avatar-circle,
.fam-avatar.ring-primary {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}

.fam-avatar.ring-error {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--red);
}

.family-name,
.avatar-name,
.fam-name {
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
}

.avatar-item.selected .avatar-name { color: var(--text); }

.alert-dot,
.avatar-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--red);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.upcoming-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg);
}

/* Avatar add button */
.avatar-add {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  background: transparent;
  cursor: pointer;
}
.avatar-add:active { opacity: 0.6; }


/* ═══════════════════════════════════════════
   17. FAMILY CARDS (desktop grid)
   ═══════════════════════════════════════════ */
.family-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.family-card:hover {
  border-color: var(--text3);
  transform: translateY(-1px);
}

.family-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.family-card .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.family-card .info { flex: 1; min-width: 0; }
.family-card .name { font-weight: 600; font-size: 14px; }

.family-card .summary,
.family-card .desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

.family-card .avatar .dot,
.family-card-header .badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.family-card-add {
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 104px;
}

.family-card-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}


/* ═══════════════════════════════════════════
   18. PATIENT DETAIL OVERLAY
   ═══════════════════════════════════════════ */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 150;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.detail-overlay.visible {
  display: flex;
}

.detail-header,
.detail-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  transition: padding 0.2s ease, gap 0.2s ease;
}

/* SAL.CRONICAS.BARS-COLAPSABLES · topbar + tabs compactas al scroll > 40px */
.detail-topbar.compact {
  gap: 8px;
  padding: 4px 16px;
  padding-top: calc(4px + var(--safe-top));
}
.detail-topbar.compact .detail-title { font-size: 15px; transition: font-size 0.2s ease; }
.detail-topbar.compact #topbar-chronic-chip { transform: scale(0.82); transform-origin: right center; }
.detail-title, #topbar-chronic-chip { transition: font-size 0.2s ease, transform 0.2s ease; }
.detail-tabs { transition: padding 0.2s ease; }
.detail-tabs.compact .detail-tab { padding: 6px 14px; font-size: 12px; transition: padding 0.2s ease, font-size 0.2s ease; }
.detail-tab { transition: padding 0.2s ease, font-size 0.2s ease; }

/* Bottom nav compacta: solo íconos, 44px */
.bottom-nav.compact,
.bottom-tabs.compact {
  height: calc(44px + var(--safe-bottom));
  transition: height 0.2s ease;
}
.bottom-nav,
.bottom-tabs { transition: height 0.2s ease; }
.bottom-nav.compact .btab span:last-child,
.bottom-tabs.compact .btab span:last-child,
.bottom-nav.compact .nav-btn span:last-child,
.bottom-tabs.compact .nav-item span:last-child { display: none; }
.bottom-nav.compact .btab,
.bottom-tabs.compact .btab { padding: 4px 16px; }

@media (prefers-reduced-motion: reduce) {
  .detail-topbar, .detail-title, #topbar-chronic-chip, .detail-tabs, .detail-tab,
  .bottom-nav, .bottom-tabs { transition: none !important; }
}

.detail-back,
.detail-edit {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 4px;
}

.patient-title,
.detail-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
}

.patient-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

/* Detail tabs */
.detail-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  overflow-x: auto;

  border-bottom: 0.5px solid var(--border);
  background: var(--bg);
}

.detail-tabs::-webkit-scrollbar { display: none; }

.detail-tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
  font-family: inherit;
}

.detail-tab.active {
  color: var(--primary);
  border-color: var(--primary);
}

.tab-content {
  flex: 1 1 0;
  min-height: 0; /* necesario para que overflow-y funcione dentro de un flex container */
  overflow-y: auto;

  padding: 16px;
  padding-bottom: calc(32px + var(--safe-bottom));
  position: relative;
  z-index: 1;
}

.tab-content.active { display: block; }


/* ═══════════════════════════════════════════
   19. SEGMENTS / SEGMENTED CONTROL
   ═══════════════════════════════════════════ */
.segments,
.segmented-control,
.segment-control {
  display: flex;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.segment,
.seg-btn,
.segment-btn {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.segment.active,
.seg-btn.active,
.segment-btn.active {
  background: var(--surface3);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.segment:active,
.seg-btn:active { opacity: 0.7; }


/* ═══════════════════════════════════════════
   20. SPECIALTY CARDS
   ═══════════════════════════════════════════ */
.spec-card,
.specialty-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.spec-card:active,
.specialty-card:active { border-color: var(--text3); }

.spec-top,
.specialty-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.specialty-header:hover { background: var(--surface2); }

.spec-left,
.specialty-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spec-icon,
.specialty-icon,
.specialty-header .icon {
  font-size: 20px;
}

.spec-name,
.specialty-name,
.specialty-header .name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.spec-badge,
.specialty-badge,
.specialty-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.spec-badge.en_tratamiento,
.spec-badge.blue,
.specialty-badge.blue,
.status-en-tratamiento {
  background: var(--blue-dim);
  color: var(--blue);
}

.spec-badge.alerta,
.spec-badge.red,
.specialty-badge.red,
.status-alerta {
  background: var(--red-dim);
  color: var(--red);
}

.spec-badge.estable,
.spec-badge.green,
.specialty-badge.green,
.status-estable {
  background: var(--green-dim);
  color: var(--green);
}

.spec-badge.pendiente {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.spec-expand,
.chevron-icon,
.specialty-header .chevron {
  transition: transform 0.2s;
  color: var(--text3);
  font-size: 20px;
}

.spec-card.expanded .spec-expand,
.specialty-card.expanded .chevron-icon,
.specialty-card.expanded .specialty-header .chevron {
  transform: rotate(180deg);
}

.spec-detail,
.specialty-detail {
  padding: 0 16px 16px;
  display: none;
  animation: fadeIn 0.2s ease;
}

.spec-card.expanded .spec-detail,
.specialty-card.expanded .specialty-detail { display: block; }

.specialty-detail-text,
.specialty-body-inner {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 12px;
}

/* Collapsible body for desktop */
.specialty-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.specialty-card.expanded .specialty-body { max-height: 500px; }


/* ═══════════════════════════════════════════
   21. MINI CHARTS
   ═══════════════════════════════════════════ */
.mini-chart,
.chart-container {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
}

.chart-title {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
  font-weight: 500;
}

.chart-svg,
.chart-container svg,
.mini-chart svg {
  width: 100%;
  display: block;
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: url(#chartGradient);
  opacity: 0.3;
}

.chart-dot {
  fill: var(--primary);
}

.chart-ref {
  stroke: var(--text3);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-ref-area {
  fill: var(--green-dim);
  opacity: 0.3;
}

.chart-val {
  font-size: 11px;
  fill: var(--text2);
}


/* ═══════════════════════════════════════════
   22. TREATMENT CARDS
   ═══════════════════════════════════════════ */
.treatment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

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

.treatment-name,
.treatment-title,
.treatment-header .label {
  font-size: 15px;
  font-weight: 600;
}

.treatment-count,
.treatment-sessions,
.treatment-header .sessions {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  margin-bottom: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--teal));
  transition: width 0.5s ease;
}

.treatment-meta,
.treatment-detail {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-trend,
.pain-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.pain-score .down,
.score-trend .down { color: var(--green); }


/* ═══════════════════════════════════════════
   23. TIMELINE
   ═══════════════════════════════════════════ */
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
  border-radius: 8px;
}

.timeline-item:hover { background: var(--surface2); }
.timeline-item:active { opacity: 0.6; }
.timeline-item:last-child { border-bottom: none; }

.timeline-date {
  min-width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.timeline-date .day,
.timeline-date-day {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.timeline-date .month,
.timeline-date-month {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
}

.timeline-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-icon .material-icons-round,
.timeline-icon .material-symbols-outlined { font-size: 18px; }

.timeline-icon.blue { background: var(--blue-dim); color: var(--blue); }
.timeline-icon.green { background: var(--green-dim); color: var(--green); }
.timeline-icon.purple { background: var(--primary-dim); color: var(--primary); }
.timeline-icon.red { background: var(--red-dim); color: var(--red); }
.timeline-icon.yellow { background: var(--yellow-dim); color: var(--yellow); }

.timeline-body,
.timeline-info { flex: 1; min-width: 0; }

.timeline-title,
.timeline-info .title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.timeline-sub,
.timeline-desc,
.timeline-info .subtitle {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

.timeline-alert { color: var(--yellow); }

/* Timeline search */
.timeline-search {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
}
.timeline-search-wrap { position: relative; margin-bottom: 16px; }
.timeline-search-wrap .material-icons-round {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text3);
}


/* ═══════════════════════════════════════════
   24. RESUMEN BOX
   ═══════════════════════════════════════════ */
.resumen-box,
.summary-box {
  background: linear-gradient(135deg, var(--primary-dim), rgba(96, 165, 250, 0.06));
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.resumen-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 12px;
}

.resumen-actions,
.summary-actions {
  display: flex;
  gap: 8px;
}

.resumen-btn,
.summary-actions button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface3);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  transition: all 0.15s;
  border: none;
  cursor: pointer;
}

.resumen-btn:hover,
.summary-actions button:hover {
  color: var(--text);
  background: var(--border);
}


/* ═══════════════════════════════════════════
   25. SEARCH BAR
   ═══════════════════════════════════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.search-bar .material-icons-round,
.search-bar .material-symbols-outlined {
  font-size: 20px;
  color: var(--text3);
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  padding: 0;
}

.search-bar input::placeholder { color: var(--text3); }

/* Search bar wrap (with icon inside) */
.search-bar-wrap { position: relative; margin-bottom: 14px; }
.search-bar-wrap .material-icons-round,
.search-bar-wrap .material-symbols-outlined {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text3);
}
.search-bar-wrap input {
  width: 100%;
  padding: 11px 14px 11px 40px;
}

/* Search header (legacy) */
.search-header { padding: 0 0 12px; }
.search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.search-input::placeholder { color: var(--text3); }
.search-clear { background: none; border: none; color: var(--text3); cursor: pointer; }

/* Search page (desktop) */
.search-page-input {
  width: 100%;
  padding: 16px 20px 16px 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
}
.search-page-wrap { position: relative; margin-bottom: 24px; }
.search-page-wrap .material-icons-round {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  color: var(--text3);
}
.search-examples .label { font-size: 12px; color: var(--text3); margin-bottom: 10px; }
.search-example {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.search-example:hover { border-color: var(--primary); color: var(--primary); }


/* ═══════════════════════════════════════════
   26. CHAT (FAB + PANEL)
   ═══════════════════════════════════════════ */
.chat-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 36%, transparent);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s, opacity 0.2s;
}

.chat-fab:hover { transform: scale(1.05); }
.chat-fab:active { transform: scale(0.9); }
.chat-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }
.chat-fab .material-icons-round,
.chat-fab .material-symbols-outlined { font-size: 24px; }

/* Mobile: chat as bottom sheet */
.chat-panel,
.chat-modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 430px;
  height: 60vh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 301;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel.open,
.chat-modal.open {
  transform: translateX(-50%) translateY(0);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-header .title { font-size: 14px; font-weight: 600; }

.chat-body,
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-msg.bot {
  background: var(--surface3);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.cerebro-badge {
  font-size: 0.65rem;
  color: var(--primary);
  opacity: 0.7;
  margin-top: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Legacy chat bubble aliases */
.chat-msg-user { align-self: flex-end; background: var(--primary-dim); border-bottom-right-radius: 4px; }
.chat-msg-ai { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 4px; }

/* Inline chat bubbles (patient detail) */
.fchat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.fchat-bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.fchat-bubble.assistant { align-self: flex-start; background: var(--surface2); color: var(--text); border-bottom-left-radius: 4px; }

.chat-input-row,
.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--surface);
}

.chat-input {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.chat-input::placeholder { color: var(--text3); }
.chat-input:focus { border-color: var(--primary); }
.chat-input-wrap input { flex: 1; padding: 9px 14px; }

.chat-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.chat-send:hover { opacity: 0.9; }
.chat-send:active { opacity: 0.7; }
.chat-send .material-icons-round,
.chat-send .material-symbols-outlined { font-size: 20px; }

/* Desktop: chat as floating panel */
@media (min-width: 768px) {
  .chat-fab {
    bottom: 24px;
    right: 24px;
  }

  .chat-panel {
    bottom: 24px;
    right: 24px;
    left: auto;
    transform: none;
    width: 400px;
    height: 520px;
    max-width: none;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: none;
    animation: slideUp 0.25s ease;
  }

  .chat-panel.open {
    display: flex;
    transform: none;
  }
}


/* ═══════════════════════════════════════════
   27. MODALS & OVERLAYS
   ═══════════════════════════════════════════ */
.modal-backdrop,
.modal-overlay,
.overlay {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-backdrop.visible,
.modal-overlay.open,
.modal-overlay.visible,
.overlay.visible {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  animation: fadeIn 0.2s ease;
}

/* Modal centrado siempre (mobile y desktop), visibility controla apertura.
   !important porque hay reglas legacy en otros bloques que pisan position/top/transform. */
.modal-sheet,
.modal {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  bottom: auto !important;
  right: auto !important;
  transform: translate(-50%, -50%) !important;
  width: 92%;
  max-width: 500px;
  background: var(--surface);
  border-radius: 20px;
  z-index: 201;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.modal-sheet.open,
.modal.open {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translate(-50%, -50%) !important;
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--text3);
  border-radius: 2px;
  margin: 8px auto 0;
}

.modal-header,
.modal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 1;
}

.modal-header h2,
.modal-header h3,
.modal-nav h2 {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3);
  border: none;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.modal-close:hover { background: var(--border); }
.modal-close:active { opacity: 0.6; }
.modal-close .material-icons-round,
.modal-close .material-symbols-outlined { font-size: 18px; color: var(--text2); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0; /* necesario para que overflow-y funcione dentro de un flex container */
}

.modal-nav button {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.modal-save { font-weight: 600 !important; }

/* Modal body: scroll explícito (calc para no depender de flex-basis) */
.modal .modal-body,
.modal-sheet .modal-body {
  max-height: calc(88vh - 62px); /* 62px ≈ alto del header */
  overflow-y: auto;
}

/* Modal variants for desktop */
.doc-modal { width: 600px; max-height: 80vh; }
.create-appt-modal { width: 500px; }


/* ═══════════════════════════════════════════
   28. UPLOAD MODAL
   ═══════════════════════════════════════════ */

/* Overlay backdrop */
.upload-overlay,
.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 249;
  display: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.upload-overlay.open,
.chat-overlay.open {
  display: block;
  opacity: 1;
}
.chat-overlay { z-index: 299; }

/* Bottom sheet base (upload + more) */
.upload-modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 250;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  /* SAL.CICLO.UI — modal invisible NO debe capturar clicks. En desktop el modal
     queda centrado con opacity:0 sobre el panel derecho del paciente; sin esto
     el calendario (botón ‹) recibía el click en el dropzone del modal en vez
     de en el botón → abría file picker fantasma. */
  pointer-events: none;
}
.upload-modal.open {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.upload-modal-handle {
  width: 36px;
  height: 4px;
  background: var(--text3);
  border-radius: 2px;
  margin: 8px auto 0;
  flex-shrink: 0;
}

.upload-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 1;
  flex-shrink: 0;
}

.upload-modal-header h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.upload-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3, var(--surface2));
  border: none;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.upload-modal-close:active { opacity: 0.6; }

.upload-modal-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  margin-top: 16px;
}
.section-label:first-child { margin-top: 0; }

/* Document detail modal (fullscreen on mobile) */
.doc-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 249;
  display: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.doc-detail-overlay.open {
  display: block;
  opacity: 1;
}

.doc-detail-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 250;
  display: none;
  overflow-y: auto;

}
.doc-detail-modal.open {
  display: block;
}

@media (min-width: 768px) {
  .doc-detail-modal {
    inset: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }
}

.upload-dropzone,
.dropzone,
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
  -webkit-tap-highlight-color: transparent;
}

.upload-dropzone:hover,
.dropzone:hover,
.drop-zone:hover {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.upload-dropzone:active,
.dropzone:active,
.drop-zone:active {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.upload-dropzone .material-icons-round,
.dropzone .material-icons-round,
.drop-zone .material-icons-round {
  font-size: 36px;
  color: var(--text3);
  margin-bottom: 8px;
  display: block;
}

.dropzone-text,
.drop-zone .label { font-size: 14px; color: var(--text2); font-weight: 500; margin-bottom: 4px; }
.dropzone-sub,
.drop-zone .formats { font-size: 12px; color: var(--text3); margin-top: 6px; }

.upload-preview,
.file-preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.upload-preview.visible,
.file-preview.visible { display: flex; }

.file-preview-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--blue-dim);
  display: flex; align-items: center; justify-content: center;
}
.file-preview-icon .material-icons-round { font-size: 20px; color: var(--blue); }
.file-preview-info { flex: 1; }
.file-preview-name { font-size: 13px; font-weight: 500; }
.file-preview-size { font-size: 11px; color: var(--text3); }
.file-preview-remove { background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px; }

/* Upload patient selector */
.upload-patients,
.patient-selector { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; padding-bottom: 4px; }

.upload-patient,
.patient-selector-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; flex-shrink: 0; padding: 6px; border-radius: var(--radius-sm);
  transition: all 0.15s; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; min-width: 56px;
}
.upload-patient:active { background: var(--surface2); }
.patient-selector-item:hover { background: var(--surface2); }

/* Avatar selection ring — match all avatar class variants */
.upload-patient .avatar-circle,
.upload-patient .human-avatar,
.upload-patient .init-avatar { width: 44px; height: 44px; font-size: 16px; transition: box-shadow 0.2s; }
.upload-patient.selected .avatar-circle,
.upload-patient.selected .human-avatar,
.upload-patient.selected .init-avatar,
.patient-selector-item.selected .sel-avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); border-color: var(--primary); }
.upload-patient span { font-size: 11px; color: var(--text2); }
.upload-patient.selected span { color: var(--primary); font-weight: 600; }

.sel-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; border: 2px solid transparent;
  transition: border-color 0.15s;
}
.patient-selector-item .sel-name { font-size: 10px; color: var(--text2); }

.upload-desc {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  min-height: 48px;
  outline: none;
  margin-bottom: 16px;
}
.upload-desc::placeholder { color: var(--text3); }
.upload-desc:focus { border-color: var(--primary); }


/* ═══════════════════════════════════════════
   29. NOTIFICATION PANEL
   ═══════════════════════════════════════════ */
.notif-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: 100%;
  max-width: 430px;
  height: 100%;
  background: var(--bg);
  z-index: 250;
  transition: right 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notif-panel.open {
  right: 0;
  animation: slideRight 0.3s ease;
}

.notif-panel-header,
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.notif-header h3 { font-size: 16px; font-weight: 700; }
.notif-header .mark-read { font-size: 12px; color: var(--primary); cursor: pointer; }

.notif-mark-read {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.notif-body { flex: 1; overflow-y: auto; padding: 12px; }

.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.notif-item:hover { background: var(--surface2); }
.notif-item:active { background: var(--surface); }

.notif-item.unread,
.notif-unread {
  background: var(--primary-dim);
  border-radius: var(--radius-sm);
}

.notif-icon-wrap,
.notif-item .icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.notif-content,
.notif-item .content { flex: 1; }
.notif-text,
.notif-item .content .text { font-size: 13px; line-height: 1.4; }
.notif-time,
.notif-item .content .time { font-size: 11px; color: var(--text3); margin-top: 4px; }

.notif-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 179;
  display: none;
}
.notif-backdrop.visible { display: block; }

/* Desktop notification panel */
@media (min-width: 768px) {
  .notif-panel {
    width: 360px;
    right: -360px;
    border-left: 1px solid var(--border);
  }
  .notif-panel.open { right: 0; }
}


/* ═══════════════════════════════════════════
   30. MORE MENU
   ═══════════════════════════════════════════ */
.more-menu {
  display: none;
}

.more-menu.open {
  display: block;
}



/* ═══════════════════════════════════════════
   31. DOCUMENT DETAIL
   ═══════════════════════════════════════════ */
.doc-detail,
.doc-viewer {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 24px;
}

.doc-detail .material-icons-round,
.doc-viewer .material-icons-round { font-size: 48px; color: var(--text3); }
.doc-viewer-actions { display: flex; gap: 8px; }

.doc-preview {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 32px;
  text-align: center;
  margin-bottom: 16px;
}
.doc-preview .material-icons-round { font-size: 48px; color: var(--text3); margin-bottom: 8px; display: block; }
.doc-preview-btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.doc-preview-btns button {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 14px; background: var(--surface3); border-radius: 8px;
  font-size: 12px; font-weight: 500; color: var(--text2); transition: all 0.15s;
}
.doc-preview-btns button:hover { background: var(--border); color: var(--text); }

.doc-analysis,
.ai-analysis {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  margin-top: 16px;
}
.doc-analysis h4 { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.ai-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

.doc-badges,
.classification-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.doc-badge,
.class-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--surface3);
  color: var(--text2);
}

.doc-summary,
.ai-summary { font-size: 13px; color: var(--text2); line-height: 1.6; margin-bottom: 12px; }

.doc-correlation {
  background: var(--yellow-dim);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--yellow);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ai-correlation { background: var(--surface2); border-radius: var(--radius-sm); padding: 12px; margin-top: 8px; }
.ai-correlation-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.ai-correlation-text { font-size: 12px; color: var(--text2); line-height: 1.5; }
.ai-alert { color: var(--yellow); font-weight: 500; }

.doc-ocr,
.doc-extracted,
.extracted-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.doc-extracted-header,
.extracted-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.doc-extracted-header:active,
.extracted-header:active { opacity: 0.7; }
.doc-extracted-header .label,
.extracted-header .label { font-size: 12px; font-weight: 600; color: var(--text2); }

.doc-extracted-body,
.extracted-body {
  padding: 0 14px 14px;
  font-size: 12px;
  color: var(--text3);
  line-height: 1.6;
  white-space: pre-wrap;
}
.doc-extracted-body.collapsed { display: none; }
.extracted-body { display: none; }
.extracted-text.expanded .extracted-body { display: block; }

.extracted-pre {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn-reprocess {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--surface3); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; color: var(--text2);
  margin-top: 14px; transition: all 0.15s; border: none; cursor: pointer;
}
.btn-reprocess:hover { background: var(--border); color: var(--text); }

/* Document list items */
.doc-cell { padding: 14px 16px; border-bottom: 0.5px solid var(--border); }
.doc-cell:last-child { border: none; }

.doc-list-item {
  display: flex; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  cursor: pointer; transition: all 0.15s;
}
.doc-list-item:hover { border-color: var(--text3); }
.doc-list-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.doc-list-info { flex: 1; }
.doc-list-info .title { font-size: 13px; font-weight: 500; }
.doc-list-info .detail { font-size: 12px; color: var(--text2); }
.doc-list-date { font-size: 11px; color: var(--text3); padding-top: 2px; }


/* ═══════════════════════════════════════════
   32. GRID LAYOUTS
   ═══════════════════════════════════════════ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.datos-grid,
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}


/* ═══════════════════════════════════════════
   33. RIGHT PANEL (desktop patient detail)
   ═══════════════════════════════════════════ */
.right-panel {
  width: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
}

.right-panel.open {
  width: var(--panel-w);
  min-width: var(--panel-w);
}

.right-panel-header,
.panel-inner { width: var(--panel-w); height: 100%; display: flex; flex-direction: column; }

.right-panel-header,
.panel-header {
  padding: 20px 20px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.panel-header .patient-info h2 { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.panel-header .patient-info .meta { font-size: 12px; color: var(--text2); }

.right-panel-close,
.panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.right-panel-close:hover,
.panel-close:hover { background: var(--surface3); }

.right-panel-close .material-icons-round,
.panel-close .material-icons-round { font-size: 18px; color: var(--text2); }

.right-panel-body,
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
}


/* ═══════════════════════════════════════════
   34. FILTER CHIPS
   ═══════════════════════════════════════════ */
.filter-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.chip,
.filter-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.chip:hover,
.filter-chip:hover {
  border-color: var(--border);
  color: var(--text);
}

.chip.active,
.filter-chip.active {
  background: var(--primary-dim);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 36%, transparent);
}


/* ═══════════════════════════════════════════
   35. SCORE BUTTONS (check-in)
   ═══════════════════════════════════════════ */
.score-btns,
.score-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.score-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}

.score-btn:hover { background: var(--primary-dim); color: var(--primary); }
.score-btn:active { transform: scale(0.9); }

.score-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Check-in card */
.checkin-section,
.checkin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.checkin-title,
.checkin-card .label { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.checkin-card .question { font-size: 12px; color: var(--text2); margin-bottom: 10px; }


/* ═══════════════════════════════════════════
   36. CALENDAR
   ═══════════════════════════════════════════ */
.mini-calendar { margin-bottom: 24px; }

.cal-header,
.cal-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 16px;
}

.cal-month-title,
.cal-month-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.cal-nav {
  display: flex;
  gap: 4px;
}

.cal-nav button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-nav button:hover { background: var(--surface3); }
.cal-nav button:active { opacity: 0.6; }
.cal-nav button .material-icons-round { font-size: 18px; color: var(--text2); }

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

.cal-day-header,
.cal-day-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  padding: 8px 0;
  text-transform: uppercase;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text2);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-day:hover { background: var(--surface2); }
.cal-day:active { background: var(--surface2); }

.cal-day.today {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.cal-day.other-month {
  color: var(--text3);
  opacity: 0.4;
}

.cal-day.has-event { font-weight: 600; }

.cal-dots,
.cal-dot {
  display: flex;
  gap: 3px;
  justify-content: center;
  position: absolute;
  bottom: 4px;
}

.cal-dots span,
.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

/* Appointments */
.appt-item {
  display: flex; gap: 14px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  transition: border-color 0.15s;
}
.appt-item:hover { border-color: var(--text3); }
.appt-date-box { width: 48px; text-align: center; }
.appt-date-box .day { font-size: 20px; font-weight: 700; }
.appt-date-box .month { font-size: 11px; color: var(--text3); text-transform: uppercase; }
.appt-info { flex: 1; }
.appt-info .title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.appt-info .detail { font-size: 12px; color: var(--text2); }
.appt-info .time { font-size: 12px; color: var(--text3); margin-top: 4px; }
.appt-member-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; }

/* Upcoming items */
.upcoming-title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 12px; }
.upcoming-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-date-col { min-width: 50px; text-align: center; flex-shrink: 0; }
.upcoming-day { font-size: 20px; font-weight: 700; }
.upcoming-month { font-size: 11px; color: var(--text3); text-transform: uppercase; }
.upcoming-color { width: 4px; border-radius: 2px; align-self: stretch; flex-shrink: 0; }
.upcoming-info { flex: 1; }
.upcoming-info h4 { font-size: 14px; font-weight: 600; }
.upcoming-info p { font-size: 12px; color: var(--text2); margin-top: 2px; }
.upcoming-info .time-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text2); margin-top: 4px; }


/* ═══════════════════════════════════════════
   37. BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { opacity: 0.7; transform: scale(0.97); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { opacity: 0.7; transform: scale(0.97); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: none;
  color: var(--text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { background: var(--surface2); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-destructive {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red-dim);
  color: var(--red);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-is-loading,
.btn-is-success,
.btn-is-error {
  transition: background 0.2s, color 0.2s, opacity 0.2s;
  pointer-events: none;
}

.btn-is-loading { opacity: 0.85; }

.btn-is-loading .btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes btnSpin { to { transform: rotate(360deg); } }

.btn-is-success {
  background: #0f3b28 !important;
  color: #a7f3cf !important;
  border-color: #1b6b46 !important;
}

.btn-is-error {
  background: #3b1212 !important;
  color: #fca5a5 !important;
  border-color: #8a2a2a !important;
}

.cal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.cal-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.btn-link-subtle {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  align-self: center;
}
.btn-link-subtle:hover { color: var(--text); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-icon:active { opacity: 0.6; }
.btn-icon .material-icons-round,
.btn-icon .material-symbols-outlined { font-size: 18px; }

/* iOS-style buttons */
.btn-ios {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 18px; border-radius: var(--radius-xl);
  border: none; font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; background: var(--surface2); color: var(--text);
}
.btn-ios.btn-primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn-ios.btn-destructive { background: var(--red-dim); color: var(--red); }

/* Add item button */
.add-item-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 0; background: none; border: none;
  color: var(--primary); font-family: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.add-item-btn:active { opacity: 0.6; }

.btn-add-small {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--primary); font-weight: 600; cursor: pointer;
}
.btn-add-small .material-icons-round { font-size: 14px; }

.btn-edit-data {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: var(--surface3); border-radius: 6px;
  font-size: 11px; font-weight: 500; color: var(--text2);
  cursor: pointer; transition: all 0.15s; border: none;
}
.btn-edit-data:hover { background: var(--border); color: var(--text); }


/* ═══════════════════════════════════════════
   38. FORM ELEMENTS
   ═══════════════════════════════════════════ */
.form-group {
  margin-bottom: 16px;
}

.form-label,
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.form-input,
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  color-scheme: dark;
}

.form-input:focus,
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  background: var(--surface3);
}

.form-input::placeholder { color: var(--text3); }

.form-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  color-scheme: dark;
  appearance: none;
}

.form-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
  min-height: 80px;
}

.form-textarea:focus { border-color: var(--primary); }

.form-group.highlight {
  background: var(--primary-glow);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
}
.form-group.highlight label { color: var(--primary); }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }


/* ═══════════════════════════════════════════
   39. TOGGLES
   ═══════════════════════════════════════════ */
.toggle-row,
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child,
.setting-item:last-child { border-bottom: none; }

.setting-label { font-size: 14px; font-weight: 500; }
.setting-desc { font-size: 12px; color: var(--text3); margin-top: 2px; }

.toggle-switch,
.toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--surface3);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after,
.toggle::after {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.toggle-switch.on,
.toggle.on {
  background: var(--primary);
}

.toggle-switch.on::after,
.toggle.on::after {
  transform: translateX(18px);
}


/* ═══════════════════════════════════════════
   40. TOASTS
   ═══════════════════════════════════════════ */
.toast,
#toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface3);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  z-index: 10000;
  display: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toast.show {
  display: block;
  animation: fadeInUp 0.3s ease forwards;
}

.toast.toast-success {
  background: #0f3b28;
  border-color: #1b6b46;
  color: #a7f3cf;
}

.toast.toast-error {
  background: #3b1212;
  border-color: #8a2a2a;
  color: #fca5a5;
}


/* ═══════════════════════════════════════════
   41. EMPTY STATES
   ═══════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state p {
  color: var(--text3);
  font-size: 14px;
  margin-top: 12px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text3);
  font-size: 14px;
}


/* ═══════════════════════════════════════════
   42. LOGIN PAGE
   ═══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 48px 32px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.login-btn:hover { opacity: 0.85; }
.login-btn:active { opacity: 0.7; transform: scale(0.98); }


/* ═══════════════════════════════════════════
   43. SETTINGS PAGE
   ═══════════════════════════════════════════ */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.settings-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row .label { font-size: 13px; }

.family-settings-member {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.family-settings-member:last-child { border-bottom: none; }
.family-settings-member .name { flex: 1; font-size: 13px; font-weight: 500; }
.family-settings-member .role { font-size: 11px; color: var(--text3); padding: 2px 8px; background: var(--surface2); border-radius: 4px; }

.invite-code-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.invite-code {
  padding: 8px 14px; background: var(--surface2); border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: monospace; letter-spacing: 1px;
}
.btn-copy {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; background: var(--surface3); border-radius: 8px;
  font-size: 12px; font-weight: 500; color: var(--text2);
  cursor: pointer; transition: all 0.15s; border: none;
}
.btn-copy:hover { background: var(--border); color: var(--text); }
.btn-invite {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--primary); color: #fff;
  font-weight: 600; font-size: 13px; border-radius: var(--radius-sm);
  margin-top: 12px; transition: opacity 0.15s; border: none; cursor: pointer;
}
.btn-invite:hover { opacity: 0.9; }

.account-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.account-row:last-child { border-bottom: none; }
.account-row .label { font-size: 12px; color: var(--text3); }
.account-row .value { font-size: 13px; }


/* ═══════════════════════════════════════════
   44. PATIENT DATA SECTION
   ═══════════════════════════════════════════ */
.data-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.data-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.data-section-title { font-size: 14px; font-weight: 600; }

.data-field label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.data-field p { font-size: 14px; font-weight: 500; margin-top: 2px; }

.data-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.data-list-item:last-child { border-bottom: none; }
.data-list-name { font-size: 14px; }
.data-list-detail { font-size: 12px; color: var(--text2); }
.data-list-expired { color: var(--red); font-size: 12px; font-weight: 500; }

.dato-item .label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.dato-item .value { font-size: 13px; font-weight: 500; }
.dato-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; margin-top: 18px; }
.dato-section-header h4 { font-size: 13px; font-weight: 600; }
.dato-list-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.dato-list-item:last-child { border-bottom: none; }
.dato-list-item .name { font-weight: 500; }
.dato-list-item .detail { font-size: 12px; color: var(--text2); }
.dato-list-item.expired .name { color: var(--red); }


/* ═══════════════════════════════════════════
   45. PATIENT CELLS
   ═══════════════════════════════════════════ */
.patient-cell {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  cursor: pointer;
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.patient-cell:active { background: var(--surface2); }

.patient-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  position: relative;
}

.patient-name { font-size: 15px; font-weight: 600; }
.patient-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }


/* ═══════════════════════════════════════════
   46. PERSON GROUPS (activity rows on home)
   ═══════════════════════════════════════════ */
.person-group {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}

.person-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 6px;
}

.person-header-name { font-size: 15px; font-weight: 600; }

.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 52px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.1s;
}

.activity-row:last-child { border: none; }
.activity-row:active { background: rgba(255, 255, 255, 0.02); }

/* Family section (colored left border) */
.family-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--pink);
}
.family-section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.family-section-name { font-size: 15px; font-weight: 600; }
.family-section-badge {
  font-size: 11px; color: var(--text2);
  background: var(--surface3); padding: 2px 8px; border-radius: var(--radius-full);
}


/* ═══════════════════════════════════════════
   47. BADGES
   ═══════════════════════════════════════════ */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

.badge-primary { background: var(--primary-dim); color: var(--primary); }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-warn, .badge-warning { background: var(--yellow-dim); color: var(--yellow); }
.badge-error, .badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-gray { background: var(--surface2); color: var(--text3); }


/* ═══════════════════════════════════════════
   48. GROUPED LISTS (iOS style)
   ═══════════════════════════════════════════ */
.group {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 0.5px solid var(--border);
  transition: background 0.1s;
}

.row:last-child { border: none; }
.row:active { background: rgba(255, 255, 255, 0.03); }

.ios-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
}
.ios-row:last-child { border: none; }
.ios-row-label { font-size: 14px; color: var(--text2); }
.ios-row-value { font-size: 14px; text-align: right; }

/* Grouped table iOS — usado en Buscar y resultados del server */
.ios-section {
  margin-bottom: 20px;
}
.ios-section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px 8px;
}
.ios-table {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.ios-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--border);
  transition: background 0.1s;
}
.ios-cell:last-child { border-bottom: none; }
.ios-cell:hover { background: var(--surface2); }
.ios-cell:active { background: var(--surface3); }
.cell-chevron {
  color: var(--text3, var(--text2));
  font-size: 18px;
  line-height: 1;
  margin-left: 8px;
  flex-shrink: 0;
  opacity: 0.5;
}


/* ═══════════════════════════════════════════
   49. MED CELLS
   ═══════════════════════════════════════════ */
.med-cell {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 0.5px solid var(--border);
}
.med-cell:last-child { border: none; }
.med-icon-wrap {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--primary-dim); display: flex; align-items: center; justify-content: center;
}
.med-info { flex: 1; min-width: 0; }
.med-name { font-size: 14px; font-weight: 600; }
.med-indication { font-size: 12px; color: var(--primary); margin-top: 1px; }
.med-detail { font-size: 12px; color: var(--text3); margin-top: 1px; }


/* ═══════════════════════════════════════════
   50. VACCINE CELLS
   ═══════════════════════════════════════════ */
.vac-cell {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 0.5px solid var(--border);
}
.vac-cell:last-child { border: none; }
.vac-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.vac-dot-green { background: var(--green); }
.vac-dot-red { background: var(--red); }
.vac-dot-orange { background: var(--yellow); }


/* ═══════════════════════════════════════════
   51. ALERT BANNER
   ═══════════════════════════════════════════ */
.alert-banner {
  background: var(--yellow-dim);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}


/* ═══════════════════════════════════════════
   52. AVATAR SELECTOR
   ═══════════════════════════════════════════ */
.avatar-selector { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid transparent; background: var(--surface2);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.avatar-btn.selected { border-color: var(--primary); background: var(--primary-dim); }


/* ═══════════════════════════════════════════
   53. NOTES / TEXT
   ═══════════════════════════════════════════ */
.notes-text {
  font-size: 14px; line-height: 1.5;
  color: var(--text2); white-space: pre-line;
}


/* ═══════════════════════════════════════════
   54. DELETE BUTTON
   ═══════════════════════════════════════════ */
.delete-btn {
  background: none; border: none;
  color: var(--red); font-size: 18px;
  cursor: pointer; padding: 4px; opacity: 0.7;
}
.delete-btn:hover { opacity: 1; }


/* ═══════════════════════════════════════════
   55. ALLERGY BADGE
   ═══════════════════════════════════════════ */
.allergy-badge {
  display: inline-block;
  background: var(--red-dim);
  color: var(--red);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin: 2px;
}


/* ═══════════════════════════════════════════
   56. VOICE / ANIMATION STATES
   ═══════════════════════════════════════════ */
.voice-active {
  color: var(--red) !important;
  animation: pulse-voice 1s infinite;
}


/* ═══════════════════════════════════════════
   57. UTILITY CLASSES
   ═══════════════════════════════════════════ */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }


/* ═══════════════════════════════════════════
   58. RESPONSIVE — DESKTOP (>=768px)
   ═══════════════════════════════════════════ */
@media (min-width: 768px) {
  /* Main area shifts for sidebar */
  .main {
    padding-bottom: 0;
  }

  .page {
    padding: 24px 32px;
    max-width: none;
  }

  /* Detail overlay → full-width panel on desktop (minus sidebar) */
  .detail-overlay {
    left: var(--sidebar-w);
    right: 0;
    top: 0;
    bottom: 0;
    width: auto;
    border-left: 1px solid var(--border);
    box-shadow: none;
  }
  .detail-overlay .tab-content {
    max-width: 800px;
  }

  /* Upload & More modals → centered on desktop */
  .upload-modal {
    bottom: auto;
    top: 50%;
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2);
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    width: min(500px, calc(100vw - var(--sidebar-w) - 32px));
    max-width: none;
    max-height: 80vh;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    padding-bottom: 20px;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .upload-modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  .upload-modal-handle { display: none; }

  .upload-modal-header {
    border-radius: var(--radius) var(--radius) 0 0;
  }

  /* Overlays don't cover sidebar on desktop */
  .modal-overlay,
  .upload-overlay,
  .chat-overlay,
  .doc-detail-overlay {
    left: var(--sidebar-w);
  }

  /* Doc detail modal as centered panel on desktop */
  .doc-detail-modal {
    inset: auto;
    top: 50%;
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2);
    transform: translate(-50%, -50%);
    width: min(600px, calc(100vw - var(--sidebar-w) - 32px));
    max-height: 85vh;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }

  /* Page header non-sticky on desktop (sidebar handles nav) */
  .page-header {
    position: static;
    padding: 0;
    margin-bottom: 28px;
  }

  /* Toast repositions */
  .toast, #toast {
    bottom: 40px;
  }
}

/* ── Skeleton de carga unificado (Sprint A · Capa 1 v2.0) ───────────── */
/* Mientras /api/inicio carga, mostramos placeholders coherentes en vez */
/* de bloques que aparecen uno tras otro (efecto salpicado).            */
.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}
.skeleton-card {
  height: 88px;
  border-radius: 12px;
  background: var(--surface, #1a1a1a);
  border: 1px solid var(--surface-elevated, #2a2a2a);
}
.skel-shimmer {
  background-image: linear-gradient(
    90deg,
    var(--surface, #1a1a1a) 0%,
    var(--surface-elevated, #2a2a2a) 50%,
    var(--surface, #1a1a1a) 100%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
}
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skel-shimmer { animation: none; opacity: 0.7; }
}

/* ───────────────────────────────────────────────────────────────────── */
/*  SAL.CHAT.CITATIONS — Chips de citas en respuestas del chat            */
/* ───────────────────────────────────────────────────────────────────── */
.cite-chip {
  display: inline-block;
  padding: 1px 8px;
  margin: 0 2px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(20, 184, 166, 0.10);
  border: 1px solid rgba(20, 184, 166, 0.32);
  border-radius: 11px;
  color: var(--accent, #14b8a6);
  cursor: pointer;
  vertical-align: baseline;
  font-family: inherit;
  line-height: 1.5;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.cite-chip:hover,
.cite-chip:focus-visible {
  background: rgba(20, 184, 166, 0.20);
  border-color: var(--accent, #14b8a6);
  transform: translateY(-1px);
  outline: none;
}
.cite-chip:active { transform: translateY(0); }

/* Modal de fuente al hacer click en un chip */
.citation-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: min(80vh, 700px);
  background: var(--surface-container, #131313);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  z-index: 1200;
  display: none;
  overflow: hidden;
  flex-direction: column;
}
.citation-modal.open { display: flex; }

.cite-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  gap: 8px;
}
.cite-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary, #999);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: inherit;
}
.cite-modal-close:hover { background: rgba(255,255,255,0.06); color: var(--text, #e8e8e8); }
.cite-modal-badge {
  font-size: 11px;
  padding: 2px 10px;
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid rgba(20, 184, 166, 0.30);
  border-radius: 11px;
  color: var(--accent, #14b8a6);
  font-weight: 600;
}
.cite-modal-body {
  padding: 4px 20px 20px;
  overflow-y: auto;
}
.cite-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text, #e8e8e8);
  line-height: 1.3;
}
.cite-subtitle {
  font-size: 13px;
  color: var(--text-secondary, #999);
  margin-bottom: 4px;
}
.cite-date {
  font-size: 12px;
  color: var(--text-secondary, #999);
  margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.cite-snippet {
  background: var(--surface, #1a1a1a);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 16px;
  white-space: pre-wrap;
  border-left: 3px solid var(--accent, #14b8a6);
  color: var(--text, #e8e8e8);
}
.cite-modal-link {
  display: inline-block;
  padding: 8px 14px;
  background: var(--accent, #14b8a6);
  color: var(--on-accent, #0a0a0a);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.cite-modal-link:hover { filter: brightness(1.1); }
.cite-modal-loading,
.cite-error {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary, #999);
  font-size: 14px;
}
.cite-error { color: #ef4444; }

/* SAL.VIG.UI.BANNER · Píldora de alerta del motor de vigilancia inline en cards.
   Se inserta dentro de la card de condición o fila de medicamento cuando
   patient_actions tiene fila pending con source='vigilancia' y target_card matching. */
.vig-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 8px 0 0 0;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  transition: filter 120ms ease, transform 120ms ease;
}
.vig-pill:hover { filter: brightness(1.08); }
.vig-pill:active { transform: translateY(1px); }
.vig-pill .vig-pill-icon { font-size: 13px; flex-shrink: 0; line-height: 1; }
.vig-pill .vig-pill-text {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vig-pill .vig-pill-chev { font-size: 14px; flex-shrink: 0; opacity: 0.7; line-height: 1; }
.vig-pill.alta {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.32);
}
.vig-pill.media {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.32);
}
.vig-pill:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Chips de razón en el form de resolución de alerta de vigilancia */
.vig-reason-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--on-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 120ms ease;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
}
.vig-reason-chip:hover { filter: brightness(1.08); }
.vig-reason-chip.selected {
  background: rgba(20, 184, 166, 0.18);
  color: var(--accent, #14b8a6);
  border-color: var(--accent, #14b8a6);
  font-weight: 600;
}
.vig-reason-chip:focus-visible {
  outline: 2px solid var(--accent, #14b8a6);
  outline-offset: 2px;
}

/* SAL.VIG.UI.BANNER (A+++) · Multi-select chips con sub-chips expandibles */
.vig-chips-grid { display: flex; flex-direction: column; gap: 8px; }
.vig-chip-block { display: flex; flex-direction: column; gap: 6px; }
.vig-chip-principal {
  display: inline-block;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--on-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  width: 100%;
  transition: all 120ms ease;
}
.vig-chip-principal:hover { filter: brightness(1.06); }
.vig-chip-principal.selected {
  background: rgba(20, 184, 166, 0.18);
  color: var(--accent, #14b8a6);
  border-color: var(--accent, #14b8a6);
}
.vig-sub-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 2px 0 2px 0;
  padding-left: 12px;
  border-left: 2px solid rgba(20, 184, 166, 0.25);
}
.vig-chip-sub {
  display: inline-block;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-3, var(--surface-2));
  color: var(--on-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  transition: all 120ms ease;
}
.vig-chip-sub:hover { filter: brightness(1.08); }
.vig-chip-sub.selected {
  background: var(--accent, #14b8a6);
  color: #fff;
  border-color: var(--accent, #14b8a6);
  font-weight: 600;
}
.vig-chip-principal:focus-visible,
.vig-chip-sub:focus-visible {
  outline: 2px solid var(--accent, #14b8a6);
  outline-offset: 2px;
}

/* ── Carpeta Clínica ── */
.carpeta-stats {
  display: flex; gap: 12px; padding: 12px 16px; margin-bottom: 4px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.carpeta-stat {
  display: flex; flex-direction: column; align-items: center;
  min-width: 60px; padding: 8px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.carpeta-stat-n { font-size: 20px; font-weight: 700; line-height: 1.2; }
.carpeta-stat-l { font-size: 11px; color: var(--text3); margin-top: 2px; }

.carpeta-cat {
  margin-bottom: 4px; border-bottom: 1px solid var(--border);
}
.carpeta-cat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.carpeta-cat-header:active { background: var(--surface-2); }
.carpeta-chevron {
  transition: transform 0.2s; color: var(--text3); font-size: 10px;
  display: flex; align-items: center;
}
.carpeta-cat.collapsed .carpeta-chevron { transform: rotate(0deg); }
.carpeta-cat:not(.collapsed) .carpeta-chevron { transform: rotate(90deg); }
.carpeta-cat.collapsed .carpeta-slots { display: none; }

.carpeta-slots { padding: 0 8px 8px; }

.carpeta-slot {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; margin-bottom: 4px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
  border-left: 3px solid transparent;
}
.carpeta-slot:active { background: var(--surface-3, rgba(0,0,0,0.06)); }
.carpeta-slot.slot-vencido   { border-left-color: #ef4444; }
.carpeta-slot.slot-por-vencer { border-left-color: #f59e0b; }

.carpeta-slot-icon {
  flex-shrink: 0; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3, rgba(0,0,0,0.04)); border-radius: 8px;
}
.carpeta-slot-info { flex: 1; min-width: 0; }
.carpeta-slot-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  text-transform: capitalize; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.carpeta-slot-meta {
  display: flex; gap: 8px; font-size: 11px; color: var(--text3); margin-top: 2px;
}
.carpeta-slot-summary {
  font-size: 12px; color: var(--text2); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.carpeta-slot-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 99px; white-space: nowrap;
  align-self: center;
}
