/* ═══════════════════════════════════════════════════════════════════════════
   ORTOGRAFÍA × CARNÉ v2 — style.css
═══════════════════════════════════════════════════════════════════════════ */

:root {
  --blue:    #2E7BCF;
  --blue-dk: #1D5A9E;
  --green:   #1A5C2A;
  --green-lt:#E8F5E9;
  --red:     #C0392B;
  --red-lt:  #FDECEA;
  --orange:  #C45000;
  --orange-lt:#FFF3E0;
  --gold:    #F9A825;
  --bg:      #F0F4F8;
  --card:    #FFFFFF;
  --border:  #D6E0EA;
  --text:    #1A2B3C;
  --muted:   #6B7A8D;
  --radius:  12px;
  --shadow:  0 2px 8px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Navbar ───────────────────────────────────────────────────────────────── */

.navbar {
  background: var(--blue);
  color: #fff;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.nav-brand { font-weight: 700; font-size: 16px; letter-spacing: -.3px; }
.nav-stats { display: flex; gap: 8px; }

.stat-pill {
  background: rgba(255,255,255,.18);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-panel-link {
  font-size: 12px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px;
  transition: background .2s;
}
.nav-panel-link:hover { background: rgba(255,255,255,.15); }

/* ─── Layout ───────────────────────────────────────────────────────────────── */

.container { max-width: 600px; margin: 0 auto; padding: 16px; }

.view { display: none; }
.view.active { display: block; }

/* ─── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title { font-size: 15px; font-weight: 700; }
.card-sub   { font-size: 13px; color: var(--muted); }

/* ─── Penalty banner ───────────────────────────────────────────────────────── */

.penalty-banner {
  background: var(--orange-lt);
  border: 1.5px solid var(--orange);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--orange);
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.penalty-banner .penalty-icon { font-size: 20px; flex-shrink: 0; }

/* ─── Mes / Nivel card ─────────────────────────────────────────────────────── */

.level-card { padding: 20px; }

.level-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.level-emoji { font-size: 36px; line-height: 1; margin-bottom: 4px; }
.level-name  { font-size: 17px; font-weight: 800; }
.level-sub   { font-size: 13px; color: var(--muted); margin-top: 2px; }

.level-badge {
  text-align: right;
}
.level-pct {
  font-size: 32px;
  font-weight: 900;
  color: var(--blue);
  line-height: 1;
}
.level-pct-label { font-size: 11px; color: var(--muted); }

.level-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.level-progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  transition: width .6s ease;
}

.level-progress-label { font-size: 12px; color: var(--muted); }

/* ─── Stats row ────────────────────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-val { font-size: 22px; font-weight: 800; color: var(--blue); }
.stat-val.orange { color: var(--orange); }
.stat-val.red    { color: var(--red); }
.stat-val.green  { color: var(--green); }
.stat-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }

/* ─── Day grid ─────────────────────────────────────────────────────────────── */

.day-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid transparent;
  transition: transform .15s;
}

.day-cell .day-num { font-size: 14px; font-weight: 800; }
.day-cell .day-ico { font-size: 10px; margin-top: 1px; }

.day-cell.completed { background: var(--green-lt); border-color: var(--green); color: var(--green); }
.day-cell.current   { background: var(--blue); color: #fff; border-color: var(--blue-dk); cursor: pointer; }
.day-cell.current:hover { transform: scale(1.08); }
.day-cell.pending   { background: #f0f0f0; color: #aaa; }
.day-cell.missed    { background: var(--red-lt); border-color: var(--red); color: var(--red); }

/* ─── Milestones ───────────────────────────────────────────────────────────── */

.milestones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.milestone-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
}

.milestone-row.done {
  background: var(--green-lt);
  border-color: var(--green);
}
.milestone-row.current {
  background: #EBF4FF;
  border-color: var(--blue);
}

.ms-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.milestone-row.done .ms-dot    { background: var(--green); }
.milestone-row.current .ms-dot { background: var(--blue); }

.ms-info { flex: 1; }
.ms-mes  { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.ms-tema { font-size: 13px; font-weight: 700; }
.ms-hito { font-size: 12px; color: var(--muted); }

.ms-pct  { font-size: 16px; font-weight: 900; color: var(--blue); }
.milestone-row.done .ms-pct { color: var(--green); }

/* ─── CTA ──────────────────────────────────────────────────────────────────── */

.cta-area { margin: 6px 0 20px; }
.cta-hint { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, transform .1s;
  text-align: center;
}
.btn-primary:hover:not(:disabled) { background: var(--blue-dk); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s;
}
.btn-secondary:hover { background: #EBF4FF; }

.btn-back {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ─── Exercise view ────────────────────────────────────────────────────────── */

.exercise-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.exercise-progress { font-size: 13px; color: var(--muted); font-weight: 600; }

.exercise-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.tag-type   { background: #EBF4FF; color: var(--blue); }
.tag-diff   { background: var(--orange-lt); color: var(--orange); }
.tag-km     { background: var(--green-lt); color: var(--green); }
.tag-fuente { background: #F5F0FF; color: #6B3FA0; font-size: 11px; }

.exercise-card { padding: 20px; }

.ex-context {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 14px;
  font-style: italic;
}

.ex-question {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  line-height: 1.4;
}

.options-list { display: flex; flex-direction: column; gap: 8px; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: border-color .15s, background .15s;
  width: 100%;
}
.option-btn:hover:not(:disabled) { border-color: var(--blue); background: #EBF4FF; }
.option-btn.selected { border-color: var(--blue); background: #EBF4FF; }
.option-btn.correct  { border-color: var(--green); background: var(--green-lt); }
.option-btn.wrong    { border-color: var(--red); background: var(--red-lt); }
.option-btn:disabled { cursor: default; }

.option-letter {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}
.option-btn.selected .option-letter { background: var(--blue); color: #fff; }
.option-btn.correct  .option-letter { background: var(--green); color: #fff; }
.option-btn.wrong    .option-letter { background: var(--red); color: #fff; }

/* ─── Feedback ─────────────────────────────────────────────────────────────── */

.feedback-card {
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  border: 2px solid;
}
.feedback-card.correct { border-color: var(--green); background: var(--green-lt); }
.feedback-card.wrong   { border-color: var(--red); background: var(--red-lt); }

.feedback-header {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 8px;
}
.feedback-header.correct { color: var(--green); }
.feedback-header.wrong   { color: var(--red); }

.feedback-explanation { font-size: 14px; color: var(--text); margin-bottom: 8px; }

.feedback-multa {
  font-size: 13px;
  color: var(--orange);
  font-weight: 600;
  background: var(--orange-lt);
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
}

.feedback-km {
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  margin-top: 8px;
}

/* ─── Day complete / Modal ─────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-box {
  background: var(--card);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.modal-emoji { font-size: 48px; margin-bottom: 12px; }
.modal-box h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.modal-box p  { font-size: 15px; color: var(--muted); margin-bottom: 12px; }
.modal-prize  { font-size: 16px; font-weight: 700; color: var(--blue); }

/* ─── KM Toast ─────────────────────────────────────────────────────────────── */

.km-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  transition: transform .3s ease, opacity .3s;
  opacity: 0;
  z-index: 300;
  pointer-events: none;
}
.km-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ─── Progress bar generic ─────────────────────────────────────────────────── */

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
  transition: width .5s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}

.login-box {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
  text-align: center;
}

.login-box .login-emoji { font-size: 48px; margin-bottom: 12px; }
.login-box h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-box p  { font-size: 14px; color: var(--muted); margin-bottom: 24px; }

.input-group { margin-bottom: 16px; text-align: left; }
.input-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.input-group input:focus { border-color: var(--blue); }

.login-error {
  font-size: 13px;
  color: var(--red);
  margin-bottom: 12px;
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PANEL DEL PADRE
═══════════════════════════════════════════════════════════════════════════ */

.panel-nav {
  background: #1A2B3C;
  color: #fff;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.panel-nav-brand { font-weight: 700; font-size: 16px; }

.panel-container { max-width: 900px; margin: 0 auto; padding: 20px 16px; }

.panel-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-section-header {
  background: var(--bg);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-section-header h2 { font-size: 15px; font-weight: 700; }
.panel-section-body { padding: 20px; }

/* Summary grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 480px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
}

.summary-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}

.summary-card .s-val { font-size: 28px; font-weight: 900; color: var(--blue); }
.summary-card .s-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

/* Hitos bar */
.hitos-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.hito-segment {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border-right: 1px solid var(--border);
  transition: background .3s;
}
.hito-segment:last-child { border-right: none; }
.hito-segment.done { background: var(--green-lt); color: var(--green); }
.hito-segment.current { background: #EBF4FF; color: var(--blue); }

.hito-segment .h-mes { font-size: 10px; opacity: .8; }
.hito-segment .h-pct { font-size: 15px; font-weight: 900; }

/* Heat map */
.heatmap-wrapper { overflow-x: auto; }

.heatmap {
  display: grid;
  grid-template-columns: 60px repeat(20, 32px);
  gap: 3px;
  min-width: 720px;
}

.hm-header {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  padding: 4px 0;
}

.hm-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding-right: 8px;
}

.hm-cell {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  background: #E0E0E0;
  cursor: default;
  transition: transform .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.hm-cell:hover { transform: scale(1.2); z-index: 1; }
.hm-cell.done    { background: #4CAF50; }
.hm-cell.missed  { background: #EF5350; }
.hm-cell.current { background: var(--blue); }

/* Errors table */
.errors-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.errors-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.errors-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg);
}
.errors-table tr:last-child td { border-bottom: none; }
.errors-table .pct-bar {
  display: inline-block;
  height: 8px;
  background: var(--red);
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
}

/* Reset controls */
.reset-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

.reset-group { display: flex; flex-direction: column; gap: 6px; }
.reset-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.reset-group select {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
}

/* ─── Loading ──────────────────────────────────────────────────────────────── */

.loading-screen {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-screen {
  background: var(--red-lt);
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--red);
  margin: 32px 0;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 380px) {
  .day-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .stat-val  { font-size: 18px; }
}
