/* El Sintrom de Paco — estilos
   Colores suaves (azul claro, blanco y verde), letra grande y botones amplios. */

@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2');
}

:root {
  --bg: #F4F8FC;
  --surface: #FFFFFF;
  --ink: #1E2A38;
  --muted: #586779;
  --line: #DCE5EF;
  --blue: #3B7DD8;
  --blue-d: #2A64B5;
  --blue-50: #EEF5FD;
  --blue-100: #DCEBFB;
  --green: #2E9E6E;
  --green-d: #22805A;
  --green-50: #EAF7F0;
  --green-100: #CDEEDD;
  --amber: #9A5C00;
  --amber-dot: #D98A00;
  --amber-50: #FFF6E6;
  --amber-100: #FBE3B8;
  --red: #B9382A;
  --red-50: #FDEEEB;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(30, 42, 56, .05), 0 4px 16px rgba(30, 42, 56, .06);
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tap: 52px;
  --bottomnav-h: 74px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .5rem; }
a { color: var(--blue-d); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

.ic { width: 1.25em; height: 1.25em; flex: none; }
.ic-ok { color: var(--green); }
.ic-pend { color: var(--blue); }
.ic-flask { color: #7A5CC8; }
.ic-note { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; display: flex; justify-content: center; }
.mt { margin-top: .75rem; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

.boot, .loading { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 60px 16px; color: var(--muted); font-size: 1.1rem; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--blue-100); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { padding: 24px; text-align: center; }

/* ---------- Estructura ---------- */
.layout { min-height: 100vh; }
.sidebar { display: none; }
.main { min-width: 0; padding-bottom: calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.logo-mark { width: 44px; height: 44px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: .78rem; color: var(--green-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { max-width: 1120px; margin: 0 auto; padding: 20px 16px; outline: none; }
.app-foot { max-width: 1120px; margin: 0 auto; padding: 8px 16px 24px; color: var(--muted); font-size: .8rem; text-align: center; }

.bell { position: relative; }
.bell-count {
  position: absolute; top: 4px; right: 4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--amber-dot); color: #fff; font-size: .72rem; font-weight: 700;
  display: grid; place-items: center;
}

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(30, 42, 56, .06);
}
.bn-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--bottomnav-h); padding: 6px 2px; text-decoration: none; color: var(--muted);
  font-size: clamp(.66rem, 2.9vw, .8rem); font-weight: 700; letter-spacing: -.01em;
}
.bn-link .ic { width: 28px; height: 28px; }
.bn-link.active { color: var(--blue-d); background: var(--blue-50); box-shadow: inset 0 3px 0 var(--blue); }

@media (min-width: 1000px) {
  .layout { display: grid; grid-template-columns: 290px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 22px 16px; background: var(--surface); border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: 4px 8px 20px; }
  .sidebar .logo-mark { width: 54px; height: 54px; }
  .sidebar .brand-text small { white-space: normal; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .sn-link {
    display: flex; align-items: center; gap: 14px; min-height: var(--tap); padding: 10px 14px;
    border-radius: 14px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.02rem;
    border: 0; background: none; cursor: pointer; text-align: left; width: 100%;
  }
  .sn-link .ic { width: 26px; height: 26px; color: var(--blue); }
  .sn-link:hover { background: var(--blue-50); }
  .sn-link.active { background: var(--blue-100); color: var(--blue-d); }
  .side-sep { margin: 18px 14px 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
  .sn-logout { margin-top: auto; color: var(--muted); }
  .sn-logout .ic { color: var(--muted); }
  .bottomnav { display: none; }
  .main { padding-bottom: 0; }
  .topbar { justify-content: flex-end; background: transparent; border: 0; backdrop-filter: none; padding: 16px 28px 0; position: static; }
  .brand-top { display: none; }
  .content { padding: 8px 28px 28px; }
  .avisos { padding: 0 28px; }
}

/* ---------- Avisos superiores ---------- */
.avisos { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: grid; gap: 10px; }
.avisos:not(:empty) { padding-top: 14px; }
.aviso {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius); background: var(--blue-50); border: 1px solid var(--blue-100);
}
.aviso-toma { background: var(--green-50); border-color: var(--green-100); }
.aviso-analitica { background: #F3EFFC; border-color: #E2D9F7; }
.aviso-ic { width: 46px; height: 46px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--blue); flex: none; }
.aviso-toma .aviso-ic { color: var(--green); }
.aviso-analitica .aviso-ic { color: #7A5CC8; }
.aviso-ic .ic { width: 26px; height: 26px; }
.aviso-txt { flex: 1 1 200px; display: flex; flex-direction: column; }
.aviso-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Encabezados ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.page-head h1 { display: flex; align-items: center; gap: 12px; }
.page-head h1 .ic { color: var(--blue); width: 32px; height: 32px; }
.page-sub { color: var(--muted); margin: 6px 0 0; font-size: 1.05rem; }
.eyebrow { color: var(--green-d); font-weight: 700; margin-bottom: 4px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 28px 0 12px; }
.section-title .ic { color: var(--blue); }
.count-line { color: var(--muted); font-weight: 700; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; border: 1px solid #E8EEF5; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-title { display: flex; align-items: center; gap: 10px; }
.card-title { margin-bottom: 14px; }
.card-head h2 .ic, .card-title .ic { color: var(--blue); }

.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin-bottom: 18px; }
.dash-grid .card { margin: 0; }
.kpi-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border-top: 5px solid var(--blue-100); }
.card-label { display: flex; align-items: center; gap: 8px; font-size: 1rem; color: var(--muted); font-weight: 700; }
.card-label .ic { color: var(--blue); }
.kpi-big { font-size: 3.2rem; font-weight: 700; line-height: 1; margin: 4px 0; letter-spacing: -.02em; }
.kpi-mid { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin: 2px 0; }
.kpi-meta { color: var(--muted); margin: 0; }
.kpi-empty { color: var(--muted); font-size: 1.05rem; }
.kpi-inr { background: linear-gradient(180deg, var(--blue-50), var(--surface) 60%); }
.st-dentro { border-top-color: var(--green); }
.st-dentro .kpi-big { color: var(--green-d); }
.st-alto, .st-bajo { border-top-color: var(--amber-dot); }
.st-alto .kpi-big, .st-bajo .kpi-big { color: var(--amber); }

.pauta-mini, .pauta-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; width: 100%; }
.pm-day, .pw-day { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 10px; background: var(--bg); font-size: .82rem; }
.pm-day span, .pw-day span { color: var(--muted); }
.pm-day strong, .pw-day strong { font-size: .95rem; }
.pm-day.today { background: var(--green-100); }
.pauta-week { margin-bottom: 8px; }
.pw-day strong { font-size: 1.1rem; }
.pauta-week.small .pw-day strong { font-size: .95rem; }

.home-head h1 { font-size: 1.9rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 12px 22px; border-radius: 14px; border: 2px solid transparent;
  font-weight: 700; font-size: 1.02rem; text-decoration: none; cursor: pointer; line-height: 1.2;
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 3px 10px rgba(46, 158, 110, .28); }
.btn-primary:hover { background: var(--green-d); }
.btn-secondary { background: var(--blue-50); color: var(--blue-d); border-color: var(--blue-100); }
.btn-secondary:hover { background: var(--blue-100); }
.btn-ghost { background: transparent; color: var(--blue-d); }
.btn-ghost:hover { background: var(--blue-50); }
.btn-ghost-danger { color: var(--red); }
.btn-ghost-danger:hover { background: var(--red-50); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #9E2F23; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: .95rem; }
.btn-lg { min-height: 58px; padding: 14px 26px; font-size: 1.08rem; }
.btn-xl { min-height: 64px; padding: 16px 28px; font-size: 1.15rem; letter-spacing: .02em; border-radius: 16px; }
.btn-xl .ic { width: 28px; height: 28px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--blue-50); }
.icon-btn .ic { width: 26px; height: 26px; }
.icon-btn-lg { width: 56px; height: 56px; background: var(--blue-50); color: var(--blue-d); }
.link-btn { background: none; border: 0; color: var(--blue-d); text-decoration: underline; cursor: pointer; padding: 12px 0 0; font-size: 1rem; }

@media (max-width: 640px) {
  .page-head .btn-xl, .page-head .btn-lg { width: 100%; }
}

/* ---------- Distintivos y avisos ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .88rem; font-weight: 700; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge .ic { width: 1em; height: 1em; }
.badge-dentro { background: var(--green-50); color: var(--green-d); }
.badge-alto, .badge-bajo { background: var(--amber-50); color: var(--amber); }
.badge-info { background: var(--blue-50); color: var(--blue-d); }
.badge-pend { background: var(--blue-50); color: var(--blue-d); }
.badge-muted { background: var(--bg); color: var(--muted); }

.notice { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); margin-bottom: 16px; }
.notice > .ic { width: 28px; height: 28px; margin-top: 1px; }
.notice .btn { margin-top: 8px; margin-left: 4px; }
.notice-info { background: var(--blue-50); border: 1px solid var(--blue-100); }
.notice-info > .ic { color: var(--blue); }
.notice-warn { background: var(--amber-50); border: 1px solid var(--amber-100); }
.notice-warn > .ic { color: var(--amber-dot); }

.empty { text-align: center; padding: 40px 20px; background: var(--surface); border-radius: var(--radius); border: 2px dashed var(--line); }
.empty .ic { width: 56px; height: 56px; color: var(--blue); margin: 0 auto 12px; opacity: .8; }
.empty p { color: var(--muted); max-width: 440px; margin: 8px auto 0; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: .9rem; margin: 12px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ic { width: 18px; height: 18px; }
.lg { display: inline-block; width: 16px; height: 16px; border-radius: 5px; }
.lg-realizada { background: var(--green-100); border: 2px solid var(--green); }
.lg-pendiente { background: var(--blue-50); border: 2px solid var(--blue); }
.lg-pauta { background: var(--surface); border: 2px dashed #A9BACB; }
.lg-band { background: rgba(46, 158, 110, .18); border: 1.5px dashed var(--green); }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.dot-ok { background: var(--green); }
.dot-out { background: var(--amber-dot); }

/* ---------- Semana (inicio) ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.ws-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; min-width: 0;
}
.ws-day:hover { border-color: var(--blue); }
.ws-wd { font-size: .78rem; color: var(--muted); font-weight: 700; }
.ws-num { font-size: 1.25rem; font-weight: 700; }
.ws-dose { font-size: .82rem; font-weight: 700; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-st { display: flex; gap: 2px; min-height: 20px; }
.ws-st .ic { width: 18px; height: 18px; }
.ws-realizada { background: var(--green-50); border-color: var(--green-100); }
.ws-realizada .ws-st { color: var(--green); }
.ws-pendiente { background: var(--blue-50); border-color: var(--blue-100); }
.ws-pendiente .ws-st { color: var(--blue); }
.ws-pauta { border-style: dashed; }
.ws-pauta .ws-dose { color: var(--muted); }
.ws-day.today { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-100); }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.quick {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 18px 10px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); font-weight: 700; border: 1px solid #E8EEF5; min-height: 104px;
}
.quick .ic { width: 34px; height: 34px; color: var(--blue); }
.quick:hover { background: var(--blue-50); }

/* ---------- Lista de INR ---------- */
.inr-list, .rec-list, .note-list, .plain-list, .event-list, .tl-list { list-style: none; padding: 0; margin: 0; }
.inr-item { display: grid; grid-template-columns: auto 1fr; gap: 16px 18px; align-items: start; }
.inr-value {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 92px; height: 92px; border-radius: 20px; background: var(--blue-50); color: var(--blue-d);
}
.inr-value.st-dentro { background: var(--green-50); color: var(--green-d); }
.inr-value.st-alto, .inr-value.st-bajo { background: var(--amber-50); color: var(--amber); }
.inr-num { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.inr-lbl { font-size: .8rem; font-weight: 700; opacity: .8; }
.inr-date { font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
.inr-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 16px; margin: 10px 0 0; }
.inr-meta dt { font-size: .82rem; color: var(--muted); }
.inr-meta dd { margin: 0; font-weight: 700; }
.inr-obs { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--bg); white-space: pre-wrap; }
.item-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }

/* ---------- Calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cal-title { font-size: 1.45rem; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-top: 10px; }
.cal-wd { text-align: center; font-weight: 700; color: var(--muted); font-size: .85rem; padding: 4px 0; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-height: 82px; padding: 6px 2px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); cursor: pointer; min-width: 0; text-align: center;
}
.cal-cell:hover { border-color: var(--blue); }
.cal-out { border: 0; background: transparent; cursor: default; }
.cal-num { font-weight: 700; font-size: 1.05rem; }
.cal-dose { font-size: .8rem; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.2em; }
.cal-icons { display: flex; gap: 2px; min-height: 18px; }
.cal-icons .ic { width: 17px; height: 17px; }
.cal-inr { font-size: .66rem; font-weight: 700; color: var(--blue-d); background: var(--blue-50); border-radius: 6px; padding: 0 4px; white-space: nowrap; }
.cal-realizada { background: var(--green-50); border-color: var(--green-100); }
.cal-pendiente { background: var(--blue-50); border-color: var(--blue-100); }
.cal-pauta { border-style: dashed; }
.cal-pauta .cal-dose { color: var(--muted); font-weight: 400; }
.cal-past.cal-pendiente { border-color: #9DBDE6; }
.cal-today { box-shadow: 0 0 0 3px var(--blue); border-color: var(--blue); }
.cal-today .cal-num { color: var(--blue-d); }
@media (min-width: 700px) {
  .cal-cell { min-height: 96px; }
  .cal-dose { font-size: .95rem; }
  .cal-inr { font-size: .75rem; }
}
.pauta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.pauta-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.day-title { font-size: 1.15rem; font-weight: 700; color: var(--blue-d); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .98rem; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 700; background: var(--bg); }
.row-click { cursor: pointer; }
.row-click:hover { background: var(--blue-50); }

/* ---------- Evolución ---------- */
.chart-box { position: relative; height: 340px; }
@media (min-width: 900px) { .chart-box { height: 400px; } }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid #E8EEF5; box-shadow: var(--shadow); }
.card .stat { box-shadow: none; background: var(--bg); border: 0; }
.stat-label { color: var(--muted); font-size: .88rem; font-weight: 700; }
.stat-value { font-size: 1.7rem; font-weight: 700; }
.stat-trend { display: flex; align-items: center; gap: 6px; font-size: 1.35rem; }
.stat-sub { color: var(--muted); font-size: .8rem; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.month-card { padding: 16px; border-radius: 16px; background: var(--bg); }
.month-card h3 { margin-bottom: 8px; color: var(--blue-d); }
.mc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin: 0 0 10px; }
.mc-list dt { font-size: .8rem; color: var(--muted); }
.mc-list dd { margin: 0; font-size: 1.2rem; font-weight: 700; }
.inr-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.details { margin-top: 16px; }
.details summary { cursor: pointer; font-weight: 700; color: var(--blue-d); padding: 10px 0; min-height: 44px; }

/* ---------- Segmentos y filtros ---------- */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--blue-50); border-radius: 14px; margin-bottom: 16px; }
.seg-full { display: flex; width: 100%; }
.seg-full .seg-btn { flex: 1; }
.seg-scroll { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; max-width: 640px; }
.seg-scroll .seg-btn { padding: 8px 4px; font-size: clamp(.82rem, 3.6vw, 1rem); }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 18px;
  border-radius: 11px; border: 0; background: transparent; font-weight: 700; color: var(--blue-d);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(30, 42, 56, .12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; color: var(--muted);
}
.chip .ic { width: 18px; height: 18px; }
.chip.active { border-color: var(--blue); background: var(--blue-50); color: var(--blue-d); }

/* ---------- Historial ---------- */
.two-col { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.sub-title { font-size: 1rem; color: var(--muted); margin-bottom: 8px; }
.event-list li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.event-list li > .ic { width: 24px; height: 24px; color: #7A5CC8; margin-top: 2px; }
.event-list li > .ic-ok { color: var(--green); }
.timeline { margin-top: 8px; }
.tl-month { font-size: 1.15rem; margin: 22px 0 10px; color: var(--blue-d); }
.tl-list { position: relative; padding-left: 8px; }
.tl-list::before { content: ''; position: absolute; left: 30px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-item { position: relative; display: flex; gap: 16px; padding: 8px 0; }
.tl-dot { position: relative; z-index: 1; width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); color: var(--blue); }
.tl-dot .ic { width: 22px; height: 22px; }
.tl-inr .tl-dot { border-color: var(--blue); }
.tl-pauta .tl-dot { border-color: var(--green); color: var(--green); }
.tl-toma .tl-dot { color: var(--green-d); }
.tl-evento .tl-dot { color: #7A5CC8; border-color: #D8CDF3; }
.tl-nota .tl-dot { color: var(--muted); }
.tl-body { flex: 1; min-width: 0; background: var(--surface); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); border: 1px solid #E8EEF5; }
.tl-future .tl-body { border: 2px dashed #D8CDF3; }
.tl-date { color: var(--muted); font-size: .88rem; margin-bottom: 2px; }
.tl-title { font-weight: 700; font-size: 1.08rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-detail { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- Recordatorios ---------- */
.rec-item { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.rec-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.rec-ic .ic { width: 28px; height: 28px; }
.rec-toma { background: var(--green-50); color: var(--green); }
.rec-analitica { background: #F3EFFC; color: #7A5CC8; }
.rec-title { font-weight: 700; font-size: 1.1rem; margin: 0; }
.rec-when { margin: 2px 0; }
.rec-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.rec-off { opacity: .65; }
.rec-past .rec-when { color: var(--muted); }
.notif-card p { display: flex; gap: 8px; align-items: flex-start; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 48px; font-weight: 700; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; width: 58px; height: 32px; border-radius: 16px; background: #C5D1DE; transition: background .15s; flex: none; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--green); }
.switch input:checked + .switch-ui::after { transform: translateX(26px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Diario ---------- */
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.note-date { font-weight: 700; margin: 0; }
.note-text { white-space: pre-wrap; word-break: break-word; font-size: 1.05rem; }
.note .item-actions { margin-top: 10px; }

/* ---------- Formularios ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 700; font-size: 1rem; }
.req { color: var(--red); }
.field-hint { color: var(--muted); font-size: .88rem; }
.field-error { display: flex; align-items: center; gap: 6px; color: var(--red); font-weight: 700; font-size: .92rem; }
.input {
  width: 100%; min-height: var(--tap); padding: 12px 14px; border-radius: 12px;
  border: 2px solid #C9D6E3; background: var(--surface); font-size: 1.05rem;
}
textarea.input { resize: vertical; min-height: 90px; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-100); }
.input[aria-invalid='true'] { border-color: var(--red); background: var(--red-50); }
.field-big .input { font-size: 1.5rem; font-weight: 700; }
.fieldset { border: 2px solid var(--line); border-radius: 14px; padding: 12px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.fieldset legend { font-weight: 700; padding: 0 6px; color: var(--blue-d); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.form-error { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--red-50); color: var(--red); font-weight: 700; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 1rem; }
.check input { width: 26px; height: 26px; flex: none; margin: 1px 0 0; accent-color: var(--green); }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 56px; }
.pass-wrap .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pass-wrap .icon-btn.on { color: var(--blue); }
.choice-row, .choice-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; padding: 10px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; text-align: center;
}
.choice input:checked + span { border-color: var(--blue); background: var(--blue-50); color: var(--blue-d); }
.choice-ok input:checked + span { border-color: var(--green); background: var(--green-50); color: var(--green-d); }
.choice input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Ventanas ---------- */
.modal { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100%; }
.modal::backdrop { background: rgba(20, 32, 48, .45); }
.modal-card { background: var(--surface); width: min(640px, 100%); margin: 0 auto; border-radius: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-sm .modal-card { width: min(480px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 8px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.3rem; }
.modal-body { padding: 18px 22px 22px; overflow-y: auto; }
.confirm-text { font-size: 1.08rem; }
@media (max-width: 640px) {
  .modal { margin: 0; height: 100%; max-height: 100%; }
  .modal-card { border-radius: 0; min-height: 100%; max-height: 100%; width: 100%; }
  .modal-sm .modal-card { width: 100%; }
  .form-actions .btn { flex: 1 1 140px; }
}

/* ---------- Mensajes flotantes ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 32px)); pointer-events: none; }
@media (min-width: 1000px) { #toasts { bottom: 24px; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 14px; background: #1E2A38; color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: toast-in .2s ease-out; transition: opacity .4s, transform .4s; }
.toast .ic { color: #7FD8AE; }
.toast-error .ic { color: #FFB4A6; }
.toast-warn .ic { color: #FFD38A; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Acceso ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--blue-100), transparent), radial-gradient(800px 400px at 100% 100%, var(--green-50), transparent), var(--bg); }
.auth-hero { text-align: center; margin-bottom: 22px; }
.auth-logo .logo-mark { width: 92px; height: 92px; margin: 0 auto 14px; filter: drop-shadow(0 8px 18px rgba(59, 125, 216, .3)); }
.auth-hero h1 { font-size: 2.1rem; }
.auth-sub { color: var(--green-d); font-weight: 700; font-size: 1.15rem; margin-top: 6px; }
.auth-card { width: min(520px, 100%); padding: 24px; }
.auth-title { margin-bottom: 4px; }
.auth-foot { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; color: var(--muted); margin-top: 18px; font-size: .92rem; text-align: center; }
.auth-foot .ic { color: var(--green); }
.recovery-code { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: .08em; text-align: center; padding: 16px; border-radius: 14px; background: var(--green-50); border: 2px dashed var(--green); color: var(--green-d); margin: 12px 0; word-break: break-all; }

@media print {
  .sidebar, .bottomnav, .topbar, .avisos, .app-foot { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Página de privacidad ---------- */
.legal { max-width: 820px; }
.legal .brand { margin: 8px 0 18px; }
.legal h2 { margin: 22px 0 8px; font-size: 1.15rem; color: var(--blue-d); }
.legal ul { padding-left: 1.2rem; }
.legal li { margin-bottom: 6px; }

/* ---------- Firma ---------- */
.credit { display: block; margin-top: 10px; font-size: .74rem; font-style: italic; color: #8796A6; text-align: center; letter-spacing: .02em; }
