:root {
  --fondo: #f6f5f1;
  --papel: #ffffff;
  --tinta: #1d1f1e;
  --suave: #5f6663;
  --linea: #dedbd2;
  --marca: #1f6f5c;
  --marca-suave: #e3f0ec;
  --aviso: #9a4b12;
  --aviso-fondo: #fbeee2;
  --ok: #2f6f2f;
  --radio: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #151716;
    --papel: #1f2221;
    --tinta: #ecefed;
    --suave: #a3aba7;
    --linea: #333836;
    --marca: #5fbfa4;
    --marca-suave: #1d3530;
    --aviso: #f0b07a;
    --aviso-fondo: #3a2716;
    --ok: #8fd18f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fondo);
  color: var(--tinta);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 96px;
}
[hidden] { display: none !important; }
a { color: var(--marca); }
h1 { font-size: 1.7rem; margin: 0.2rem 0 0.2rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 0.5rem; }
.sub { color: var(--suave); font-weight: 400; font-size: 0.95rem; margin-left: 0.4rem; }

/* Barra */
.barra {
  position: sticky; top: 0; z-index: 5;
  background: var(--papel);
  border-bottom: 1px solid var(--linea);
  padding: 0.4rem 1rem 0;
}
.pasada { margin: 0 0 0.3rem; font-size: 0.85rem; color: var(--suave); }
.pasada.aviso { color: var(--aviso); font-weight: 600; }
.nav { display: flex; gap: 0.2rem; overflow-x: auto; }
.nav a {
  padding: 0.55rem 0.8rem; text-decoration: none; color: var(--suave);
  border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600;
}
.nav a.activa { color: var(--tinta); border-bottom-color: var(--marca); }
.insignia {
  display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: 1em;
  background: var(--marca); color: var(--papel); font-size: 0.8rem; text-align: center;
}

.vista { max-width: 760px; margin: 0 auto; padding: 1rem; outline: none; }
.fuente { color: var(--suave); margin: 0 0 1rem; }
.vacio, .cargando { color: var(--suave); padding: 2rem 0; text-align: center; }
.error { color: var(--aviso); }
.pie { margin-top: 1.5rem; text-align: center; }

/* Tarjetas de Hoy */
.tarjeta {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 1rem 1.1rem; margin-bottom: 0.9rem;
}
.tarjeta .titulo { font-size: 1.2rem; font-weight: 650; color: var(--tinta); text-decoration: none; display: block; }
.tarjeta .titulo:hover { text-decoration: underline; }
.tarjeta .porque { margin: 0.3rem 0 0.8rem; color: var(--suave); }
.tarjeta.cerrada { opacity: 0.65; }
.tarjeta.cerrada .titulo { text-decoration: line-through; }
.marca-hoy { margin: 0.5rem 0 0; font-weight: 600; color: var(--suave); }
.marca-hoy.ok { color: var(--ok); }

/* Agenda: eventos del calendario, solo lectura (los que ya terminaron, en gris) */
.bloque-agenda h2 { margin-top: 1.4rem; }
.h-enlace { color: inherit; text-decoration: none; }
.h-enlace:hover { text-decoration: underline; }
.agenda {
  list-style: none; margin: 0 0 0.9rem; padding: 0;
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
}
.evento { display: flex; gap: 0.8rem; align-items: baseline; padding: 0.55rem 1rem; }
.evento + .evento { border-top: 1px solid var(--linea); }
.evento .hora { flex: 0 0 3.2rem; font-weight: 650; color: var(--marca); font-variant-numeric: tabular-nums; }
.evento .texto { flex: 1 1 auto; min-width: 0; }
.evento .t { font-weight: 600; overflow-wrap: anywhere; }
.evento .motivo { color: var(--suave); font-size: 0.9rem; margin: 0.1rem 0 0; overflow-wrap: anywhere; }
.evento.pasado { opacity: 0.55; }
.evento.pasado .hora { color: var(--suave); }

.alerta {
  background: var(--aviso-fondo); color: var(--aviso); border-radius: 10px;
  padding: 0.5rem 0.75rem; margin: 0 0 0.8rem; font-weight: 600;
}

/* Botones */
button, .boton {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--linea);
  background: var(--papel); color: var(--tinta); padding: 0.6rem 1rem; min-height: 44px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
}
button:hover, .boton:hover { border-color: var(--suave); }
button:disabled { opacity: 0.5; cursor: wait; }
button.prim, .boton.prim { background: var(--marca); border-color: var(--marca); color: var(--papel); font-weight: 650; }
button.enlace { border: 0; background: none; color: var(--marca); padding: 0 0.3rem; min-height: 0; text-decoration: underline; }
.botones { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.botones .prim { flex: 1 1 8rem; }
.botones .sec { flex: 1 1 8rem; }
.fila { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.fila > input, .fila > select { flex: 1 1 12rem; }
.espacio { flex: 1; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.item {
  background: var(--papel); border: 1px solid var(--linea); border-radius: 12px;
  padding: 0.7rem 0.9rem; margin-bottom: 0.5rem;
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
}
.item .texto { flex: 1 1 16rem; min-width: 0; }
.item a.t { color: var(--tinta); font-weight: 600; text-decoration: none; }
.item a.t:hover { text-decoration: underline; }
.item .motivo { color: var(--suave); font-size: 0.9rem; margin: 0.1rem 0 0; }
.chip {
  display: inline-block; font-size: 0.78rem; padding: 0.05rem 0.5rem; border-radius: 1em;
  background: var(--marca-suave); color: var(--marca); font-weight: 600; margin-right: 0.3rem; vertical-align: 1px;
}
.chip.gris { background: var(--linea); color: var(--suave); }
details summary { cursor: pointer; color: var(--suave); margin: 1.2rem 0 0.6rem; font-weight: 600; }

/* Ficha */
.ficha label { display: block; font-weight: 600; margin: 0.8rem 0 0.25rem; }
input, textarea, select {
  font: inherit; color: var(--tinta); background: var(--papel);
  border: 1px solid var(--linea); border-radius: 10px; padding: 0.55rem 0.7rem; width: 100%; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--marca); outline-offset: 1px; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin: 1rem 0; }
.checks label { display: flex; align-items: center; gap: 0.4rem; font-weight: 400; margin: 0; }
.checks input { width: auto; min-height: 0; }
.enlaces { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
.historial { padding-left: 1.2rem; color: var(--suave); }
.meta { color: var(--suave); font-size: 0.85rem; }
.volver { margin: 0 0 0.6rem; }

/* Diálogos */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 2rem));
  background: var(--papel); color: var(--tinta);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.caja { padding: 1.2rem; }
.caja h2 { margin-top: 0; }
.opcion { margin-bottom: 0.9rem; }
.opcion label { display: block; font-weight: 600; margin-bottom: 0.3rem; }

/* Botón + */
.fab {
  position: fixed; right: 1.2rem; bottom: 1.2rem; width: 64px; height: 64px; border-radius: 50%;
  background: var(--marca); color: var(--papel); border: 0; font-size: 2rem; line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); z-index: 6;
}

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(150%);
  background: var(--tinta); color: var(--fondo); padding: 0.7rem 1.1rem; border-radius: 12px;
  transition: transform 0.2s; max-width: calc(100vw - 7rem); z-index: 10;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.mal { background: var(--aviso); color: #fff; }

.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login form { display: grid; gap: 0.7rem; margin-top: 1.2rem; }
.demo-aviso { background: var(--aviso-fondo); color: var(--aviso); text-align: center; padding: 0.3rem; font-size: 0.85rem; margin: 0; }
