/* ============================================================
   INSTITUTO INTERNACIONAL DE GESTION DEPORTIVA
   Sistema Académico - Estilos Principales
   Paleta: Navy #1a2456 | Naranja #e84b2a | Fondo #f0f2f8
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400&family=Barlow+Condensed:wght@500;700;800&display=swap');

:root {
  --navy:        #1a2456;
  --navy-dark:   #0f1635;
  --navy-light:  #2d3a6b;
  --orange:      #e84b2a;
  --orange-dark: #c43a1e;
  --orange-light:#ff6b4d;
  --bg:          #f0f2f8;
  --bg-card:     #ffffff;
  --text:        #1e2235;
  --text-muted:  #6b7280;
  --border:      #d1d8e8;
  --success:     #0d9488;
  --warning:     #d97706;
  --danger:      #dc2626;
  --info:        #2563eb;
  --sidebar-w:   260px;
  --header-h:    64px;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(26,36,86,.10);
  --shadow-lg:   0 8px 32px rgba(26,36,86,.16);
  --transition:  0.22s cubic-bezier(.4,0,.2,1);
  --font-main:   'Barlow', sans-serif;
  --font-cond:   'Barlow Condensed', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ============================================================ SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-light); }

/* ============================================================ LAYOUT */
.layout { display: flex; min-height: 100vh; }

/* ============================================================ SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
}

.sidebar-brand img { width: 36px; height: 36px; object-fit: contain; }

.sidebar-brand-text {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.sidebar-brand-text span { color: var(--orange); }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-title {
  font-family: var(--font-cond);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 14px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(232,75,42,.15);
  color: #fff;
  border-left-color: var(--orange);
}

.nav-item.active .nav-icon { color: var(--orange); }

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg { width: 18px; height: 18px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: rgba(255,255,255,.4);
  text-align: center;
}

/* ============================================================ MAIN */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================ HEADER */
.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-family: var(--font-cond);
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.breadcrumb a { color: var(--orange); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: var(--bg);
  border-radius: 50px;
  cursor: pointer;
  transition: background var(--transition);
}

.user-chip:hover { background: var(--border); }

.user-avatar-sm {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-chip-info { line-height: 1.2; }
.user-chip-name { font-size: 13px; font-weight: 600; }
.user-chip-role { font-size: 11px; color: var(--text-muted); }

/* ============================================================ CONTENT */
.content {
  flex: 1;
  padding: 28px;
}

/* ============================================================ CARDS */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-family: var(--font-cond);
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
}

.card-body { padding: 24px; }

/* ============================================================ STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--navy));
}

.stat-card-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-bg, rgba(26,36,86,.08));
}

.stat-card-icon svg { width: 22px; height: 22px; color: var(--accent, var(--navy)); }

.stat-card-value {
  font-family: var(--font-cond);
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  color: var(--navy);
}

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================ TABLES */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data-table thead th {
  background: var(--navy);
  color: #fff;
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}

table.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

table.data-table tbody tr:hover { background: rgba(26,36,86,.03); }

table.data-table tbody td {
  padding: 11px 16px;
  vertical-align: middle;
}

table.data-table tbody tr:last-child { border-bottom: none; }

/* ============================================================ BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover { background: var(--orange-dark); transform: translateY(-1px); }

.btn-secondary {
  background: var(--navy);
  color: #fff;
}
.btn-secondary:hover { background: var(--navy-light); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--navy); background: var(--bg); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 9px; font-size: 11px; border-radius: 6px; }
.btn-icon { padding: 8px; }
.btn-icon svg { width: 16px; height: 16px; }

/* ============================================================ FORMS */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,75,42,.12);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 90px; }

select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================ BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-success { background: rgba(13,148,136,.12); color: #0d7a72; }
.badge-danger  { background: rgba(220,38,38,.12); color: #b91c1c; }
.badge-warning { background: rgba(217,119,6,.12); color: #b45309; }
.badge-info    { background: rgba(37,99,235,.12); color: #1d4ed8; }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================ AVATAR */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.avatar-lg { width: 72px; height: 72px; }
.avatar-xl { width: 100px; height: 100px; }

.avatar-placeholder {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

/* ============================================================ SEARCH BOX */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  padding-left: 38px;
  width: 280px;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  max-height: 340px;
  overflow-y: auto;
  z-index: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  display: none;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.search-result-item:hover { background: var(--bg); }
.search-result-item:last-child { border-bottom: none; }

/* ============================================================ MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,22,53,.55);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .22s cubic-bezier(.4,0,.2,1);
}

.modal-lg { max-width: 900px; }
.modal-sm { max-width: 420px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-cond);
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body { padding: 24px; overflow-y: auto; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================ ALERTS */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(13,148,136,.1); color: #0f5f59; border: 1px solid rgba(13,148,136,.2); }
.alert-danger   { background: rgba(220,38,38,.1);  color: #7f1d1d; border: 1px solid rgba(220,38,38,.2); }
.alert-warning  { background: rgba(217,119,6,.1);  color: #78350f; border: 1px solid rgba(217,119,6,.2); }
.alert-info     { background: rgba(37,99,235,.1);  color: #1e3a8a; border: 1px solid rgba(37,99,235,.2); }

/* ============================================================ TABS */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  font-family: var(--font-cond);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================ FILE UPLOAD */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.file-drop:hover, .file-drop.drag-over {
  border-color: var(--orange);
  background: rgba(232,75,42,.04);
}

.file-drop-icon { color: var(--text-muted); margin-bottom: 10px; }
.file-drop-text { font-size: 13px; color: var(--text-muted); }
.file-drop-text strong { color: var(--orange); }

/* ============================================================ PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 16px;
}

.page-btn {
  min-width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text);
}

.page-btn:hover { border-color: var(--orange); color: var(--orange); }
.page-btn.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================ CUOTAS */
.cuota-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  transition: background var(--transition);
}

.cuota-row:hover { background: var(--bg); }

/* ============================================================ PAYMENT RECEIPT */
.receipt {
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.receipt-header {
  background: var(--navy);
  color: #fff;
  padding: 20px 24px;
  text-align: center;
  border-radius: var(--radius) var(--radius) 0 0;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
}

.receipt-total {
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ============================================================ CHART WRAPPER */
.chart-wrapper {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ============================================================ GRID UTILITIES */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-4 { margin-top: 16px; }

.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-orange { color: var(--orange); }
.text-navy { color: var(--navy); }
.text-right { text-align: right; }
.text-center { text-align: center; }

.fw-bold { font-weight: 700; }
.font-cond { font-family: var(--font-cond); }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ============================================================ LOGIN PAGE */
.login-page {
  min-height: 100vh;
  background: var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(232,75,42,.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(45,58,107,.5) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 48px 44px;
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo img { max-width: 220px; }

.login-title {
  font-family: var(--font-cond);
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}

.login-footer {
  text-align: center;
  color: rgba(255,255,255,.4);
  font-size: 11px;
  position: absolute;
  bottom: 20px;
  left: 0; right: 0;
}


/* ============================================================
   RESPONSIVE — MOBILE FIRST
   Breakpoints: 1024 (tablet) | 768 (mobile) | 480 (small)
   ============================================================ */

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,15,40,.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Tablet ≤ 1024px ──────────────────────────────────────── */

/* ================================================================
   RESPONSIVE DESIGN COMPLETO
   Breakpoints:
     1280px  →  Desktop grande
     1024px  →  Tablet landscape / Laptop pequeño
     768px   →  Tablet portrait / Móvil grande
     480px   →  Móvil estándar
     360px   →  Móvil pequeño
   ================================================================ */

/* ── Overlay del sidebar (móvil) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,15,40,.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity .25s;
}
.sidebar-overlay.active { display: block; }

/* ── Asegurar que imágenes y contenedores no desborden ──────────── */
*, *::before, *::after { box-sizing: border-box; }
img { max-width: 100%; height: auto; }
input, select, textarea, button { max-width: 100%; }

/* ── Scrollbar horizontal en tablas ─────────────────────────────── */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* ====================================================
   ≤ 1280px  Desktop mediano
   ==================================================== */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ====================================================
   ≤ 1024px  Tablet landscape / Laptop
   ==================================================== */
@media (max-width: 1024px) {

  /* ── Sidebar: drawer deslizable ── */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 40px rgba(0,0,0,.35);
  }
  .main { margin-left: 0 !important; }

  /* ── Mostrar botón hamburguesa ── */
  #sidebarToggle { display: flex !important; }

  /* ── Topbar ── */
  .topbar { padding: 0 14px; gap: 8px; }
  .user-chip-info { display: none; }
  .breadcrumb { font-size: 12px; }

  /* ── Grids ── */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* ── Tablas ── */
  table.data-table { min-width: 600px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
}

/* ====================================================
   ≤ 768px  Tablet portrait / Móvil grande
   ==================================================== */
@media (max-width: 768px) {

  :root { --header-h: 56px; }

  /* ── Layout general ── */
  .content { padding: 12px; }

  /* ── Topbar ── */
  .topbar { padding: 0 12px; height: var(--header-h); }
  .breadcrumb { display: none; }
  .page-title { font-size: 16px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 6px; }

  /* ── Sidebar ── */
  .sidebar { width: 260px; }
  .nav-item { padding: 12px 18px; min-height: 48px; font-size: 14px; }

  /* ── Grids: todo a 1 columna ── */
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr !important; gap: 12px; }

  /* ── Stats: 2 columnas en móvil grande ── */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }

  /* ── Formularios ── */
  .form-row,
  .form-row-2,
  .form-row-3 { grid-template-columns: 1fr !important; gap: 0; }

  /* ── Cards ── */
  .card-header { flex-direction: column; align-items: flex-start; padding: 12px 14px; }
  .card-header .card-title { font-size: 14px; }
  .card-header .btn,
  .card-header a.btn { align-self: stretch; justify-content: center; }
  .card-body { padding: 14px; }

  /* ── Stat cards ── */
  .stat-card { padding: 14px 12px; }
  .stat-card-value { font-size: 20px; }
  .stat-card-icon { width: 36px; height: 36px; }
  .stat-card-icon svg { width: 18px; height: 18px; }

  /* ── Tablas ── */
  table.data-table { min-width: 520px; font-size: 12px; }
  table.data-table thead th,
  table.data-table tbody td { padding: 8px 10px; }

  /* ── Botones touch-friendly ── */
  .btn { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .btn-sm { min-height: 36px; padding: 6px 12px; font-size: 12px; }
  .btn-xs { min-height: 30px; }
  .btn-icon { min-width: 40px; min-height: 40px; }

  /* ── Formularios filter (inline flex) ── */
  form[style*="display:flex"],
  form[style*="display: flex"] { flex-wrap: wrap !important; gap: 8px !important; }
  form .form-control[style*="width"] { width: 100% !important; min-width: 0 !important; }

  /* ── Inputs y selects ── */
  .form-control { font-size: 14px; }
  select.form-control[style*="width"] { width: 100% !important; }
  input.form-control[style*="width"] { width: 100% !important; }

  /* ── Alerts ── */
  .alert { font-size: 13px; padding: 10px 14px; }

  /* ── Badges ── */
  .badge { font-size: 10px; padding: 3px 8px; }

  /* ── Page header row ── */
  .page-header,
  div[style*="justify-content:flex-end"][style*="margin-bottom"],
  div[style*="justify-content:space-between"][style*="margin-bottom"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* ── Modales ── */
  .modal { margin: 12px; max-width: calc(100vw - 24px) !important; max-height: calc(100vh - 24px); }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; justify-content: center; min-width: 100px; }

  /* ── Upload zones ── */
  .dz-hover { padding: 16px !important; }

  /* ── Dropdowns de búsqueda ── */
  .search-results-dropdown,
  #dropAlumno {
    max-width: calc(100vw - 32px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }

  /* ── Recibo / impresión ── */
  div[style*="max-width:580px"],
  div[style*="max-width:600px"],
  div[style*="max-width:560px"] {
    max-width: 100% !important;
    padding: 0 10px !important;
  }

  /* ── Div con grid-template en inline style ── */
  div[style*="grid-template-columns:repeat(3"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:repeat(4"] { grid-template-columns: repeat(2,1fr) !important; }

  /* ── Texto largo en celdas ── */
  .data-table td[style*="white-space:nowrap"] { white-space: normal !important; }

  /* ── Paginación ── */
  .pagination,
  div[style*="display:flex"][style*="gap:4px"] { flex-wrap: wrap; gap: 4px; }

  /* ── Login ── */
  .login-page { align-items: flex-start; padding: 20px 0; }
  .login-card { padding: 28px 18px; border-radius: 12px; }
  .login-title { font-size: 20px; }
  .login-logo img { max-width: 160px; }
}

/* ====================================================
   ≤ 480px  Móvil estándar
   ==================================================== */
@media (max-width: 480px) {

  .content { padding: 8px; }

  /* ── Sidebar más angosta ── */
  .sidebar { width: 240px; }

  /* ── Stats: 1 columna ── */
  .stats-grid { grid-template-columns: 1fr !important; }

  /* ── Topbar ultra compacto ── */
  .page-title { font-size: 15px; max-width: 140px; }
  .user-chip span,
  .user-avatar-sm + div { display: none; }
  .user-avatar-sm { width: 30px; height: 30px; font-size: 11px; }
  .topbar-right .btn-outline:not(#sidebarToggle) { display: none; }

  /* ── Tablas compactas ── */
  table.data-table { min-width: 420px; font-size: 11px; }
  table.data-table thead th,
  table.data-table tbody td { padding: 7px 8px; }

  /* ── Cards ajustadas ── */
  .card-body { padding: 10px; }
  .card-header { padding: 10px 12px; }

  /* ── Stat card horizontal en pantalla muy pequeña ── */
  .stat-card { padding: 10px 12px; gap: 10px; }
  .stat-card-value { font-size: 18px; }

  /* ── Botones full width en acciones principales ── */
  .card-body > div[style*="display:flex"] > .btn,
  .card-body > div[style*="display:flex"] > a.btn { flex: 1; justify-content: center; }

  /* ── Grilla de formas de pago (pagos) ── */
  div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* ── Grilla de notas (calificaciones) ── */
  div[style*="grid-template-columns:repeat(5"] { grid-template-columns: repeat(3,1fr) !important; }

  /* ── Recibo ── */
  div[style*="max-width:580px"],
  div[style*="max-width:600px"],
  div[style*="max-width:560px"] { padding: 0 4px !important; margin: 10px auto !important; }

  /* ── Login ── */
  .login-card { padding: 24px 14px; margin: 0 12px; }
  .login-logo img { max-width: 140px; }
  .login-title { font-size: 18px; }

  /* ── Modales full screen en móvil pequeño ── */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { margin: 0; border-radius: 14px 14px 0 0; max-height: 92vh; width: 100% !important; max-width: 100% !important; }

  /* ── Ocultar columnas no críticas en tablas ── */
  .table-hide-xs { display: none !important; }
}

/* ====================================================
   ≤ 360px  Móvil pequeño
   ==================================================== */
@media (max-width: 360px) {
  .content { padding: 6px; }
  .sidebar { width: 220px; }
  .page-title { font-size: 13px; max-width: 110px; }
  table.data-table { min-width: 360px; font-size: 10px; }
  .btn { padding: 7px 10px; font-size: 12px; }
  .stat-card-value { font-size: 16px; }
}

/* ====================================================
   Landscape móvil
   ==================================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar { overflow-y: auto; }
  :root { --header-h: 50px; }
  .modal { max-height: 90vh; }
  .stats-grid { grid-template-columns: repeat(4,1fr) !important; }
}

/* ====================================================
   IMPRESIÓN
   ==================================================== */
@media print {
  .sidebar,
  .topbar,
  .sidebar-overlay,
  #sidebarToggle,
  .btn:not(.btn-print),
  .modal-overlay,
  nav,
  form[method="GET"] { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc; page-break-inside: avoid; }
  table.data-table { min-width: unset !important; font-size: 10px; }
  .table-container { overflow: visible !important; }
  .badge { border: 1px solid currentColor; }
  body { font-size: 12px; }
}

/* ====================================================
   ANIMACIONES Y UTILIDADES
   ==================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease forwards; }

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-pg { to { transform: rotate(360deg); } }
@keyframes spin-anim { to { transform: rotate(360deg); } }

/* ── Login responsive ── */
@media (max-width: 480px) {
  .login-card { padding: 28px 16px; border-radius: 12px; }
}
