:root {
  --bg: #f4f6fa; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #1d4ed8; --brand-2: #1e40af; --brand-soft: #e8efff;
  --gray: #94a3b8; --gray-soft: #f1f5f9; --orange: #ea7a0c; --orange-soft: #fff3e3;
  --green: #15803d; --green-soft: #e3f6e8; --red: #dc2626; --red-soft: #fdecec; --blue: #1d4ed8; --blue-soft: #e6eefe;
  --wa: #1fa855; --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); padding-bottom: 76px; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.45rem; margin: .2rem 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .7rem; }
h3 { font-size: .92rem; margin: 1rem 0 .4rem; color: var(--muted); }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.help { color: var(--muted); font-size: .88rem; margin: .2rem 0 1rem; max-width: 70ch; }

/* Cabecera */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-weight: 700; min-width: 0; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-weight: 500; color: var(--muted); font-size: .72rem; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 800; flex: none; }
.logo.big { width: 52px; height: 52px; font-size: 1.5rem; border-radius: 14px; }
.nav-desktop { display: none; gap: .2rem; margin-left: auto; }
.nav-desktop a { padding: .45rem .8rem; border-radius: 10px; color: var(--muted); font-weight: 600; }
.nav-desktop a.on, .nav-desktop a:hover { background: var(--brand-soft); color: var(--brand); }
.usermenu { margin-left: auto; position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu { position: absolute; right: 0; top: 46px; width: 250px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; display: flex; flex-direction: column; gap: .5rem; }
.usermenu .pw { display: flex; flex-direction: column; gap: .35rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .8rem; flex: none; }
.nav-mobile { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-mobile a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: .45rem 0 .5rem; font-size: .72rem; color: var(--muted); font-weight: 600; }
.nav-mobile a span { font-size: 1.25rem; line-height: 1.2; }
.nav-mobile a.on { color: var(--brand); }
@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .nav-desktop { display: flex; }
  .usermenu { margin-left: .5rem; }
  .nav-mobile { display: none; }
}

/* Estructura */
.wrap { max-width: 1180px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 640px; }
.grid2 { display: grid; gap: 1rem; }
.grid2 > .card { margin: 0; }
@media (min-width: 860px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; }
.pagehead h2 { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 1rem; }
.toolbar form { margin: 0; }
.section { margin-top: 1.6rem; }
.backlink { display: inline-block; margin-bottom: .5rem; font-weight: 600; }
.empty { background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.6rem; text-align: center; color: var(--muted); margin: 1rem 0; }
.callout { background: var(--brand-soft); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.callout.warn { background: var(--orange-soft); }
.callout .btn { margin-left: auto; }
.flash { border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; font-weight: 500; background: var(--green-soft); color: #14532d; }
.flash-error { background: var(--red-soft); color: #7f1d1d; }
.flash-warn { background: var(--orange-soft); color: #7c2d12; }

/* Botones y formularios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; padding: .55rem .95rem; border-radius: 10px; cursor: pointer; min-height: 40px; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .86rem; }
.btn.big { min-height: 52px; font-size: 1.05rem; width: 100%; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; min-height: 42px; }
input[type=color] { padding: .2rem; }
input[type=checkbox] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .88rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span2 { grid-column: span 2; } }
.form-grid.compact { padding-top: .8rem; border-top: 1px solid var(--line); margin-top: .6rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .8rem; }
.form-inline input, .form-inline select { width: auto; flex: 1 1 130px; }
.form-inline .w-num { flex: 0 0 80px; }
.row-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.inline-right { display: flex; justify-content: flex-end; margin-top: .6rem; }
.searchbar { margin-bottom: .6rem; }
.copybox { display: flex; gap: .4rem; }
.copybox input { font-size: .8rem; }

/* Listas */
.list { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; align-items: center; gap: .7rem; padding: .6rem .2rem; border-bottom: 1px solid var(--line); color: inherit; }
.card .row:last-child { border-bottom: 0; }
.list > .row { background: #fff; border: 0; border-radius: 12px; padding: .7rem .9rem; box-shadow: var(--shadow); }
.row form { margin: 0; }
.row .grow, .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row small { color: var(--muted); }
.row .num { text-align: right; display: flex; flex-direction: column; line-height: 1.1; }
.row .num b { font-size: 1.2rem; }
.row.hist .num { min-width: 32px; color: var(--muted); }
.tags-inline { color: var(--ink) !important; }
.note-inline { font-style: italic; }
.fold summary { list-style: none; cursor: pointer; padding: 0; border: 0; }
.fold summary::-webkit-details-marker { display: none; }
.fold { padding: .6rem .9rem; margin: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.count { display: inline-block; background: var(--gray-soft); color: var(--muted); border-radius: 99px; padding: 0 .5rem; font-size: .8rem; vertical-align: middle; }
.send-row { flex-wrap: wrap; }
.send-row small span { margin-right: .4rem; }
.t-gray { color: var(--muted); } .t-orange { color: var(--orange); font-weight: 600; } .t-green { color: var(--green); font-weight: 600; } .t-red { color: var(--red); font-weight: 600; }

/* Insignias */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge-gray { background: var(--gray-soft); color: #475569; }
.badge-orange { background: var(--orange-soft); color: #b45309; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .8rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .6rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: .86rem; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.tag { background: var(--brand-soft); color: var(--brand-2); border-radius: 99px; padding: .2rem .65rem; font-size: .84rem; font-weight: 600; }
.note { background: var(--gray-soft); border-radius: 10px; padding: .6rem .8rem; }

/* Inicio */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: .8rem 0 1rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1rem; color: var(--ink); display: flex; flex-direction: column; border-top: 4px solid var(--gray); }
.stat b { font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.green { border-color: var(--green); } .stat.orange { border-color: var(--orange); } .stat.blue { border-color: var(--blue); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; }
.kv.top { margin-top: 1rem; }

/* Agenda */
.weeknav { display: flex; align-items: center; gap: .6rem; }
.weeknav h1 { font-size: 1.2rem; margin: 0; }
.week { display: flex; flex-direction: column; gap: .8rem; }
.day { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem; }
.day.today { outline: 2px solid var(--brand); }
.day h2 { font-size: .95rem; margin: 0 0 .5rem; }
.day h2 span { color: var(--muted); font-weight: 500; }
.cols { display: grid; gap: .6rem; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
@media (max-width: 560px) { .cols { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.colhead { font-size: .8rem; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.slot { display: block; border-radius: 9px; padding: .4rem .55rem; background: var(--gray-soft); border-left: 4px solid var(--c, var(--gray)); color: var(--ink); font-size: .88rem; }
.slot small { display: block; color: var(--muted); }
.slot.st-sent { background: var(--orange-soft); }
.slot.st-confirmed { background: var(--green-soft); }
.slot.st-declined { background: var(--red-soft); }
.slot.st-declined small { color: var(--red); font-weight: 700; }
.slot.st-done { background: var(--blue-soft); opacity: .75; }
.add { font-size: .8rem; color: var(--muted); padding: .25rem .4rem; border: 1px dashed var(--line); border-radius: 8px; text-align: center; }
.add:hover { color: var(--brand); border-color: var(--brand); }

/* Mis clases */
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; text-align: center; }
.dayhead h1 { margin: 0; }
.dayhead p { margin: 0; }
.timeline { display: flex; flex-direction: column; gap: .6rem; }
.lesson-card { display: flex; gap: .8rem; align-items: center; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem; border-left: 5px solid var(--gray); }
.lesson-card.st-sent { border-color: var(--orange); }
.lesson-card.st-confirmed { border-color: var(--green); }
.lesson-card.st-declined, .lesson-card.st-noshow { border-color: var(--red); }
.lesson-card.st-done { border-color: var(--blue); opacity: .7; }
.lesson-card .time { display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.lesson-card .time b { font-size: 1.15rem; }
.lesson-card .time small { color: var(--muted); }
.lesson-card .grow a { color: var(--ink); }
.lesson-card .actions { display: flex; flex-direction: column; gap: .35rem; }

/* Ficha de clase y alumno */
.lessonhead { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.lessonhead p { margin: .1rem 0 .4rem; }
.counter { display: flex; flex-direction: column; align-items: center; text-align: center; background: var(--brand-soft); color: var(--brand-2); border-radius: 14px; padding: .5rem .9rem; min-width: 92px; }
.counter b { font-size: 1.9rem; line-height: 1; }
.counter span { font-size: .78rem; font-weight: 600; }
.counter.big b { font-size: 2.6rem; }
.skills { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.skills legend { font-weight: 600; font-size: .88rem; margin-bottom: .4rem; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span { display: inline-block; padding: .5rem .8rem; border-radius: 99px; border: 1px solid #cbd5e1; font-weight: 500; cursor: pointer; user-select: none; }
.pill input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.skillbars { display: flex; flex-direction: column; gap: .3rem; }
.skillbar { display: grid; grid-template-columns: 11rem 1fr 1.6rem; align-items: center; gap: .5rem; font-size: .86rem; }
.skillbar i { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--brand) var(--w), var(--gray-soft) var(--w)); }
.skillbar b { text-align: right; }
.skillbar.zero { color: var(--muted); }
@media (max-width: 480px) { .skillbar { grid-template-columns: 8.5rem 1fr 1.4rem; } }
select.result-apto { background: var(--green-soft); } select.result-no_apto { background: var(--red-soft); }

/* Acceso y portal */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 400px; padding: 1.6rem; }
.auth-head { text-align: center; margin-bottom: 1rem; }
.auth-head p { margin: 0; }
.top.portal { justify-content: center; }
.wrap.portal { max-width: 620px; }
body:has(.wrap.portal) { padding-bottom: 1rem; }
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.hero p { margin: .2rem 0; }
.portal-lesson { flex-wrap: wrap; }
.portal-lesson.st-confirmed b { color: var(--green); }

/* Repostajes */
.refuel { margin: 0; }
.refuel.open { outline: 2px solid var(--orange-soft); }
.refuel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.refuel-head h2 { margin: 0; }
.refuel-head p { margin: .15rem 0 .5rem; }
.refuel .amount { font-size: 1.35rem; white-space: nowrap; }
.refuel .kv { margin-top: .4rem; font-size: .9rem; grid-template-columns: minmax(0, 1fr) auto; }
.refuel .kv b { text-align: right; white-space: nowrap; }
.lessons-fold { margin-top: .8rem; }
.lessons-fold summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.tbl { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .86rem; }
.tbl th, .tbl td { padding: .4rem .35rem; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl .r { text-align: right; white-space: nowrap; }
@media (max-width: 480px) { .tbl th:nth-child(3), .tbl td:nth-child(3) { display: none; } }
.kmform { margin: .2rem 0 .4rem; }
.kmform label.check { font-weight: 600; }
.w-km { max-width: 10rem; }
.fold summary .btn { flex: none; }
