/* Calculadora UIP — Liquid Glass sobre azul noche (tema único, oscuro) */
:root {
  color-scheme: dark;
  --fondo: #08122b;
  --panel: rgba(255, 255, 255, .07);
  --panel-borde: rgba(255, 255, 255, .14);
  --brillo: rgba(255, 255, 255, .16);
  --texto: #f5f5f7;
  --sutil: #a9b3c9;
  --campo: rgba(255, 255, 255, .06);
  --suave: rgba(255, 255, 255, .06);
  --azul: #409cff;
  --azul-2: #0071e3;  /* blanco encima: 4,7:1 */
  --oro: #e0b44a;
  --hoy: #ffd60a;
  --turno: #c47cf5;
  --salida: #b8781f;
  --bien: #30d158;
  --mal: #ff6961;
  --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --r: 28px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.5 var(--fuente);
  -webkit-font-smoothing: antialiased;
}

/* Fondo: azul noche con brillos suaves (fijo, no repinta al desplazar) */
body::before {
  /* 100lvh: cubre también la franja que deja la barra de direcciones de Android al ocultarse */
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 100lvh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% -5%, rgba(64, 120, 255, .35), transparent 70%),
    radial-gradient(40% 35% at 95% 30%, rgba(224, 180, 74, .10), transparent 70%),
    radial-gradient(50% 40% at 0% 85%, rgba(30, 80, 200, .22), transparent 70%),
    linear-gradient(180deg, #0c1a3d, #060d20);
}

.saltar { position: absolute; left: -999px; }
.saltar:focus { left: 16px; top: 16px; background: var(--fondo); padding: 8px 12px; z-index: 2; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
/* iOS pinta un recuadro gris translúcido al tocar; el foco y :active ya dan respuesta visual */
html { -webkit-tap-highlight-color: transparent; }


/* Cabecera */
.hero { padding: 32px 16px 20px; }
.hero-in, main, .pie { max-width: 760px; margin: 0 auto; }
.hero-in { display: flex; align-items: center; gap: 18px; }
.escudo {
  width: 140px; height: auto; flex-shrink: 0;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .55)) drop-shadow(0 0 28px rgba(224, 180, 74, .22));
}
.hero h1 { margin: 0; font-size: clamp(1.9rem, 6vw, 2.6rem); line-height: 1.05; font-weight: 700; letter-spacing: -.025em; }
.hero p { margin: 6px 0 0; color: var(--sutil); }

main, .pie { padding: 0 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-borde);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .7), inset 0 1px 0 var(--brillo);
  animation: subir .5s ease both;
}
main > .panel:nth-of-type(2) { animation-delay: .06s; }
main > .panel:nth-of-type(3) { animation-delay: .12s; }
@keyframes subir { from { opacity: 0; transform: translateY(10px); } }

.h-seccion { font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; }
.h-seccion:not(:first-child) { margin-top: 24px; }

/* Ciclo */
.ciclo-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ciclo-tit { text-align: center; min-width: 0; }
.ciclo-tit h2 { margin: 0; font-size: .85rem; font-weight: 600; color: var(--azul); }
.ciclo-tit p { margin: 2px 0 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.btn-nav {
  width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; cursor: pointer;
  color: var(--texto); background: var(--suave); border: 1px solid var(--panel-borde); border-radius: 50%;
}
.btn-nav svg, .tipo svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.calendario { margin-top: 16px; }
.cal-dias, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dias span { text-align: center; font-size: .72rem; font-weight: 600; color: var(--sutil); padding-bottom: 4px; }
.dia {
  position: relative; aspect-ratio: 1; min-height: 38px; display: grid; place-items: center;
  font: 500 .95rem var(--fuente); color: var(--texto); font-variant-numeric: tabular-nums;
  background: var(--suave); border: 1px solid var(--panel-borde); border-radius: 14px; cursor: pointer;
}
.dia:hover { border-color: var(--azul); }
.dia.finde { background: rgba(255, 69, 58, .16); }
.dia.salida { background: color-mix(in srgb, var(--salida) 60%, transparent); }
.dia.hoy { background: var(--hoy); color: #1c1c1e; font-weight: 700; border-color: transparent; box-shadow: 0 6px 18px -4px rgba(255, 214, 10, .6); }
.dia .serv {
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  font-size: .6rem; font-weight: 700; line-height: 1; color: var(--oro);
}
.dia.hoy .serv { color: #1c1c1e; }
.dia.con-turno::after {
  content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--turno);
}
.dia.hoy.con-turno::after { background: #1c1c1e; }

.leyenda { list-style: none; display: flex; flex-wrap: wrap; gap: 14px; padding: 0; margin: 10px 0 0; font-size: .78rem; color: var(--sutil); }
.leyenda li { display: flex; align-items: center; gap: 6px; }
.leyenda i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.l-hoy { background: var(--hoy); }
.l-turno { background: var(--turno); border-radius: 50% !important; }
.l-salida { background: var(--salida); }

.alta { animation: subir .5s ease .06s both; }
/* Widgets cuadrados estilo iPhone: etiqueta arriba, cifra grande abajo */
.balance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.balance div {
  aspect-ratio: 1; display: flex; flex-direction: column; justify-content: space-between; padding: 14px;
  background: var(--panel); border: 1px solid var(--panel-borde); border-radius: 26px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .7), inset 0 1px 0 var(--brillo);
}
.balance dt { font-size: .85rem; font-weight: 600; color: var(--sutil); }
.balance dd { margin: 0; font-size: 3rem; line-height: 1; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.dif.faltan dd { color: var(--mal); }
.dif.exceso dd, .dif.al-dia dd { color: var(--bien); }

.progreso { height: 6px; background: var(--suave); border-radius: 99px; margin-top: 14px; overflow: hidden; }
.progreso span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--azul-2), #5ac8fa); border-radius: inherit; transition: width .4s ease; }
.explica { margin: 10px 4px 16px; color: var(--sutil); font-size: .9rem; }

/* Pestañas */
.pestanas { display: grid; grid-template-columns: 1fr 1fr; background: var(--suave); border: 1px solid var(--panel-borde); padding: 4px; border-radius: 999px; margin-bottom: 18px; }
.pestanas button { min-height: 42px; font: 600 1rem var(--fuente); color: var(--sutil); background: none; border: 0; border-radius: 999px; cursor: pointer; }
.pestanas button[aria-selected="true"] { background: rgba(255, 255, 255, .16); color: var(--texto); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 4px 14px rgba(0, 0, 0, .25); }

/* Formularios */
.campo { display: block; font-size: .85rem; font-weight: 600; color: var(--sutil); }
.campo input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 14px; min-height: 52px;
  font: 500 1.15rem var(--fuente); color: var(--texto); background: var(--campo);
  border: 1px solid var(--panel-borde); border-radius: 16px; font-variant-numeric: tabular-nums;
}
.campo input:focus { border-color: var(--azul); outline: none; box-shadow: 0 0 0 4px rgba(64, 156, 255, .25); }
.campo input[aria-invalid="true"] { border-color: var(--mal); }
.campo input[type="text"] { text-align: center; font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.campo input::placeholder { color: var(--sutil); opacity: .45; font-weight: 500; }
.campo input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .7; }

.horas { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; margin-top: 14px; }
.horas .campo { min-width: 0; }
.flecha { padding-bottom: 14px; color: var(--azul); font-size: 1.3rem; }
.ayuda { margin: 8px 0 0; font-size: .85rem; color: var(--sutil); }
#p-salida > .ayuda { margin: 0 0 14px; }
#f-salida .horas { margin-top: 0; }
#f-salida .campo input { font-size: 1rem; padding: 10px; min-width: 0; }

.tipos { border: 0; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tipos legend { font-size: .85rem; font-weight: 600; color: var(--sutil); margin-bottom: 8px; padding: 0; }
.tipo {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 14px; min-height: 44px; border: 1px solid var(--panel-borde); border-radius: 20px;
  cursor: pointer; font-size: .9rem; line-height: 1.3; color: var(--sutil); background: var(--campo);
}
.tipo b { color: var(--texto); font-weight: 600; }
.tipo svg { color: var(--azul); }
.tipo input { position: absolute; opacity: 0; pointer-events: none; }
.tipo:has(input:checked) { border-color: var(--azul); background: rgba(64, 156, 255, .16); }
.tipo:has(input:focus-visible) { outline: 3px solid var(--azul); outline-offset: 2px; }

.previo { display: block; margin-top: 16px; padding: 12px 14px; border-radius: 18px; background: var(--suave); font-weight: 600; min-height: 48px; }
.previo:empty { display: none; }
.previo strong { font-size: 1.25rem; font-weight: 700; color: var(--azul); }
.error { margin: 10px 0 0; color: var(--mal); font-weight: 500; }
.error:empty { display: none; }

.btn {
  margin-top: 16px; width: 100%; min-height: 52px; cursor: pointer;
  font: 600 1.05rem var(--fuente); color: #fff; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, var(--azul-2), #0062cc);
  box-shadow: 0 10px 24px -8px rgba(10, 132, 255, .7), inset 0 1px 0 rgba(255, 255, 255, .4);
}
.btn:hover { filter: brightness(1.1); }

/* Microinteracciones */
.btn, .btn-nav, .dia, .pestanas button, .tipo { transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease, filter .2s ease; }
.btn:active, .btn-nav:active, .dia:active { transform: scale(.97); }

/* Listas */
.lista { list-style: none; padding: 0; margin: 0; }
.lista li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--panel-borde); }
.lista li:first-child { border-top: 0; }
.lista .vacio { color: var(--sutil); font-size: .95rem; }
.lista small { display: block; color: var(--sutil); font-size: .85rem; }
.item-der { display: flex; align-items: center; gap: 10px; }
.chip { font-size: 1.05rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-dif { display: grid; justify-items: end; line-height: 1.1; white-space: nowrap; }
.chip-dif small { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--sutil); }
.chip-dif b { font-size: 1.3rem; font-weight: 700; }
.chip-dif.exceso b, .chip-dif.al-dia b { color: var(--bien); }
.chip-dif.faltan b { color: var(--mal); }
.btn-borrar {
  width: 36px; height: 36px; display: grid; place-items: center; flex-shrink: 0; cursor: pointer;
  color: var(--sutil); background: none; border: 1px solid var(--panel-borde); border-radius: 999px;
}
.btn-borrar:hover { color: var(--mal); border-color: var(--mal); }
.btn-borrar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Tablas */
details { border-top: 1px solid var(--panel-borde); padding: 12px 0; }
details:first-of-type { border-top: 0; }
summary { cursor: pointer; font-weight: 600; }
.tabla-scroll { max-height: 420px; overflow: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .95rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--panel-borde); }
thead th { position: sticky; top: 0; background: #142349; }
#tabla-turnos h3 { margin: 16px 0 4px; font-size: .95rem; }

/* Contenido explicativo */
.texto p { margin: 0 0 12px; color: var(--sutil); }
.texto h3 { margin: 18px 0 6px; font-size: 1rem; }
.texto details p { margin: 8px 0 0; }

/* Hueco publicitario: separado y rotulado para que no se confunda con la calculadora */
.anuncio { margin: 0 0 16px; min-height: 120px; border: 1px dashed var(--panel-borde); border-radius: 16px; }
.anuncio::before { content: "Publicidad"; display: block; padding: 6px 12px; font-size: .7rem; color: var(--sutil); text-transform: uppercase; letter-spacing: .08em; }

.pie a { color: var(--azul); }
.pie { padding-top: 8px; padding-bottom: 40px; color: var(--sutil); font-size: .85rem; }

/* Tableta */
@media (min-width: 640px) and (max-width: 1023px) {
  .tipos { grid-template-columns: repeat(3, 1fr); }
}

/* Escritorio: dos columnas, formulario fijo a la derecha */
@media (min-width: 1024px) {
  .hero-in, main, .pie { max-width: 1120px; }
  main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }
  main > .pestanas { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: min(100%, 420px); }
  main > section:nth-of-type(1) { grid-column: 1; grid-row: 2; }
  main > section:nth-of-type(2) { grid-column: 2; grid-row: 2 / span 3; position: sticky; top: 20px; }
  main > section:nth-of-type(3) { grid-column: 1; grid-row: 3; }
  main > section:nth-of-type(4) { grid-column: 1; grid-row: 4; }
  main > section:nth-of-type(n+5), main > .anuncio { grid-column: 1 / -1; }
}

/* Móvil */
@media (max-width: 560px) {
  .hero { padding-top: 22px; }
  .escudo { width: 104px; }
  .tipos { grid-template-columns: 1fr; }
  .tipo { flex-direction: row; align-items: center; padding: 12px 14px; }
  .balance { gap: 10px; }
  .balance div { padding: 12px 10px; border-radius: 22px; }
  .balance dt { font-size: .74rem; }
  .balance dd { font-size: 2.3rem; }
  .panel { padding: 16px; }
  .cal-dias, .cal-grid { gap: 4px; }
  .ciclo-tit h2 { font-size: .75rem; }
  .ciclo-tit p { font-size: 1.05rem; white-space: nowrap; }
}
@media (max-width: 400px) {
  #f-salida .horas { grid-template-columns: 1fr; gap: 12px; }
  #f-salida .flecha { display: none; }
}

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

/* Salida en preparación (pestaña Salida activa) */
.dia.previa { border: 2px dashed var(--azul); background: rgba(64, 156, 255, .22); }
.dia.previa.hoy { background: var(--hoy); }

/* Primer y último día del ciclo */
.dia.cambio { box-shadow: inset 0 0 0 2px var(--bien); }
.dia.cambio.hoy { box-shadow: inset 0 0 0 2px var(--bien), 0 6px 18px -4px rgba(255, 214, 10, .6); }
.l-cambio { box-shadow: inset 0 0 0 2px var(--bien); }

/* Resumen de la salida en preparación, bajo el calendario */
.cal-resumen { margin: 12px 0 0; padding: 10px 14px; border-radius: 16px; background: rgba(64, 156, 255, .12); border: 1px solid rgba(64, 156, 255, .35); font-size: .92rem; }
.cal-resumen strong { color: var(--azul); font-size: 1.05rem; }
.error-inline { color: var(--mal); font-weight: 500; }

/* Página legal: una sola columna */
main.legal { display: block; max-width: 760px; }
.hero a.volver, .texto a { color: var(--azul); }
.dia.siguiente { opacity: .6; }
.dia.siguiente:hover, .dia.siguiente:focus-visible { opacity: 1; }
