/* Agenda de Trabajo — hoja de estilo única, móvil primero */

:root {
  --primario: #7c3aed;
  --primario-suave: #f3edff;
  --texto: #16161d;
  --texto-2: #63636e;
  --borde: #e3e3ea;
  --fondo: #f5f5f8;
  --panel: #ffffff;
  --ok: #0f9d58;
  --alerta: #d93025;
  --aviso: #b26a00;
  --r: 14px;
  --sombra: 0 1px 2px rgba(16, 16, 30, .06), 0 6px 20px rgba(16, 16, 30, .06);
  --barra-inf: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--primario); }

/* ---------- Splash ---------- */
.splash { display: grid; place-items: center; min-height: 100dvh; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--borde); border-top-color: var(--primario);
  animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Estructura ---------- */
.pantalla { min-height: 100dvh; padding-bottom: calc(var(--barra-inf) + env(safe-area-inset-bottom)); }

.cabecera {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px calc(12px) ;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--borde);
}
.cabecera .marca { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cabecera .logo {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  background: var(--primario); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; overflow: hidden;
}
.cabecera .logo img { width: 100%; height: 100%; object-fit: cover; }
.cabecera .titulo { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cabecera .sub { font-size: 11.5px; color: var(--texto-2); }
.cabecera .der { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.contenido { padding: 14px; max-width: 980px; margin: 0 auto; }

/* ---------- Barra inferior (móvil) ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--panel); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; border: 0; background: none; padding: 8px 4px 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: inherit; font-size: 10.5px; color: var(--texto-2); font-weight: 600;
}
.nav button svg { width: 22px; height: 22px; }
.nav button.activo { color: var(--primario); }

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--r);
  padding: 14px; box-shadow: var(--sombra); margin-bottom: 12px;
}
.tarjeta.plana { box-shadow: none; }
.tarjeta-btn { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; display: block; }

.fila { display: flex; align-items: center; gap: 10px; }
.fila.sep { justify-content: space-between; }
.crece { flex: 1; min-width: 0; }
.silencio { color: var(--texto-2); font-size: 13px; }
.mini { font-size: 12px; color: var(--texto-2); }
.recorta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.centro { text-align: center; }
.vacio { text-align: center; color: var(--texto-2); padding: 34px 16px; }
.vacio svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 8px; }

/* ---------- Etiquetas ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--primario-suave); color: var(--primario); white-space: nowrap;
}
.tag.gris { background: #eeeef3; color: var(--texto-2); }
.tag.ok { background: #e6f5ec; color: var(--ok); }
.tag.alerta { background: #fdecea; color: var(--alerta); }
.tag.aviso { background: #fff4e0; color: var(--aviso); }

/* ---------- Botones ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 11px 16px; border-radius: 11px; border: 1px solid var(--borde);
  background: var(--panel); color: var(--texto); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn.primario { background: var(--primario); border-color: var(--primario); color: #fff; }
.btn.peligro { color: var(--alerta); border-color: #f3c9c5; background: #fff; }
.btn.bloque { width: 100%; }
.btn.chico { min-height: 36px; padding: 7px 12px; font-size: 13.5px; border-radius: 9px; }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.botones { display: flex; gap: 9px; flex-wrap: wrap; }
.botones > .btn { flex: 1 1 auto; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--barra-inf) + 16px + env(safe-area-inset-bottom));
  z-index: 25; border: 0; border-radius: 999px; padding: 15px 20px;
  background: var(--primario); color: #fff; font: inherit; font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 20px rgba(124, 58, 237, .4); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.fab svg { width: 20px; height: 20px; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 13px; }
.campo > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--texto-2); margin-bottom: 5px; }
.campo input, .campo select, .campo textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 12px;
  border: 1px solid var(--borde); border-radius: 11px; background: #fff; color: var(--texto);
  min-height: 46px;
}
.campo textarea { min-height: 76px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none; border-color: var(--primario); box-shadow: 0 0 0 3px var(--primario-suave);
}
.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 0 11px; }
.rejilla-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 11px; }

.opciones { display: flex; gap: 8px; flex-wrap: wrap; }
.opciones label {
  flex: 1 1 30%; position: relative; cursor: pointer;
  border: 1.5px solid var(--borde); border-radius: 11px; padding: 10px 6px;
  text-align: center; font-size: 13.5px; font-weight: 600; background: #fff;
}
.opciones input { position: absolute; opacity: 0; pointer-events: none; }
.opciones input:checked + span { color: var(--primario); }
.opciones label:has(input:checked) { border-color: var(--primario); background: var(--primario-suave); }

.ayuda { font-size: 12px; color: var(--texto-2); margin-top: -6px; margin-bottom: 12px; }
.error-form { background: #fdecea; color: var(--alerta); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 12px; }

/* ---------- Modal / hoja inferior ---------- */
.modal-capa {
  position: fixed; inset: 0; z-index: 60; background: rgba(16, 16, 30, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparecer .16s ease;
}
/* Sin esto, el display:flex de arriba le gana al atributo hidden y la capa
   se queda encima de toda la aplicación, oscureciéndola y bloqueando los clics. */
.modal-capa[hidden] { display: none; }
@keyframes aparecer { from { opacity: 0; } }
.modal {
  background: var(--panel); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; max-height: 92dvh; overflow-y: auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: subir .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes subir { from { transform: translateY(24px); } }
.modal-cab { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-cab h2 { flex: 1; }
.cerrar {
  border: 0; background: #f0f0f5; width: 34px; height: 34px; border-radius: 50%;
  font-size: 19px; line-height: 1; cursor: pointer; color: var(--texto-2); flex: 0 0 auto;
}

/* ---------- Avisos ---------- */
.avisos { position: fixed; left: 12px; right: 12px; bottom: calc(var(--barra-inf) + 12px); z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.aviso-msg {
  background: #16161d; color: #fff; padding: 12px 14px; border-radius: 11px;
  font-size: 14px; box-shadow: var(--sombra); animation: aparecer .18s ease;
}
.aviso-msg.malo { background: var(--alerta); }
.aviso-msg.bueno { background: var(--ok); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 22px; }
.login .caja { width: 100%; max-width: 380px; }
.login .logo-grande {
  width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px;
  background: var(--primario); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 24px; overflow: hidden;
}
.login .logo-grande img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Listas de citas ---------- */
.cita { display: flex; gap: 11px; padding: 12px; align-items: flex-start; }
.cita .hora {
  flex: 0 0 62px; text-align: center; background: var(--primario-suave); color: var(--primario);
  border-radius: 10px; padding: 7px 4px; font-weight: 800; font-size: 13px; line-height: 1.2;
}
.cita .hora small { display: block; font-size: 9.5px; font-weight: 700; opacity: .7; }
.cita.cancelada { opacity: .5; }
.cita.cancelada .nombre { text-decoration: line-through; }
.cita .nombre { font-weight: 700; font-size: 15.5px; }
.linea-pagos { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }

.totales { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--borde); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.totales div { background: var(--panel); padding: 11px 12px; }
.totales dt, .totales .et { font-size: 11px; color: var(--texto-2); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.totales .va { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Tabla de corte ---------- */
.corte-tabla { width: 100%; border-collapse: collapse; }
.corte-tabla td { padding: 11px 12px; border-bottom: 1px solid var(--borde); font-size: 14px; }
.corte-tabla td.et { font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--texto-2); letter-spacing: .02em; }
.corte-tabla td.et small { display: block; font-weight: 500; text-transform: none; font-size: 11.5px; letter-spacing: 0; }
.corte-tabla td.va { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.corte-tabla tr.fuerte td { background: #fafaff; font-size: 15px; }
.corte-tabla tr.fuerte td.et { color: var(--texto); }
.corte-tabla tr.final td { background: var(--primario); color: #fff; font-size: 16px; border: 0; }
.corte-tabla tr.final td.et { color: #fff; }
.corte-tabla tr.final td.et small { color: #e5d9ff; }

.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table.datos { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
table.datos th, table.datos td { padding: 9px 8px; border-bottom: 1px solid var(--borde); text-align: left; white-space: nowrap; }
table.datos th { font-size: 11px; text-transform: uppercase; color: var(--texto-2); letter-spacing: .02em; }
table.datos td.num, table.datos th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.datos tr.total td { font-weight: 800; border-top: 2px solid var(--texto); }

.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.lista-simple li:last-child { border-bottom: 0; }

.icono-btn { border: 0; background: none; padding: 6px; cursor: pointer; color: var(--texto-2); border-radius: 8px; line-height: 0; }
.icono-btn:hover { background: #f0f0f5; }
.icono-btn svg { width: 19px; height: 19px; }
.icono-btn.peligro { color: var(--alerta); }

.seccion-titulo { display: flex; align-items: center; gap: 8px; margin: 20px 2px 9px; }
.seccion-titulo h2 { flex: 1; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--texto-2); }

/* ---------- Escritorio ---------- */
@media (min-width: 860px) {
  :root { --barra-inf: 0px; }
  .nav {
    position: sticky; top: 0; height: 100dvh; width: 208px; flex-direction: column;
    border-top: 0; border-right: 1px solid var(--borde); padding: 14px 10px; gap: 4px;
  }
  .nav button { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 11px; font-size: 14.5px; padding: 11px 13px; border-radius: 10px; }
  .nav button.activo { background: var(--primario-suave); }
  .marco { display: flex; align-items: flex-start; }
  .marco > .pantalla { flex: 1; min-width: 0; padding-bottom: 30px; }
  .contenido { padding: 20px 24px; }
  .fab { bottom: 26px; right: 26px; }
  .modal-capa { align-items: center; }
  .modal { border-radius: 18px; max-height: 88dvh; }
  .avisos { left: auto; right: 22px; bottom: 22px; width: 340px; }
  .totales { grid-template-columns: repeat(4, 1fr); }
  .lista-citas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .lista-citas .tarjeta { margin-bottom: 0; }
}

@media print {
  .nav, .fab, .cabecera, .avisos, .no-imprimir { display: none !important; }
}
