/* RotaLivre — visual escuro "trilha noturna" com destaque limão */
:root {
  --bg: #101513;
  --bg2: #171e1b;
  --card: #1c2421;
  --line: #2a3430;
  --text: #eef2ee;
  --muted: #8d9a94;
  --accent: #c6f432;
  --accent-ink: #101513;
  --run: #ff8a3d;
  --walk: #4cc9f0;
  --bike: #b388ff;
  --danger: #ff5c5c;
  --radius: 16px;
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
code { background: var(--card); padding: 2px 6px; border-radius: 6px; }

/* ---------- topo e abas ---------- */
.topbar {
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font: 700 22px/1 var(--display); letter-spacing: .5px; text-transform: uppercase; }
.logo-mark { width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--accent); position: relative; }
.logo-mark::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }

#view { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
#view.v-gravar { max-width: none; padding: 0; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg2); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg .fill { fill: currentColor; stroke: none; }
.tabbar a.on { color: var(--accent); }

/* ---------- elementos ---------- */
.title { font: 700 32px/1.05 var(--display); text-transform: uppercase; letter-spacing: .3px; margin: 8px 0 16px; }
.sub { font: 600 20px/1 var(--display); text-transform: uppercase; color: var(--muted); letter-spacing: .6px; margin: 28px 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list { display: grid; gap: 12px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: 600 15px var(--body); padding: 12px 18px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.liked { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn.small { padding: 6px 14px; min-height: 34px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; }
.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 14px; font: 500 13px var(--body); cursor: pointer; }
.link { background: none; border: 0; color: var(--accent); font: 500 14px var(--body); padding: 10px; cursor: pointer; }

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input, select, textarea {
  font: 16px var(--body); color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search { margin-bottom: 14px; }

.tag {
  display: inline-block; font: 600 11px/1 var(--body); text-transform: uppercase; letter-spacing: .6px;
  padding: 4px 8px; border-radius: 6px; background: var(--line); color: var(--text); margin-right: 8px;
}
.t-corrida { background: color-mix(in srgb, var(--run) 22%, transparent); color: var(--run); }
.t-caminhada { background: color-mix(in srgb, var(--walk) 22%, transparent); color: var(--walk); }
.t-bike { background: color-mix(in srgb, var(--bike) 22%, transparent); color: var(--bike); }

.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.seg button { background: none; border: 0; color: var(--muted); font: 600 14px var(--body); padding: 8px 18px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.notice { background: color-mix(in srgb, var(--accent) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }
.skeleton { height: 110px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--bg2), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
.skeleton.tall { height: 320px; }
@keyframes sk { to { background-position: -200% 0; } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 500; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 2000; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- login ---------- */
.auth { max-width: 420px; margin: 6vh auto 0; }
.hero { font: 700 54px/.95 var(--display); text-transform: uppercase; margin: 0 0 12px; }
.hero em { color: var(--accent); font-style: normal; }
.auth .card { padding: 20px; margin-top: 24px; display: grid; }

/* ---------- gravar ---------- */
.rec { position: relative; height: calc(100dvh - 57px - var(--tabbar-h) - env(safe-area-inset-bottom) - env(safe-area-inset-top)); display: flex; flex-direction: column; }
.rec-map { flex: 1; min-height: 200px; background: #222; }
.gps-pill {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 800;
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.gps-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.gps-pill.good i { background: #2bd47d; box-shadow: 0 0 0 4px rgba(43, 212, 125, .2); }
.gps-pill.ok i { background: #ffc53d; }
.gps-pill.bad i { background: var(--danger); }
.rec-panel { background: var(--bg); border-top: 1px solid var(--line); padding: 14px 16px 16px; }
.types { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.types button { background: var(--card); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font: 600 13px var(--body); cursor: pointer; }
.types button.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.types.locked button:not(.on) { display: none; }
.big-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; text-align: center; }
.bs b { display: block; font: 700 40px/1 var(--display); font-variant-numeric: tabular-nums; }
.bs.main { grid-column: 1 / -1; }
.bs.main b { font-size: 68px; color: var(--accent); }
.bs span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.controls { display: flex; justify-content: center; gap: 16px; margin-top: 14px; }
.round {
  width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer;
  font: 700 18px var(--display); letter-spacing: 1px; display: grid; place-items: center;
}
.round svg { width: 30px; height: 30px; fill: currentColor; }
.round.go { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); }
.round.pause { background: var(--text); color: var(--bg); }
.round.stop { background: var(--danger); color: #fff; }
.round.small { width: 92px; height: 92px; font-size: 16px; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 0; min-height: 1em; }

/* ---------- cards de atividade ---------- */
.act { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px; color: var(--text); position: relative; }
.mini { width: 110px; height: 90px; background: var(--bg); border-radius: 10px; }
.mini path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.mini .s { fill: #2bb673; }
.mini .e { fill: var(--danger); }
.act h3 { margin: 0 0 4px; font: 600 17px/1.2 var(--body); padding-right: 40px; }
.act .who { font-size: 12px; color: var(--accent); font-weight: 600; }
.meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.nums { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.nums b { font: 700 20px var(--display); color: var(--text); }
.kudos { position: absolute; top: 12px; right: 14px; font-size: 13px; color: var(--muted); }
.kudos.on { color: var(--accent); }

/* ---------- detalhe ---------- */
.back { display: inline-block; margin-bottom: 6px; font-weight: 500; }
.act-head .who { color: var(--muted); font-size: 13px; }
.act-head .title { margin: 4px 0 8px; }
.notes { color: var(--text); opacity: .85; }
.act-map { height: 340px; border-radius: var(--radius); margin: 16px 0; border: 1px solid var(--line); background: #222; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.grid-stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.grid-stats b { display: block; font: 700 26px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.grid-stats span { font-size: 12px; color: var(--muted); }
.elev { width: 100%; height: 140px; display: block; }
.elev .area { fill: color-mix(in srgb, var(--accent) 18%, transparent); }
.elev .ln { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.elev-lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.splits { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.splits th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.splits td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.splits td:first-child { width: 44px; color: var(--muted); }
.splits td:nth-child(2) { width: 110px; font-weight: 600; }
.splits td i { display: block; height: 8px; border-radius: 4px; background: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

/* ---------- estatísticas ---------- */
.weeks { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 160px; }
.wk { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.wk i { width: 100%; background: color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 6px 6px 2px 2px; }
.wk.now i { background: var(--accent); }
.wk span { font-size: 10px; color: var(--muted); }
.type-row { display: flex; align-items: center; gap: 14px; padding: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.type-row b { color: var(--text); font: 700 18px var(--display); }

/* ---------- pessoas ---------- */
.person { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px; }
.person small { display: block; color: var(--muted); font-size: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 20px var(--display); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 1500; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg2); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; border: 1px solid var(--line);
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow: auto;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { font: 700 26px var(--display); text-transform: uppercase; margin: 0 0 10px; }
.sheet form { display: grid; }
.sheet .link { justify-self: center; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.summary { display: flex; gap: 24px; margin: 6px 0 16px; }
.summary b { font: 700 36px/1 var(--display); color: var(--accent); display: block; }
.summary span { font-size: 12px; color: var(--muted); }

/* ---------- instalador ---------- */
.install { padding: 24px 16px; }
.narrow { max-width: 520px; margin: 0 auto; padding: 24px; }
.install h1 { font: 700 34px var(--display); text-transform: uppercase; margin-top: 0; }
.brand { color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 2px; margin: 0 0 16px; }
legend { padding: 0 6px; color: var(--accent); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
.ok { color: #2bd47d; }
.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); padding: 10px 12px; border-radius: 10px; }

/* Leaflet no tema escuro */
.leaflet-container { font-family: var(--body); background: #1a1f1d; }
.leaflet-control-attribution { background: rgba(16, 21, 19, .75) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

@media (min-width: 760px) {
  .act { grid-template-columns: 140px 1fr; }
  .mini { width: 140px; height: 105px; }
  .act-map { height: 440px; }
}
