/* LifeOS NoLimit — mobile first. Tema: automático (sistema), claro ou escuro (data-theme no <html>). */
:root {
  --bg: #0E1012; --surface: #171A1E; --surface-2: #21252B; --line: #2B3038;
  --fg: #ECEEF1; --muted: #8B93A0; --accent: #4C8DFF; --accent-fg: #fff; --accent-soft: rgba(76,141,255,.14);
  --ok: #3DD68C; --ok-soft: rgba(61,214,140,.14); --bad: #FF6B6B; --warn: #F5B83D;
  --t-musculacao: #4C8DFF; --t-corrida: #FF8A4C; --t-bike: #F5B83D; --t-natacao: #3CC8E8; --t-muay_thai: #E85C7A;
  --t-forca: #9B7BFF; --t-caminhada: #7BC67B; --t-mobilidade: #C79BFF; --t-outro: #8B93A0;
  --r: 14px; --r-sm: 10px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabs-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F3F4F6; --surface: #FFFFFF; --surface-2: #ECEEF2; --line: #DFE2E7;
    --fg: #14171B; --muted: #646C78; --accent: #2F6FE8; --accent-soft: rgba(47,111,232,.10);
    --ok: #1F9D61; --ok-soft: rgba(31,157,97,.12); --bad: #D64545; --warn: #B7791F;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
    --bg: #F3F4F6; --surface: #FFFFFF; --surface-2: #ECEEF2; --line: #DFE2E7;
    --fg: #14171B; --muted: #646C78; --accent: #2F6FE8; --accent-soft: rgba(47,111,232,.10);
    --ok: #1F9D61; --ok-soft: rgba(31,157,97,.12); --bad: #D64545; --warn: #B7791F;
    color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; }
body { overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

#view {
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-right)) calc(var(--tabs-h) + env(safe-area-inset-bottom) + 84px) max(16px, env(safe-area-inset-left));
  max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
}

/* Barra de abas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabs a.on { color: var(--accent); }
.tabs svg, .ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Cabeçalho de página */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 6px; }
.ph h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.ph .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface); display: grid; place-items: center; color: var(--fg); flex: none; }
.icon-btn .ico { width: 20px; height: 20px; }

/* Cartões */
.card { background: var(--surface); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 a, .card h2 button.link { font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; background: none; border: 0; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 14px 8px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { font-size: 22px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .d { font-size: 12px; color: var(--muted); }
.kpi.big { grid-column: 1 / -1; }
.kpi.big .v { font-size: 32px; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r-sm); padding: 12px 16px; font-weight: 700; font-size: 15px; background: var(--surface-2); color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.ok { background: var(--ok); color: #06210f; }
.btn.danger { background: transparent; color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }

/* Campos */
.field { width: 100%; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); padding: 12px 14px; font-size: 16px; outline: none; }
.field:focus { border-color: var(--accent); }
label.lbl { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 6px; }
.quick { display: flex; gap: 8px; }
.quick .field { flex: 1; }

/* Chips e segmentos */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 0; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--fg); }

/* Barras horizontais */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 14px; }
.bar .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar .val small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.bar .tr { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar .fl { height: 100%; border-radius: 3px; background: var(--accent); }

/* Listas */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.item .r { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dayhead { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 14px 0 2px; }
.dot { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.dot .ico { width: 18px; height: 18px; }
button.item { background: none; border: 0; border-top: 1px solid var(--line); width: 100%; text-align: left; color: inherit; }
button.item:first-child { border-top: 0; }

/* Tarefas */
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: transparent; flex: none; display: grid; place-items: center; padding: 0; }
.check.on { background: var(--ok); border-color: var(--ok); }
.check.on::after { content: ""; width: 10px; height: 6px; border: 2.5px solid #06210f; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.done .t { text-decoration: line-through; color: var(--muted); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.late { background: rgba(255,107,107,.14); color: var(--bad); }
.tag.today { background: var(--accent-soft); color: var(--accent); }

/* Semana de treinos */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-weight: 600; }
.week .c { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; color: var(--fg); position: relative; }
.week .c.today { outline: 2px solid var(--accent); outline-offset: 2px; }
.week .pips { display: flex; gap: 2px; height: 6px; }
.week .pip { width: 6px; height: 6px; border-radius: 50%; }

/* Treino ativo (estilo Hevy) */
.workout { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wk-head { position: sticky; top: 0; z-index: 3; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
.wk-top { display: flex; align-items: center; gap: 10px; }
.wk-top .ttl { flex: 1; font-weight: 800; font-size: 17px; }
.wk-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.wk-stats div { display: flex; flex-direction: column; }
.wk-stats .l { font-size: 11px; color: var(--muted); font-weight: 600; }
.wk-stats .v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wk-body { padding: 14px max(16px, env(safe-area-inset-right)) calc(140px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.ex { display: flex; flex-direction: column; gap: 8px; }
.ex-h { display: flex; align-items: center; gap: 10px; }
.ex-h .nm { flex: 1; font-weight: 800; color: var(--accent); font-size: 16px; background: none; border: 0; padding: 0; text-align: left; }
.ex-rest { font-size: 13px; color: var(--accent); background: none; border: 0; padding: 0; display: inline-flex; gap: 6px; align-items: center; align-self: flex-start; font-weight: 600; }
.ex-rest .ico { width: 16px; height: 16px; }
.ex-notes { width: 100%; border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 0; resize: none; outline: none; }
.sets { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.sets th { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 4px; text-align: center; }
.sets td { padding: 0 3px; text-align: center; height: 40px; }
.sets tr.feita td { background: var(--ok-soft); }
.sets tr.feita td:first-child { border-radius: 8px 0 0 8px; }
.sets tr.feita td:last-child { border-radius: 0 8px 8px 0; }
.sets .st { width: 34px; height: 30px; border-radius: 8px; border: 0; background: var(--surface-2); font-weight: 800; font-size: 14px; }
.sets .st.aquecimento { color: var(--warn); } .sets .st.drop { color: var(--t-forca); } .sets .st.falha { color: var(--bad); }
.sets .prev { color: var(--muted); font-size: 13px; white-space: nowrap; background: none; border: 0; padding: 0; }
.sets input { width: 100%; max-width: 74px; height: 32px; border: 0; border-radius: 8px; background: var(--surface-2); text-align: center; font-weight: 700; font-size: 16px; outline: none; font-variant-numeric: tabular-nums; }
.sets tr.feita input, .sets tr.feita .st { background: transparent; }
.sets input:focus { outline: 2px solid var(--accent); }
.sets .ck { width: 34px; height: 30px; border-radius: 8px; border: 0; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto; }
.sets .ck .ico { width: 18px; height: 18px; stroke-width: 3; color: var(--muted); }
.sets tr.feita .ck { background: var(--ok); }
.sets tr.feita .ck .ico { color: #06210f; }
.add-set { border: 0; background: var(--surface); border-radius: 10px; padding: 10px; font-weight: 700; font-size: 14px; color: var(--fg); }
.rest-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 10px; }
.rest-bar .prog { position: absolute; top: -1px; left: 0; height: 3px; background: var(--accent); transition: width 1s linear; }
.rest-bar .tm { flex: 1; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; }
.mini-treino { position: fixed; z-index: 19; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px);
  border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-fg); padding: 12px 16px; font-weight: 700; display: flex; justify-content: space-between; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

/* Folha inferior (bottom sheet) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; animation: fade .18s ease-out; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 14px; animation: up .22s cubic-bezier(.2,.8,.2,1); max-width: 640px; margin: 0 auto; }
.sheet::before { content: ""; width: 38px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; flex: none; }
.sheet h3 { margin: 0; font-size: 19px; font-weight: 800; }
.sheet .item { background: none; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-bg { animation: none; } }

.toast { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); background: var(--fg); color: var(--bg);
  padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.3); }

/* Gráfico */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

/* Login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px; max-width: 420px; margin: 0 auto; }
.login h1 { font-size: 34px; margin: 0; font-weight: 800; letter-spacing: -.02em; }
.login .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px; }

.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: rot .8s linear infinite; margin: 30px auto; }
@keyframes rot { to { transform: rotate(360deg); } }
.skel { background: var(--surface); border-radius: var(--r); height: 90px; }
.sheet .seg { background: var(--surface-2); }
.sheet .seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
