:root {
  --bg: #0f0f12;
  --bg-card: #1a1a22;
  --bg-elevated: #242430;
  --text: #f5f5f7;
  --text-muted: #9b9bab;
  --pink: #ff2d8a;
  --pink-soft: rgba(255, 45, 138, 0.15);
  --pink-glow: rgba(255, 45, 138, 0.35);
  --cyan: #00e5ff;
  --present: #22c55e;
  --present-bg: rgba(34, 197, 94, 0.12);
  --absent: #ef4444;
  --absent-bg: rgba(239, 68, 68, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Outfit", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--pink-glow), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(0, 229, 255, 0.08), transparent 50%),
    var(--bg);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(88px + var(--safe-bottom));
}

.header {
  padding: 20px 20px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink), #c026d3);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  box-shadow: 0 8px 24px var(--pink-glow);
}

.brand-kicker {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--pink);
  font-weight: 700;
}

.brand-title {
  margin: 2px 0 0;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}

.header-date {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}

.tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--pink-soft);
  border-color: rgba(255, 45, 138, 0.45);
  color: var(--text);
}

.tab-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel,
.stats,
.toolbar,
.list-wrap {
  padding-left: 20px;
  padding-right: 20px;
}

.sede-panel {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-select,
.field-text,
.field-search {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  outline: none;
}

.field-select:focus,
.field-text:focus,
.field-search:focus {
  border-color: rgba(255, 45, 138, 0.6);
  box-shadow: 0 0 0 3px var(--pink-soft);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-present .stat-value { color: var(--present); }
.stat-absent .stat-value { color: var(--absent); }
.stat-total .stat-value { color: var(--cyan); }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.search-wrap {
  flex: 1;
}

.hint {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.student-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 14px 14px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.student-item:active {
  transform: scale(0.985);
}

.student-item.present {
  border-color: rgba(34, 197, 94, 0.25);
  background: var(--present-bg);
}

.student-item.absent {
  border-color: rgba(239, 68, 68, 0.45);
  background: var(--absent-bg);
}

.student-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 800;
}

.student-item.present .student-check {
  border-color: var(--present);
  background: var(--present);
  color: #052e16;
}

.student-item.absent .student-check {
  border-color: var(--absent);
  background: var(--absent);
  color: #fff;
}

.student-name {
  flex: 1;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.25;
}

.student-item.absent .student-name {
  text-decoration: line-through;
  opacity: 0.9;
}

.btn-baja {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-baja:hover,
.btn-baja:focus {
  color: var(--absent);
  background: rgba(239, 68, 68, 0.1);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px;
}

.loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--pink);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(15, 15, 18, 0.92) 24%, var(--bg) 60%);
  backdrop-filter: blur(8px);
}

.footer .btn-save {
  max-width: 480px;
  margin: 0 auto;
  display: block;
  width: 100%;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-save {
  background: linear-gradient(135deg, var(--pink), #c026d3);
  color: #fff;
  font-size: 1.05rem;
  box-shadow: 0 8px 28px var(--pink-glow);
}

.btn-primary {
  background: var(--pink);
  color: #fff;
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: end center;
  padding: 20px;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-card {
  position: relative;
  width: min(100%, 420px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 400px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 200;
  font-weight: 600;
  text-align: center;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.5);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast[hidden] {
  display: none !important;
}

@media (min-width: 481px) {
  .app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
}
