/* ==========================================================================
   Me Cuido — estilos
   Mobile-first, letra grande y botones amplios (pensado para adultos mayores).
   ========================================================================== */

:root {
  --bg: #f4f8f6;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #1d2b28;
  --muted: #5a6b66;
  --border: #dce7e2;
  --primary: #23806f;
  --primary-strong: #1a6557;
  --primary-soft: #e0f2ec;
  --on-primary: #ffffff;
  --blue: #3a74c4;
  --blue-soft: #e5eefa;
  --violet: #7b5bb8;
  --violet-soft: #efe9f8;
  --amber: #b86e0a;
  --amber-soft: #fdf1df;
  --danger: #b8402f;
  --danger-soft: #fbe9e6;
  --ok: #23806f;
  --shadow: 0 1px 2px rgba(22, 50, 44, .06), 0 4px 14px rgba(22, 50, 44, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 52px;
  --nav-h: 72px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

html { font-size: 18px; -webkit-text-size-adjust: 100%; }
html[data-font-scale="grande"] { font-size: 20px; }
html[data-font-scale="muy-grande"] { font-size: 22.5px; }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: .4rem 0; }
a { color: var(--primary-strong); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.icon { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.2em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.center-block { display: flex; justify-content: center; margin-top: .6rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ok-text { color: var(--ok); font-weight: 600; }

/* ── Estructura ─────────────────────────────────────────────────────────── */
.app { min-height: 100vh; min-height: 100dvh; }
.view { outline: none; padding: max(16px, env(safe-area-inset-top)) 16px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 760px; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 16px; animation: fade .18s ease-out; }
.page-onboarding { padding-bottom: 0; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } * { transition: none !important; } }

.boot { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.boot-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ── Navegación inferior (celular) / lateral (computadora) ─────────────── */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.nav-brand { display: none; }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 700; min-width: 0; letter-spacing: -0.035em;
  border-radius: 14px; margin: 6px 0;
}
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item .icon { width: 1.55rem; height: 1.55rem; padding: 2px; }
.nav-item.active { color: var(--primary-strong); }
.nav-item.active .icon { background: var(--primary-soft); border-radius: 10px; width: 3rem; padding: 3px 0; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 24px 14px; border-top: 0; border-right: 1px solid var(--border); background: var(--surface);
  }
  .nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; padding: 4px 12px 22px; color: var(--primary-strong); }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: .95rem; padding: 12px 14px; margin: 0; }
  .nav-item .icon { width: 1.35rem; height: 1.35rem; }
  .nav-item.active { background: var(--primary-soft); }
  .nav-item.active .icon { background: none; width: 1.35rem; padding: 2px; }
  .nav-item:hover { background: var(--surface-2); }
  .view { padding: 32px 32px 48px; width: 100%; }
}
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--primary); color: #fff; }

/* ── Encabezados ───────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.page-head-text { flex: 1; min-width: 0; }
.page-head h1 { font-size: 1.6rem; overflow-wrap: anywhere; }
.page-head .muted { margin: 2px 0 0; }
.page-head-actions { display: flex; gap: 6px; }
.back-btn { margin-left: -8px; }

.home-head .eyebrow { margin: 0 0 4px; color: var(--muted); font-weight: 600; }
.day-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.day-title { font-size: 2.3rem; font-weight: 800; color: var(--primary-strong); text-transform: uppercase; letter-spacing: .02em; }
.day-date { margin: 0; color: var(--muted); font-size: 1.05rem; }
.day-date::first-letter, .day-events-head h2::first-letter { text-transform: uppercase; }
.day-nav { display: flex; align-items: center; gap: 6px; }

/* ── Botones ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 20px; border-radius: 14px; border: 2px solid transparent;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; text-align: center;
  transition: transform .08s, background .15s, box-shadow .15s; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.busy { opacity: .7; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 8px rgba(35, 128, 111, .25); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: var(--surface); color: var(--primary-strong); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost.danger, .link-btn.danger, .icon-btn.danger { color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 42px; padding: 6px 12px; font-size: .9rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn-row > .btn { flex: 1 1 140px; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border-radius: 14px; border: 0; background: transparent; color: var(--text); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .icon { width: 1.45rem; height: 1.45rem; }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255, 255, 255, .15); }
.pill-btn { display: inline-flex; align-items: center; min-height: 40px; padding: 4px 14px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; text-decoration: none; font-size: .9rem; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 8px 4px; color: var(--primary-strong); font-weight: 700; cursor: pointer; text-decoration: none; min-height: 44px; }

:focus-visible { outline: 3px solid #f0b429; outline-offset: 2px; border-radius: 8px; }

/* ── Tarjetas ──────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--border); }
a.card { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 14px; }
a.card:active { transform: scale(.995); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; margin-bottom: 10px; }
.card-title .icon { color: var(--primary); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.chev { color: var(--muted); margin-left: auto; display: grid; }
.group-title { font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 4px 8px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag .icon { width: 1em; height: 1em; }
.tag-ok { background: var(--primary-soft); color: var(--primary-strong); }
.tag-warn { background: var(--amber-soft); color: var(--amber); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-violet { background: var(--violet-soft); color: var(--violet); }
.tag-muted { background: var(--surface-2); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 10px; background: var(--surface-2); font-size: .85rem; font-weight: 600; }
.chip .icon { width: 1em; height: 1em; color: var(--primary); }
.chip-muted { color: var(--muted); }
.chip-violet { background: var(--violet-soft); color: var(--violet); }

.note { display: flex; gap: 8px; align-items: flex-start; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); }
.note .icon { margin-top: 2px; color: var(--primary); }
.note.warn { background: var(--amber-soft); color: var(--amber); }
.note.warn .icon { color: var(--amber); }

/* ── Inicio ────────────────────────────────────────────────────────────── */
.progress-card { background: var(--primary-soft); border-radius: var(--radius); padding: 14px 16px; }
.progress-text { font-size: 1rem; margin-bottom: 8px; }
.progress-bar { height: 10px; background: rgba(255, 255, 255, .8); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }

.dose-list { display: flex; flex-direction: column; gap: 14px; }
.dose-group { display: flex; flex-direction: column; gap: 8px; }
.dose-time { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.35rem; color: var(--text); }
.dose-time::after { content: ""; flex: 1; height: 2px; background: var(--border); border-radius: 2px; }
.dose-cards { display: flex; flex-direction: column; gap: 10px; }
.dose { background: var(--surface); border-radius: var(--radius); border: 2px solid var(--border); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.dose-overdue { border-color: #f0c98a; }
.dose-taken { border-color: #b9e0d4; background: #f7fcfa; }
.dose-skipped { opacity: .8; }
.dose-main { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.dose-thumb, .med-thumb { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; overflow: hidden; flex: none; }
.dose-thumb img, .med-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dose-thumb .icon, .med-thumb .icon { width: 1.6rem; height: 1.6rem; }
.dose-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dose-name { font-weight: 800; font-size: 1.2rem; }
.dose-strength { font-weight: 600; color: var(--muted); font-size: .9em; }
.dose-qty { color: var(--muted); }
.dose-info .tag { align-self: flex-start; margin-top: 6px; }
.dose-actions { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; }
.btn-take { background: var(--primary); color: #fff; font-size: 1.1rem; min-height: 58px; }
.btn-take:hover { background: var(--primary-strong); }
.btn-skip { background: var(--surface); border-color: var(--border); color: var(--muted); min-height: 58px; }
.dose-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 700; padding: 8px 12px; border-radius: var(--radius-sm); }
.dose-status > span { display: inline-flex; align-items: center; gap: 6px; }
.dose-status.is-ok { background: var(--primary-soft); color: var(--primary-strong); }
.dose-status.is-skip { background: var(--surface-2); color: var(--muted); }
.dose-status .link-btn { color: inherit; font-weight: 600; font-size: .85rem; padding: 4px 2px; gap: 4px; }
.dose-note { color: var(--muted); font-size: .9rem; margin: 0; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.summary-card {
  display: flex; flex-direction: column; gap: 3px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); text-decoration: none; color: inherit; min-width: 0;
}
.summary-card strong { font-size: .98rem; overflow-wrap: anywhere; }
.summary-card .muted { font-size: .85rem; }
.summary-card.is-warning { border-color: #f0c98a; background: #fffaf2; }
.summary-label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 2px; }
.summary-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.summary-icon .icon { width: 1.3rem; height: 1.3rem; }
.tone-green { background: var(--primary-soft); color: var(--primary-strong); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-neutral { background: var(--surface-2); color: var(--muted); }

/* ── Medicamentos ──────────────────────────────────────────────────────── */
.med-card { align-items: flex-start !important; }
.med-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.med-title { font-weight: 800; font-size: 1.15rem; }
.med-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.collapsible { margin-top: 6px; }
.collapsible > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 14px 4px; font-weight: 700; color: var(--muted); min-height: var(--tap); }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible .caret { margin-left: auto; transition: transform .2s; }
.collapsible[open] .caret { transform: rotate(180deg); }

.detail-hero { display: flex; flex-direction: column; gap: 10px; }
.hero-photo { border: 0; padding: 0; border-radius: var(--radius); overflow: hidden; max-height: 220px; cursor: zoom-in; background: var(--surface-2); }
.hero-photo img { width: 100%; height: 220px; object-fit: cover; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.sched-view { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.sched-view li { display: grid; grid-template-columns: auto 1fr; gap: 0 14px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.sched-view li strong { font-size: 1.3rem; grid-row: span 2; align-self: center; }
.sched-view li .muted { font-size: .85rem; }
.stock-grid { display: flex; gap: 22px; margin-bottom: 8px; }
.stock-grid > div { display: flex; flex-direction: column; }
.big-num { font-size: 2rem; font-weight: 800; color: var(--primary-strong); line-height: 1.1; }

.list { list-style: none; padding: 0; margin: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.row-actions { display: flex; align-items: center; gap: 4px; }

.info-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-row:last-of-type { border-bottom: 0; }
.info-icon { color: var(--primary); padding-top: 2px; }
.info-label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.info-value { display: block; white-space: pre-line; overflow-wrap: anywhere; }

.danger-zone { display: flex; flex-wrap: wrap; gap: 10px; }
.danger-zone > * { flex: 1 1 200px; }

/* ── Formularios ───────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-section { background: var(--surface); border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.section-title h2 { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.section-title h2 .icon { color: var(--primary); }
.section-title p { margin: 4px 0 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.compact { gap: 4px; }
.field label, .label { font-weight: 700; font-size: .92rem; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: .82rem; margin: 0; display: block; font-weight: 400; }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: #fff; font-size: 1rem;
}
textarea.input { min-height: 0; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235a6b66' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px var(--primary-soft); }
input[type="date"].input, input[type="time"].input { min-width: 0; -webkit-appearance: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }
.form-errors { background: var(--danger-soft); color: var(--danger); padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 600; white-space: pre-line; }
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 5;
  display: flex; gap: 10px; padding: 10px; background: rgba(244, 248, 246, .94); backdrop-filter: blur(8px);
  border-radius: var(--radius); border: 1px solid var(--border);
}
.sticky-actions > * { flex: 1; }
.sticky-actions .btn-primary { flex: 1.6; }
@media (min-width: 900px) { .sticky-actions { bottom: 16px; } }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; padding: 6px 0; min-height: var(--tap); }
.switch-row > span { display: flex; flex-direction: column; }
.switch { appearance: none; width: 58px; height: 34px; border-radius: 99px; background: #c9d6d1; position: relative; flex: none; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(24px); }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--primary); flex: none; }

.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-preview { width: 84px; height: 84px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); flex: none; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

.sched-list { display: flex; flex-direction: column; gap: 12px; }
.sched-row { border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fbfdfc; }
.sched-top { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px; align-items: end; }
.sched-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chip { min-width: 44px; min-height: 44px; border-radius: 12px; border: 2px solid var(--border); background: #fff; font-weight: 700; cursor: pointer; color: var(--muted); }
.day-chip.all { padding: 0 12px; }
.day-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.attach-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .attach-buttons { grid-template-columns: 1fr; } }
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.attach-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: #fff; flex: none; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-name { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.file-badge { display: inline-grid; place-items: center; min-width: 40px; height: 26px; padding: 0 6px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); font-weight: 800; font-size: .72rem; }
.file-name { display: flex; align-items: center; gap: 10px; min-width: 0; overflow-wrap: anywhere; }

/* ── Estudios ──────────────────────────────────────────────────────────── */
.filters { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.search { position: relative; display: block; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 44px; }
.study-icon, .event-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet); flex: none; }
.study-body, .event-body, .appt-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.study-title, .appt-title { font-weight: 800; font-size: 1.08rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb { aspect-ratio: 1; border: 0; padding: 0; border-radius: 12px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Turnos ────────────────────────────────────────────────────────────── */
.segmented { display: flex; background: var(--surface-2); padding: 4px; border-radius: 14px; gap: 4px; }
.segmented > * { flex: 1; display: grid; place-items: center; min-height: 46px; border-radius: 11px; font-weight: 700; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer; padding: 0 8px; text-align: center; }
.segmented > .on { background: #fff; color: var(--primary-strong); box-shadow: var(--shadow); }
.date-block { width: 60px; flex: none; border-radius: 14px; background: var(--blue-soft); color: var(--blue); display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.db-day { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.db-month { font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.appt-card.is-past .date-block { background: var(--surface-2); color: var(--muted); }
.appt-body .small .icon { width: 1em; height: 1em; }
.appt-hero { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; background: var(--blue-soft); border-color: transparent; }
.appt-hero.is-past { background: var(--surface-2); }
.appt-when { font-size: 1.25rem; font-weight: 800; }
.appt-when::first-letter { text-transform: uppercase; }
.appt-time { font-size: 1.15rem; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }

/* ── Calendario ────────────────────────────────────────────────────────── */
.cal { padding: 14px 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head h2 { font-size: 1.25rem; text-transform: capitalize; }
.cal-today { margin: 0 auto 8px; display: flex; width: max-content; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: .8rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1 / 1.05; border: 0; background: none; border-radius: 12px; cursor: pointer; padding: 4px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; min-height: 44px;
}
.cal-day:hover { background: var(--surface-2); }
.cal-num { font-weight: 700; width: 2em; height: 2em; display: grid; place-items: center; border-radius: 50%; font-size: .95rem; }
.cal-day.out { opacity: .35; }
.cal-day.today .cal-num { background: var(--primary-soft); color: var(--primary-strong); }
.cal-day.sel { background: var(--primary); }
.cal-day.sel .cal-num { color: #fff; background: transparent; }
.cal-day.sel .dot { box-shadow: 0 0 0 2px #fff; }
.cal-dots { display: flex; gap: 3px; height: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.ev-appt.dot, .dot.ev-appt { background: var(--blue); }
.dot.ev-study { background: var(--violet); }
.dot.ev-rebuy { background: var(--amber); border-radius: 2px; transform: rotate(45deg) scale(.9); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 12px; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.day-events { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 16px; }
.day-events-head h2 { font-size: 1.15rem; }
.event-card { border-left: 6px solid var(--border); }
.event-card.ev-appt { border-left-color: var(--blue); }
.event-card.ev-appt .event-icon { background: var(--blue-soft); color: var(--blue); }
.event-card.ev-study { border-left-color: var(--violet); }
.event-card.ev-rebuy { border-left-color: var(--amber); }
.event-card.ev-rebuy .event-icon { background: var(--amber-soft); color: var(--amber); }
.event-kind { font-size: .78rem; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }

/* ── Historial ─────────────────────────────────────────────────────────── */
.chip-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chip-tabs::-webkit-scrollbar { display: none; }
.chip-tab { flex: none; padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center; border-radius: 999px; border: 2px solid var(--border); background: #fff; color: var(--muted); font-weight: 700; text-decoration: none; }
.chip-tab.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.range-select { max-width: 280px; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.tl-day { position: relative; margin-bottom: 18px; }
.tl-date { display: flex; align-items: baseline; gap: 8px; padding-left: 52px; margin-bottom: 8px; color: var(--primary-strong); }
.tl-date::before { content: ""; position: absolute; left: 15px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--bg); }
.tl-items { list-style: none; padding: 0 0 0 52px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.tl-link, .tl-details > summary { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; color: inherit; }
.tl-details > summary { list-style: none; cursor: pointer; }
.tl-details > summary::-webkit-details-marker { display: none; }
.tl-details .caret { margin-left: auto; color: var(--muted); transition: transform .2s; display: grid; }
.tl-details[open] .caret { transform: rotate(180deg); }
.tl-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.tl-body { display: flex; flex-direction: column; min-width: 0; }
.k-intake { background: var(--primary-soft); color: var(--primary-strong); }
.k-intake.partial { background: var(--amber-soft); color: var(--amber); }
.k-purchase { background: var(--amber-soft); color: var(--amber); }
.k-study { background: var(--violet-soft); color: var(--violet); }
.k-appt { background: var(--blue-soft); color: var(--blue); }
.k-med { background: var(--danger-soft); color: var(--danger); }
.tl-detail-list { list-style: none; margin: 6px 0 0; padding: 4px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.tl-detail-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .92rem; flex-wrap: wrap; }
.tl-detail-list li:last-child { border-bottom: 0; }

/* ── Más / perfil ──────────────────────────────────────────────────────── */
.menu-list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow); }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--border); min-height: 72px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: var(--surface-2); }
.menu-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; overflow: hidden; flex: none; position: relative; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; }
.avatar > .icon { width: 1.8rem; height: 1.8rem; }
.avatar-lg { width: 92px; height: 92px; cursor: pointer; }
.avatar-lg > .icon { width: 2.6rem; height: 2.6rem; }
.avatar-edit { position: absolute; bottom: 0; inset-inline: 0; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; height: 28px; }
.avatar-edit .icon { width: 1rem; height: 1rem; }
.profile-hero { display: flex; align-items: center; gap: 18px; }
.profile-mini > span:nth-child(2) { display: flex; flex-direction: column; }
.soon-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bullets { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.danger-card { border-color: #f1c8c1; }
.confirm-text { font-size: 1.05rem; }

/* ── Vacío ─────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 1.15rem; }
.empty p { max-width: 32ch; }
.empty .btn { margin-top: 8px; }
.empty-icon { width: 64px; height: 64px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty-icon .icon { width: 2rem; height: 2rem; }

/* ── Bienvenida ────────────────────────────────────────────────────────── */
.onboarding { max-width: 460px; margin: 0 auto; padding-top: 6vh; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ob-logo { width: 84px; height: 84px; border-radius: 26px; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 30px rgba(35, 128, 111, .3); }
.ob-logo .icon { width: 2.6rem; height: 2.6rem; }
.onboarding h1 { font-size: 2.2rem; color: var(--primary-strong); margin-top: 8px; }
.ob-lead { font-size: 1.15rem; color: var(--muted); max-width: 26ch; }
.onboarding .card { width: 100%; text-align: left; margin-top: 14px; }
.onboarding .card h2 { font-size: 1.2rem; }
.ob-privacy { display: flex; gap: 8px; color: var(--muted); font-size: .88rem; text-align: left; margin-top: 8px; }
.ob-privacy .icon { color: var(--primary); margin-top: 2px; }

/* ── Hoja modal ────────────────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 35, 31, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 18px calc(18px + var(--safe-b));
  transform: translateY(30px); transition: transform .2s;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: -8px; background: var(--surface); padding: 8px 0; z-index: 1; }
.sheet-head h2 { font-size: 1.25rem; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; padding-bottom: 6px; }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 24px; }
}

/* ── Visor de imágenes ─────────────────────────────────────────────────── */
.viewer { position: fixed; inset: 0; z-index: 60; background: #0d1513; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-top { position: absolute; top: 0; inset-inline: 0; display: flex; align-items: center; justify-content: space-between; padding: max(8px, env(safe-area-inset-top)) 10px 8px 18px; color: #fff; background: linear-gradient(rgba(0, 0, 0, .6), transparent); z-index: 1; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .18); color: #fff; display: grid; place-items: center; cursor: pointer; }
.viewer-nav.prev { left: 10px; }
.viewer-nav.next { right: 10px; }

/* ── Avisos ────────────────────────────────────────────────────────────── */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(94vw, 480px); pointer-events: none; }
@media (min-width: 900px) { #toast-root { bottom: 24px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #1f2f2b; color: #fff; padding: 12px 14px 12px 18px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; font-weight: 600;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); }
.toast-action { background: rgba(255, 255, 255, .16); color: #fff; border: 0; border-radius: 10px; padding: 8px 12px; font-weight: 800; cursor: pointer; min-height: 40px; }

@media print {
  .nav, .sticky-actions, #toast-root { display: none !important; }
  .view { padding: 0; }
}
