:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #25231f; --muted: #6f6a60; --line: #e6e1d6; --soft: #efece4;
  --brand: #0d9488; --brand-ink: #0b6b63; --brand-soft: #d9f2ee; --on-brand: #ffffff;
  --coral: #f2673f; --ok: #15803d; --ok-soft: #dcf5e3; --warn: #b45309; --warn-soft: #fdecc8;
  --bad: #b91c1c; --bad-soft: #fde2e2; --snooze: #5b4bc4; --snooze-soft: #e7e3fb;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 6px 20px rgba(40, 30, 10, .06);
  --r: 16px; --nav-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a19; --card: #1d2524; --ink: #ecefee; --muted: #9aa5a3; --line: #2c3736; --soft: #232c2b;
    --brand: #2dd4bf; --brand-ink: #5eead4; --brand-soft: #143d39; --on-brand: #06302c;
    --coral: #ff8a65; --ok: #4ade80; --ok-soft: #14351f; --warn: #fbbf24; --warn-soft: #3d2f0c;
    --bad: #f87171; --bad-soft: #3f1a1a; --snooze: #a5b4fc; --snooze-soft: #25254a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100dvh; font-size: 28px; font-weight: 800; color: var(--brand); }

/* estructura */
.wrap { max-width: 600px; margin: 0 auto; padding: 0 16px; }
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); padding-top: env(safe-area-inset-top); border-bottom: 1px solid transparent; }
.top .bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 6px; }
.top h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.top h1 small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.me-btn { font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
main.wrap { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px); min-height: 70dvh; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav .wrap { display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav-h); padding: 0 4px; }
.nav button { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); }
.nav button .ic { font-size: 21px; line-height: 1; filter: grayscale(1) opacity(.7); }
.nav button.on { color: var(--brand-ink); }
.nav button.on .ic { filter: none; }

/* chips de perfil */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px 12px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; background: var(--card); border: 1.5px solid var(--line); font-weight: 700; font-size: 14px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.chip.add { border-style: dashed; color: var(--muted); }

/* tarjetas y texto */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.sec { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 4px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.empty { text-align: center; padding: 36px 20px; }
.empty .big { font-size: 46px; line-height: 1; margin-bottom: 10px; }
.empty h2 { font-size: 19px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 18px; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 800; background: var(--brand); color: var(--on-brand); width: 100%; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; width: auto; border-radius: 11px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.link { color: var(--brand-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.fab { position: fixed; right: max(16px, calc(50vw - 284px)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 4; width: auto; box-shadow: 0 8px 24px rgba(13, 148, 136, .35); border-radius: 99px; }

/* formularios */
label.f { display: block; margin-bottom: 14px; }
label.f > span, .flabel { display: block; font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.in, select.in, textarea.in { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); outline: none; appearance: none; -webkit-appearance: none; }
textarea.in { min-height: 76px; resize: vertical; }
.in:focus { border-color: var(--brand); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 9px 14px; border-radius: 11px; background: var(--soft); font-weight: 700; font-size: 14px; border: 1.5px solid transparent; }
.seg button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.seg.emoji button { font-size: 24px; padding: 6px 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--ink); }
.timerow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.timerow .in { flex: 1; }
.timerow label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.x { width: 40px; height: 40px; border-radius: 10px; background: var(--soft); font-size: 18px; color: var(--muted); flex: none; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }

/* hoy */
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.daynav button.arrow { width: 44px; height: 44px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; font-weight: 800; }
.daynav .d { text-align: center; }
.daynav .d b { display: block; font-size: 18px; text-transform: capitalize; }
.daynav .d button { font-size: 12px; font-weight: 800; color: var(--brand-ink); }
.progress { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.next { background: linear-gradient(135deg, var(--brand), #0f766e); color: #fff; }
.next .lbl { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; opacity: .85; }
.next .when { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.slot { margin-bottom: 14px; }
.slot > .t { font-size: 15px; font-weight: 800; margin: 0 4px 6px; display: flex; align-items: baseline; gap: 8px; }
.slot > .t small { font-size: 12px; font-weight: 700; color: var(--muted); }
.dose { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 10px 8px 10px 12px; margin-bottom: 6px; box-shadow: var(--shadow); border-left: 5px solid var(--pc, var(--line)); }
.dose .main { flex: 1; min-width: 0; text-align: left; display: flex; align-items: center; gap: 12px; min-height: 44px; }
.dose .bx { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2.5px solid var(--line); display: grid; place-items: center; font-size: 16px; font-weight: 900; color: transparent; transition: .15s; }
.dose .tx { min-width: 0; }
.dose .tx b { display: block; font-size: 15.5px; line-height: 1.25; }
.dose .tx span { display: block; font-size: 13px; color: var(--muted); }
.dose .tx .tag { display: inline-block; font-size: 11px; margin-top: 2px; }
.dose .more { width: 40px; height: 44px; font-size: 22px; color: var(--muted); flex: none; border-radius: 10px; }
.dose.taken .bx { background: var(--ok); border-color: var(--ok); color: #fff; }
.dose.taken .tx b { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.dose.skipped .bx { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.dose.missed .bx { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.dose.snoozed .bx { border-color: var(--snooze); color: var(--snooze); background: var(--snooze-soft); }
.dose.due .bx { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.dose.wait .bx { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.dose.opt { opacity: .75; }
.tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; margin-right: 4px; vertical-align: 1px; }
.tag.ok, .dose .tx .tag.ok { color: var(--ok); }
.tag.warn, .dose .tx .tag.warn { color: var(--warn); }
.tag.bad, .dose .tx .tag.bad { color: var(--bad); }
.tag.snz, .dose .tx .tag.snz { color: var(--snooze); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.snz { background: var(--snooze-soft); color: var(--snooze); }
.tag.neutral { background: var(--soft); color: var(--muted); }

/* tratamientos */
.tcard { border-left: 5px solid var(--pc, var(--line)); text-align: left; width: 100%; display: block; }
.tcard h3 { font-size: 16.5px; }
.tcard .times { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tcard .times span { font-size: 13px; font-weight: 800; background: var(--soft); border-radius: 8px; padding: 3px 8px; }
.phead { display: flex; align-items: center; gap: 10px; margin: 22px 4px 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; background: var(--pc, var(--soft)); flex: none; }
.phead b { font-size: 17px; }

/* informe */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 6px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: 11px; font-weight: 700; color: var(--muted); }
.stat.ok b { color: var(--ok); } .stat.warn b { color: var(--warn); } .stat.bad b { color: var(--bad); }
.meter { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--soft); margin: 8px 0 4px; }
.meter i { display: block; height: 100%; }
.meter .a { background: var(--ok); } .meter .b { background: #f59e0b; } .meter .c { background: var(--bad); }
.inc { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.inc:first-child { border-top: 0; }
.inc .w { flex: none; width: 92px; color: var(--muted); font-weight: 700; font-size: 13px; }

/* ajustes */
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 24px; font-weight: 800; letter-spacing: .06em; text-align: center; padding: 16px 8px; background: var(--brand-soft); color: var(--brand-ink); border-radius: 14px; margin: 10px 0; user-select: all; -webkit-user-select: all; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; padding-top: 0; }
.li:last-child { padding-bottom: 0; }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; background: var(--warn-soft); color: var(--ink); margin-bottom: 12px; }
.notice.info { background: var(--brand-soft); }
.steps { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.steps li { margin-bottom: 4px; }

/* bienvenida */
.welcome { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding-top: 32px; padding-bottom: 32px; }
.welcome .logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.welcome h1 { font-size: 36px; font-weight: 800; letter-spacing: -.03em; }
.welcome .lead { color: var(--muted); font-size: 17px; margin: 6px 0 28px; }
.welcome .btn { margin-bottom: 10px; }
.back { font-weight: 800; color: var(--brand-ink); margin-bottom: 18px; align-self: flex-start; min-height: 44px; }

/* hoja inferior */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(10, 15, 14, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 600px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .2s; overscroll-behavior: contain; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 12px; }
.sheet .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet .head h2 { font-size: 20px; letter-spacing: -.01em; }
.sheet .acts { display: grid; gap: 8px; }
.sheet .acts .btn { justify-content: flex-start; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 20px); z-index: 40; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }
.offline { background: var(--bad-soft); color: var(--bad); font-weight: 700; font-size: 13px; text-align: center; padding: 8px 12px; border-radius: 10px; margin-bottom: 10px; }

/* impresión del informe */
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #000; --muted: #444; --line: #ccc; --soft: #eee; --shadow: none; }
  .top, .nav, .fab, .no-print, #toast, #sheet-root { display: none !important; }
  .print-only { display: block; }
  main.wrap, main.wrap.has-fab { padding: 0 !important; }
  .card, .stat { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
  body { font-size: 12pt; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* retoques */
a.btn { text-decoration: none; }
.li .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 8px; }

/* espacio para que el botón flotante y la barra inferior nunca tapen el final de la lista */
main.wrap.has-fab { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 104px); }
.addrow { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border-radius: var(--r); border: 2px dashed var(--line); color: var(--brand-ink); font-weight: 800; margin-bottom: 12px; }

/* calendario día a día del informe */
.dgrid { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 8px; }
.dgrid i { width: 19px; height: 19px; border-radius: 5px; display: grid; place-items: center; font-style: normal; font-size: 9px; font-weight: 800; color: #fff; }
.dgrid i.ok, .legend i.ok { background: var(--ok); } .dgrid i.warn, .legend i.warn { background: #f59e0b; } .dgrid i.bad, .legend i.bad { background: var(--bad); }
.dgrid i.none, .legend i.none { background: var(--soft); color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin: -2px 4px 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* cartilla */
.ccard { display: flex; align-items: center; gap: 12px; border-left: 5px solid var(--pc, var(--line)); }
.ccard .cmain { flex: 1; min-width: 0; text-align: left; }
.ccard h3 { font-size: 16px; }
.notice.row { display: flex; align-items: center; }

.tag.fire, .dose .tx .tag.fire { background: #ffedd5; color: #c2410c; }
@media (prefers-color-scheme: dark) { .tag.fire, .dose .tx .tag.fire { background: #43200c; color: #fdba74; } }
