:root {
  --bg: #f3f4f7; --card: #fff; --ink: #14182b; --muted: #5b6275; --line: #dde1ea;
  --navy: #14213d; --accent: #f29e0c; --primary: #1d4ed8; --primary-ink: #fff;
  --ok: #157f3b; --ok-bg: #e3f5ea; --warn: #9a5b00; --warn-bg: #fff3d6; --danger: #b42318; --danger-bg: #fde8e6;
  --neutral-bg: #eef0f5; --zA: #157f3b; --zC: #1d4ed8; --zD: #5b6275;
  --s1: #1d4ed8; --s2: #157f3b; --s3: #9a5b00; --s4: #7c3aed; --p1: #b42318; --p2: #e76f51; --p3: #f2b705;
  --radius: 12px; --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: .25rem 0; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem; z-index: 10; }
.skip:focus { left: .5rem; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--navy); color: #fff; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand svg { color: var(--accent); }
.sync { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; border-radius: 999px; padding: .3rem .75rem; font-size: .8rem; min-height: 32px; cursor: pointer; }
.sync.ok::before { content: "● "; color: #4ade80; }
.sync.off::before, .sync.busy::before { content: "● "; color: var(--accent); }
.sync.err::before { content: "● "; color: #f87171; }

main { max-width: 1040px; margin: 0 auto; padding: 1rem; outline: none; }
.loading { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .25rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.row.end { justify-content: flex-end; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .danger-text { color: var(--danger); }
.back { text-decoration: none; font-size: .9rem; }
.more { display: inline-block; margin-top: .5rem; }
.disclaimer { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .75rem; }
.fonte { font-size: .78rem; color: var(--muted); display: block; }
.notice { border-radius: var(--radius); padding: .75rem 1rem; margin: 0; border: 1px solid transparent; }
.notice p { margin: .25rem 0 0; }
.notice.ok { background: var(--ok-bg); border-color: #b5e2c4; }
.notice.warn { background: var(--warn-bg); border-color: #f3d48a; }
.notice.danger { background: var(--danger-bg); border-color: #f5b8b1; }
.notice.neutral { background: var(--neutral-bg); }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: var(--tap); padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #b8bfcf; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { color: var(--danger); border-color: #f0b4ae; }
.btn.link { border: 0; background: none; color: var(--primary); font-weight: 500; }
.btn.small { min-height: 40px; padding: .35rem .75rem; font-size: .875rem; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions .btn { flex: 1 1 160px; }

/* formulários */
.form { display: flex; flex-direction: column; gap: .75rem; }
.form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1rem; }
.form.inset { background: var(--neutral-bg); border-radius: var(--radius); padding: .75rem; margin-bottom: .75rem; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field.wide, .wide { grid-column: 1 / -1; }
label, .label { font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; min-height: 44px; padding: .5rem .65rem; border: 1px solid #c3c9d6; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 64px; }
input[aria-invalid], select[aria-invalid] { border-color: var(--danger); background: var(--danger-bg); }
.err { color: var(--danger); min-height: 0; }
.err:empty { display: none; }
.help { color: var(--muted); font-size: .8rem; }
.form-error { color: var(--danger); margin: 0; }
.form-error:empty { display: none; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
label.inline select, label.inline input { width: auto; }
label.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
label.check input { width: 22px; min-height: 22px; }
.is-treino .only-prova { display: none; }

.seg { display: inline-flex; border: 1px solid #c3c9d6; border-radius: 10px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg-opt { position: relative; font-weight: 600; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; min-height: 0; cursor: pointer; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .9rem; }
.seg-opt input:checked + span { background: var(--navy); color: #fff; }
.seg-opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); padding: .5rem 0; }
.list > li:first-child { border-top: 0; }
.list-link { display: flex; justify-content: space-between; align-items: center; gap: .5rem; text-decoration: none; color: inherit; min-height: 44px; }
.list-main { display: flex; flex-direction: column; min-width: 0; }
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.prova { background: #e0e7ff; color: #3730a3; }
.badge.treino { background: #e6f4f1; color: #0f6b5c; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0; }
.empty { text-align: center; padding: 1.5rem 1rem; border: 2px dashed var(--line); border-radius: var(--radius); background: #fff; }
.empty-title { font-weight: 700; font-size: 1.05rem; margin-top: 0; }

/* painel */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; }
.kpi { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; text-decoration: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.kpi-v { font-size: 1.5rem; font-weight: 800; }
.kpi-l { font-size: .8rem; color: var(--muted); }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { border-top: 1px solid var(--line); }
.alerts li:first-child { border-top: 0; }
.alerts summary { display: grid; grid-template-columns: auto 1fr; gap: 0 .6rem; align-items: center; padding: .55rem 0; cursor: pointer; list-style: none; min-height: 44px; }
.alerts summary .sev { grid-row: span 2; }
.alerts summary::-webkit-details-marker { display: none; }
.al-title { font-weight: 600; line-height: 1.3; }
.al-date { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.al-body { padding: 0 0 .75rem 2rem; font-size: .9rem; }
.al-body p { margin: .25rem 0; }
.sev { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 800; font-size: .8rem; }
.sev-vencido { background: var(--danger); color: #fff; } .sev-urgente { background: var(--danger-bg); color: var(--danger); }
.sev-atencao { background: var(--warn-bg); color: var(--warn); } .sev-info { background: var(--neutral-bg); color: var(--muted); }
.hab-line strong { font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin: .75rem 0; }
.stat { display: flex; flex-direction: column; background: var(--neutral-bg); border-radius: 10px; padding: .5rem .65rem; }
.stat-v { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat-l { font-size: .75rem; color: var(--muted); }
.last { text-decoration: none; color: inherit; display: block; }
.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }

/* tabelas */
.table-wrap { overflow-x: auto; margin: .5rem 0; }
.tbl { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl thead th { font-size: .78rem; color: var(--muted); }
.tbl .num { text-align: right; }
.tbl .strong { font-weight: 800; }

/* lançamento de pista */
.pista { display: flex; flex-direction: column; gap: .9rem; max-width: 560px; margin: 0 auto; }
.pista-top { display: flex; justify-content: space-between; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 2fr; gap: .75rem; }
.counters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.cnt { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: .4rem; display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.cnt-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0 .25rem; min-width: 0; }
.cnt-l { font-weight: 800; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cnt-hint { font-size: .72rem; color: var(--muted); }
.cnt-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: center; gap: .25rem; }
.cnt-v { font-size: 1.7rem; font-weight: 800; text-align: center; min-width: 1.6ch; font-variant-numeric: tabular-nums; }
.cnt-btn { min-width: 56px; width: 56px; padding: 0; min-height: 56px; border-radius: 10px; border: 1px solid #c3c9d6; background: var(--neutral-bg); font-size: 1.6rem; font-weight: 700; cursor: pointer; color: var(--ink); touch-action: manipulation; }
.cnt-btn.plus { background: var(--navy); color: #fff; border-color: var(--navy); }
.cnt-btn:active { transform: scale(.96); }
.cnt.zona-a { border-color: #9fd8b3; } .cnt.zona-a .cnt-l { color: var(--zA); }
.cnt.zona-c .cnt-l { color: var(--zC); }
.cnt.pen { border-color: #f3c0ba; } .cnt.pen .cnt-l { color: var(--danger); } .cnt.pen .cnt-btn.plus { background: var(--danger); border-color: var(--danger); }
.tempo-in { font-size: 1.8rem; font-weight: 800; text-align: center; min-height: 60px; font-variant-numeric: tabular-nums; }
.live { background: var(--navy); color: #fff; border-radius: var(--radius); padding: .6rem 1rem; position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 4; box-shadow: 0 6px 18px rgba(20,33,61,.25); }
.live-hf { display: flex; justify-content: space-between; align-items: baseline; }
.live-l { font-size: .9rem; opacity: .85; }
.live-v { font-size: 2.6rem; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.live-grid { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .9rem; }
.live .danger-text { color: #fca5a5; } .live .muted { color: #cbd5e1; }
.live p { margin: .25rem 0 0; }
.opt summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.pista-actions { display: grid; grid-template-columns: 1fr; gap: .5rem; }

/* habitualidade */
.reqs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin: .5rem 0; }
.bar { height: 12px; background: var(--neutral-bg); border-radius: 999px; overflow: hidden; margin: .25rem 0; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.bar-fill.done { background: var(--ok); }

/* desempenho */
.filters { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; }
.filters select { width: auto; min-width: 120px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 1rem; }
.chart { margin: 0; }
.chart figcaption { margin-bottom: .25rem; }
.chart-svg { width: 100%; max-width: 760px; height: auto; display: block; }
.chart-svg .grid { stroke: #e6e9f0; }
.chart-svg .axis { stroke: #9aa3b5; }
.chart-svg .tick { font-size: 12.5px; fill: var(--muted); }
.chart-svg .line { fill: none; stroke-width: 2.5; stroke: var(--s1); }
.chart-svg .dot { fill: #fff; stroke-width: 2.5; stroke: var(--s1); }
.chart-svg .s2 { stroke: var(--s2); } .chart-svg .s3 { stroke: var(--s3); } .chart-svg .s4 { stroke: var(--s4); stroke-dasharray: 5 4; }
.chart-svg .dot.s4 { stroke-dasharray: none; }
.chart-svg .barra.p1 { fill: var(--p1); } .chart-svg .barra.p2 { fill: var(--p2); } .chart-svg .barra.p3 { fill: var(--p3); }
.legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .8rem; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: .3rem; }
.sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; background: var(--s1); }
.sw.s2 { background: var(--s2); } .sw.s3 { background: var(--s3); } .sw.s4 { background: var(--s4); }
.sw.p1 { background: var(--p1); height: 10px; } .sw.p2 { background: var(--p2); height: 10px; } .sw.p3 { background: var(--p3); height: 10px; }
details.data summary { font-size: .8rem; color: var(--primary); cursor: pointer; }

/* regras */
.rules fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 .75rem; padding: .5rem .75rem; }
.rules legend { font-weight: 700; padding: 0 .25rem; }
.rule { display: grid; grid-template-columns: 1fr 96px; gap: .75rem; align-items: center; padding: .35rem 0; border-top: 1px solid var(--line); }
.rule:first-of-type { border-top: 0; }
.rule label { font-weight: 500; }
.rule input { text-align: right; }
.rule input.changed { border-color: var(--accent); background: var(--warn-bg); }

.auth { max-width: 420px; margin: 1.5rem auto; }

/* navegação inferior */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem .1rem; min-height: 60px; font-size: .72rem;
  color: var(--muted); text-decoration: none; font-weight: 600; }
.bottomnav svg { width: 24px; height: 24px; fill: currentColor; }
.bottomnav a[aria-current="page"] { color: var(--navy); }
.bottomnav a[aria-current="page"] svg { fill: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  pointer-events: none; transition: all .2s; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; max-width: min(92vw, 520px); z-index: 20; font-size: .95rem; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.erro { background: var(--danger); }
.dialog { border: 0; border-radius: var(--radius); padding: 1.25rem; max-width: min(92vw, 420px); }
.dialog::backdrop { background: rgba(20,24,43,.5); }

@media (min-width: 900px) {
  .bottomnav { left: 50%; right: auto; transform: translateX(-50%); width: 640px; border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgba(20,33,61,.08); }
  .bottomnav a { font-size: .8rem; }
  .pista-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .cnt-v { font-size: 1.45rem; }
  .cnt-l { font-size: .9rem; }
  .cnt-row { grid-template-columns: 52px minmax(0, 1fr) 52px; }
  .cnt-btn { min-width: 52px; width: 52px; min-height: 52px; font-size: 1.4rem; }
  main { padding: .75rem; }
}

select.inline-sel { width: auto; min-height: 36px; padding: .2rem .4rem; display: inline-block; }
main:focus, main:focus-visible { outline: none; }
[hidden] { display: none !important; }

/* clube / multi-atleta */
.top-actions { display: inline-flex; align-items: center; gap: .5rem; }
.top-link { color: #fff; font-weight: 700; text-decoration: none; padding: .35rem .7rem; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; min-height: 36px; display: inline-flex; align-items: center; }
.atleta-bar { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 5; display: flex; align-items: center; gap: .5rem; padding: .4rem 1rem;
  background: #e8ecf6; border-bottom: 1px solid var(--line); font-size: .9rem; font-weight: 600; }
.atleta-bar select { flex: 1; max-width: 360px; min-height: 40px; }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; }
.kpi.danger .kpi-v { color: var(--danger); } .kpi.warn .kpi-v { color: var(--warn); }
.seg-link { display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .9rem; border-radius: 999px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); font-weight: 600; }
.seg-link.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem 1rem; margin: 0 0 .5rem; }
.dl dt { font-size: .75rem; color: var(--muted); } .dl dd { margin: 0; font-weight: 600; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: .75rem 0 0; border-left: 3px solid var(--line); }
.timeline li { padding: .25rem 0 .5rem 1rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: .55rem; width: 13px; height: 13px; border-radius: 50%; background: var(--navy); }
.timeline p { margin: .2rem 0; }
.inline-edit { flex-wrap: wrap; margin-top: .4rem; }
.inline-edit input { width: auto; }
details.docs { width: 100%; }
details.docs > summary { list-style: none; display: inline-flex; }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }

.brand span { white-space: nowrap; letter-spacing: -.01em; }
.sync, .top-link { white-space: nowrap; }
@media (max-width: 400px) { .brand span { font-size: .95rem; } .brand svg { width: 22px; height: 22px; } .topbar { padding-left: .75rem; padding-right: .75rem; } }
