:root {
  --ink: #15171C;
  --muted: #5B616E;
  --line: #E6E8EC;
  --soft: #F1F2F5;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --blue: #1D4ED8;
  --blue-dark: #1E3A8A;
  --blue-tint: #EAF0FF;
  --blue-line: #C9D3EE;
  --orange: #C2410C;
  --orange-tint: #FFF1E8;
  --orange-line: #F0CDB8;
  --tag: #7A3E00;
  --tag-bg: #FFF1E0;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); min-height: 100%; }
body { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
[hidden] { display: none !important; }

.screen { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.pad { padding: calc(20px + var(--safe-t)) 20px 0; }
.stack { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 600; }

h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }

/* Botones */
.btn {
  height: 48px; border-radius: 12px; border: 0; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-dark); }
.btn-primary:disabled { background: #6B7280; }
.btn-ghost { background: #fff; border: 1px dashed #B8BEC9; color: var(--ink); font-weight: 500; font-size: 14px; height: 44px; }
.btn-pill { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--blue-line); background: #fff; color: var(--blue); font-size: 13px; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; }
.avatar-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--blue); color: #fff; font-weight: 600; font-size: 15px; }

/* Login */
.login { justify-content: center; padding: 32px 24px calc(32px + var(--safe-b)); gap: 28px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.login-logo { width: 220px; max-width: 70%; height: auto; }
.head-logo { width: 56px; height: auto; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--blue); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  height: 50px; border-radius: 12px; border: 1px solid #D5D9E0; background: #fff; padding: 0 14px;
  font-size: 16px; font-weight: 400; color: var(--ink);
}
.field input:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.error { color: var(--orange); font-size: 14px; font-weight: 500; min-height: 20px; }

/* Selector de día */
.segment { display: flex; align-items: center; gap: 4px; padding: 4px; background: #E9EBEF; border-radius: 12px; }
.segment .icon-btn { width: 40px; height: 40px; background: #fff; border-radius: 9px; }
.segment .day { flex: 1; width: auto; background: transparent; text-align: center; font-size: 14px; font-weight: 600; }

/* Tarjetas de clase */
.cards { display: flex; flex-direction: column; gap: 12px; padding-bottom: calc(24px + var(--safe-b)); }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px; border: 2px solid transparent;
  display: flex; flex-direction: column; gap: 14px; color: var(--ink); text-align: left; width: 100%;
}
.card.now { border-color: var(--blue); }
.card .when { font-size: 13px; color: var(--muted); }
.card.now .when { color: var(--blue); font-weight: 600; }
.card .name { font-size: 17px; font-weight: 600; }
.chip { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.chip-done { background: var(--blue-tint); color: var(--blue); }
.chip-pending { background: var(--soft); color: var(--muted); font-weight: 500; }
.chip-sub { background: var(--tag-bg); color: var(--tag); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* Pasar lista */
.lesson { background: #fff; }
.lesson-head { position: sticky; top: 0; z-index: 2; background: #fff; padding: calc(12px + var(--safe-t)) 20px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.progress { height: 6px; border-radius: 3px; background: #EEF0F3; overflow: hidden; }
.progress > div { height: 100%; background: var(--blue); width: 0; transition: width .2s; }
.counts { display: flex; gap: 14px; font-size: 13px; }
.c-present { color: var(--blue); font-weight: 600; }
.c-absent { color: var(--orange); font-weight: 600; }
.banner { background: var(--soft); color: var(--muted); font-size: 13px; padding: 10px 12px; border-radius: 10px; }

.list { padding: 4px 20px 16px; flex: 1 1 auto; }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 16px 0 4px; }
.student { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--soft); }
.initials { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 19px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.student .who { font-size: 15px; font-weight: 500; }
.tag { font-size: 11px; font-weight: 600; color: var(--tag); background: var(--tag-bg); padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.mark { width: 46px; height: 46px; flex: 0 0 auto; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: #fff; }
.mark.p { border: 1.5px solid var(--blue-line); color: var(--blue); }
.mark.p.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.mark.a { border: 1.5px solid var(--orange-line); color: var(--orange); }
.mark.a.on { background: var(--orange); border-color: var(--orange); color: #fff; }
.mark:disabled { opacity: .55; }
.remove { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; }

.footer { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 20px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.footer .row { gap: 8px; }
.footer .row .btn { flex: 1; }
.btn-send { height: 52px; border-radius: 14px; font-size: 16px; }

/* Hoja inferior (modales) */
.backdrop { position: fixed; inset: 0; background: rgba(21, 23, 28, .4); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 520px; background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px;
  max-height: 88vh; overflow: auto;
}
.sheet h3 { margin: 0; font-size: 20px; }
.results { display: flex; flex-direction: column; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--soft); background: #fff; text-align: left; width: 100%; min-height: 56px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 20;
  max-width: calc(100% - 40px);
}
.spinner { padding: 64px 0; text-align: center; color: var(--muted); }

.mode-pill { align-self: flex-start; margin-top: 4px; border: 0; background: var(--blue-tint); color: var(--blue); font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; }
.who-btn { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 4px 0; text-align: left; border-radius: 10px; }
.who-btn:active { background: var(--soft); }
.contact-row { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 6px; }
.contact-value { font-size: 17px; font-weight: 600; }
.sheet .btn { width: 100%; }
