:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --accent: #0f766e;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --danger: #dc2626;
  --success: #16a34a;
  --warn-bg: #fef9c3;
  --warn-border: #eab308;
}

* { box-sizing: border-box; font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 13px; }
.w-full { width: 100%; }
.ico { width: 14px; height: 14px; vertical-align: -2px; flex-shrink: 0; }
.btn-primary, .btn-secondary, .btn-tool, .btn-danger, .pane-header > span { display: inline-flex; align-items: center; gap: 5px; }

.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%); padding: 1rem;
}
.login-card {
  background: var(--surface); padding: 2rem; border-radius: 14px;
  width: 100%; max-width: 380px; box-shadow: 0 16px 32px rgba(15, 23, 42, 0.1);
  border: 1px solid var(--border);
}
.login-header { text-align: center; margin-bottom: 1.25rem; }
.logo-circle {
  width: 48px; height: 48px; border-radius: 12px; background: #dbeafe;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 0.5rem;
}
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.35rem; }
.subtitle { margin: 0; color: var(--muted); font-size: 0.85rem; }
.login-card label { display: block; font-size: 0.8rem; margin-bottom: 0.25rem; font-weight: 600; color: var(--muted); }
.login-card input {
  width: 100%; padding: 0.55rem 0.7rem; margin-bottom: 1rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem;
}

.desktop-shell {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

.topbar {
  background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff; padding: 0.45rem 1rem;
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.badge { background: rgba(255,255,255,0.18); padding: 0.18rem 0.6rem; border-radius: 999px; font-size: 0.78rem; }
.year-badge { background: #dc2626; color: #fff; padding: 0.18rem 0.6rem; border-radius: 6px; font-weight: 700; font-size: 0.85rem; }

.filters-bar {
  background: var(--surface); padding: 0.45rem 1rem;
  display: flex; flex-wrap: wrap; gap: 0.65rem; border-bottom: 1px solid var(--border); flex-shrink: 0; align-items: flex-end;
}
.field { display: flex; flex-direction: column; flex: 1; min-width: 150px; }
.cohortes-box, .pct-box { display: flex; flex-direction: column; }
.cohortes-box label, .pct-box label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 0.15rem; }
.cohortes-grid { display: flex; gap: 0.25rem; }
.coh-item {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 5px;
  padding: 0.15rem 0.45rem; text-align: center; min-width: 38px;
}
.coh-item span { display: block; font-size: 0.65rem; color: var(--muted); }
.coh-item strong { font-size: 0.78rem; color: var(--text); }
.pct-box strong {
  background: #e2e8f0; padding: 0.3rem 0.65rem; border-radius: 5px; font-size: 0.85rem; text-align: center;
}
.ctx-menu {
  position: fixed; z-index: 9999; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); padding: 0.3rem 0; min-width: 210px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; background: transparent; border: none;
  padding: 0.4rem 0.85rem; font-size: 0.82rem; cursor: pointer; color: var(--text);
}
.ctx-menu button:hover { background: #eff6ff; color: var(--primary); }
.ctx-menu hr { border: none; border-top: 1px solid var(--border); margin: 0.25rem 0; }
.field label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 0.15rem; }
.field select, input, select {
  padding: 0.32rem 0.5rem; border: 1px solid var(--border); border-radius: 5px;
  font-size: 0.82rem; background: #fff; color: var(--text);
}

.split-top {
  display: grid; grid-template-columns: 58% 42%; gap: 0.5rem;
  padding: 0.5rem 0.75rem 0.25rem; flex: 1; min-height: 0;
}
.pane {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.pane-bottom {
  margin: 0.25rem 0.75rem 0.6rem; height: 34vh; flex-shrink: 0;
}
.pane-header {
  background: #f8fafc; padding: 0.4rem 0.75rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 0.82rem; color: var(--primary); flex-shrink: 0;
}
.pane-actions { display: flex; align-items: center; gap: 0.5rem; }
.sub-badge { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

.table-scroll { flex: 1; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { padding: 0.28rem 0.45rem; border-bottom: 1px solid #e2e8f0; text-align: left; }
th { background: #f1f5f9; position: sticky; top: 0; z-index: 1; font-size: 0.72rem; text-transform: uppercase; color: var(--muted); }
tbody tr:hover { background: #f8fafc; cursor: pointer; }
tbody tr.row-active { background: #dbeafe !important; }
tbody tr.row-dirty { background: var(--warn-bg) !important; box-shadow: inset 3px 0 0 var(--warn-border); }

.col-chk { width: 28px; text-align: center; }
.col-num { width: 38px; text-align: center; color: var(--muted); }
.col-nf { width: 64px; }
.col-nf input { width: 58px; text-align: center; }
.col-vn { width: 110px; }
.col-vn select { width: 100%; }
.col-fal { width: 52px; }
.col-fal input { width: 46px; text-align: center; }
.student-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }

.mid-toolbar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.75rem;
  flex-shrink: 0; flex-wrap: wrap;
}
.search-input { flex: 1; min-width: 200px; }
.add-ind-inline { display: flex; gap: 0.4rem; align-items: center; flex: 1; max-width: 650px; }
.add-ind-inline input { flex: 1; }

.btn-primary { background: var(--primary); color: #fff; border: none; padding: 0.45rem 0.9rem; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: rgba(255,255,255,0.16); color: #fff; border: 1px solid rgba(255,255,255,0.3); padding: 0.25rem 0.65rem; border-radius: 6px; cursor: pointer; font-size: 0.78rem; }
.btn-tool { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 0.32rem 0.7rem; border-radius: 6px; cursor: pointer; font-size: 0.78rem; font-weight: 600; }
.btn-tool:hover:not(:disabled) { background: #f1f5f9; border-color: var(--primary); }
.btn-tool:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 0.25rem 0.5rem; border-radius: 4px; cursor: pointer; }
.btn-danger:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-xs { padding: 0.25rem 0.6rem; font-size: 0.76rem; }

.pill-warn { background: #eab308; color: #fff; padding: 0.1rem 0.45rem; border-radius: 999px; font-size: 0.72rem; }
.tag-saved { background: #dcfce7; color: #166534; padding: 0.12rem 0.45rem; border-radius: 999px; font-size: 0.72rem; }
.tag-locked { background: #fee2e2; color: #991b1b; padding: 0.12rem 0.45rem; border-radius: 999px; font-size: 0.72rem; }
.status-msg { color: var(--success); font-size: 0.78rem; font-weight: 600; }
.error-inline { color: var(--danger); font-size: 0.78rem; font-weight: 600; }
.error-msg { color: var(--danger); font-size: 0.82rem; margin-top: 0.5rem; text-align: center; }
.empty-hint { padding: 1.5rem; text-align: center; color: var(--muted); font-size: 0.82rem; }

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton-bar {
  height: 12px; border-radius: 4px; width: 100%;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.2s infinite linear;
}

.mobile-tabs, .mobile-filter-toggle, .mobile-step-btn {
  display: none;
}
.mobile-student-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 960px) {
  html, body, .desktop-shell {
    height: auto !important;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto !important;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
  }
  .mobile-filter-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: #eef2ff;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
  }
  .filters-bar {
    display: none;
  }
  .filters-bar.mobile-filters-open {
    display: flex;
  }
  .mobile-tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem 0;
  }
  .mobile-tabs button {
    flex: 1;
    padding: 0.55rem 0.4rem;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
  }
  .mobile-tabs button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .mobile-step-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
  }
  .split-top {
    grid-template-columns: 1fr;
    flex: none;
    min-height: auto;
  }
  .pane-bottom .pane-header {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .mobile-hidden {
    display: none !important;
  }
  .pane, .pane-students, .pane-bottom {
    height: auto !important;
    max-height: none !important;
    min-height: 0;
    overflow: visible !important;
  }
  .pane .table-scroll {
    width: 100%;
    overflow-x: auto !important;
    overflow-y: visible !important;
    max-height: none !important;
    -webkit-overflow-scrolling: touch;
  }
  .pane .table-scroll table {
    min-width: 560px;
  }
  .pane-concepts {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }
  .pane-concepts .table-scroll {
    max-height: 220px;
    overflow-y: auto;
  }
  .pane-bottom {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
    margin-bottom: 4.5rem;
  }
  .pane-students input[type="number"] {
    min-width: 52px;
    height: 34px;
    font-size: 0.95rem;
  }
  .table-scroll {
    overflow-x: auto;
    overflow-y: auto;
  }
  .add-ind-inline {
    flex-wrap: wrap;
    max-width: 100%;
  }
}

.mobile-fab {
  display: none;
}

@media (max-width: 960px) {
  .mobile-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 50;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.28);
    cursor: pointer;
  }
}

/* === Móvil: listado de estudiantes compacto (todas las columnas visibles) === */
@media (max-width: 960px) {
  .split-top { grid-template-columns: minmax(0, 1fr) !important; }
  .split-top > .pane { min-width: 0; max-width: 100%; }

  .pane-students .table-scroll { overflow-x: auto !important; overflow-y: visible !important; }
  .pane-students .table-scroll table { min-width: 0 !important; width: 100%; table-layout: fixed; }

  .pane-students th, .pane-students td { padding: 0.25rem 0.2rem; }
  .pane-students th { font-size: 0.6rem; }

  .pane-students .col-chk { width: 24px; }
  .pane-students .col-num { width: 24px; font-size: 0.7rem; }
  .pane-students .student-name {
    white-space: normal; max-width: none; overflow: visible;
    font-size: 0.74rem; line-height: 1.15; word-break: break-word;
  }
  .pane-students .col-nf { width: 50px; }
  .pane-students .col-vn { width: 58px; font-size: 0.64rem; }
  .pane-students .col-fal { width: 40px; }

  .pane-students input[type="number"] {
    min-width: 0 !important; height: 32px; font-size: 0.9rem; padding: 0.2rem; text-align: center;
  }
  .pane-students .col-nf input { width: 46px; }
  .pane-students .col-fal input { width: 36px; }
}

/* === Modal flotante Nuevo / Editar Desempeño === */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.modal-header {
  background: #f8fafc; padding: 0.65rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 0.9rem; color: var(--primary);
}
.modal-body {
  padding: 1rem; display: flex; flex-direction: column;
}
.modal-body label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.25rem;
}
.modal-body textarea {
  width: 100%; padding: 0.55rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; resize: vertical;
  color: var(--text); background: #fff;
}
.char-counter {
  font-size: 0.72rem; text-align: right; margin-top: 0.25rem; font-weight: 600;
}
.modal-footer {
  background: #f8fafc; padding: 0.65rem 1rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.5rem;
}
