/* ==========================================================================
   EduTrack SIS — "Registro" (implements EduTrack Registro.dc.html)
   White · Inter · crimson #960E0B · rounded, listing-style layout.
   ========================================================================== */
:root {
  --brand: #960e0b;
  --brand-hover: #7a0b08;
  --ink: #222222;
  --muted: #6a6a6a;
  --ink-3: #3f3f3f;
  --line: #dddddd;
  --line-soft: #ebebeb;
  --fam-bg: #f6ecec;
  --chip: #f2f2f2;
  --row-hover: #f7f7f7;
  --danger: #c13515;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans); color: var(--ink); background: #fff;
  font-size: 14px; letter-spacing: -0.1px; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
input, select, button { font-family: inherit; }

.rows::-webkit-scrollbar, .modalscroll::-webkit-scrollbar { width: 10px; }
.rows::-webkit-scrollbar-thumb, .modalscroll::-webkit-scrollbar-thumb {
  background: #ddd; border-radius: 9999px; border: 3px solid #fff;
}

/* ---- Buttons ---- */
.btn { font-size: 16px; font-weight: 500; border: 1px solid transparent; border-radius: 8px;
  padding: 0 22px; height: 48px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; transition: background .13s ease, border-color .13s ease, color .13s ease, opacity .13s; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: #f7f7f7; }
.btn-block { width: 100%; }
.plus { font-size: 19px; line-height: 1; margin-top: -1px; }
.lnk { background: none; border: none; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink); }
.lnk:hover { text-decoration: underline; }
.lnk-del { color: var(--danger); }

/* ---- Logo mark (Liceo Inglés icon) ---- */
.logo-mark { width: 42px; height: 42px; object-fit: contain; flex: none; display: block; }

/* ---- Login ---- */
.login-view { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; border: 1px solid var(--line); border-radius: 20px;
  padding: 34px 30px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: rgba(0,0,0,.03) 0 1px 3px, rgba(0,0,0,.06) 0 8px 28px; }
.login-logo { width: 210px; height: auto; display: block; margin: 4px 0 2px; }
.login-card h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; margin-top: 12px; }
.login-card > p { margin-bottom: 6px; }
.login-card label, .form-grid label { display: flex; flex-direction: column; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.login-card input, .form-grid input, .form-grid select { font-size: 15px; font-weight: 400;
  text-transform: none; letter-spacing: -0.1px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; width: 100%; background: #fff; }
.login-card .btn { margin-top: 6px; }
input:focus, select:focus { outline: none; border-color: var(--ink); }
.multi-field { display: flex; flex-wrap: wrap; gap: 8px; }
.multi-opt { flex-direction: row; align-items: center; gap: 7px; text-transform: none; letter-spacing: 0;
  font-size: 14px; font-weight: 500; color: var(--ink); border: 1px solid var(--line); border-radius: 9999px;
  padding: 7px 14px; cursor: pointer; }
.multi-opt input { width: auto; margin: 0; }
.field-hint { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); margin-top: 4px; }
.nivel-cell { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ---- Portal padres (admin) ---- */
.table-scroll { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.dt th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .3px; padding: 13px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.dt th.r, table.dt td.r { text-align: right; }
table.dt td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.dt tbody tr:last-child td, table.dt tr:last-child td { border-bottom: none; }
.portal-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -6px 0 16px; }
.portal-search { flex: 1 1 260px; max-width: 420px; }
.pt-parent { line-height: 1.35; }
.pt-login { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pt-copy { border: none; background: none; cursor: pointer; color: var(--brand); font-size: 14px; padding: 0 2px; line-height: 1; }
.pt-see { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--brand);
  color: var(--brand); background: #fff; font-size: 11px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.pt-see:hover { background: var(--brand); color: #fff; }

/* ---- Informes de progreso (admin) ---- */
.inf-gen { padding: 20px 22px 8px; }
.inf-h { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.inf-sub { font-size: 13px; margin: 4px 0 14px; max-width: 640px; line-height: 1.45; }
.inf-genrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.inf-select { height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font: inherit; font-size: 14px; background: #fff; }
.inf-progress { margin-top: 14px; display: flex; align-items: center; gap: 12px; min-height: 8px; flex-wrap: wrap; }
.inf-bar { flex: 1; max-width: 320px; height: 8px; background: var(--line-soft); border-radius: 8px; overflow: hidden; }
.inf-bar-fill { height: 100%; background: var(--brand); border-radius: 8px; transition: width .2s; }
.inf-vis { margin-top: 8px; }
.inf-force { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.pt-toggle { width: 44px; height: 25px; border-radius: 9999px; border: none; background: #cfcfcf; cursor: pointer;
  position: relative; padding: 0; transition: background .15s ease; flex: none; }
.pt-toggle.on { background: #1a7f4b; }
.pt-toggle span { position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s ease; }
.pt-toggle.on span { left: 22px; }

.btn-google { width: 100%; height: 50px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 11px;
  transition: box-shadow .15s, border-color .15s; }
.btn-google:hover { box-shadow: rgba(0,0,0,.08) 0 3px 12px; border-color: #c9c9c9; }
.btn-google svg { width: 19px; height: 19px; }
.fineprint { font-size: 12.5px; line-height: 1.5; text-align: center; margin-top: 4px; }

/* ==========================================================================
   Login — editorial split (photo right, form left). Scoped to .login-split so
   it doesn't touch the app tokens or the restricted-view card.
   ========================================================================== */
.login-split { display: grid; grid-template-columns: 1fr 1.15fr; min-height: 100vh; }

/* -- left: form column -- */
.ls-form { display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 64px; background: #fff; }

.ls-lockup { display: flex; align-items: center; gap: 18px; }
.ls-logo { height: 56px; width: auto; display: block; }
.ls-divider { width: 1px; height: 32px; background: #e7e2dd; display: block; flex: none; }
.ls-kicker { font-family: var(--sans); font-size: 10px; font-weight: 600; line-height: 1.6;
  color: #78716c; letter-spacing: 2.2px; }

.ls-center { width: 100%; max-width: 400px; }
.ls-eyebrow { font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-weight: 500;
  font-size: 22px; color: #960e0b; line-height: 1; }
.ls-title { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 400; font-size: 46px;
  line-height: 1.06; color: #1c1917; letter-spacing: 0; margin-top: 4px; }
.ls-lead { font-family: var(--sans); font-size: 15px; font-weight: 400; line-height: 1.65;
  color: #57534e; margin-top: 14px; letter-spacing: 0; }

.ls-google { width: 100%; height: 56px; margin-top: 36px; background: #fff;
  border: 1px solid #c7bda6; border-radius: 2px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--sans); font-size: 15px; font-weight: 600; color: #1c1917;
  transition: background .15s ease, border-color .15s ease,
    transform .3s cubic-bezier(.22,.61,.36,1), box-shadow .3s cubic-bezier(.22,.61,.36,1); }
.ls-google:hover { background: #F7EFE6; border-color: #1c1917; transform: translateY(-2px);
  box-shadow: 0 12px 28px -14px rgba(28,25,23,0.3); }
.ls-google svg { width: 19px; height: 19px; flex: none; }

.ls-error { font-family: var(--sans); font-size: 13px; font-weight: 500; color: #c13515; margin-top: 12px; }

.ls-notice { display: flex; align-items: center; gap: 10px; background: #F7EFE6; border-radius: 2px;
  padding: 14px 16px; margin-top: 22px; font-family: var(--sans); font-size: 13px; line-height: 1.5; color: #57534e; }
.ls-notice svg { width: 15px; height: 15px; color: #960e0b; flex: none; }
.ls-notice b { color: #1c1917; font-weight: 600; }

.ls-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  font-family: var(--sans); font-size: 12px; color: #a9a29d; }
.ls-foot a { color: #78716c; transition: color .15s ease; }
.ls-foot a:hover { color: #960e0b; }

/* -- right: photo column -- */
.ls-photo { position: relative; overflow: hidden; background: #14100f; }
.ls-photo-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.62; }
.ls-photo-shade { position: absolute; inset: 0;
  background: linear-gradient(200deg, rgba(20,16,15,0.1) 0%, rgba(20,16,15,0.68) 100%); }
.ls-caption { position: absolute; left: 56px; right: 56px; bottom: 56px; }
.ls-cap-eyebrow { font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-weight: 500;
  font-size: 22px; color: rgba(255,255,255,0.85); line-height: 1; }
.ls-cap-title { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 400; font-size: 44px;
  line-height: 1.1; color: #fff; max-width: 480px; margin-top: 6px; }
.ls-cap-meta { display: flex; align-items: center; gap: 14px; margin-top: 18px;
  font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 2px; color: rgba(255,255,255,0.7); }
.ls-rule { width: 34px; height: 2px; background: #960e0b; display: block; flex: none; }

/* -- entrance cascade -- */
@keyframes lsRise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
.ls-lockup, .ls-eyebrow, .ls-title, .ls-lead, .ls-google, .ls-notice, .ls-foot {
  animation: lsRise .9s cubic-bezier(.22,.61,.36,1) both; }
.ls-lockup { animation-delay: 0s; }
.ls-eyebrow { animation-delay: .12s; }
.ls-title { animation-delay: .12s; }
.ls-lead { animation-delay: .24s; }
.ls-google { animation-delay: .36s; }
.ls-notice { animation-delay: .48s; }
.ls-foot { animation-delay: .6s; }
@media (prefers-reduced-motion: reduce) {
  .ls-lockup, .ls-eyebrow, .ls-title, .ls-lead, .ls-google, .ls-notice, .ls-foot { animation: none; }
}

/* -- responsive: collapse to one column, hide the photo -- */
@media (max-width: 1128px) {
  .login-split { grid-template-columns: 1fr; }
  .ls-photo { display: none; }
  .ls-form { align-items: center; padding: 40px 28px; }
  .ls-lockup, .ls-center, .ls-foot { width: 100%; max-width: 400px; }
}

/* role badges (Usuarios list) */
.role-badge { display: inline-flex; align-items: center; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 9999px; background: var(--chip); color: var(--ink); }
.role-badge.role-admin { background: var(--fam-bg); color: var(--brand); }
.role-badge.role-academic { background: #e6f1f5; color: #1f6f8b; }
.role-badge.role-viewer { background: #f0f0f0; color: #6a6a6a; }

/* viewer = read-only: hide every mutation control (RLS enforces server-side) */
body.role-viewer #new-btn,
body.role-viewer .row-actions [data-edit],
body.role-viewer .row-actions [data-del],
body.role-viewer #d-edit { display: none !important; }

/* ---- Top nav ---- */
.topbar { position: sticky; top: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--line-soft); }
.topbar-inner { max-width: 1360px; margin: 0 auto; height: 80px; padding: 0 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.wordmark { display: flex; flex-direction: column; line-height: 1.05; }
.logo-text { font-size: 19px; font-weight: 700; color: var(--brand); letter-spacing: -0.4px; }
.logo-sub { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 1px; margin-top: 2px; text-transform: uppercase; }

.tabs { display: flex; align-items: flex-end; gap: 6px; height: 80px; flex: none; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 80px; justify-content: center;
  padding: 0 14px; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--muted); font-size: 15px; font-weight: 600; transition: color .13s, border-color .13s; }
.tab svg { width: 24px; height: 24px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

.user { display: flex; align-items: center; gap: 14px; flex: none; }
.topbar-link { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 8px 12px; border-radius: 9999px; transition: background .13s, color .13s; }
.topbar-link:hover { color: var(--ink); background: #f2f2f2; }
.topbar-link svg { width: 18px; height: 18px; }
@media (max-width: 760px) { .topbar-link span { display: none; } }
#user-email { font-size: 14px; }
.user-pill { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 14px;
  border: 1px solid var(--line); border-radius: 9999px; background: #fff; cursor: pointer;
  transition: box-shadow .15s ease; }
.user-pill:hover { box-shadow: rgba(0,0,0,.08) 0 2px 8px; }
.user-pill svg { width: 16px; height: 16px; }
.user-mono { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 9999px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; }

/* ---- Content ---- */
.content { max-width: 1360px; margin: 0 auto; padding: 32px 40px 64px; }

.toolbar { display: flex; align-items: center; gap: 24px; margin-bottom: 28px; }
.searchpill { flex: 1; display: flex; align-items: center; gap: 14px; height: 64px; background: #fff;
  border: 1px solid var(--line); border-radius: 9999px; padding: 0 8px 0 24px;
  box-shadow: rgba(0,0,0,.02) 0 0 0 1px, rgba(0,0,0,.04) 0 2px 6px, rgba(0,0,0,.06) 0 4px 8px;
  transition: box-shadow .15s ease; }
.searchpill:focus-within { box-shadow: rgba(0,0,0,.02) 0 0 0 1px, rgba(0,0,0,.06) 0 2px 8px, rgba(0,0,0,.12) 0 6px 16px; }
.searchpill input { flex: 1; height: 100%; border: none; outline: none; background: transparent; font-size: 16px; color: var(--ink); }
.orb { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 9999px;
  background: var(--brand); border: none; cursor: pointer; flex: none; transition: background .13s ease; }
.orb:hover { background: var(--brand-hover); }
.orb svg { width: 19px; height: 19px; }
.toolbar-actions { display: flex; align-items: center; gap: 22px; flex: none; }
#count-label { font-size: 15px; }
#count-label b { color: var(--ink); font-weight: 600; }

/* ---- Filter chips (parentesco / grado) ---- */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -10px 0 26px; }
.filterbar .flabel { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .4px;
  text-transform: uppercase; margin-right: 4px; }
.fchip { height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: 9999px; background: #fff;
  color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: background .13s ease, border-color .13s ease, color .13s ease; }
.fchip:hover { border-color: var(--ink); }
.fchip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.fbreak { flex-basis: 100%; height: 0; margin: 0; }
.fselect { height: 38px; padding: 0 34px 0 14px; border: 1px solid var(--line); border-radius: 9999px; background: #fff;
  color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23666' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center;
  transition: border-color .13s ease; }
.fselect:hover { border-color: var(--ink); }
.fselect:focus { outline: none; border-color: var(--brand); }

/* ---- Family list ---- */
.fam-emblem { width: 52px; height: 52px; border-radius: 14px; background: var(--fam-bg); color: var(--brand);
  display: flex; align-items: center; justify-content: center; flex: none; }
.fam-emblem svg { width: 24px; height: 24px; }
.av-stack { display: flex; align-items: center; flex: none; }
.av-stack .sav { width: 42px; height: 42px; border-radius: 9999px; object-fit: cover; flex: none;
  border: 2px solid #fff; margin-left: -13px; background: #f2f2f2; font-size: 13px;
  display: flex; align-items: center; justify-content: center; }
.av-stack .sav:first-child { margin-left: 0; }
/* large member-photo stack in the family detail header (replaces the house emblem) */
.fam-stack-lg { flex: none; }
.fam-stack-lg .sav { width: 66px; height: 66px; font-size: 20px; margin-left: -24px; border-width: 3px; }
.fam-stack-lg .sav:first-child { margin-left: 0; }
.av-stack .sav.more { background: var(--chip); color: var(--muted); font-weight: 600; }
.fam-col { min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fam-col.parents { flex-direction: column; align-items: stretch; gap: 12px; flex-wrap: nowrap; }
.mini-chip { display: inline-flex; align-items: center; background: var(--chip); color: var(--ink);
  font-size: 13px; font-weight: 500; padding: 3px 10px; border-radius: 9999px; white-space: nowrap; }
.mini-chip.rel { background: var(--fam-bg); color: var(--brand); font-weight: 600; }
.fam-col .muted { font-size: 13px; }
.fam-parent { min-width: 0; }
.fp-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fp-name { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-contact { display: flex; flex-wrap: wrap; gap: 3px 18px; margin-top: 5px; min-width: 0; }
.fp-contact span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  min-width: 0; font-variant-numeric: tabular-nums; }
.fp-contact svg { width: 14px; height: 14px; flex: none; }
.fp-contact .fp-email { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Register (grid table) ---- */
.grid-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.thead { display: grid; align-items: center; gap: 16px; padding: 16px 28px; border-bottom: 1px solid var(--line-soft); }
.thead .th { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .4px; }
.thead .th-right { text-align: right; }
.rows { max-height: 640px; overflow-y: auto; }
.rowline { display: grid; align-items: center; gap: 16px; padding: 12px 28px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background .13s ease; }
.rowline:last-child { border-bottom: none; }
.rowline:hover { background: var(--row-hover); }

.id-cell { display: flex; align-items: center; gap: 16px; min-width: 0; }
.av { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; flex: none; background: #f2f2f2; display: block; }
.mono-av { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; }
.id-text { min-width: 0; }
.id-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.id-name { font-size: 16px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- View toggle (Tarjetas / Lista) ---- */
.view-toggle { display: inline-flex; }
.seg { display: inline-flex; background: var(--chip); border-radius: 9999px; padding: 4px; gap: 2px; }
.seg-btn { border: none; background: none; cursor: pointer; height: 34px; padding: 0 16px; border-radius: 9999px;
  font-size: 14px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
  transition: background .13s ease, color .13s ease; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---- Group header (homeroom / grade summary) ---- */
.list-header { display: flex; align-items: center; gap: 20px; background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 18px 24px; margin-bottom: 18px; flex-wrap: wrap; }
.lh-badge { width: 58px; height: 58px; border-radius: 16px; background: var(--brand); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700; }
.lh-id { flex: 1 1 160px; min-width: 0; }
.lh-id h2 { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.4px; }
.lh-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.lh-sub b { color: var(--ink); font-weight: 600; }
.lh-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.lh-stat { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: var(--chip); border-radius: 14px; padding: 11px 22px; min-width: 82px; }
.lh-stat.lh-stat-main { background: var(--fam-bg); }
.lh-stat b { font-size: 25px; font-weight: 700; color: var(--ink); line-height: 1; }
.lh-stat.lh-stat-main b { color: var(--brand); }
.lh-stat span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 5px; }

/* ---- Card view ---- */
.rows.cards { max-height: none; overflow: visible; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; padding: 20px; }
.scard { border: 1px solid var(--line); border-radius: 18px; padding: 22px 16px 18px; text-align: center;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: box-shadow .13s ease, border-color .13s ease, transform .13s ease; }
.scard:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); transform: translateY(-2px); }
.card-av { width: 96px; height: 96px; border-radius: 9999px; object-fit: cover; flex: none; background: #f2f2f2;
  font-size: 30px; margin-bottom: 10px; }
.scard-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scard-name { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.scard-link { font-size: 13px; font-weight: 700; color: var(--brand); margin-top: 8px; }

.fam { display: inline-flex; align-items: center; gap: 7px; background: var(--fam-bg); color: var(--brand);
  font-size: 14px; font-weight: 600; padding: 5px 13px; border-radius: 9999px; font-variant-numeric: tabular-nums; }
.fam svg { width: 10px; height: 10px; }
.cell { font-size: 15px; color: var(--ink); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.mono { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 20px; }
.empty { padding: 48px; text-align: center; color: var(--muted); font-size: 16px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 22px; }
.pager .btn { height: 42px; padding: 0 18px; font-size: 14px; }
#page-label { font-size: 14px; }

/* ---- Modals (shared) ---- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 24px; overflow-y: auto; }
.detail-card, .form-card { width: 100%; background: #fff; border-radius: 20px; max-height: calc(100vh - 96px);
  overflow-y: auto; box-shadow: rgba(0,0,0,.02) 0 0 0 1px, rgba(0,0,0,.18) 0 12px 40px; }
.detail-card { max-width: 920px; padding: 32px 40px 36px; }
.form-card { max-width: 640px; padding: 28px 32px 30px; }

.modal-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-topbar h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; }
.modal-eyebrow { font-size: 14px; font-weight: 600; color: var(--muted); }
.close-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9999px;
  background: #f2f2f2; border: none; cursor: pointer; color: var(--ink); flex: none; }
.close-btn:hover { background: #e8e8e8; }
.close-btn svg { width: 16px; height: 16px; }

/* identity row */
.identity { display: flex; align-items: center; gap: 28px; padding: 12px 0 28px; border-bottom: 1px solid var(--line-soft); }
.portrait { width: 128px; height: 128px; border-radius: 14px; object-fit: cover; flex: none; background: #f2f2f2; font-size: 44px; }
.portrait.fam-emblem-lg { display: flex; align-items: center; justify-content: center; background: var(--fam-bg); color: var(--brand); }
.portrait.fam-emblem-lg svg { width: 58px; height: 58px; }
.fam-display.clickable { cursor: pointer; border-radius: 12px; transition: background .13s ease; }
.fam-display.clickable:hover { background: var(--fam-bg); }
.identity-main { flex: 1; min-width: 0; }
.identity-main h2 { font-size: 26px; font-weight: 600; color: var(--ink); letter-spacing: -0.5px; line-height: 1.15; }
.chips { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; background: var(--chip); color: var(--ink);
  font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 9999px; }
.chips .meta { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* status (Activo/Inactivo) */
.st-chip { display: inline-flex; align-items: center; font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: 9999px; }
.st-chip.st-on { background: #e7f4ec; color: #1a7f4b; }
.st-chip.st-off { background: #efefef; color: #6a6a6a; }
.st-badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; padding: 1px 7px; border-radius: 5px; background: #fbe9e4; color: #c13515;
  vertical-align: middle; margin-left: 8px; }
.chips .dot { color: var(--line); }

.fam-display { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding-left: 28px; border-left: 1px solid var(--line-soft); align-self: stretch; }
.fam-badge { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px;
  border-radius: 12px; background: var(--fam-bg); color: var(--brand); flex: none; }
.fam-badge svg { width: 22px; height: 22px; }
.fam-num { text-align: center; }
.fam-n { font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1; letter-spacing: -0.6px; font-variant-numeric: tabular-nums; }
.fam-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .5px; margin-top: 5px; text-transform: uppercase; }

/* field grid */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; padding: 8px 0 4px; }
.field { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.field-k { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.field-v { font-size: 16px; color: var(--ink); margin-top: 5px; }

/* related sections (acudientes / hermanos cards) */
.rel-section { margin-top: 32px; }
.rel-section h3 { font-size: 20px; font-weight: 600; color: var(--ink); letter-spacing: -0.3px; margin-bottom: 18px; }
.card-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }

/* ---- MAP (NWEA) results in the student detail ---- */
.map-term { margin-bottom: 16px; }
.map-term:last-child { margin-bottom: 0; }
.map-term-h { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.map-table { width: 100%; border: 1px solid var(--line); border-radius: 12px; border-collapse: separate;
  border-spacing: 0; overflow: hidden; font-size: 14px; }
.map-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; color: var(--muted); background: #f7f7f7; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.map-table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; color: var(--ink); }
.map-table tr:last-child td { border-bottom: none; }
.map-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.map-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .map-table { font-size: 13px; } .map-table th, .map-table td { padding: 8px 10px; } }
.person-card { min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: 20px; cursor: pointer; transition: border-color .13s, box-shadow .13s; }
.person-card:hover { border-color: var(--ink); box-shadow: rgba(0,0,0,.06) 0 4px 14px; }
.pc-head { display: flex; align-items: center; gap: 14px; }
.pc-av { width: 48px; height: 48px; border-radius: 9999px; font-size: 16px; flex: none; }
.pc-name { font-size: 16px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-rel { font-size: 14px; color: var(--muted); }
.pc-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--ink); min-width: 0; }
.pc-row svg { width: 16px; height: 16px; flex: none; }
.pc-row span { font-size: 15px; font-variant-numeric: tabular-nums; min-width: 0; }
.pc-email { flex: 1; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-card.mini .pc-head { align-items: center; }

.modal-foot { display: flex; justify-content: flex-end; gap: 14px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line-soft); }

/* form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-card .modal-foot { margin-top: 22px; padding-top: 18px; }

/* photo editor (admin|academic) */
.photo-editor { display: flex; align-items: center; gap: 18px; padding: 16px; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: 14px; background: #fafafa; }
.pe-pic { flex: none; }
.pe-portrait { width: 84px; height: 84px; border-radius: 14px; object-fit: cover; display: flex;
  align-items: center; justify-content: center; font-size: 26px; background: #f2f2f2; }
.pe-portrait.pe-loading { color: var(--muted); font-size: 22px; }
.pe-controls { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pe-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.pe-btns { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn-file { height: 40px; padding: 0 16px; font-size: 14px; cursor: pointer; }
.pe-hint { font-size: 12px; }

/* camera capture (webcam / phone) — sits above the edit modal (z 60) */
.cam-modal { position: fixed; inset: 0; z-index: 85; background: rgba(0, 0, 0, .82);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.cam-card { background: #14100f; border-radius: 14px; padding: 14px; width: 100%; max-width: 560px;
  display: flex; flex-direction: column; gap: 12px; }
.cam-stage { border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.cam-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-btns { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.cam-btns .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .4); }
.cam-btns .btn-outline:hover:not(:disabled) { border-color: #fff; }
@media (max-width: 560px) { .cam-btns { justify-content: stretch; } .cam-btns .btn { flex: 1; } }

/* image lightbox */
img.zoomable { cursor: zoom-in; }
.img-lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.86);
  display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.img-lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 12px;
  box-shadow: rgba(0,0,0,.5) 0 20px 60px; }
.lightbox-close { position: fixed; top: 16px; right: 20px; width: 44px; height: 44px; border-radius: 9999px;
  border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 26px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .13s; }
.lightbox-close:hover { background: rgba(255,255,255,.3); }

/* toast */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 13px 20px; border-radius: 10px; z-index: 80; box-shadow: rgba(0,0,0,.25) 0 10px 30px; font-size: 14px; }
.toast.err { background: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .topbar-inner, .content { padding-left: 20px; padding-right: 20px; }
  #user-email { display: none; }
  .field-grid, .card-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .identity { flex-wrap: wrap; row-gap: 16px; }
  .fam-display { padding-left: 0; border-left: none; align-self: auto; }
}

@media (max-width: 760px) {
  /* top nav — compact */
  .topbar-inner { height: 60px; gap: 10px; }
  .tabs { height: 60px; gap: 2px; }
  .tab { height: 60px; padding: 0 10px; font-size: 12px; gap: 4px; }
  .tab svg { width: 20px; height: 20px; }
  .logo-sub { display: none; }
  .logo-mark { width: 34px; height: 34px; }
  .user-pill { height: 40px; padding: 0 5px 0 12px; }

  /* toolbar stacks */
  .toolbar { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 20px; }
  .searchpill { height: 54px; padding-left: 18px; }
  .searchpill input { font-size: 15px; }
  .orb { width: 42px; height: 42px; }
  .toolbar-actions { justify-content: space-between; }

  /* register: grid rows -> stacked cards (overrides JS inline grid) */
  .thead { display: none; }
  .grid-card { border-radius: 16px; }
  .rows { max-height: none; }
  .rowline { display: flex !important; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 14px 16px; }
  .id-cell { flex: 1 1 100%; }
  .rowline .cell, .rowline .fam-col { display: none; }  /* hide secondary columns; keep id + actions */
  .row-actions { margin-left: auto; gap: 18px; }

  /* modals */
  .modal-overlay { padding: 16px 12px; }
  .detail-card { padding: 24px 20px 26px; }
  .form-card { padding: 22px 20px 24px; }
  .identity-main h2 { font-size: 22px; }
  .fam-n { font-size: 26px; }
  .portrait { width: 104px; height: 104px; }
}

@media (max-width: 600px) {
  /* Detail identity was forcing the whole card wider than the phone (min-content
     of portrait + name + núcleo-familiar). Let the name shrink and drop the
     family core onto its own row so nothing overflows. */
  .identity { flex-wrap: wrap; align-items: flex-start; }
  .identity-main { flex: 1 1 150px; }
  .fam-display { flex-basis: 100%; flex-direction: row; align-items: center;
    justify-content: flex-start; gap: 12px; padding-top: 6px; }
  .fam-num { text-align: left; }
  .field-v { overflow-wrap: anywhere; }
}

@media (max-width: 480px) {
  .wordmark { display: none; }          /* keep just the icon mark */
  .user-pill svg { display: none; }     /* keep just the avatar */
  .user-pill { padding: 5px; gap: 0; }
  .tab { padding: 0 9px; }
}

@media (max-width: 440px) {
  .toolbar-actions .btn { padding: 0 16px; }
  #count-label { font-size: 14px; }
  .rowline .fam { font-size: 13px; }
  .av { width: 46px; height: 46px; }
  .modal-topbar h2 { font-size: 19px; }
}
