:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --text-muted: #78716c;
  --border: #e7e5e4;
  --accent: #1c1917;
  --accent-soft: #f5f5f4;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --transition: 200ms ease;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes logoReveal {
  from { opacity: 0; transform: scale(0.85); filter: blur(8px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(15px, -20px) rotate(2deg); }
  66% { transform: translate(-10px, 10px) rotate(-1deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-container {
  min-height: 100dvh;
  background: #ffffff;
}

.login-split {
  display: grid;
  grid-template-columns: 6fr 4fr;
  min-height: 100dvh;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: #ffffff;
}

.login-logo-wrap {
  animation: logoReveal 1s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.1s;
}

.login-logo {
  width: min(52vw, 700px);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo:hover {
  transform: scale(1.03);
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 3rem;
  background: #fafaf9;
  border-left: 1px solid rgba(0,0,0,0.06);
}

.login-card {
  width: 100%;
  max-width: 340px;
  animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.3s;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .login-split {
    grid-template-columns: 1fr;
  }

  .login-brand {
    padding: 3rem 2rem 1rem;
  }

  .login-logo {
    width: min(80vw, 320px);
  }

  .login-form-side {
    padding: 1.5rem 2rem 3rem;
    border-left: none;
    background: #ffffff;
  }

  .login-title { font-size: 1.3rem; }
}

.input-group {
  position: relative;
  margin-bottom: 1rem;
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.input-group:nth-child(1) { animation-delay: 0.5s; }
.input-group:nth-child(2) { animation-delay: 0.6s; }

.input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: rgba(0,0,0,0.25);
  pointer-events: none;
  transition: color 0.3s ease;
}

.input-group input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.8rem;
  background: rgba(0,0,0,0.03);
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--text);
  font-family: inherit;
  transition: all 0.3s ease;
}

.input-group input::placeholder {
  color: rgba(0,0,0,0.3);
}

.input-group input:focus {
  outline: none;
  border-color: rgba(0,0,0,0.3);
  background: rgba(0,0,0,0.02);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.04);
}

.input-group:focus-within .input-icon {
  color: rgba(0,0,0,0.6);
}

.login-btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: #1c1917;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.7s;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.login-btn:active {
  transform: translateY(0) scale(0.98);
}

.login-btn svg {
  transition: transform 0.3s ease;
}
.login-btn:hover svg {
  transform: translateX(3px);
}

.login-card .error-text {
  color: #dc2626;
  animation: shake 0.4s ease, fadeUp 0.3s ease;
}

.login-card.login-shake {
  animation: shake 0.4s ease;
}

.error-text {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* ── App Layout ── */
.app-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100dvh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-user {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: all var(--transition);
}

.sidebar-logout:hover {
  color: #dc2626;
  background: #fef2f2;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition);
  text-align: left;
}

.sidebar-item:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.sidebar-item.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.sidebar-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.6;
}

.sidebar-item.active svg,
.sidebar-item:hover svg {
  opacity: 1;
}

/* ── App Content ── */
.app-content {
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--bg);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--transition);
}

.btn-primary:hover { opacity: 0.85; }

/* ── Horario Time Grid ── */
.horario-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.horario-header {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(110px, 1fr));
  min-width: 860px;
  border-bottom: 2px solid var(--accent);
}

.horario-corner {
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dia-header {
  text-align: center;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.55rem 0.25rem;
  background: var(--accent);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.horario-scroll {
  overflow: auto;
  max-height: 72vh;
}

.horario-body {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(110px, 1fr));
  min-width: 860px;
}

.horario-times {
  border-right: 1px solid var(--border);
  background: var(--accent-soft);
  position: relative;
}

.time-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
}

.dia-col {
  position: relative;
  border-left: 1px solid var(--border);
}

.hora-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
  pointer-events: none;
  z-index: 0;
}

.hora-line-half {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(0,0,0,0.04);
  pointer-events: none;
  z-index: 0;
}

.clase-card {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
  cursor: pointer;
  border-left: 3px solid;
  overflow: hidden;
  z-index: 1;
  transition: box-shadow var(--transition), transform var(--transition);
}

.clase-card:hover {
  box-shadow: var(--shadow-lg);
  transform: scaleX(1.03);
  z-index: 3;
}

.clase-card .clase-hora {
  font-weight: 700;
  font-size: 0.62rem;
  opacity: 0.65;
  line-height: 1.2;
}

.clase-card .clase-nombre {
  font-weight: 600;
  line-height: 1.2;
  margin-top: 1px;
}

.clase-card .clase-instructor {
  font-size: 0.62rem;
  opacity: 0.55;
  line-height: 1.2;
}

/* ── Card List ── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color var(--transition);
}

.item-card:hover { border-color: var(--accent); }

.item-card .item-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.item-card .item-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.item-card .item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover { border-color: var(--accent); }
.btn-icon.danger:hover { border-color: #dc2626; color: #dc2626; }

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.badge-pendiente {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.badge-pagado {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: #dcfce7;
  color: #166534;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.badge-rechazado {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.mp-banner {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.mp-banner.warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.mp-banner.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.pago-monto {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pago-link-btn {
  background: #0070f3;
  color: white;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: opacity var(--transition);
}

.pago-link-btn:hover { opacity: 0.85; }

.badge-inactive {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ── Member Avatar ── */
.member-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--accent-soft);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.member-avatar span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.foto-upload-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.foto-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.foto-preview:hover {
  border-color: var(--accent);
}

.foto-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.foto-preview .foto-placeholder {
  font-size: 1.5rem;
  color: var(--text-muted);
  opacity: 0.4;
}

.foto-input-wrap {
  flex: 1;
}

.foto-input-wrap input[type="file"] {
  font-size: 0.8rem;
  font-family: inherit;
}

/* ── Stats ── */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  transition: border-color var(--transition);
}

.stat-tile:hover { border-color: var(--accent); }

.stat-tile .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.stat-tile .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-tile .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.stats-card h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

.stats-card-wide {
  grid-column: 1 / -1;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}

.chart-wrap-square {
  height: 240px;
  max-width: 280px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .chart-wrap { height: 220px; }
  .chart-wrap-square { max-width: 240px; height: 200px; }
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea { resize: vertical; min-height: 60px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
}

.btn-secondary:hover { background: var(--border); }

/* ── Detail panel (clase) ── */
.detail-panel {
  margin-top: 1rem;
}

.miembro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.miembro-row:last-child { border-bottom: none; }

.add-miembro-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.add-miembro-row select { flex: 1; }

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 50;
  }
  .sidebar-nav {
    flex-direction: row;
    padding: 0;
    overflow-x: auto;
  }
  .sidebar-item {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 0.6rem 1rem;
    white-space: nowrap;
    justify-content: center;
    flex: 1;
    gap: 0.4rem;
    font-size: 0.78rem;
  }
  .sidebar-item.active {
    border-bottom-color: var(--accent);
    border-left-color: transparent;
  }
  .sidebar-item svg { width: 18px; height: 18px; }
  .app-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .horario-scroll { max-height: 65vh; }
  .member-avatar { width: 38px; height: 38px; }
}
