:root {
  --bg: #eef6f6;
  --surface: #ffffff;
  --ink: #10262a;
  --muted: #5b7378;
  --line: #d7e6e6;
  --brand: #0f5c63;
  --brand-2: #1b7f86;
  --brand-soft: #e3f2f1;
  --ok: #0d6b45;
  --ok-bg: #e6f2eb;
  --bad: #a3261b;
  --bad-bg: #fbe9e6;
  --warn: #9a5600;
  --warn-bg: #fdf0dc;
  --shadow: 0 1px 2px rgba(16, 38, 42, .06), 0 6px 18px rgba(16, 38, 42, .05);
  --radio: 15px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

h1, h2, h3, p { margin: 0; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* --------------------------------------------------------------- barra */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(238, 246, 246, .88);
  backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-in { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 9px; }
.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-mini {
  width: 34px; height: 34px; border-radius: 10px;
  display: block; object-fit: cover; flex: none;
}
.eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.marca h1 { font-size: 17px; font-weight: 720; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --------------------------------------------------------------- barra inferior */
.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 760px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.2) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 10px; text-decoration: none; color: var(--muted);
  font-size: 10.5px; font-weight: 600;
}
.tabbar a.activo { color: var(--brand); }
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.activo svg { stroke-width: 2.1; }

/* --------------------------------------------------------------- piezas */
.titulo-pagina { font-size: 23px; font-weight: 760; letter-spacing: -.03em; margin: 18px 0 12px; }
.titulo-chico { font-size: 12px; font-weight: 700; color: var(--muted); }
.nota { color: var(--muted); font-size: 13px; margin-top: 8px; }
.sec { color: var(--muted); font-size: 12px; white-space: nowrap; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.peligro { border-color: #eec4be; }

.hero {
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
  color: #fff; border-radius: 18px; padding: 18px;
  margin-bottom: 12px; box-shadow: 0 10px 24px rgba(15, 92, 99, .22);
}
.hero .eyebrow { color: rgba(255, 255, 255, .78); }
.hero-v { font-size: 34px; font-weight: 780; letter-spacing: -.035em; margin-top: 2px; }
.hero-s { color: rgba(255, 255, 255, .84); font-size: 13px; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; border: 0; border-radius: 13px; padding: 12px 16px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 680;
  text-decoration: none; cursor: pointer; width: 100%;
}
.btn:active { transform: scale(.99); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.chico { width: auto; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }

.fila {
  display: block; width: 100%; text-align: left; font: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 12px 14px; margin-bottom: 9px;
  text-decoration: none; color: inherit; cursor: pointer;
}
.fila:active { transform: scale(.995); }
.fila.estatica { cursor: default; }
.fila-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fila-sub { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.nombre { font-weight: 660; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-weight: 720; font-variant-numeric: tabular-nums; }

.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.pill.confirmada { background: #e6f0ff; color: #1f4f8f; }
.pill.atendida { background: var(--ok-bg); color: var(--ok); }
.pill.cancelada { background: var(--bad-bg); color: var(--bad); }
.pill.no_asistio { background: var(--warn-bg); color: var(--warn); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2.apretado { gap: 8px 12px; }
.dato { background: var(--brand-soft); border-radius: 12px; padding: 9px 11px; }
.dato span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.dato strong { font-size: 15px; font-weight: 720; }

.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acciones .btn { width: auto; flex: 1 1 45%; }
.fila-acciones { margin: 0 0 12px; }

.seccion-t { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.seccion-t h3 { font-size: 15px; font-weight: 720; }
.seccion-t .btn { width: auto; padding: 8px 12px; font-size: 13px; }

.dia-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 12px; }
.dia-caja { text-align: center; min-width: 0; }
.dia-caja strong { display: block; font-size: 15px; font-weight: 720; text-transform: capitalize; }
.dia-caja span { font-size: 12px; color: var(--muted); }
.icono {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 20px;
  font-weight: 700; cursor: pointer; flex: none;
}

.vacio { text-align: center; color: var(--muted); padding: 18px 6px; }
.vacio .btn { margin-top: 12px; }

.buscar {
  width: 100%; border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 14px; font: inherit; background: var(--surface); margin-bottom: 10px;
}

.alerta { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 10px; }

.bienvenida { text-align: center; padding: 46px 6px 12px; }
.bienvenida .logo {
  width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 26px;
  display: block; object-fit: contain;
}
.bienvenida h1 { font-size: 32px; line-height: 1.12; letter-spacing: -.035em; font-weight: 780; }
.bienvenida p { color: var(--muted); font-size: 14.5px; margin: 14px 0 22px; }

.volver { display: inline-block; margin-top: 16px; color: var(--brand); text-decoration: none; font-weight: 650; font-size: 14px; }

/* --------------------------------------------------------------- formularios */
form label { display: block; font-size: 13px; font-weight: 620; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  width: 100%; margin-top: 5px; border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 12px; font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(27, 127, 134, .25); border-color: var(--brand-2); }
textarea { resize: vertical; }

/* --------------------------------------------------------------- hoja modal */
dialog {
  border: 0; padding: 0; border-radius: 20px 20px 0 0;
  width: 100%; max-width: 760px; margin: auto auto 0;
  background: var(--surface); color: var(--ink);
  max-height: 92vh;
}
dialog::backdrop { background: rgba(16, 38, 42, .45); }
.hoja-in { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: 92vh; }
.hoja-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.hoja-head h2 { font-size: 20px; font-weight: 760; letter-spacing: -.02em; }
.x { border: 0; background: var(--brand-soft); color: var(--brand); width: 34px; height: 34px; border-radius: 10px; font-size: 20px; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; max-width: 90%; text-align: center;
  transition: opacity .18s, transform .18s; z-index: 50;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 620px) {
  .bienvenida h1 { font-size: 38px; }
}

/* --------------------------------------------------------------- v0.2 clínica */
.centro { text-align: center; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.punto { display: inline-block; width: 8px; height: 8px; border-radius: 999px; margin-right: 6px; vertical-align: middle; }
.filtro { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin: 0 0 10px; }
.filtro select { margin-top: 4px; }
.cab-paciente { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cab-paciente .titulo-pagina { margin-bottom: 8px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; text-decoration: none; color: var(--muted); font-size: 12.5px; font-weight: 680;
  padding: 7px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
}
.tab.activo { background: var(--brand); color: #fff; border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; margin: 0; }
.separador { margin: 18px 0 10px; font-size: 14px; }
.bloqueo { text-align: center; padding-top: 42px; }
.bloqueo .logo {
  width: 82px; height: 82px; margin: 0; border-radius: 24px;
  display: block; object-fit: contain;
}
.logo-candado { position: relative; width: 96px; margin: 0 auto 18px; }
.logo-candado .logo { width: 96px; height: 96px; }
.candado {
  position: absolute; right: -6px; bottom: -6px; width: 34px; height: 34px;
  padding: 7px; border-radius: 999px; background: var(--surface); color: var(--brand);
  box-shadow: 0 4px 14px rgba(8, 44, 48, .18);
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.bloqueo h1 { font-size: 24px; letter-spacing: -.03em; }
.bloqueo .card { max-width: 380px; margin: 18px auto; text-align: left; }
.bloqueo .nota { margin-top: 8px; }
.acciones-mini { display: inline-flex; gap: 10px; align-items: center; }
.link { border: 0; background: none; color: var(--bad); font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; padding: 0; }
.lista .fila:last-child { margin-bottom: 0; }
.aviso { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 13px; }

/* odontograma */
.odontograma { overflow-x: auto; padding: 4px 0 8px; }
.arcada { display: grid; grid-template-columns: repeat(16, minmax(26px, 1fr)); gap: 3px; margin-bottom: 6px; min-width: 520px; }
.diente {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  font: inherit; font-size: 10.5px; font-weight: 720; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0;
}
.diente span { font-size: 8px; font-weight: 700; opacity: .75; line-height: 1; }
.diente:active { transform: scale(.96); }
.c-sano { background: #fff; }
.c-caries { background: #fbe9e6; color: #a3261b; border-color: #eec4be; }
.c-obturado { background: #e6f0ff; color: #1f4f8f; border-color: #c9dcf7; }
.c-corona { background: #fdf0dc; color: #9a5600; border-color: #f0d8b4; }
.c-ausente { background: #eceff1; color: #607d8b; border-color: #d5dde0; text-decoration: line-through; }
.c-implante { background: #e6f2eb; color: #0d6b45; border-color: #c4e3d1; }
.c-endodoncia { background: #f3e8ff; color: #6b21a8; border-color: #e0cdf5; }
.c-fractura { background: #fee2e2; color: #991b1b; border-color: #f5c2c2; }
.c-sellante { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.c-protesis { background: #fef9c3; color: #854d0e; border-color: #f0e6a8; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.leyenda span { display: inline-flex; align-items: center; gap: 4px; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }

@media (min-width: 620px) {
  .btn { width: auto; }
  .fila-acciones .btn, .acciones .btn { width: auto; }
  .bloqueo h1 { font-size: 30px; }
}
