:root {
  --bg: #fef9f4;
  --card: #ffffff;
  --ink: #3a3238;
  --muted: #8a7f87;
  --accent: #ff8a65;
  --accent-dark: #e8734f;
  --blue: #64b5f6;
  --green: #66bb6a;
  --red: #ef5350;
  --border: #f0e4da;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

header.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

header.topbar .brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent-dark);
  text-decoration: none;
}

nav.mainnav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

nav.mainnav a {
  text-decoration: none;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
}

nav.mainnav a:hover, nav.mainnav a.active {
  background: var(--accent);
  color: white;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

h1 { font-size: 1.6rem; margin: 0 0 6px; color: #7209b7; font-weight: 900; }
h2 { font-size: 1.2rem; color: #2a9d8f; font-weight: 800; }
p.subtitle { color: var(--muted); margin-top: 0; }

.nombre-color { font-weight: 800; text-decoration: none; }
.nombre-color:hover { text-decoration: underline; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat .num { font-size: 2rem; font-weight: 800; color: var(--accent-dark); }
.stat .label { color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  border: none;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: var(--blue); }
.btn.secondary:hover { background: #4a9fe0; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.big { font-size: 1.1rem; padding: 16px 26px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

form.filtros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 16px;
}
form.filtros label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
select, input[type=text], input[type=date], input[type=file] {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: white;
  color: var(--ink);
}

table { width: 100%; border-collapse: collapse; }
table th, table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
table th { color: var(--muted); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; }

.badge {
  display: inline-block;
  background: #fff1ea;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-grado { background: #4361ee; color: white; }
.badge-grupo { background: #f72585; color: white; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: #e6f6e6; color: #2e7d32; }
.flash.error { background: #fdecea; color: #c62828; }

.alumno-row { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border);
  background: #f2ece6;
}

.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.formgrid .full { grid-column: 1 / -1; }
.formgrid label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }

@media (max-width: 640px) {
  .formgrid { grid-template-columns: 1fr; }
}

/* ---------------- Bitácora de clase ---------------- */
.muted { color: var(--muted); font-size: 0.88rem; }
.bit-top { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 12px; }
.bit-fecha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.bit-fecha label { font-weight: 700; }
.bit-fecha input[type=date] { font-size: 1.05rem; padding: 10px 12px; }

textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 2px solid var(--border);
  font-size: 1.05rem; font-family: inherit; color: var(--ink); resize: vertical;
}

.grupos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.grupo-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.grupo-card .btn { text-align: center; }
.grupo-nombre { text-decoration: none; font-size: 2.4rem; font-weight: 900; line-height: 1.1; }
.grupo-nombre small { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.destino { width: 100%; padding: 18px; border-radius: 16px; border: 3px solid var(--border);
  background: #fff; font-size: 1.25rem; font-weight: 800; color: var(--ink); cursor: pointer; margin-bottom: 14px; }
.destino.sel { border-color: #7209b7; background: #f3e5fa; color: #7209b7; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
  border-radius: 14px; border: 3px solid var(--border); background: #fff; cursor: pointer; font-family: inherit; }
.tile img { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; background: #f2ece6; }
.tile-vacio { width: 62px; height: 62px; border-radius: 50%; background: #f2ece6; font-size: 2rem;
  display: flex; align-items: center; justify-content: center; }
.tile-nombre { font-weight: 800; font-size: 0.95rem; color: var(--ink); }
.tile-apellido { font-size: 0.78rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.sel { border-color: #7209b7; background: #f3e5fa; box-shadow: 0 0 0 3px rgba(114,9,183,.25); }

.etiquetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.etq { padding: 16px 12px; border-radius: 16px; border: 3px solid var(--border); background: #fff;
  font-size: 1.05rem; font-weight: 700; color: var(--ink); cursor: pointer; font-family: inherit; text-align: left; }
.etq-emoji { font-size: 1.5rem; margin-right: 4px; }
.etq.sel { border-color: #2a9d8f; background: #e0f5f1; color: #1d7a6f; }

.btn.mic { margin-top: 10px; width: 100%; font-size: 1.15rem; padding: 16px; background: #4361ee; }
.btn.mic.on { background: #e63946; animation: pulso 1.2s infinite; }
@keyframes pulso { 50% { opacity: .7; } }

.guardar-barra { position: sticky; bottom: 0; z-index: 20; background: rgba(254,249,244,.97);
  border-top: 2px solid var(--border); padding: 10px 4px 12px; margin: 0 -4px 18px; }
.guardar-para { font-size: 0.9rem; font-weight: 700; color: var(--muted); margin-bottom: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.guardar { width: 100%; font-size: 1.25rem; padding: 18px; background: #43aa8b; }
.btn.guardar:disabled { background: #cfc6cc; cursor: not-allowed; }

.nota { border-bottom: 1px solid var(--border); padding: 12px 0; }
.nota:last-child { border-bottom: none; }
.nota-cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nota-etq { font-weight: 700; color: #1d7a6f; margin-top: 4px; }
.nota-txt { margin-top: 4px; white-space: pre-wrap; }
.nota-acc { margin-top: 8px; display: flex; gap: 8px; }
.nota-acc .btn { padding: 7px 14px; font-size: 0.85rem; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(30px);
  background: #2b2430; color: white; padding: 12px 20px; border-radius: 999px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 92vw; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.fechas-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 8px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--border);
  text-decoration: none; color: var(--ink); font-weight: 700; font-size: 0.9rem; }
.chip.sel { background: #7209b7; border-color: #7209b7; color: white; }

.resumen-dia h3 { margin: 18px 0 6px; color: #7209b7; }
.res-lista { margin: 4px 0 10px; padding-left: 22px; }
.res-lista li { margin-bottom: 6px; }
.res-etq { font-weight: 700; color: #1d7a6f; margin-right: 6px; }
.res-alumno { margin: 10px 0 14px; }

.etq-fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }

@media print {
  header.topbar, .no-print, .toast { display: none !important; }
  body { background: white; }
  .card { border: none; padding: 0; }
}

/* Informe del día */
.acciones-informe { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.acciones-informe .btn { text-align: center; flex: 1 1 200px; }
.acciones-informe .btn:disabled { opacity: .5; cursor: not-allowed; }
.informe { padding: 26px 22px; }
.informe-fecha { text-align: center; font-weight: 700; }
.informe-titulo { text-align: center; font-size: 1.6rem; font-weight: 900; color: #7209b7; margin-top: 4px; }
.informe-materia { text-align: center; color: var(--muted); margin-bottom: 8px; }
.informe-grupo { color: #4361ee; border-bottom: 2px solid var(--border); padding-bottom: 4px; margin-top: 26px; }
.informe h3 { margin: 12px 0 4px; }

/* Reportes */
.reporte-resuelto { opacity: .75; }
#tipos { grid-template-columns: 1fr 1fr; }
#tipos .etq { padding: 14px 8px; font-size: 1rem; }

.correo-opciones { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -6px 0 18px; font-size: 0.92rem; }
.correo-opciones label { font-weight: 700; }
.correo-opciones select { font-size: 1rem; padding: 8px 10px; }
.correo-destino { margin: -8px 0 18px; font-size: 0.92rem; }
.correo-destino .muted { margin-top: 4px; }

/* ---------------- Foto del alumno (cámara) ---------------- */
.tile { position: relative; }
.tile .foto-ok { display: none; position: absolute; top: 3px; right: 5px; font-size: 0.8rem; }
.tile.con-foto .foto-ok { display: block; }
.guardar-fila { display: flex; gap: 10px; }
.btn.foto { flex: 0 0 auto; font-size: 1.1rem; padding: 18px 20px; background: #4361ee; }
.btn.foto:disabled { background: #cfc6cc; cursor: not-allowed; }
.guardar-fila .btn.guardar { flex: 1; }

.camara { position: fixed; inset: 0; z-index: 400; background: #111; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; padding: 14px 12px 18px; color: white; }
.camara[hidden] { display: none; }
.camara-nombre { font-size: 1.25rem; font-weight: 800; text-align: center; padding: 4px 8px; }
.camara-visor { position: relative; width: min(94vw, 62vh); aspect-ratio: 1 / 1; border-radius: 18px;
  overflow: hidden; background: #000; }
.camara-visor video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camara-visor video.espejo { transform: scaleX(-1); }
.camara-guia { position: absolute; inset: 9%; border: 3px dashed rgba(255,255,255,.8); border-radius: 50%; pointer-events: none; }
.camara-flash { position: absolute; inset: 0; background: white; opacity: 0; pointer-events: none; transition: opacity .15s; }
.camara-flash.on { opacity: .85; transition: none; }
.camara-msg { min-height: 44px; text-align: center; font-weight: 700; padding: 0 10px; font-size: .95rem; }
.camara-msg .btn { margin-top: 8px; }
.camara-botones { display: flex; align-items: center; justify-content: space-around; width: 100%; max-width: 460px; }
.camara-lado { background: none; border: none; color: white; font-size: 1.7rem; cursor: pointer; width: 84px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.camara-lado small { font-size: .78rem; font-weight: 700; }
.disparo { width: 84px; height: 84px; border-radius: 50%; border: 6px solid white; background: #e63946;
  box-shadow: 0 0 0 4px rgba(255,255,255,.25); cursor: pointer; }
.disparo:active { background: #b5232f; transform: scale(.95); }
.disparo:disabled { opacity: .5; }
.guardar-fila .btn { padding: 14px 14px; font-size: 1.05rem; }
.btn.foto { padding: 14px 16px; }
