/* ════════════════════════════════════════════════════════
   PAGOS · High School Steve Jobs — Estilos
   ════════════════════════════════════════════════════════ */

:root {
  --navy:    #1B2E5E;
  --navy-2:  #16254c;
  --yellow:  #F5C518;
  --gn:      #10b981;
  --gn-bg:   #d1fae5;
  --gn-tx:   #065f46;
  --rd:      #ef4444;
  --rd-bg:   #fee2e2;
  --rd-tx:   #991b1b;
  --gy:      #94a3b8;
  --gy-bg:   #e2e8f0;
  --gy-tx:   #475569;
  --bg:      #f1f5f9;
  --card:    #ffffff;
  --ink:     #0f172a;
  --ink2:    #334155;
  --ink3:    #64748b;
  --border:  #e2e8f0;
  --r:       12px;
  --shadow:  0 1px 3px rgba(0,0,0,.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
button { font-family: inherit; }

/* ── LOGIN ─────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-2) 60%, #0e1a38 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: white; border-radius: 18px; padding: 36px 32px;
  width: 400px; max-width: 94vw; text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
}
.login-logo {
  width: 62px; height: 62px; margin: 0 auto 14px;
  background: var(--yellow); color: var(--navy);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; letter-spacing: -1px;
}
.login-title { font-size: 19px; font-weight: 800; color: var(--navy); }
.login-sub   { font-size: 12px; color: var(--ink3); margin: 4px 0 24px; }
.login-input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14px; outline: none; text-align: center;
  transition: border-color .2s;
}
.login-input:focus { border-color: var(--navy); }
.login-err { font-size: 12px; color: var(--rd); min-height: 18px; margin-top: 8px; font-weight: 600; }
.btn-login {
  width: 100%; padding: 12px; margin-top: 6px;
  background: var(--navy); color: white; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.btn-login:hover { opacity: .9; }
.login-divider {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 14px;
  color: var(--ink3); font-size: 11px;
}
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-viewer {
  width: 100%; padding: 11px;
  background: white; color: var(--ink2); border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-viewer:hover { border-color: var(--navy); background: #f8fafc; }
.login-foot { margin-top: 20px; font-size: 10px; color: var(--ink3); }

/* ── HEADER ────────────────────────────────────────── */
header {
  background: var(--navy); color: white;
  padding: 0 20px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.hdr-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.hdr-logo {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--yellow); color: var(--navy); border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px;
}
.hdr-title { font-size: 14px; font-weight: 700; white-space: nowrap; }
.hdr-sub   { font-size: 10px; color: #94a3b8; }
.hdr-right { display: flex; align-items: center; gap: 8px; }
.role-badge {
  font-size: 10px; font-weight: 700; padding: 4px 11px; border-radius: 20px;
  letter-spacing: .4px; white-space: nowrap;
}
.role-admin  { background: var(--yellow); color: var(--navy); }
.role-viewer { background: rgba(255,255,255,.14); color: #cbd5e1; border: 1px solid rgba(255,255,255,.25); }
.btn-logout {
  background: rgba(255,255,255,.12); color: white;
  border: 1px solid rgba(255,255,255,.2); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ── NAV TABS ──────────────────────────────────────── */
.nav-bar {
  background: white; border-bottom: 1px solid var(--border);
  padding: 0 20px; display: flex; gap: 4px;
  position: sticky; top: 60px; z-index: 90;
  overflow-x: auto;
}
.nav-tab {
  padding: 13px 18px; font-size: 13px; font-weight: 700;
  color: var(--ink3); background: none; border: none;
  border-bottom: 3px solid transparent; cursor: pointer;
  white-space: nowrap; transition: color .15s;
}
.nav-tab:hover { color: var(--navy); }
.nav-tab.active { color: var(--navy); border-bottom-color: var(--yellow); }

/* ── MAIN ──────────────────────────────────────────── */
main { max-width: 1500px; margin: 0 auto; padding: 20px 20px 60px; }
.loading-screen { text-align: center; padding: 80px 0; color: var(--ink3); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border: 3.5px solid var(--border); border-top-color: var(--navy);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.viewer-banner {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 10px; padding: 9px 16px; font-size: 12px; font-weight: 600;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}

/* ── KPI CARDS ─────────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 16px;
}
.kpi-card {
  background: var(--card); border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.k-green::before  { background: var(--gn); }
.k-red::before    { background: var(--rd); }
.k-navy::before   { background: var(--navy); }
.k-yellow::before { background: var(--yellow); }
.kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--ink3); }
.kpi-value { font-size: 24px; font-weight: 800; margin: 4px 0 2px; }
.kpi-sub   { font-size: 11px; color: var(--ink3); }

.mini-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 14px;
}
.mini-grid-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; }
.mini-card {
  background: var(--card); border-radius: var(--r); padding: 12px 16px;
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between;
}
.mini-lbl { font-size: 11.5px; font-weight: 600; color: var(--ink2); }
.mini-val { font-size: 19px; font-weight: 800; }
.mini-val.ok   { color: var(--gn); }
.mini-val.bad  { color: var(--rd); }
.mini-val.warn { color: #b45309; }

/* ── CHARTS ────────────────────────────────────────── */
.charts-grid {
  display: grid; grid-template-columns: 5fr 3fr 4fr;
  gap: 14px; margin-bottom: 16px;
}
.chart-card {
  background: var(--card); border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.chart-title { font-size: 13px; font-weight: 700; }
.chart-sub   { font-size: 11px; color: var(--ink3); margin-bottom: 12px; }

/* ── TOOLBAR / FILTERS ─────────────────────────────── */
.toolbar {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 11px 14px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.search-inp {
  border: 1.5px solid var(--border); border-radius: 9px;
  padding: 8px 12px; font-size: 13px; width: 230px; outline: none;
  transition: border-color .2s;
}
.search-inp:focus { border-color: var(--navy); }
.filter-sel {
  border: 1.5px solid var(--border); border-radius: 9px;
  padding: 8px 10px; font-size: 13px; background: white; outline: none; color: var(--ink);
}
.lvl-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 9px; padding: 3px; }
.lvl-tab {
  padding: 6px 13px; font-size: 12px; font-weight: 700; border: none;
  background: none; border-radius: 7px; cursor: pointer; color: var(--ink3);
}
.lvl-tab.active { background: var(--navy); color: white; }
.chk-retired { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink3); font-weight: 600; cursor: pointer; user-select: none; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-primary {
  background: var(--navy); color: white; border: none; border-radius: 9px;
  padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-yellow {
  background: var(--yellow); color: var(--navy); border: none; border-radius: 9px;
  padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.btn-yellow:hover { opacity: .85; }
.btn-outline {
  background: white; color: var(--ink2); border: 1.5px solid var(--border);
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-outline:hover { border-color: var(--navy); }

/* ── LEYENDA ───────────────────────────────────────── */
.legend-bar { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; padding: 0 4px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink3); font-weight: 600; }
.ldot { width: 11px; height: 11px; border-radius: 3px; }
.ld-paid { background: var(--gn); }
.ld-pend { background: var(--rd); }
.ld-unk  { background: var(--gy-bg); border: 1px solid #cbd5e1; }

/* ── GRADE SECTIONS / STUDENT TABLE ────────────────── */
.grade-sec { margin-bottom: 22px; }
.grade-hdr {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 0 4px;
}
.grade-title { font-size: 15px; font-weight: 800; color: var(--navy); }
.grade-count { font-size: 11px; font-weight: 600; color: var(--ink3); background: var(--gy-bg); padding: 2px 10px; border-radius: 12px; }
.grade-debt  { font-size: 11px; font-weight: 700; color: var(--rd); margin-left: auto; }

.stu-table-wrap {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  overflow-x: auto;
}
table.stu-table { width: 100%; border-collapse: collapse; }
.stu-table thead th {
  background: #f8fafc; padding: 8px 10px; text-align: left;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.stu-table thead th.c { text-align: center; }
.stu-table tbody td {
  padding: 9px 10px; border-bottom: 1px solid #f8fafc; vertical-align: middle;
}
.stu-table tbody tr:last-child td { border-bottom: none; }
.stu-table tbody tr:hover td { background: #fafbfc; }
.stu-name { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.stu-grade-mobile { display: none; }
.stu-note { font-size: 10px; color: var(--rd); font-weight: 600; margin-top: 1px; }
.stu-debt { font-size: 12px; font-weight: 700; white-space: nowrap; }
.stu-debt.zero { color: var(--ink3); font-weight: 500; }
.stu-debt.owe  { color: var(--rd); }
tr.row-retired td { opacity: .45; }
tr.row-retired .stu-name { text-decoration: line-through; }

/* ── CHIPS DE CONCEPTOS (D-25 · Mat · Paq · Unif) ──── */
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; padding: 4px 6px; border-radius: 6px;
  font-size: 9.5px; font-weight: 700; border: 1px solid transparent;
  user-select: none; white-space: nowrap; line-height: 1;
}
.chip.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.chip.clickable:hover { transform: scale(1.1); box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.chip.paid    { background: var(--gn-bg); color: var(--gn-tx); border-color: #a7f3d0; }
.chip.pending { background: var(--rd-bg); color: var(--rd-tx); border-color: #fecaca; }
.chip.unknown { background: #f1f5f9; color: var(--gy-tx); border-color: var(--border); }
.chip-row { display: flex; gap: 3px; flex-wrap: wrap; }

/* ── BARRA DE PENSIONES (10 segmentos Mar–Dic) ──────── */
.pension-bar { display: flex; gap: 2px; }
.pseg {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 22px; border-radius: 4px;
  font-size: 9px; font-weight: 700; border: 1px solid transparent;
  user-select: none; flex-shrink: 0;
}
.pseg.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.pseg.clickable:hover { transform: scale(1.15); box-shadow: 0 2px 6px rgba(0,0,0,.2); z-index: 2; position: relative; }
.pseg.paid    { background: var(--gn-bg); color: var(--gn-tx); border-color: #a7f3d0; }
.pseg.pending { background: var(--rd-bg); color: var(--rd-tx); border-color: #fecaca; }
.pseg.unknown { background: #f1f5f9; color: #94a3b8; border-color: var(--border); }

/* ── PASTILLA DE EXÁMENES ──────────────────────────── */
.exam-pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 10px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; border: 1px solid transparent;
  white-space: nowrap; user-select: none;
}
.exam-pill.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.exam-pill.clickable:hover { transform: scale(1.05); box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.exam-ok   { background: var(--gn-bg); color: var(--gn-tx); border-color: #a7f3d0; }
.exam-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.exam-bad  { background: var(--rd-bg); color: var(--rd-tx); border-color: #fecaca; }

.act-btn {
  background: none; border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 9px; font-size: 11px; font-weight: 600; color: var(--ink3);
  cursor: pointer; white-space: nowrap;
}
.act-btn:hover { border-color: var(--rd); color: var(--rd); }
.act-btn.restore:hover { border-color: var(--gn); color: var(--gn); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink3); }

/* ── MODALS ────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.5); align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 16px; padding: 26px;
  width: 440px; max-width: 94vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal h2 { font-size: 17px; margin-bottom: 6px; color: var(--navy); }
.modal .m-sub { font-size: 12.5px; color: var(--ink3); margin-bottom: 18px; line-height: 1.5; }
.m-label { display: block; font-size: 11px; font-weight: 700; color: var(--ink2); text-transform: uppercase; letter-spacing: .4px; margin: 14px 0 5px; }
.m-input, .m-select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 9px; font-size: 14px; outline: none; background: white;
  transition: border-color .2s;
}
.m-input:focus, .m-select:focus { border-color: var(--navy); }
.m-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.btn-cancel { background: var(--bg); color: var(--ink3); border: none; border-radius: 9px; padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-danger { background: var(--rd); color: white; border: none; border-radius: 9px; padding: 10px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-danger:hover { opacity: .9; }

/* ── TOAST ─────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: white;
  padding: 11px 22px; border-radius: 10px;
  font-size: 13px; font-weight: 600; z-index: 999;
  transition: transform .25s; white-space: nowrap; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--rd); }

/* ── SETUP WARNING ─────────────────────────────────── */
.setup-banner {
  background: var(--rd-bg); border: 1px solid #fecaca; color: var(--rd-tx);
  border-radius: 10px; padding: 12px 16px; font-size: 12.5px; font-weight: 600;
  margin-bottom: 16px; line-height: 1.5;
}

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid, .mini-grid, .mini-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  main { padding: 12px 10px 50px; }
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-grid, .mini-grid, .mini-grid-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hdr-title { font-size: 12px; }
  .hdr-sub { display: none; }
  .search-inp { width: 100%; }
  .lvl-tabs { width: 100%; justify-content: space-between; }
  .lvl-tab { flex: 1; padding: 8px 6px; }
  .filter-sel { flex: 1; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .toolbar-right .btn-outline, .toolbar-right .btn-yellow { flex: 1; }

  .grade-hdr { flex-wrap: wrap; }

  /* Tabla de alumnos → tarjetas apiladas (más cómodo para uso táctil) */
  .stu-table-wrap { overflow-x: visible; box-shadow: none; background: none; }
  table.stu-table, table.stu-table tbody { display: block; width: 100%; }
  .stu-table thead { display: none; }
  .stu-table tbody tr {
    display: block; background: var(--card); border-radius: var(--r);
    box-shadow: var(--shadow); margin-bottom: 10px; padding: 12px 14px;
  }
  .stu-table tbody tr:last-child { margin-bottom: 0; }
  .stu-table tbody tr:hover td { background: none; }
  .stu-table tbody td {
    display: block; padding: 7px 0; border-bottom: 1px dashed #eef2f7;
  }
  .stu-table tbody tr td:first-child { padding-top: 0; }
  .stu-table tbody tr td:last-child { border-bottom: none; padding-bottom: 0; }
  .stu-table td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block; font-size: 9.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--ink3); margin-bottom: 5px;
  }
  .stu-table td[data-label="Alumno"]::before { content: none; }
  .stu-grade-mobile { display: block; font-size: 11px; color: var(--ink3); font-weight: 600; margin-top: 1px; }
  .pension-bar { flex-wrap: wrap; }
  .pseg { width: 24px; height: 26px; font-size: 10px; }
  .chip { min-width: 42px; padding: 6px 8px; font-size: 10.5px; }
  .exam-pill { padding: 7px 14px; font-size: 11.5px; }
  .act-btn { width: 100%; padding: 9px; }
}
