/* Neutral, quiet, lots of air — but built for direct sun: dark ink, 16px+ text, 48px+ targets. */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --accent: #1b2a4a; /* azul marino oscuro */
  --accent-ink: #fafaf9;
  --red: #b91c1c;
  --red-bg: #fef2f2;
  --amber: #92400e;
  --amber-bg: #fffbeb;
  --green: #166534;
  --green-bg: #f0fdf4;
  --radius: 14px;
  --gap: 16px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100dvh; }
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; margin: 8px 0 20px; font-weight: 650; }
main > h1:first-child { font-size: 1.3rem; margin: 4px 0 14px; }
h1 .sub, h1 .n { color: var(--muted); font-weight: 500; }
h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 32px 0 12px; font-weight: 600; }
h2 .n { color: var(--ink); }
h3 { font-size: 1.05rem; margin: 0 0 4px; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
.meta { color: var(--muted); font-size: 0.88rem; }
.vacio { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- shell ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.sel-puerto { font: inherit; font-weight: 650; border: 0; background: transparent; color: var(--ink); padding: 8px 0; min-height: 44px;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; min-width: 0; }
.sel-puerto .chev { width: 18px; height: 18px; flex: none; color: var(--muted); }
.usuario { font: inherit; font-size: 0.9rem; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px; min-height: 44px; white-space: nowrap; }
main { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(110px + env(safe-area-inset-bottom)); }
.abajo {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.abajo a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; color: var(--muted);
  font-size: 0.82rem; padding: 6px 0; min-height: 58px; justify-content: center; white-space: nowrap; }
.abajo a.activo { color: var(--accent); font-weight: 650; }
/* Five tabs (encargada) at 375 px: a touch smaller so the long labels never touch. */
.abajo a:first-child:nth-last-child(5), .abajo a:first-child:nth-last-child(5) ~ a { font-size: 0.76rem; }
.abajo a { padding-inline: 2px; overflow: hidden; text-overflow: ellipsis; }
.ico-caja { position: relative; display: grid; place-items: center; height: 32px; }
.abajo .ico { width: 24px; height: 24px; }
.abajo a.mas .ico-caja { background: var(--accent); color: var(--accent-ink); width: 44px; height: 32px; border-radius: 16px; }
.abajo a.mas .ico { width: 22px; height: 22px; }
.insignia { position: absolute; top: -4px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 0.72rem; font-weight: 700; line-height: 18px; text-align: center; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600;
  min-height: 52px; padding: 12px 20px; border-radius: 12px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); text-decoration: none; cursor: pointer; text-align: center;
}
.btn:disabled { opacity: 0.45; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-grande { width: 100%; min-height: 60px; font-size: 1.1rem; }
.btn-sec { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn-ghost.peligro { color: var(--red); }
.btn-sm { min-height: 48px; padding: 8px 16px; font-size: 0.95rem; }
:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.fila { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.fila > * { flex: 1; }
.segmento { display: flex; gap: 4px; padding: 4px; background: #f0efed; border-radius: 12px; margin-bottom: 12px; overflow-x: auto; }
.segmento button, .segmento .opc span {
  flex: 1; font: inherit; font-size: 0.95rem; font-weight: 550; border: 0; background: transparent; color: var(--muted);
  min-height: 44px; padding: 6px 8px; border-radius: 9px; line-height: 1.2; text-align: center; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.segmento button.activo, .segmento .opc input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.opc { flex: 1; display: flex; }
.opc input, .dia-sem input { position: absolute; opacity: 0; pointer-events: none; }
.opc input:focus-visible + span, .dia-sem input:focus-visible + span { outline: 3px solid #2563eb; }

/* ---------- cards ---------- */
.lista { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 14px 14px 18px; position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-strong); }
.card.estado-asignada::before { background: var(--accent); }
.card.estado-pendiente::before { background: #d97706; }
.card.estado-hecha::before { background: var(--green); }
.card.es-vencida { border-color: #fecaca; background: var(--red-bg); }
.card.es-vencida::before { background: var(--red); }
.card.pausada { opacity: 0.6; }
.card-pie { display: flex; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.card.es-vencida .card-pie { border-top-color: #fecaca; }
.persona-card { flex-direction: row; align-items: center; }
.card.fact .card-link p:not(.meta) { margin-top: 2px; }
.card-link { flex: 1; min-width: 0; text-decoration: none; display: block; }
.card-link h3 { overflow-wrap: anywhere; }
.asignado { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; font-weight: 650; color: var(--accent); }
.asignado .inicial {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
}
.asignado.libre { font-weight: 500; color: var(--muted); font-size: 0.92rem; }
.persona-card { text-decoration: none; color: inherit; }
.inicial.grande { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem; text-transform: uppercase; }
.mt { margin-top: 16px; }
.pin-grande { font-size: 3rem; font-weight: 700; letter-spacing: 0.3em; text-align: center; margin: 8px 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.btn-peligro { background: var(--red); border-color: var(--red); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 0.85rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #f0efed; color: var(--ink); }
.chip.rojo { background: var(--red); color: #fff; }
.chip.ambar { background: var(--amber-bg); color: var(--amber); border: 1px solid #fde68a; }
.chip.azul { background: #e8edf6; color: var(--accent); border: 1px solid #c7d2e6; }
.chip.verde { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }

/* ---------- detail ---------- */
.volver { display: inline-block; color: var(--muted); text-decoration: none; padding: 10px 0; min-height: 44px; }
.desc { margin: 16px 0 0; white-space: pre-wrap; }
.resumen { margin: -8px 0 12px; }
.resumen .asignado { font-size: 1.05rem; }
.motivo { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); border: 1px solid #fde68a; }
.gestion { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.btn-sec.peligro { color: var(--red); border-color: #fecaca; }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0 8px; }
.acciones .btn-grande { grid-column: 1 / -1; }
.datos { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 24px 0 0; padding: 16px 0; border-top: 1px solid var(--line); }
.datos dt { color: var(--muted); font-size: 0.9rem; }
.datos dd { margin: 0; overflow-wrap: anywhere; }
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.foto { position: relative; }
.foto-x { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(28 25 23 / 0.72); color: #fff; font-size: 1rem; display: grid; place-items: center; }
.aviso-pend { margin-top: 16px; padding: 10px 14px; border-radius: 10px; background: #e8edf6; color: var(--accent); font-weight: 600; font-size: 0.92rem; }
.fotos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; background: var(--line); }
.historial { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.historial li { display: flex; flex-direction: column; font-size: 0.95rem; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.form label, .filtros label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 12px; min-height: 50px; width: 100%;
}
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
fieldset .segmento { margin-bottom: 0; }
.form .check { flex-direction: row-reverse; justify-content: space-between; align-items: center; gap: 12px; color: var(--ink); font-size: 1rem; font-weight: 500; min-height: 48px; cursor: pointer; }
/* Checkboxes drawn as on/off switches: same input, same semantics. */
.check input {
  appearance: none; flex: none; width: 48px; height: 28px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 14px;
  background: var(--line-strong); position: relative; cursor: pointer; transition: background 0.15s;
}
.check input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); transition: transform 0.15s; }
.check input:checked { background: var(--accent); }
.check input:checked::before { transform: translateX(20px); }
.bloque { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 8px; display: flex; flex-direction: column; }
.bloque-titulo { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.bloque .check + .check { border-top: 1px solid var(--line); }
.bloque .sub-campos { margin: 6px 0 8px; }
@media (prefers-reduced-motion: reduce) { .check input, .check input::before { transition: none; } }
.sub-campos { display: flex; flex-direction: column; gap: 18px; padding-left: 16px; border-left: 2px solid var(--line); }
.dias { display: flex; gap: 6px; }
.dia-sem { flex: 1; }
.dia-sem span { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-weight: 600; color: var(--ink); }
.dia-sem input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.foto-grande {
  font: inherit; font-weight: 600; font-size: 1.1rem; color: var(--ink); width: 100%; min-height: 180px; border: 2px dashed var(--line-strong);
  border-radius: var(--radius); background: var(--surface); display: grid; place-items: center; position: relative; overflow: hidden; padding: 0; cursor: pointer;
}
.foto-grande img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.foto-grande .repetir { position: absolute; bottom: 10px; right: 10px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 999px; font-size: 0.9rem; }
.filtro-zona { margin: 0 0 14px; min-height: 44px; padding: 8px 12px; }
.filtros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.nota { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.nota p { white-space: pre-wrap; margin-bottom: 6px; }
.nota-form { display: flex; flex-direction: column; gap: 10px; }

/* ---------- login / day ---------- */
.sin-shell main { padding-bottom: 32px; }
.login { max-width: 440px; padding-top: calc(48px + env(safe-area-inset-top)); }
.marca { color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-nombre { background: var(--surface); color: var(--ink); border-color: var(--line-strong); min-height: 64px; font-size: 1.05rem; }
.puntos { display: flex; gap: 16px; justify-content: center; margin: 24px 0 8px; }
.punto { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.punto.lleno { background: var(--ink); }
.error { color: var(--red); text-align: center; min-height: 1.5em; font-weight: 600; }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.tecla { font: inherit; font-size: 1.6rem; font-weight: 550; min-height: 68px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.tecla-txt { font-size: 0.95rem; color: var(--muted); }
.tecla:active { background: #f0efed; }
.turnos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.turno {
  font: inherit; text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 16px; min-height: 88px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer;
}
.turno span { font-size: 0.82rem; color: var(--muted); }
.turno.activo { border: 2px solid var(--ink); padding: 15px; }

/* ---------- overlays ---------- */
dialog { border: 0; border-radius: 18px; padding: 24px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(28 25 23 / 0.4); }
.dlg-form { display: flex; flex-direction: column; gap: 12px; }
.dlg-form h2 { margin-top: 0; font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.dlg-form .segmento { margin-bottom: 4px; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20; margin: 0 auto; max-width: 480px;
  background: var(--ink); color: var(--accent-ink); padding: 14px 18px; border-radius: 12px; font-weight: 550; text-align: center;
}
.offline { position: sticky; top: 0; z-index: 30; background: var(--accent); color: #fff; text-align: center; padding: 6px; font-size: 0.85rem; font-weight: 600; }

@media (max-width: 380px) { .filtros { grid-template-columns: 1fr; } }
@media print {
  .no-print, .abajo, .top { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { break-inside: avoid; border-color: #999; }
  .card .btn { display: none; }
}
.card > .btn-sm { align-self: flex-end; }
