/* ===== Tokens ===== */
:root {
  --bg: #121212;
  --card: #1e1e1e;
  --card-2: #262626;
  --line: #2f2f2f;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-light: #86efac;
  --orange: #f97316;
  --blue: #3b82f6;
  --red: #ef4444;
  --cell: #2a2a2a;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}

body.rest-on #app { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 120px); }

/* ===== Cabeçalho / títulos ===== */
.hdr { padding: 6px 2px 14px; }
.hdr .date { color: var(--muted); font-size: .85rem; }
.hdr h1 { margin: 2px 0 6px; font-size: 1.6rem; letter-spacing: -.02em; }
.status-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--card-2); color: var(--muted);
}
.chip.ok { background: rgba(34,197,94,.15); color: var(--green); }
.chip.warn { background: rgba(249,115,22,.15); color: var(--orange); }
.chip.blue { background: rgba(59,130,246,.15); color: var(--blue); }

.page-title { font-size: 1.5rem; margin: 6px 2px 14px; letter-spacing: -.02em; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid #262626;
}
.card-title { margin: 0 0 12px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: -4px 0 12px; }
.hint.small { font-size: .75rem; margin: 12px 0 0; }
.muted { color: var(--muted); }

/* ===== Jornada ===== */
.journey { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card-2); border-radius: 14px; padding: 14px; }
.stat .label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: .9rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat .sub { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.stat.streak .value { color: var(--orange); }
.stat.roi .value { color: var(--green); font-size: 1.7rem; }
.cycle-line { margin-top: 12px; font-size: .78rem; color: var(--muted); text-align: center; }

/* ===== Escudos ===== */
.shield-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(59,130,246,.12);
  border: 1px solid rgba(59,130,246,.35);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.shields { display: flex; gap: 6px; }
.shield { width: 30px; height: 34px; }
.shield path { fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linejoin: round; }
.shield.on path { fill: var(--blue); }
.shield-banner .txt { font-size: .85rem; line-height: 1.3; }
.shield-banner .txt strong { display: block; color: var(--blue); font-size: .95rem; }
.shield-banner .txt span { color: var(--muted); }

/* ===== Treino do dia ===== */
.wk-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.wk-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.wk-count { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ex-list { list-style: none; margin: 10px 0 0; padding: 0; }
.ex-list li { border-top: 1px solid var(--line); }
.ex-list li:first-child { border-top: 0; }
.ex-item { display: flex; align-items: center; gap: 6px; }
.help-btn {
  flex: 0 0 auto; position: relative; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #52525b;
  background: none; color: var(--muted); font-weight: 800; font-size: .95rem; cursor: pointer; padding: 0;
}
.help-btn:hover { color: var(--text); border-color: #a1a1aa; }
.help-btn.has { border-color: var(--blue); color: var(--blue); }
.help-btn.has::after { content: ""; position: absolute; top: -1px; right: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.ex {
  display: flex; align-items: center; gap: 14px; width: 100%; flex: 1; min-width: 0;
  padding: 13px 2px; background: none; border: 0; text-align: left; cursor: pointer; min-height: 52px;
}
.box {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid #52525b; display: grid; place-items: center; transition: .15s;
}
.box svg { width: 16px; height: 16px; stroke: #04210f; stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.5); transition: .15s; }
.ex.done .box { background: var(--green); border-color: var(--green); }
.ex.done .box svg { opacity: 1; transform: scale(1); }
.ex .name { flex: 1; font-size: 1rem; }
.ex .series { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex.done .name { color: var(--muted); text-decoration: line-through; text-decoration-color: #52525b; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: .92rem; }

/* ===== Botões ===== */
.actions { display: grid; gap: 10px; margin-bottom: 14px; }
.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 14px; padding: 13px 18px;
  font-weight: 700; transition: transform .08s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green); color: #04210f; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-big { width: 100%; padding: 19px 18px; font-size: 1.15rem; border-radius: 18px; box-shadow: 0 8px 24px rgba(34,197,94,.22); }
.btn-ghost { background: var(--card-2); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.14); color: var(--red); }
.btn-sm { padding: 10px 14px; font-size: .9rem; border-radius: 12px; }
.btn-quiet { background: none; color: var(--muted); width: 100%; font-weight: 600; padding: 12px; border: 1px dashed #3f3f46; }
.btn-quiet:hover { color: var(--text); border-color: #71717a; }
.btn-done { background: rgba(34,197,94,.15); color: var(--green); box-shadow: none; cursor: default; }
.btn-done:active { transform: none; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; justify-content: space-between; }
.btn-row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px; font-size: .85rem; }
.center { text-align: center; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 8px 34px rgba(34,197,94,.55); } }

/* ===== Cronômetro de descanso ===== */
.rest {
  position: fixed; left: 12px; right: 12px; z-index: 30;
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  max-width: 536px; margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
  background: #27272a; border: 1px solid #3f3f46; border-radius: 16px; padding: 10px 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); overflow: hidden;
}
.rest-time { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rest-label { color: var(--muted); font-size: .8rem; }
.rest.over { border-color: var(--green); }
.rest.over .rest-time { color: var(--green); }
.seg { display: flex; background: #18181b; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 700; cursor: pointer; font-size: .85rem; }
.seg button.on { background: var(--green); color: #04210f; }
.rest-close { background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: 6px 4px; cursor: pointer; }
.rest-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #18181b; }
.rest-bar i { display: block; height: 100%; width: 100%; background: var(--green); transition: width .25s linear; }

/* ===== Navegação inferior ===== */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(24,24,24,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid #262626;
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #71717a; text-decoration: none; font-size: .68rem; font-weight: 600;
}
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--green); }

/* ===== Calendário ===== */
.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cal-top .label { font-weight: 700; font-size: 1.05rem; text-align: center; flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--card-2); cursor: pointer; font-size: 1.1rem; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.mode { display: flex; background: var(--card-2); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.mode button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; }
.mode button.on { background: var(--card); color: var(--text); }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font-size: .7rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.day {
  aspect-ratio: 1; border-radius: 10px; background: var(--cell); border: 2px solid transparent;
  display: grid; place-items: center; font-size: .82rem; font-weight: 600; color: #9a9aa3;
  cursor: pointer; padding: 0; font-variant-numeric: tabular-nums;
}
.day.blank { background: none; cursor: default; }
.day.we { color: #6b6b73; }
.day.completo { background: var(--green-dark); color: #fff; }
.day.minimo { background: var(--green-light); color: #052e16; }
.day.escudo { background: var(--blue); color: #fff; }
.day.today { border-color: #fff; }
.day.future { opacity: .4; cursor: default; }

.year-wrap { overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.year { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px; width: max-content; }
.year .m-lbl { font-size: .62rem; color: var(--muted); height: 13px; line-height: 13px; }
.year-months { display: grid; grid-auto-flow: column; grid-auto-columns: 13px; gap: 3px; width: max-content; margin-bottom: 4px; }
.cellb { width: 13px; height: 13px; border-radius: 3px; background: var(--cell); padding: 0; border: 0; cursor: pointer; }
.cellb.completo { background: var(--green-dark); }
.cellb.minimo { background: var(--green-light); }
.cellb.escudo { background: var(--blue); }
.cellb.today { outline: 1.5px solid #fff; outline-offset: 0; }
.cellb.void { background: none; cursor: default; }
.cellb.future { opacity: .35; cursor: default; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: .75rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--cell); display: inline-block; }
.legend i.completo { background: var(--green-dark); }
.legend i.minimo { background: var(--green-light); }
.legend i.escudo { background: var(--blue); }

/* ===== Progresso ===== */
.progress { height: 12px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-dark), var(--green)); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); min-width: 0; }
.progress.orange > i { background: linear-gradient(90deg, #ea580c, var(--orange)); }
.progress.blue > i { background: linear-gradient(90deg, #2563eb, var(--blue)); }
.prog-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.big-num { font-size: 2.4rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.big-num small { font-size: 1rem; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.sim { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sim .stat .value { font-size: 1.35rem; }
.tip { margin-top: 12px; font-size: .85rem; color: var(--muted); background: var(--card-2); padding: 10px 12px; border-radius: 12px; }
.tip b { color: var(--text); }

/* ===== Gamificação ===== */
.rank-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.rank-emoji { font-size: 2.4rem; width: 62px; height: 62px; display: grid; place-items: center; background: var(--card-2); border-radius: 18px; }
.rank-name { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.rank-xp { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.ranks { display: flex; justify-content: space-between; margin-top: 14px; gap: 4px; }
.ranks div { flex: 1; text-align: center; font-size: .68rem; color: #71717a; font-weight: 600; }
.ranks div b { display: block; font-size: 1.15rem; filter: grayscale(1); opacity: .5; }
.ranks div.on { color: var(--text); }
.ranks div.on b { filter: none; opacity: 1; }
.bonus-note { margin-top: 12px; font-size: .8rem; color: var(--orange); }

.vault-empty { display: grid; gap: 10px; }
.vault-title { font-weight: 800; font-size: 1.15rem; margin-bottom: 4px; }
.vault-done { text-align: center; padding: 6px 0 2px; }
.vault-done .trophy { font-size: 2.6rem; }

.medals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.medal { background: var(--card-2); border-radius: 16px; padding: 14px 12px; text-align: center; position: relative; }
.medal .em { font-size: 2.1rem; display: block; margin-bottom: 4px; }
.medal .nm { font-weight: 700; font-size: .88rem; }
.medal .ds { color: var(--muted); font-size: .72rem; margin-top: 3px; line-height: 1.3; }
.medal.locked .em { filter: grayscale(1); opacity: .35; }
.medal.locked .nm { color: #8b8b94; }
.medal.on { box-shadow: inset 0 0 0 1.5px rgba(34,197,94,.55); background: rgba(34,197,94,.07); }
.medal .mp { height: 4px; background: #18181b; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.medal .mp i { display: block; height: 100%; background: #52525b; }

/* ===== Formulários ===== */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field > span em { font-style: normal; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=url], input[type=number], textarea, select {
  width: 100%; background: var(--card-2); border: 1px solid #333; border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--green); }
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; cursor: pointer; }
.switch-row small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 50px; height: 30px; border-radius: 99px; background: #3f3f46; position: relative; transition: .2s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }

.ficha { background: var(--card-2); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.ficha-head { display: flex; gap: 8px; margin-bottom: 8px; }
.ficha-head input { background: var(--bg); font-weight: 700; }
.ficha textarea { background: var(--bg); min-height: 130px; }
.ficha .icon-btn { background: var(--bg); flex: 0 0 auto; width: 44px; height: 46px; }
.sync-status { font-size: .85rem; margin: 12px 0 0; min-height: 1.2em; color: var(--muted); }
.sync-status.ok { color: var(--green); }
.sync-status.err { color: var(--red); }
.sync-status.busy { color: var(--blue); }

/* ===== Bottom sheet ===== */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px; background: var(--card);
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-b));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
/* Guia de equipamentos */
.sheet-panel { max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; }
.guide h3 { margin-bottom: 8px; padding-right: 4px; }
.guide h4 { margin: 18px 0 6px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.guide p { margin: 0; color: var(--text); font-size: .95rem; line-height: 1.5; }
.tag { display: inline-block; padding: 4px 12px; border-radius: 999px; background: rgba(34,197,94,.15); color: var(--green); font-size: .78rem; font-weight: 700; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; font-size: .95rem; line-height: 1.45; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--card-2); color: var(--green); font-weight: 800; font-size: .8rem; display: grid; place-items: center; }
.guide a.btn { display: block; text-align: center; text-decoration: none; margin-top: 16px; }
.adj-row { display: flex; gap: 8px; }
.adj-row input { flex: 1 1 0; min-width: 0; width: auto; }
.sheet-panel .adj-row .btn { width: auto; margin-top: 0; flex: 0 0 auto; }
.sheet-panel h3 { margin: 0 0 4px; font-size: 1.15rem; }
.sheet-panel p { margin: 0 0 14px; color: var(--muted); font-size: .9rem; }
.sheet-panel .btn { width: 100%; margin-top: 8px; }

/* ===== Toasts ===== */
.toasts { position: fixed; left: 0; right: 0; top: calc(10px + var(--safe-t)); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 14px; }
.toast {
  background: #fafafa; color: #18181b; padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: .92rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); max-width: 480px; animation: drop .25s ease-out;
}
.toast.good { background: var(--green); color: #04210f; }
.toast.blue { background: var(--blue); color: #fff; }
.toast.gold { background: #facc15; color: #422006; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .3s; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }

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