/* ══════════ Base ══════════ */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --line: #e2e8f0;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-soft: #fff7ed;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --whatsapp: #25d366;
  --whatsapp-dark: #1eb455;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

h1, h2 { margin: 0; }

button { font: inherit; cursor: pointer; }

input[type="text"], input[type="tel"], input[type="password"],
input[type="number"], input[type="date"], input[type="month"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* ══════════ Login ══════════ */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #ea580c 160%);
}
.login-card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 36px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { font-size: 56px; line-height: 1; margin-bottom: 12px; }
.login-card h1 { font-size: 26px; letter-spacing: -0.02em; }
.login-sub { color: var(--ink-soft); margin: 8px 0 24px; }
#login-pin { text-align: center; font-size: 22px; letter-spacing: 8px; }

/* ══════════ Layout ══════════ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f172a;
  color: #fff;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
}
.topbar-logo { font-size: 26px; }
.topbar-text { display: flex; flex-direction: column; min-width: 0; }
.topbar-brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-view {
  font-size: 12.5px;
  font-weight: 600;
  color: #fdba74;
  margin-top: 1px;
}

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
}

.view { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.muted { font-weight: 400; color: #94a3b8; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 0; padding: 0 4px; }
.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 16px;
  line-height: 1.6;
}
.form-error { color: var(--danger); font-size: 14px; margin: 10px 0; }
.form-success { color: var(--green); font-weight: 600; text-align: center; margin: 12px 0 0; }
.check-label { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.check-label input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ══════════ Buttons ══════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  min-height: 50px;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { background: var(--whatsapp-dark); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line); }
.btn-small {
  padding: 8px 14px;
  min-height: 38px;
  font-size: 14px;
  border-radius: 10px;
}

/* ══════════ Asistencia ══════════ */
.attendance-list { display: flex; flex-direction: column; gap: 10px; }
.attend-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.attend-check {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 17px;
  font-weight: 800;
  transition: all 0.15s ease;
}
.attend-card.present {
  border-color: var(--green);
  background: var(--green-soft);
}
.attend-card.present .attend-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ══════════ Alumnos ══════════ */
.students-list { display: flex; flex-direction: column; gap: 10px; }
.student-card {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.student-card.inactive { opacity: 0.55; }
.student-info { min-width: 0; }
.student-name { font-weight: 700; font-size: 16.5px; }
.student-meta {
  color: var(--ink-soft);
  font-size: 13.5px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-inactive {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ══════════ Resumen ══════════ */
.summary-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.total-tile {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.total-tile .tile-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.total-tile .tile-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.total-tile.money .tile-value { color: var(--accent-dark); }

.summary-list { display: flex; flex-direction: column; gap: 10px; }
.summary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.summary-info { min-width: 0; }
.summary-kid { font-weight: 700; font-size: 16.5px; }
.summary-detail { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }
.summary-price { font-weight: 800; color: var(--accent-dark); }
.sent-tag {
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.summary-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ══════════ Tab bar ══════════ */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 10px 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab-icon { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent-dark); }

/* ══════════ Modales ══════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.3);
  animation: slide-up 0.22s ease;
}
@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h2 { font-size: 20px; margin-bottom: 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* Cola de envío */
.send-progress { color: var(--ink-soft); font-size: 14px; margin: 0 0 12px; }
.send-recipient {
  background: var(--accent-soft);
  border: 1px solid #fed7aa;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}
.send-to { font-weight: 800; margin: 0 0 8px; }
.send-preview {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: #431407;
  white-space: pre-wrap;
}

@media (min-width: 480px) {
  .modal-backdrop { align-items: center; }
}
