:root {
  --bg: #0B0D12; --surface: #14171D; --surface-2: #1B1F27; --surface-3: #232833;
  --line: rgba(255,255,255,.06); --line-2: rgba(255,255,255,.1); --track: #262B35;
  --text: #F2F4F8; --text-2: #B4BBC9; --muted: #7D8698;
  --accent: #4C8DFF; --accent-2: #3B78E7; --accent-soft: rgba(76,141,255,.14);
  --bjj: #C9802A; --bjj-soft: rgba(201,128,42,.15);
  --good: #3DBE8B; --warn: #E3B341; --bad: #F0616D;
  --r: 20px; --r-sm: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.num, .stat-value, .tab-nums { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { max-width: 560px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px 120px; }
@media (min-width: 900px) { .app { max-width: 980px; padding-top: 32px; } .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; } .grid-2 > .card { margin: 0; } }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.top h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 2px 10px; }
.section-title h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.section-title .link { color: var(--accent); font-size: 13px; font-weight: 500; text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card.tight { padding: 12px 14px; }
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.card .meta { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .xs { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }

.hero { background: linear-gradient(160deg, #1A2232 0%, var(--surface) 60%); border: 1px solid var(--line); border-radius: 24px; padding: 18px; margin-bottom: 12px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.week .d { text-align: center; font-size: 11px; color: var(--muted); }
.week .dot { height: 34px; border-radius: 12px; background: var(--surface-2); margin-top: 6px; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--text-2); position: relative; }
.week .dot.on { background: var(--accent); color: #fff; }
.week .dot.bjj { background: var(--bjj); color: #fff; }
.week .dot.both { background: linear-gradient(135deg, var(--accent) 50%, var(--bjj) 50%); color: #fff; }
.week .dot.today { outline: 1.5px solid var(--line-2); outline-offset: 2px; }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar.over > i { background: var(--warn); }
.bar.thin { height: 6px; }
.macro { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.macro + .macro { margin-top: 12px; }
.macro .bar { grid-column: 1 / -1; }
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--track) 0); display: grid; place-items: center; flex: none; }
.ring > span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 14px; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600; transition: transform .12s, background .15s, opacity .15s; }
.btn:hover { background: var(--accent-2); } .btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface-2); color: var(--text); } .btn.ghost:hover { background: var(--surface-3); }
.btn.bjj { background: var(--bjj); } .btn.danger { background: rgba(240,97,109,.14); color: var(--bad); }
.btn.sm { height: 36px; padding: 0 12px; border-radius: 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn.loading::after { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-2); flex: none; }
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn.plain { background: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 500; border: 1px solid transparent; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: rgba(76,141,255,.35); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 34px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-3); color: var(--text); }

label.field { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
label.field > span { display: block; margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; height: 46px; padding: 0 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; outline: none; font-size: 15px; transition: border-color .15s; }
textarea.input { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: rgba(76,141,255,.6); }
.input.invalid { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.err { color: var(--bad); font-size: 12px; margin-top: 6px; }

/* ---------- Lists ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
button.item:hover { background: var(--surface-2); }
.badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.badge.bjj { background: var(--bjj-soft); color: var(--bjj); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.tag.accent { background: var(--accent-soft); color: var(--accent); } .tag.bjj { background: var(--bjj-soft); color: var(--bjj); }
.tag.good { background: rgba(61,190,139,.14); color: var(--good); } .tag.warn { background: rgba(227,179,65,.14); color: var(--warn); }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); font-size: 14px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- Workout session ---------- */
.ex-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.ex-head { display: flex; align-items: flex-start; gap: 10px; }
.ex-head h3 { margin: 0; font-size: 15px; }
.prev { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sets { margin-top: 12px; }
.set-row { display: grid; grid-template-columns: 30px 1fr 1fr 44px 30px; gap: 8px; align-items: center; padding: 4px 0; }
.set-row.head { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.set-row .n { width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-2); }
.set-row input { height: 40px; text-align: center; padding: 0 6px; }
.check { width: 44px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); transition: background .15s, color .15s, transform .12s; }
.check:active { transform: scale(.92); }
.set-row.done .check { background: var(--accent); color: #fff; }
.set-row.done .n { background: var(--accent-soft); color: var(--accent); }
.cmp { font-size: 12px; font-weight: 600; }
.timer { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 99px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 12px; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.timer b { font-variant-numeric: tabular-nums; font-size: 16px; }

/* ---------- Achievements ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .ach-grid { grid-template-columns: repeat(4, 1fr); } }
.ach { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.ach .ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.ach.on .ico { background: var(--accent-soft); color: var(--accent); }
.ach.on.jiujitsu .ico { background: var(--bjj-soft); color: var(--bjj); }
.ach h4 { margin: 0; font-size: 14px; font-weight: 600; }
.ach p { margin: 0; font-size: 12px; color: var(--muted); flex: 1; }
.ach:not(.on) h4 { color: var(--text-2); }
.level { display: flex; align-items: center; gap: 14px; }
.level .lv { width: 58px; height: 58px; border-radius: 18px; background: var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 800; flex: none; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text); font-size: 12px; padding: 6px 9px; border-radius: 9px; white-space: nowrap; opacity: 0; transition: opacity .12s; z-index: 5; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.chart-empty { height: 120px; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 0 20px; background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255,255,255,.015) 10px 20px); border-radius: 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Nav ---------- */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40; display: flex; gap: 4px; padding: 6px; background: rgba(27,31,39,.88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line-2); border-radius: 99px; box-shadow: 0 12px 34px rgba(0,0,0,.45); }
.nav a { display: flex; align-items: center; gap: 7px; height: 46px; padding: 0 14px; border-radius: 99px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; transition: background .2s, color .2s; }
.nav a span { display: none; }
.nav a.on { background: var(--accent); color: #fff; }
.nav a.on span { display: inline; }
@media (min-width: 600px) { .nav a span { display: inline; } }

/* ---------- Sheets / modals ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(5,6,9,.62); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .26s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 24px; border-bottom: 1px solid var(--line-2); } }
.sheet .grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.full-screen { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; animation: fade .18s ease; }
.full-screen .app { padding-bottom: 140px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 90; background: var(--surface-3); border: 1px solid var(--line-2); padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 500; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: up .25s ease; max-width: calc(100vw - 32px); }
.toast.error { border-color: rgba(240,97,109,.45); } .toast.success { border-color: rgba(61,190,139,.45); }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.error .dot { background: var(--bad); } .toast.success .dot { background: var(--good); }

.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); height: 90px; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand .logo { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); display: grid; place-items: center; }
.brand h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }

/* ---------- Food parse preview ---------- */
.parsed { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; background: var(--surface-2); }
.parsed + .parsed { margin-top: 8px; }
.parsed.ask { border-color: rgba(227,179,65,.4); }
.parsed.unknown { border-color: rgba(240,97,109,.35); }
.qty-row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; margin-top: 10px; }
.micro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.mono { font-variant-numeric: tabular-nums; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav b { min-width: 120px; text-align: center; font-size: 14px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ===================== TATAME ===================== */
.belt { --c: #EDEDED; --tab: #111; position: relative; display: inline-flex; width: 64px; height: 14px; border-radius: 3px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); flex: none; overflow: hidden; }
.belt::after { content: ''; position: absolute; right: 8px; top: 0; bottom: 0; width: 22px; background: var(--tab); }
.belt i { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; z-index: 1; }
.belt.lg { width: 120px; height: 22px; border-radius: 4px; } .belt.lg::after { width: 40px; right: 14px; }
.belt.lg i { width: 4px; }
.belt[data-b=branca] { --c: #EDEDED; } .belt[data-b=cinza] { --c: #8C8F96; } .belt[data-b=amarela] { --c: #E6C229; }
.belt[data-b=laranja] { --c: #E07B28; } .belt[data-b=verde] { --c: #2E9E5B; } .belt[data-b=azul] { --c: #2563EB; }
.belt[data-b=roxa] { --c: #7C3AED; } .belt[data-b=marrom] { --c: #7B4B2A; } .belt[data-b=preta] { --c: #0E0F12; --tab: #C8102E; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.avatar { width: 42px; height: 42px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--text-2); flex: none; font-size: 14px; }
.stu { display: flex; align-items: center; gap: 12px; }
.stu .meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.mini-ring { --p: 0; width: 40px; height: 40px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--track) 0); display: grid; place-items: center; flex: none; }
.mini-ring.ok { background: conic-gradient(var(--good) 100%, var(--track) 0); }
.mini-ring > span { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.crit { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 8px 0; }
.crit + .crit { border-top: 1px solid var(--line); }
.crit .bar { grid-column: 1 / -1; }
.crit .ok { color: var(--good); } .crit .no { color: var(--muted); }
.lvl { display: flex; gap: 4px; }
.lvl button { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; transition: background .12s, color .12s, transform .1s; }
.lvl button:active { transform: scale(.92); }
.lvl button.on { color: #fff; }
.lvl button.on[data-l="0"] { background: var(--surface-3); color: var(--text-2); }
.lvl button.on[data-l="1"] { background: #3A4357; } .lvl button.on[data-l="2"] { background: #3B5E9C; } .lvl button.on[data-l="3"] { background: #4C8DFF; }
.lvl button.on[data-l="4"] { background: #2E9E7A; } .lvl button.on[data-l="5"] { background: #3DBE8B; }
.tech-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 11px 14px; }
.tech-row + .tech-row { border-top: 1px solid var(--line); }
@media (max-width: 520px) { .tech-row { grid-template-columns: 1fr; } }
.diff { display: inline-flex; gap: 2px; vertical-align: middle; }
.diff i { width: 6px; height: 6px; border-radius: 2px; background: var(--track); }
.diff i.on { background: var(--text-2); }
.att { display: flex; align-items: center; gap: 12px; padding: 10px 14px; width: 100%; text-align: left; }
.att + .att { border-top: 1px solid var(--line); }
.att .box { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: transparent; flex: none; transition: all .12s; }
.att.on .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.att.on { background: rgba(76,141,255,.06); }
.sticky-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
.day-col h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.heat { display: grid; gap: 3px; font-size: 11px; }
.heat .c { height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.heat .h { color: var(--muted); display: grid; place-items: center; }
.table-wrap { overflow-x: auto; }
table.rules { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
table.rules th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 6px; text-transform: uppercase; letter-spacing: .03em; }
table.rules td { padding: 4px 6px; border-top: 1px solid var(--line); }
table.rules input { height: 36px; padding: 0 8px; text-align: center; }
.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .kpi-row { grid-template-columns: repeat(5, 1fr); } }
a.wa { color: var(--good); text-decoration: none; font-weight: 600; font-size: 13px; }

@media (max-width: 899px) { .kpi-row > :first-child { grid-column: span 2; } }
