/* ╔══════════════════════════════════════════════════════════════╗
   ║  TEA Advisor — Mobile-first CSS                                ║
   ║  Estructura: base mobile → @media (min-width: 768px) desktop   ║
   ╚══════════════════════════════════════════════════════════════╝ */

/* ─── reset + variables ─── */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #111827;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-soft: #f3f4f6;

  --primary: #4338ca;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --primary-line: #c7d2fe;

  --green: #10b981;
  --green-bg: #d1fae5;
  --green-text: #065f46;
  --amber: #f59e0b;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --blue: #3b82f6;
  --blue-bg: #dbeafe;
  --blue-text: #1e40af;
  --purple: #8b5cf6;
  --purple-bg: #ede9fe;
  --purple-text: #5b21b6;

  --bn-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;            /* base accesible para mobile */
  color: var(--text); background: var(--bg); line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
svg { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }

/* ─── auth / loading ─── */
.auth-error, .loading {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #f8fafc; padding: 24px; gap: 16px;
}
.auth-box {
  max-width: 380px; text-align: center;
  background: #fff; padding: 32px 24px;
  border-radius: 16px; border: 1px solid var(--border);
}
.auth-icon { color: var(--red); margin-bottom: 12px; }
.auth-box h1 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.auth-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.auth-foot { font-size: 12px; color: var(--text-muted); }

.loading p { color: var(--text-muted); font-size: 13px; }
.spinner { color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { from{transform:rotate(0);} to{transform:rotate(360deg);} }

/* ─── topbar ─── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-meta { color: var(--text-muted); font-size: 11px; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.confidential {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--amber-bg); color: var(--amber-text);
  padding: 4px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.confidential .conf-text { display: none; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: var(--primary); color: #fff;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  min-height: 38px;
  transition: background .15s;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-primary .btn-text { display: none; }
.btn-upload { padding: 8px; min-width: 38px; justify-content: center; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 500;
  background: var(--card); min-height: 38px;
}

/* ─── layout ─── */
.layout {
  max-width: 1400px; margin: 0 auto;
  padding: 14px 14px calc(var(--bn-h) + var(--safe-bottom) + 14px);
}
.sidebar { display: none; }
.content { min-width: 0; }
.view { display: none; }
.view.active { display: block; animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.hero h1 { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  margin: 22px 0 10px;
  text-transform: uppercase; letter-spacing: .5px;
}
.section-title.small { margin-top: 0; }

/* ─── cards comunes ─── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card.highlight { background: linear-gradient(135deg, #eef2ff, #e0e7ff); border-color: var(--primary-line); }
.two-col { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 18px; }

/* ─── diagnósticos (home) ─── */
.dx-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.dx-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; border-top: 3px solid #d1d5db;
}
.dx-card.priority-alta { border-top-color: var(--red); }
.dx-card.priority-media { border-top-color: var(--amber); }
.dx-badge {
  display: inline-block;
  background: var(--border-soft); color: var(--text-soft);
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
  margin-bottom: 8px;
}
.dx-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; line-height: 1.3; }
.dx-detail { color: var(--text-muted); font-size: 13px; margin-bottom: 10px; }
.dx-status { display: flex; flex-wrap: wrap; gap: 4px; }

.status-pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.status-pill.green { background: var(--green-bg); color: var(--green-text); }
.status-pill.amber { background: var(--amber-bg); color: var(--amber-text); }
.status-pill.red   { background: var(--red-bg);   color: var(--red-text); }
.status-pill.blue  { background: var(--blue-bg);  color: var(--blue-text); }

/* ─── home: medicación ─── */
.med-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.med-table th { text-align: left; padding: 8px 0; color: var(--text-muted); font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--border); }
.med-table td { padding: 10px 0; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.med-table tr:last-child td { border-bottom: none; }
.muted { color: #9ca3af; font-size: 11px; }
.card-foot { font-size: 11px; color: var(--text-muted); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }

/* ─── home: próxima cita ─── */
.next-appt-big { display: flex; gap: 14px; align-items: center; padding: 6px 0; }
.appt-date-big {
  background: #fff; border: 1px solid var(--primary-line);
  border-radius: 10px; padding: 10px 14px; text-align: center;
  flex-shrink: 0;
}
.appt-day { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1; }
.appt-month-year { font-size: 10px; color: var(--primary); font-weight: 600; text-transform: uppercase; }
.appt-time { font-size: 16px; font-weight: 600; color: #1e1b4b; }
.appt-prof { font-weight: 600; color: #1e1b4b; margin-top: 2px; font-size: 13px; }
.appt-place { font-size: 12px; color: var(--primary); margin-top: 4px; }

/* ─── home: listas ─── */
.strength-list, .todo-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.strength-list li {
  color: var(--green-text); display: flex; gap: 8px; align-items: flex-start;
}
.strength-list li::before { content: ''; flex-shrink: 0; width: 16px; height: 16px; background: var(--green); border-radius: 50%; margin-top: 2px; position: relative; }
.todo-list li { display: flex; align-items: center; gap: 10px; color: var(--text-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.alta { background: var(--red); }
.dot.media { background: var(--amber); }
.dot.baja { background: var(--green); }

/* ─── AGENDA: calendario ─── */
.calendar-card { padding: 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head h3 { font-size: 15px; font-weight: 700; }
.cal-nav { width: 36px; height: 36px; border-radius: 50%; background: var(--border-soft); color: var(--text-soft); display: flex; align-items: center; justify-content: center; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day-label { font-size: 10px; color: #9ca3af; text-align: center; font-weight: 600; padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 13px; color: var(--text-soft); position: relative;
  cursor: pointer; transition: all .12s;
}
.cal-day:active { background: var(--border-soft); }
.cal-day.empty { cursor: default; }
.cal-day.has-event { font-weight: 600; }
.cal-day.has-event::after { content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; }
.cal-day.has-event.blue::after { background: var(--primary); }
.cal-day.has-event.green::after { background: var(--green); }
.cal-day.has-event.amber::after { background: var(--amber); }
.cal-day.selected { background: var(--primary); color: #fff; }
.cal-day.selected::after { background: #fff; }

.appt-list { display: flex; flex-direction: column; gap: 10px; }
.appt-row {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
  display: grid; grid-template-columns: 56px 1fr; gap: 12px;
  position: relative;
}
.appt-row.appt-primary { border-color: var(--primary-line); background: #fafbff; }
.appt-row.pending { border-style: dashed; opacity: .85; }
.appt-row.past { opacity: .65; }
.appt-date-mini { text-align: center; padding-top: 2px; }
.dm-day { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1; }
.dm-month { font-size: 9px; color: var(--text-muted); font-weight: 600; letter-spacing: .5px; }
.appt-row-title { font-weight: 600; font-size: 14px; color: var(--text); }
.appt-row-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.appt-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.appt-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; grid-column: 1 / -1; }

.btn-small {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; background: var(--card);
  white-space: nowrap; min-height: 32px;
}
.btn-small:active { background: var(--border-soft); }
.btn-small.green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-small svg { width: 13px; height: 13px; }

/* ─── GUARDIAS ─── */
.alert-warn {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--amber-bg); border: 1px solid #fcd34d;
  border-radius: 10px; padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px; color: var(--amber-text);
}
.alert-warn svg { color: var(--amber); width: 20px; height: 20px; }
.alert-warn strong { color: var(--amber-text); }

.guardia-list { display: flex; flex-direction: column; gap: 12px; }
.guardia-item {
  background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 12px; padding: 14px;
  display: grid; grid-template-columns: 60px 1fr; gap: 12px;
}
.g-date { text-align: center; padding-top: 2px; }
.g-day { font-size: 26px; font-weight: 700; color: var(--red); line-height: 1; }
.g-month { font-size: 9px; color: var(--text-muted); font-weight: 600; letter-spacing: .5px; }
.g-title { font-weight: 600; font-size: 14px; color: var(--text); }
.g-meta { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.g-tag { font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.g-tag.crisis { background: var(--red-bg); color: var(--red-text); }
.g-tag.lugar { background: var(--border-soft); color: var(--text-soft); }
.g-detail { font-size: 13px; color: var(--text-soft); margin-top: 6px; line-height: 1.55; }
.g-files { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.g-file {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 3px 6px; background: var(--primary-soft); color: var(--primary);
  border-radius: 4px; cursor: pointer;
}

/* ─── CRONOLOGÍA ─── */
.filters { display: flex; gap: 6px; flex-wrap: wrap; overflow-x: auto; padding-bottom: 4px; }
.filter { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; background: var(--card); white-space: nowrap; }
.filter.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-dot { position: absolute; left: -24px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 3px solid #6366f1; }
.tl-dot.future { border-color: var(--green); }
.tl-dot.critical { background: var(--red); border-color: var(--red); }
.tl-dot.crisis { border-color: var(--amber); }
.tl-dot.good { border-color: var(--green); }
.tl-date { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.tl-content { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tl-item.critical .tl-content { border-color: #fca5a5; background: #fef2f2; }
.tl-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 6px; }
.tag-neuro { background: var(--blue-bg); color: var(--blue-text); }
.tag-imagen { background: #fce7f3; color: #9d174d; }
.tag-lab { background: #dcfce7; color: #166534; }
.tag-psico { background: var(--purple-bg); color: var(--purple-text); }
.tag-crisis { background: var(--red-bg); color: var(--red-text); }
.tag-perinatal { background: var(--amber-bg); color: var(--amber-text); }
.tag-desarrollo { background: #cffafe; color: #155e75; }
.tl-title { font-weight: 600; color: var(--text); font-size: 14px; }
.tl-detail { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ─── DOCUMENTOS ─── */
.search-row { display: flex; gap: 6px; }
.search {
  flex: 1; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; min-height: 40px;
}

.inbox-card { background: linear-gradient(135deg, #ecfeff, #f0fdfa); border-color: #a5f3fc; margin-bottom: 18px; }
.inbox-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-row {
  display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px;
}
.inbox-row.analyzing { background: #fefce8; border-color: #fde047; }
.inbox-thumb { width: 48px; height: 48px; border-radius: 6px; background: var(--border-soft); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.inbox-info { min-width: 0; }
.inbox-name { font-weight: 500; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.inbox-ai { font-size: 12px; color: var(--text-soft); margin-top: 6px; }
.ai-tag { display: inline-flex; align-items: center; gap: 3px; background: #ddd6fe; color: var(--purple-text); padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; margin-right: 4px; }
.ai-tag.analyzing { background: #fef9c3; color: var(--amber-text); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.inbox-actions { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; margin-top: 6px; }

.folders-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.folder-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; transition: all .15s;
  display: flex; flex-direction: column; align-items: flex-start;
}
.folder-card:active { background: #fafbff; }
.folder-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.folder-name { font-weight: 600; font-size: 14px; color: var(--text); }
.folder-count { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.folder-detail { margin-top: 12px; }
.back-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--primary); padding: 6px 0; margin-bottom: 10px; }
.folder-detail h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.docs-list { display: grid; gap: 8px; }
.doc-item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer; }
.doc-item:active { background: #fafbff; }
.doc-thumb { width: 50px; height: 64px; background: var(--border-soft); border-radius: 6px; background-size: cover; background-position: top center; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-date { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.doc-title { font-weight: 500; font-size: 13px; color: var(--text); }
.doc-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── EQUIPO ─── */
.prof-detail-card {
  background: linear-gradient(135deg, #f5f3ff, #fafbff);
  border: 1px solid #c4b5fd;
  border-radius: 14px; padding: 18px;
  margin-bottom: 16px;
}
.prof-detail-head { display: flex; gap: 14px; margin-bottom: 16px; align-items: center; }
.prof-photo {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.prof-detail-info { flex: 1; min-width: 0; }
.prof-name-big { font-size: 18px; font-weight: 700; color: var(--text); margin: 4px 0; line-height: 1.2; }
.prof-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 12px 0; }
.prof-label { font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.prof-value { font-size: 12px; color: var(--text); line-height: 1.5; }

.prof-grid { display: flex; flex-direction: column; gap: 12px; }
.prof-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.prof-card.pending { background: #fafafa; border-style: dashed; }
.prof-role { font-size: 10px; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.prof-name { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 4px; line-height: 1.2; }
.prof-reg, .prof-place { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.prof-since { font-size: 11px; color: var(--green); margin-top: 6px; font-weight: 500; }
.prof-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.prof-card.mini .prof-name { font-size: 13px; }

/* ─── MEDICACIÓN ─── */
.med-card-big { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 14px; }
.med-card-head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; gap: 10px; }
.med-name { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.2; }
.med-conc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.med-status { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.med-status.green { background: var(--green-bg); color: var(--green-text); }
.med-doses { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.dose-block { background: var(--bg); padding: 12px; border-radius: 8px; text-align: center; }
.dose-num { font-size: 18px; font-weight: 700; color: var(--primary); }
.dose-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .3px; }
.med-foot { font-size: 12px; color: var(--text-muted); }

.dose-history { display: flex; flex-direction: column; gap: 8px; }
.dose-history-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.dh-date { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.dh-dose { font-weight: 600; font-size: 13px; }
.dh-tag { display: inline-block; background: var(--primary); color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 10px; margin-left: 4px; }
.dh-note { font-size: 11px; color: var(--text-muted); }

/* ─── LENGUAJE ─── */
.lang-timeline { display: flex; flex-direction: column; gap: 10px; }
.lang-stage {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.stage-meta { display: flex; gap: 8px; align-items: center; }
.stage-age { font-size: 12px; font-weight: 700; color: var(--primary); }
.stage-date { font-size: 11px; color: var(--text-muted); }
.stage-title { font-weight: 600; font-size: 15px; }
.stage-detail { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.lang-stage.stage-good { border-left: 4px solid var(--green); }
.lang-stage.stage-warning { border-left: 4px solid var(--red); background: #fef2f2; }
.lang-stage.stage-now { border-left: 4px solid #6366f1; background: var(--primary-soft); }
.stage-arrow { color: #d1d5db; font-size: 20px; text-align: center; }

/* ─── SUGERENCIAS ─── */
.sug-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.sug-list { display: flex; flex-direction: column; gap: 10px; }
.sug-item {
  background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid #d1d5db;
  border-radius: 12px; padding: 16px;
}
.sug-item.priority-urgente { border-left-color: var(--red); }
.sug-item.priority-importante { border-left-color: var(--amber); }
.sug-item.priority-cuando_se_pueda { border-left-color: var(--green); }
.sug-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.sug-pri-row { display: flex; gap: 8px; align-items: center; }
.sug-pri-icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sug-pri-icon.urgente { background: var(--red-bg); color: var(--red-text); }
.sug-pri-icon.importante { background: var(--amber-bg); color: var(--amber-text); }
.sug-pri-icon.cuando_se_pueda { background: var(--green-bg); color: var(--green-text); }
.sug-head h3 { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.3; flex: 1; min-width: 0; }
.sug-tag { font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.sug-why, .sug-how { font-size: 13px; color: var(--text-soft); margin: 6px 0; line-height: 1.55; }
.sug-why strong, .sug-how strong { color: var(--text); }
.sug-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ─── bottom nav (mobile) ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--card); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 12px rgba(0,0,0,.04);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px; min-height: var(--bn-h);
  font-size: 10px; color: var(--text-muted); font-weight: 500;
  transition: color .15s;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--primary); }
.bn-item.active svg { color: var(--primary); }
.bn-upload {
  position: relative;
}
.bn-upload-icon {
  background: var(--primary); color: #fff;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  box-shadow: 0 4px 10px rgba(67, 56, 202, .35);
}
.bn-upload-icon svg { color: #fff; width: 24px; height: 24px; }

.bn-more {
  position: fixed; bottom: calc(var(--bn-h) + var(--safe-bottom) + 14px);
  right: 14px; z-index: 65;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft);
}

.more-menu {
  position: fixed;
  bottom: calc(var(--bn-h) + var(--safe-bottom) + 70px);
  right: 14px; z-index: 64;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  display: none; flex-direction: column; gap: 2px;
  min-width: 180px;
}
.more-menu.open { display: flex; }
.mm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 14px; color: var(--text-soft);
  text-align: left; width: 100%;
}
.mm-item:active { background: var(--border-soft); }
.mm-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* ─── badges ─── */
.badge {
  background: var(--primary); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 999px; font-weight: 600;
  margin-left: auto;
}
.badge-amber { background: var(--amber); }
.badge-info { background: #06b6d4; font-size: 9px; }

/* ─── modal ─── */
.modal { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.85); align-items: center; justify-content: center; padding: 14px; padding-bottom: calc(14px + var(--safe-bottom)); }
.modal.active { display: flex; }
.modal-inner { max-width: 90vw; max-height: 92vh; position: relative; background: var(--card); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.05); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.img-modal-inner { padding: 8px; }
.img-modal-inner img { max-width: 100%; max-height: 78vh; object-fit: contain; border-radius: 8px; }
.modal-caption { font-size: 12px; color: var(--text-soft); text-align: center; padding: 4px 8px; }

/* ─── forms (modales de turno + bitácora) ─── */
.form-modal-inner { padding: 22px; max-width: 520px; }
.form-modal-inner h2 { font-size: 19px; font-weight: 700; padding-right: 36px; margin-bottom: 14px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.field input[type="text"],
.field input[type="date"],
.field input[type="time"],
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--card); color: var(--text);
  min-height: 40px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-check {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.field-check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px;
}
.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: #fee2e2; color: #991b1b;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  min-height: 38px;
  margin-right: auto;
}
.btn-danger:active { background: #fecaca; }

/* ─── bitácora ─── */
.bita-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.bita-list { display: flex; flex-direction: column; gap: 10px; }
.bita-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
  cursor: pointer;
}
.bita-card.flagged { border-left: 4px solid var(--amber); }
.bita-row1 {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  margin-bottom: 6px; flex-wrap: wrap;
}
.bita-fecha { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.bita-cat {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
}
.bita-cat-sueno          { background: #dbeafe; color: #1e40af; }
.bita-cat-alimentacion   { background: #fef3c7; color: #92400e; }
.bita-cat-comportamiento { background: #fce7f3; color: #9d174d; }
.bita-cat-lenguaje       { background: #ede9fe; color: #5b21b6; }
.bita-cat-sensorial      { background: #cffafe; color: #155e75; }
.bita-cat-crisis         { background: #fee2e2; color: #991b1b; }
.bita-cat-logro          { background: #dcfce7; color: #166534; }
.bita-cat-familia        { background: #fef3c7; color: #854d0e; }
.bita-cat-otro           { background: var(--border-soft); color: var(--text-soft); }
.bita-titulo { font-weight: 600; font-size: 15px; color: var(--text); line-height: 1.3; }
.bita-detalle { font-size: 13px; color: var(--text-soft); margin-top: 4px; line-height: 1.5; white-space: pre-wrap; }
.bita-flag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--amber-text); font-weight: 600;
  margin-top: 8px;
}
.bita-autor { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state-text { font-size: 14px; margin-top: 10px; }

/* ─── links accionables en profesionales ─── */
.prof-links {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.prof-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  text-decoration: none;
  min-height: 32px;
}
.prof-link:active { background: var(--primary-line); }
.prof-link.green { background: #d1fae5; color: #065f46; }
.prof-link.amber { background: #fef3c7; color: #92400e; }
.prof-link.blue  { background: #dbeafe; color: #1e40af; }
.prof-link.dark  { background: var(--text); color: #fff; }

/* ─── recordatorios ─── */
.push-status-card {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1px solid var(--primary-line);
  border-radius: 12px; padding: 16px;
  margin-bottom: 18px;
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap;
}
.push-status-card.granted { background: linear-gradient(135deg, #ecfdf5, #d1fae5); border-color: #86efac; }
.push-status-card.denied  { background: linear-gradient(135deg, #fef2f2, #fee2e2); border-color: #fca5a5; }
.push-status-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.push-status-text { flex: 1; min-width: 200px; }
.push-status-title { font-weight: 700; font-size: 15px; color: var(--text); }
.push-status-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.push-status-card .btns { display: flex; gap: 6px; flex-wrap: wrap; }

.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
  display: grid; grid-template-columns: 60px 1fr auto; gap: 12px; align-items: center;
  cursor: pointer;
}
.rec-card.inactive { opacity: .5; }
.rec-time {
  text-align: center; padding: 8px 4px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 8px;
  font-weight: 700; font-size: 16px;
}
.rec-icon { font-size: 22px; line-height: 1; margin-bottom: 4px; }
.rec-titulo { font-weight: 600; font-size: 14px; color: var(--text); }
.rec-cuerpo { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.rec-dias {
  display: flex; gap: 3px; margin-top: 6px;
}
.rec-dias-chip {
  display: inline-block;
  font-size: 9px; padding: 1px 4px;
  background: var(--border-soft); color: var(--text-muted);
  border-radius: 3px; font-weight: 600;
}
.rec-dias-chip.on { background: var(--primary); color: #fff; }
.rec-toggle {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--border); position: relative; cursor: pointer; transition: background .15s;
}
.rec-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .15s;
}
.rec-toggle.on { background: var(--green); }
.rec-toggle.on::after { transform: translateX(18px); }

.dias-semana {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px;
}
.dias-semana label {
  flex: 1; min-width: 36px; text-align: center;
  padding: 8px 4px;
  background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  position: relative;
}
.dias-semana input { position: absolute; opacity: 0; }
.dias-semana label:has(input:checked) {
  background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line);
}

/* ─── calendar: turnos del día seleccionado ─── */
.cal-day-events {
  margin-top: 14px;
  padding: 12px;
  background: var(--primary-soft);
  border-radius: 10px;
  display: none;
}
.cal-day-events.has-events { display: block; }
.cal-day-events-title {
  font-size: 12px; font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: .3px;
  margin-bottom: 8px;
}

/* ─── modal upload ─── */
.upload-modal-inner { padding: 22px; }
.upload-modal-inner h2 { font-size: 20px; font-weight: 700; padding-right: 36px; }
.upload-dropzone {
  background: #fafbff; border: 2px dashed var(--primary-line); border-radius: 12px;
  padding: 28px 16px; text-align: center; color: var(--primary);
  margin: 14px 0;
}
.upload-dropzone svg { color: #6366f1; margin-bottom: 10px; }
.dz-title { font-weight: 600; font-size: 15px; margin-bottom: 14px; }
.dz-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dz-buttons label { cursor: pointer; }
.dz-info { font-size: 11px; color: var(--text-muted); margin-top: 14px; }
.upload-status { font-size: 13px; margin-top: 14px; min-height: 20px; }
.upload-status.error { color: var(--red); }
.upload-status.success { color: var(--green); }

/* ╔══════════════════════════════════════════════════════════════╗
   ║  DESKTOP (≥ 768px)                                            ║
   ╚══════════════════════════════════════════════════════════════╝ */
@media (min-width: 768px) {
  html, body { font-size: 14px; }

  .layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    padding: 24px;
    padding-bottom: 24px;
    min-height: calc(100vh - 70px);
  }
  .sidebar {
    display: flex; flex-direction: column;
    background: var(--card); border-radius: 12px; padding: 14px;
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky; top: 80px;
  }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px;
    font-size: 14px; color: var(--text-soft);
    text-align: left; position: relative;
    min-height: 40px;
  }
  .nav-item:hover { background: var(--border-soft); }
  .nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  .nav-item.highlight-nav { background: linear-gradient(90deg, var(--amber-bg), transparent); }
  .nav-item.highlight-nav.active { background: #fde68a; color: #78350f; }
  .nav-item .badge { position: static; }

  .sidebar-foot {
    margin: 16px -14px -14px;
    padding: 14px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-radius: 0 0 11px 11px;
  }
  .next-appt-label { font-size: 10px; color: #047857; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
  .next-appt-date { font-size: 18px; font-weight: 700; color: #064e3b; margin-top: 4px; }
  .next-appt-meta { font-size: 11px; color: #065f46; }

  /* mobile-only elements: ocultar */
  .bottom-nav, .bn-more, .more-menu { display: none; }

  /* desktop: confidencial + texto */
  .confidential .conf-text { display: inline; }
  .btn-upload { padding: 8px 14px; }
  .btn-upload .btn-text { display: inline; }

  /* layouts más amplios */
  .hero h1 { font-size: 26px; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .dx-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .folders-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .prof-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .prof-detail-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .next-appt-big { gap: 20px; }
  .appt-day { font-size: 32px; }
  .appt-time { font-size: 18px; }

  .appt-row { grid-template-columns: 64px 1fr auto; align-items: center; }
  .appt-actions { grid-column: auto; margin-top: 0; justify-content: flex-end; }

  .med-doses { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .dose-history-item { display: grid; grid-template-columns: 180px 200px 1fr; gap: 16px; align-items: center; }

  .lang-stage { display: grid; grid-template-columns: 100px 100px 1fr; gap: 16px; align-items: center; padding: 18px 22px; max-width: 560px; margin: 0 auto; }
  .stage-meta { display: contents; }

  .sug-item { display: grid; grid-template-columns: 40px 1fr; gap: 16px; padding: 18px; }
  .sug-pri-row { display: contents; }
  .sug-pri-icon { width: 40px; height: 40px; }

  .inbox-row { grid-template-columns: 56px 1fr auto; }
  .inbox-actions { grid-column: auto; margin-top: 0; }
}

@media (min-width: 1024px) {
  .hero h1 { font-size: 28px; }
}
