/* Panel privado · estilo iOS minimalista (ver diseño en el lienzo "Agenda – diseño móvil") */

:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --ink: #1C1C1E;
  --ink-2: #3A3A3C;
  --muted: #6E6E73;
  --sep: #E5E5EA;
  --line: #D1D1D6;
  --fill: #E3E3E8;
  --accent: #2F6B57;
  --accent-dark: #24523F;
  --accent-soft: #E4EEE9;
  --wa: #177A43;
  --warn-bg: #FFF4E5;
  --warn-ink: #8A4B00;
  --warn-ink-2: #5C3300;
  --danger: #B3261E;
  --tabbar: #F9F9F9;
  --radius: 16px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
.screen { padding: calc(env(safe-area-inset-top, 0px) + 40px) 16px calc(env(safe-area-inset-bottom, 0px) + 104px); display: flex; flex-direction: column; gap: 18px; }
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 4px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; }
.large-title { margin: 2px 0 0; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-title { margin: 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-title small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.hint { margin: 0 4px; font-size: 13px; color: var(--muted); }

/* ---------- Tarjetas y listas agrupadas ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; min-height: 52px; width: 100%; border: none; background: none; text-align: left; text-decoration: none; color: var(--ink); }
.row + .row { border-top: 1px solid var(--sep); }
button.row:active, a.row:active { background: #EDEDF0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-time { width: 50px; flex: none; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.row-time b { font-size: 15px; font-weight: 600; }
.row-time span { font-size: 12px; color: var(--muted); }
.row-bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent); flex: none; }
.row-bar.pending { background: repeating-linear-gradient(180deg, var(--accent) 0 4px, transparent 4px 7px); }
.row-bar.muted { background: var(--line); }
.row.is-muted .row-title, .row.is-muted .row-time b { color: var(--muted); font-weight: 500; }
.chevron { flex: none; color: #C7C7CC; }
.row-value { font-size: 15px; color: var(--muted); text-align: right; }
.row-value.accent { color: var(--accent); font-weight: 600; }

/* ---------- Botones ---------- */
.btn { height: 52px; border-radius: 14px; border: none; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; font-size: 17px; font-weight: 600; text-decoration: none; }
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-wa { background: var(--wa); color: #FFFFFF; }
.btn-light { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-plain { border: none; background: none; color: var(--accent); font-size: 15px; font-weight: 600; padding: 10px 0 10px 10px; min-height: 44px; }
.btn-plain.danger { color: var(--danger); }
.pill { height: 34px; padding: 0 16px; border-radius: 17px; border: none; font-size: 14px; font-weight: 600; flex: none; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.pill-wa { background: var(--wa); color: #FFFFFF; }
.pill-accent { background: var(--accent); color: #FFFFFF; }
.pill-soft { background: var(--accent-soft); color: var(--accent-dark); }
.done { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; flex: none; }
.icon-btn.ghost { background: var(--card); color: var(--accent); }
.actions-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.action { height: 64px; border: none; border-radius: 14px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: none; }
.action.wa { color: var(--wa); }

/* ---------- Chips, etiquetas y avisos ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-weight: 600; padding-left: 10px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 2px 7px; }
.tag.soft { background: var(--accent-soft); color: var(--accent-dark); font-size: 14px; font-weight: 500; padding: 5px 11px; border-radius: 14px; }
.warn { background: var(--warn-bg); border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.warn-title { font-size: 13px; font-weight: 600; color: var(--warn-ink); }
.warn-text { font-size: 15px; color: var(--warn-ink-2); white-space: pre-wrap; }
.warn-inline { font-size: 13px; color: var(--warn-ink); }
.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex: none; }
.avatar.lg { width: 72px; height: 72px; border-radius: 36px; font-size: 26px; }
.error { color: var(--danger); font-size: 14px; margin: 0 4px; }

/* ---------- Formularios ---------- */
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 11px; background: var(--fill); }
.search input { flex: 1; min-width: 0; border: none; background: none; font-size: 16px; outline: none; }
.field-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 52px; }
.field-row + .field-row { border-top: 1px solid var(--sep); }
.field-row > span:first-child { width: 110px; flex: none; font-size: 15px; color: var(--muted); }
.field-row input, .field-row select { flex: 1; min-width: 0; border: none; background: none; font-size: 16px; outline: none; padding: 12px 0; text-align: right; }
.textarea { width: 100%; border: none; border-radius: var(--radius); background: var(--card); padding: 14px 16px; font-size: 15px; line-height: 1.45; resize: vertical; outline: none; min-height: 110px; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--fill); border-radius: 10px; padding: 2px; }
.segmented button { border: none; background: none; height: 36px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; flex: none; transition: background 0.2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.time-input { border: none; background: var(--bg); border-radius: 8px; padding: 6px 8px; font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- Tira de la semana ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--card); border-radius: var(--radius); padding: 10px 4px; }
.day-btn { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; }
.day-btn .dow { font-size: 11px; font-weight: 600; color: var(--muted); }
.day-btn .num { width: 34px; height: 34px; border-radius: 17px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 500; }
.day-btn.today .num { color: var(--accent); font-weight: 700; }
.day-btn.sel .num { background: var(--accent); color: #FFFFFF; font-weight: 600; }
.day-btn .dot { width: 5px; height: 5px; border-radius: 3px; }
.day-btn .dot.on { background: #8E8E93; }
.day-btn.sel .dot.on { background: var(--accent); }
.week-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.week-nav strong { font-size: 15px; font-weight: 600; }

/* ---------- Calendario de mes (selector de huecos) ---------- */
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-head strong { font-size: 17px; font-weight: 600; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; }
.month-dow { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; padding-bottom: 6px; }
.month-week { display: contents; }
.mday { border: none; background: none; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 15px; font-variant-numeric: tabular-nums; border-radius: 0; }
.mday .n { width: 30px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.mday .dot { width: 4px; height: 4px; border-radius: 2px; background: transparent; }
.mday.has .dot { background: var(--accent); }
.mday.out { color: #AEAEB2; }
.mday.past, .mday.closed { color: #AEAEB2; }
.mday.today .n { font-weight: 700; color: var(--accent); }
.mday.wsel { background: var(--accent-soft); }
.mday.wsel.first { border-radius: 12px 0 0 12px; }
.mday.wsel.last { border-radius: 0 12px 12px 0; }
.slot-day + .slot-day { border-top: 1px solid var(--sep); padding-top: 14px; }
.slot-day { display: flex; flex-direction: column; gap: 8px; }
.slot-day-label { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Burbuja de mensaje ---------- */
.bubble { align-self: flex-end; width: 100%; max-width: 340px; background: #DCF3E4; border-radius: 18px 18px 4px 18px; padding: 10px 14px; font-size: 15px; line-height: 1.4; border: none; resize: vertical; min-height: 170px; outline: none; }

/* ---------- Barra de pestañas ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(249, 249, 249, 0.96); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 1px solid var(--line); }
.tabbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 0 calc(env(safe-area-inset-bottom, 0px) + 8px); }
.tab { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; min-height: 48px; }
.tab[aria-current="page"] { color: var(--accent); }

/* ---------- Hoja inferior (sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.32); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 14px 14px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 24px); display: flex; flex-direction: column; gap: 16px; }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: #C7C7CC; align-self: center; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }

/* ---------- Entrada (login) ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; padding: 0 28px calc(env(safe-area-inset-bottom, 0px) + 52px); max-width: 480px; margin: 0 auto; }
.login-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.app-icon { width: 84px; height: 84px; border-radius: 22px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.login h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.login p { margin: 0; color: var(--muted); }
.login-actions { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
#googleBtn { display: flex; justify-content: center; min-height: 44px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%) translateY(20px); background: rgba(28, 28, 30, 0.94); color: #FFFFFF; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 60; }
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { text-align: center; color: var(--muted); font-size: 15px; padding: 18px 16px; }

/* ---------- Mapa corporal ---------- */
.bm-wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bm-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bm-figure figcaption { font-size: 12px; font-weight: 600; color: var(--muted); }
.bm-svg { width: 100%; max-width: 170px; height: auto; touch-action: manipulation; }
.bm-zone { fill: #E6E6EB; stroke: #FFFFFF; stroke-width: 2; cursor: pointer; transition: fill 0.12s; }
.bm-zone:hover { fill: #D5DED9; }
.bm-zone:focus-visible { outline: none; stroke: var(--accent); stroke-width: 3; }
.bm-zone.on { fill: var(--accent); }
.bm-elegidas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; min-height: 24px; }
.bm-chip { height: 32px; font-size: 14px; padding: 0 12px; }

/* ---------- Ficha de salud ---------- */
.ficha-form { display: flex; flex-direction: column; gap: 14px; }
.ficha-section { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ficha-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.ficha-body { display: flex; flex-direction: column; gap: 18px; margin-top: 14px; }
.ficha-group { display: flex; flex-direction: column; gap: 8px; }
.ficha-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.ficha-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 10px 12px; font-size: 16px; outline: none; }
.ficha-input:focus { border-color: var(--accent); }
textarea.ficha-input { resize: vertical; line-height: 1.45; }
.ficha-op { display: flex; gap: 8px; align-items: center; }
.ficha-op .ficha-anio { width: 86px; flex: none; }
.ficha-ops { display: flex; flex-direction: column; gap: 8px; }
.ficha-details summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 4px; position: relative; padding-right: 28px; }
.ficha-details summary::-webkit-details-marker { display: none; }
.ficha-details summary::after { content: ""; position: absolute; right: 4px; top: 6px; width: 9px; height: 9px; border-right: 2.5px solid #C7C7CC; border-bottom: 2.5px solid #C7C7CC; transform: rotate(45deg); transition: transform 0.2s; }
.ficha-details[open] summary::after { transform: rotate(-135deg); top: 11px; }
.ficha-details .chip { height: 34px; font-size: 14px; }

/* ---------- Página del cliente ---------- */
.client-page { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 40px) 16px calc(env(safe-area-inset-bottom, 0px) + 40px); display: flex; flex-direction: column; gap: 18px; }
.lead { margin: 0 4px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 0 4px; cursor: pointer; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.check-row input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.estado-final { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 8px; }
.estado-icono { width: 72px; height: 72px; border-radius: 36px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.estado-final h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.estado-final p { margin: 0; color: var(--ink-2); font-size: 16px; line-height: 1.45; max-width: 360px; }
.week-mini { display: flex; align-items: center; justify-content: space-between; }
.week-mini strong { font-size: 15px; font-weight: 600; }
.ficha-abrir { margin-top: 6px; font-size: 15px; font-weight: 600; color: var(--accent); }
.ficha-details[open] .ficha-abrir { display: none; }
.ficha-details:not([open]) { border: 1.5px dashed #C7D9D0; }
.check { width: 24px; height: 24px; border-radius: 12px; border: 1.5px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; color: transparent; }
.check.on { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
