/* AppLM — Mesada do Luiz Miguel (mobile-first) */
:root {
  --accent: #2563eb;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --ok: #16a34a;
  --bad: #dc2626;
  --mid: #d97706;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 76px;
  min-height: 100vh;
}

/* ---------- Header ---------- */
#header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
  color: #fff;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.hdr-left { display: flex; align-items: center; gap: 10px; }
.hdr-avatar { font-size: 2rem; background: rgba(255,255,255,.2); border-radius: 50%; width: 48px; height: 48px; display: grid; place-items: center; }
.hdr-name { font-weight: 800; font-size: 1.05rem; }
.hdr-day { font-size: .78rem; opacity: .9; }
.hdr-right { display: flex; align-items: center; gap: 8px; }
.hdr-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.stat { font-size: .8rem; font-weight: 800; background: rgba(255,255,255,.18); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.lock-btn { background: rgba(255,255,255,.2); border: none; font-size: 1.2rem; border-radius: 12px; padding: 8px 10px; cursor: pointer; }

/* ---------- Layout ---------- */
.screen { padding: 14px 12px 24px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 2px 10px rgba(30,41,59,.07);
}
.card h3 { margin-bottom: 8px; font-size: 1rem; }
.card.slim { padding: 12px 16px; font-size: .92rem; }
.big-card { padding: 24px 18px; }
.center { text-align: center; }
.big-emoji { font-size: 3.4rem; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: .84rem; }
.ok-strip { background: #dcfce7; color: #166534; font-weight: 700; }
.fact-card { background: linear-gradient(135deg, #fef9c3, #fef3c7); }
hr { border: none; border-top: 1px solid #e2e8f0; margin: 12px 0; }

/* ---------- Botões ---------- */
.btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 14px; padding: 12px 16px;
  font-family: inherit; font-weight: 800; font-size: .95rem;
  cursor: pointer; transition: transform .1s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .7; }
.btn-big { width: 100%; padding: 15px; font-size: 1.05rem; margin-top: 10px; }
.btn-sm { padding: 8px 12px; font-size: .85rem; border-radius: 10px; }
.btn-ghost { background: #e2e8f0; color: var(--text); }
.ok-btn { background: var(--ok); }
.no-btn { background: var(--bad); }

/* ---------- Tarefas ---------- */
.task { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.task:last-child { border-bottom: none; }
.task-icon { font-size: 1.6rem; }
.task-info { flex: 1; }
.task-name { font-weight: 700; font-size: .92rem; }
.task-val { font-size: .78rem; color: var(--muted); }
.task.done-approved { opacity: .75; }
.task.done-approved .task-name::after { content: " ✅"; }
.task.done-pending .task-name::after { content: " ⏳"; }
.summary-txt { font-style: italic; white-space: pre-wrap; }
.debit-rules { border: 2px solid #fecaca; background: #fff7f7; }
.neg-val { color: var(--bad); font-weight: 800; }

/* ---------- Barras ---------- */
.bar { background: #e2e8f0; border-radius: 999px; height: 14px; overflow: hidden; margin: 8px 0; }
.bar.sm { height: 9px; flex: 1; margin: 0 8px; }
.bar-fill { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #fff)); height: 100%; border-radius: 999px; transition: width .5s; }
.cat-row { display: flex; align-items: center; padding: 5px 0; }
.cat-name { font-size: .82rem; font-weight: 700; width: 42%; }
.cat-pct { font-size: .78rem; color: var(--muted); min-width: 38px; text-align: right; }

/* ---------- Quiz ---------- */
.quiz-top { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--muted); font-weight: 700; }
.chip { background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: .75rem; font-weight: 800; display: inline-block; }
.quiz-q { margin: 12px 0; font-size: 1.05rem; }
.opt-btn { display: block; width: 100%; margin-bottom: 8px; background: #fff; color: var(--text); border: 2px solid #e2e8f0; text-align: left; }
.opt-btn.right { border-color: var(--ok); background: #dcfce7; }
.opt-btn.wrong { border-color: var(--bad); background: #fee2e2; }
.opt-btn.mid { border-color: var(--mid); background: #fef3c7; }
.ei-opt { font-size: .9rem; line-height: 1.35; }
.fb { border-radius: 12px; padding: 12px; margin-top: 8px; font-weight: 700; font-size: .92rem; }
.fb small { font-weight: 400; }
.fb.ok { background: #dcfce7; color: #166534; }
.fb.bad { background: #fee2e2; color: #991b1b; }
.fb.mid { background: #fef3c7; color: #92400e; }

/* ---------- Skins ---------- */
.skin-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.skin { background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 14px; padding: 8px; min-width: 76px; text-align: center; cursor: pointer; font-family: inherit; }
.skin.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, #fff); }
.skin.locked { opacity: .6; }
.skin-emoji { font-size: 1.7rem; display: block; }
.skin-name { font-size: .68rem; font-weight: 700; color: var(--muted); }

/* ---------- Histórico ---------- */
.hist-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; font-size: .85rem; }
.hist-row:last-child { border-bottom: none; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.undo-btn { background: none; border: none; cursor: pointer; font-size: 1rem; }

/* ---------- Painel pais ---------- */
.pstat-row { display: flex; gap: 8px; }
.pstat { flex: 1; background: #f8fafc; border-radius: 12px; padding: 10px 8px; text-align: center; }
.pstat-v { font-weight: 900; font-size: .98rem; color: var(--accent); }
.pstat-l { font-size: .68rem; color: var(--muted); }
.man-row { display: flex; gap: 8px; margin-bottom: 8px; }
.man-row input[type=text] { flex: 2; }
.man-row input[type=number] { flex: 1; }
.man-btns { display: flex; gap: 8px; flex-wrap: wrap; }
input, textarea {
  font-family: inherit; font-size: .95rem;
  border: 2px solid #e2e8f0; border-radius: 12px; padding: 10px 12px; width: 100%;
  background: #fff; color: var(--text);
}
label { display: block; font-size: .85rem; font-weight: 700; margin-bottom: 10px; }
label input { margin-top: 4px; }
textarea { resize: vertical; margin: 8px 0; }

/* ---------- Ícones SVG ---------- */
.ico { display: inline-flex; vertical-align: -0.22em; }
.ico svg { width: 1.25em; height: 1.25em; }
.ico-xs svg { width: 1.1em; height: 1.1em; }
.ico-sm svg { width: 22px; height: 22px; }
.ico-lg svg { width: 36px; height: 36px; }
.ico-xl svg { width: 76px; height: 76px; }
h3 .ico { margin-right: 4px; }
.big-ico { margin-bottom: 8px; }
.stat .ico { vertical-align: -0.28em; }
.hdr-avatar .ico svg { width: 36px; height: 36px; }
.task-icon { display: grid; place-items: center; }
.skin-ico { display: block; height: 40px; display: grid; place-items: center; }
.theme-dot { width: 30px; height: 30px; border-radius: 50%; display: inline-block; border: 3px solid #33334d; }
.ni svg { width: 27px; height: 27px; }
.reminder .ico { vertical-align: -0.3em; }

/* ---------- Nav ---------- */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--card); display: flex;
  border-top: 1px solid #e2e8f0;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; background: none; border: none; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .66rem; font-weight: 800; color: var(--muted); cursor: pointer;
  padding: 4px 0; border-radius: 12px;
}
.nav-btn .ni { font-size: 1.45rem; }
.nav-btn.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, #fff); }

/* ---------- Lembretes ---------- */
.reminder { background: #eff6ff; border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: .86rem; }

/* ---------- Toast / modal / confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-weight: 800; font-size: .88rem; opacity: 0; transition: all .3s; z-index: 60;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); }

.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: grid; place-items: center; z-index: 50; padding: 18px;
}
.modal { background: var(--card); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto; }
.modal h3 { margin-bottom: 8px; }
.modal input { margin: 8px 0; }

/* ---------- Contrato, desafio e relatório ---------- */
.contract-card { border: 3px dashed var(--accent); }
.contract-list { list-style: none; padding: 6px 0; }
.contract-list li { padding: 3px 0; font-size: .92rem; }
.challenge-card { background: linear-gradient(135deg, #fdf4ff, #f3e8ff); border: 2px solid #a855f7; }
.evo-chart { width: 100%; height: auto; display: block; touch-action: none; }
.evo-caption { margin-top: 4px; }
.report-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 90; overflow-y: auto; padding: 20px 16px; }
.report-inner { max-width: 560px; margin: 0 auto; background: var(--card); border-radius: var(--radius); padding: 20px; }
.report-inner h1 { font-size: 1.2rem; margin-bottom: 4px; }
@media print {
  body > *:not(.report-overlay) { display: none !important; }
  .report-overlay { position: static; padding: 0; background: #fff; }
  .report-inner { box-shadow: none; }
  .no-print { display: none !important; }
}

.confetti {
  position: fixed; top: -12px; width: 10px; height: 14px; z-index: 70;
  border-radius: 3px; pointer-events: none;
  animation: fall 2.2s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .6; }
}
