/* ------------------------------------------------------------------
   Vitalia — sistema visual
   Paleta: petróleo, salvia y blanco cálido.
   ------------------------------------------------------------------ */

:root {
  --bg: #F6F3EC;
  --bg-soft: #EFEAE0;
  --surface: #FFFFFF;
  --surface-2: #FAF7F1;
  --ink: #16302E;
  --ink-2: #3F5B57;
  --muted: #6E8581;
  --line: #E3DCD0;
  --line-strong: #CFC7B8;
  --primary: #0F4C5C;
  --primary-2: #14657A;
  --primary-ink: #F7F4EA;
  --sage: #7FA99B;
  --sage-soft: #DCE8E2;
  --high: #B4472F;
  --high-bg: #F7E4DE;
  --low: #3E6CA6;
  --low-bg: #E3EAF6;
  --warn: #A3742A;
  --warn-bg: #F6EBD6;
  --ok: #2F7A63;
  --ok-bg: #E0EEE8;
  --shadow-sm: 0 1px 2px rgba(22, 48, 46, .05);
  --shadow: 0 2px 6px rgba(22, 48, 46, .05), 0 14px 34px rgba(22, 48, 46, .07);
  --radius: 20px;
  --radius-sm: 13px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ease: cubic-bezier(.22, .8, .28, 1);
}

[data-theme="dark"] {
  --bg: #0B1617;
  --bg-soft: #0F1D1E;
  --surface: #132426;
  --surface-2: #182B2D;
  --ink: #E9F0ED;
  --ink-2: #C3D3CE;
  --muted: #8AA39E;
  --line: #24393B;
  --line-strong: #335052;
  --primary: #7FC5B6;
  --primary-2: #9BD8CA;
  --primary-ink: #08211F;
  --sage: #6FA294;
  --sage-soft: #1D3733;
  --high: #E58A70;
  --high-bg: #3A2019;
  --low: #8FB0E0;
  --low-bg: #1B2838;
  --warn: #DDB173;
  --warn-bg: #33280F;
  --ok: #6FC4A6;
  --ok-bg: #143229;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 8px rgba(0, 0, 0, .28), 0 18px 40px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; display: block; }

.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------ Shell ------------------------------ */

#shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#view {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 18px 112px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 10px;
  background: var(--bg);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), background .15s;
  flex: none;
}
.icon-btn:active { transform: scale(.93); }
.icon-btn.plain { background: transparent; box-shadow: none; }
.icon-btn svg { width: 20px; height: 20px; }

.person-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  max-width: 62%;
  flex: none;
}
.person-chip .avatar { width: 32px; height: 32px; font-size: 12px; }
.person-chip span {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #FDFBF5;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .3px;
  flex: none;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(22, 48, 46, .04);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1px;
  transition: color .15s;
}
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--primary); }

/* ------------------------------ Tipografía ------------------------- */

.h1 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.5px;
  line-height: 1.15;
  margin: 6px 0 4px;
}
.h2 {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.2px;
}
.sub { color: var(--muted); font-size: 14px; line-height: 1.45; }
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 2px 12px;
}
.section-title h2 { font-family: var(--display); font-size: 20px; font-weight: 600; }
.section-title .link { font-size: 13px; font-weight: 600; color: var(--primary); }

/* ------------------------------ Tarjetas --------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.pad-sm { padding: 14px; }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 22px 22px 20px;
  color: #F8F5EC;
  background: linear-gradient(150deg, #0F4C5C 0%, #14657A 58%, #1B7488 100%);
  box-shadow: 0 18px 40px rgba(15, 76, 92, .22);
}
.hero .eyebrow { color: rgba(248, 245, 236, .72); }
.hero-date {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.3px;
  margin: 6px 0 2px;
}
.hero-lab { font-size: 13.5px; color: rgba(248, 245, 236, .75); }
.hero-stats {
  display: flex;
  gap: 28px;
  margin: 18px 0 16px;
}
.hero-stats strong {
  display: block;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
}
.hero-stats span {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  letter-spacing: .3px;
  color: rgba(248, 245, 236, .72);
}
.hero-actions { display: flex; gap: 10px; }
.hero-wave {
  position: absolute;
  right: -30px;
  bottom: -10px;
  width: 210px;
  opacity: .16;
  pointer-events: none;
}

/* ------------------------------ Botones ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .1px;
  transition: transform .14s var(--ease), opacity .14s, background .14s;
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-light { background: rgba(248, 245, 236, .16); color: #F8F5EC; border: 1px solid rgba(248, 245, 236, .22); }
.btn-soft { background: var(--bg-soft); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--high-bg); color: var(--high); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 11px; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 78px);
  z-index: 28;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 12px 26px rgba(15, 76, 92, .3);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }

/* ------------------------------ Formularios ------------------------ */

.field { margin-bottom: 14px; }
.field label,
.label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .7; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E8581' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 48px;
  height: 29px;
  border-radius: 99px;
  background: var(--line-strong);
  transition: background .18s;
  flex: none;
}
.switch .track::after {
  content: "";
  display: block;
  width: 23px;
  height: 23px;
  margin: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease);
}
.switch input:checked + .track { background: var(--sage); }
.switch input:checked + .track::after { transform: translateX(19px); }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--bg-soft);
}
.seg button {
  min-height: 38px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ------------------------------ Chips ------------------------------ */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}
.chip.ghost { background: transparent; }

/* ------------------------------ Listas ----------------------------- */

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-size: 15px; font-weight: 650; }
.list-item .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.list-item .chev { color: var(--line-strong); flex: none; }

.study-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.study-date {
  width: 50px;
  flex: none;
  text-align: center;
  padding: 7px 0;
  border-radius: 12px;
  background: var(--bg-soft);
}
.study-date strong {
  display: block;
  font-family: var(--display);
  font-size: 21px;
  line-height: 1;
  font-weight: 600;
}
.study-date span { display: block; font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.study-info { flex: 1; min-width: 0; }
.study-info .lab { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-info .det { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.person-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 14px;
}
.person-card .person-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  text-align: left;
}
.person-card .title {
  display: block;
  font-size: 15.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-card .meta {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-card .icon-btn { width: 36px; height: 36px; }

.year-label {
  margin: 24px 2px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------ Valores ---------------------------- */

.value-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: baseline;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.value-row:last-child { border-bottom: 0; }
.value-name { font-size: 14.5px; font-weight: 600; }
.value-ref { font-size: 11.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.value-num {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.1;
}
.value-num small { font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.value-num.high { color: var(--high); }
.value-num.low { color: var(--low); }
.value-num.altered { color: var(--warn); }

.bar-wrap { grid-column: 1 / -1; margin-top: 7px; }
.vbar {
  position: relative;
  height: 5px;
  border-radius: 99px;
  background: var(--bg-soft);
}
.vbar-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 99px;
  background: var(--sage);
  opacity: .38;
}
.vbar-dot {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--surface);
}
.vbar-dot.high { background: var(--high); }
.vbar-dot.low { background: var(--low); }
.vbar-dot.altered { background: var(--warn); }

.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  vertical-align: middle;
}
.flag.high { background: var(--high-bg); color: var(--high); }
.flag.low { background: var(--low-bg); color: var(--low); }
.flag.altered { background: var(--warn-bg); color: var(--warn); }
.flag.ok { background: var(--ok-bg); color: var(--ok); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 2px 4px;
}
.panel-head h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------ Editor ----------------------------- */

.entry {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 2px 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.entry-name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.entry-ref { font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.entry-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  text-align: right;
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.entry-input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
.entry-input.high { border-color: var(--high); color: var(--high); }
.entry-input.low { border-color: var(--low); color: var(--low); }
.entry-range {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 0 2px;
}
.entry-range .input { min-height: 38px; padding: 8px 10px; font-size: 13px; }
.entry-range .hint { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.entry.custom .entry-name { color: var(--primary); }

/* ------------------------------ Gráficos --------------------------- */

.chart-card { padding: 16px 12px 10px; }
.chart-wrap { position: relative; height: 240px; margin-top: 8px; }
.chart-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding: 0 4px 6px;
}
.chart-stat { text-align: center; }
.chart-stat strong {
  display: block;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chart-stat span { font-size: 10.5px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }

.trend-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.trend-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.trend-table td { padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.trend-table td:last-child, .trend-table th:last-child { text-align: right; }
.trend-table tr:last-child td { border-bottom: 0; }

/* ------------------------------ Adjuntos --------------------------- */

.attach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-top: 8px;
  width: 100%;
  text-align: left;
}
.attach .doc-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--sage-soft);
  color: var(--primary);
  flex: none;
}
.attach .doc-icon svg { width: 17px; height: 17px; }
.attach .grow { flex: 1; min-width: 0; }
.attach .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach .meta { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ------------------------------ Estados ---------------------------- */

.empty {
  text-align: center;
  padding: 46px 22px;
  color: var(--muted);
}
.empty .glyph {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  color: var(--primary);
}
.empty .glyph svg { width: 26px; height: 26px; }
.empty h3 { font-family: var(--display); font-size: 19px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: 13.5px; line-height: 1.5; max-width: 300px; margin: 0 auto; }

.skeleton {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--surface-2) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------ Lock ------------------------------- */

.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 30px) 26px calc(env(safe-area-inset-bottom) + 26px);
  background:
    radial-gradient(120% 80% at 80% -10%, rgba(168, 198, 186, .22), transparent 60%),
    linear-gradient(160deg, #0F4C5C 0%, #0B3B47 55%, #082E38 100%);
  color: #F8F5EC;
}
.lock-logo {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: rgba(248, 245, 236, .08);
  border: 1px solid rgba(248, 245, 236, .16);
  margin-bottom: 18px;
}
.lock-logo svg { width: 38px; height: 38px; }
.lock h1 {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -.4px;
}
.lock .tagline { font-size: 13px; color: rgba(248, 245, 236, .65); margin-top: 6px; letter-spacing: .3px; }
.pin-dots { display: flex; gap: 14px; margin: 34px 0 8px; }
.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(248, 245, 236, .45);
  transition: background .15s, transform .15s, border-color .15s;
}
.pin-dot.on { background: #F8F5EC; border-color: #F8F5EC; transform: scale(1.08); }
.lock-error {
  min-height: 20px;
  font-size: 12.5px;
  color: #F2B8A8;
  margin-bottom: 16px;
  text-align: center;
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 16px 22px;
  justify-content: center;
}
.pin-key {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  font-weight: 500;
  color: #F8F5EC;
  background: rgba(248, 245, 236, .07);
  border: 1px solid rgba(248, 245, 236, .1);
  transition: background .12s, transform .1s;
}
.pin-key:active { background: rgba(248, 245, 236, .16); transform: scale(.94); }
.pin-key.blank { background: transparent; border-color: transparent; pointer-events: none; }
.pin-key svg { width: 24px; height: 24px; }
.lock-foot { margin-top: 30px; font-size: 11px; color: rgba(248, 245, 236, .38); letter-spacing: .3px; }
.shake { animation: shake .38s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ------------------------------ Boot ------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.boot-inner { text-align: center; }
.boot-logo { width: 64px; height: 64px; margin: 0 auto 14px; color: var(--primary); }
.boot-name { font-family: var(--display); font-size: 24px; font-weight: 600; }
.boot-bar {
  width: 90px;
  height: 3px;
  border-radius: 99px;
  background: var(--bg-soft);
  margin: 16px auto 0;
  overflow: hidden;
}
.boot-bar::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--sage);
  border-radius: 99px;
  animation: load 1.1s ease-in-out infinite;
}
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ------------------------------ Sheet / modal ---------------------- */

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(8, 24, 24, .42);
  backdrop-filter: blur(3px);
  animation: fade .18s;
}
.sheet {
  width: 100%;
  max-width: 760px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 22px);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .2);
  animation: up .26s var(--ease);
  -webkit-overflow-scrolling: touch;
}
.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  margin: 4px auto 14px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sheet-head h2 { font-family: var(--display); font-size: 21px; font-weight: 600; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 24, 24, .48);
  backdrop-filter: blur(3px);
  animation: fade .16s;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: up .22s var(--ease);
}
.modal h2 { font-family: var(--display); font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ------------------------------ Toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  z-index: 80;
  transform: translate(-50%, 12px);
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--high); color: #fff; }

/* ------------------------------ Utilidades ------------------------- */

.stack-8 > * + * { margin-top: 8px; }
.stack-12 > * + * { margin-top: 12px; }
.stack-18 > * + * { margin-top: 18px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line) inset;
}
.swatch.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }

.medical-note {
  border-left: 3px solid var(--sage);
  padding: 10px 0 10px 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

@media (min-width: 720px) {
  .tabbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  #view { padding-left: 24px; padding-right: 24px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 360px) {
  .pin-pad { grid-template-columns: repeat(3, 66px); gap: 14px 18px; }
  .pin-key { width: 66px; height: 66px; font-size: 22px; }
  .h1 { font-size: 26px; }
  .entry { grid-template-columns: 1fr 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
