/* ===== Ritmo — base ===== */
:root {
  --bg: #0c0d10;
  --bg-2: #14161b;
  --card: #16181e;
  --card-2: #1c1f26;
  --line: #262a33;
  --txt: #f2f4f8;
  --txt-2: #9aa2b1;
  --txt-3: #626b7a;
  --acc: #d8ff3e;
  --acc-dim: #97b32b;
  --warm: #ff7a45;
  --cool: #4fc3f7;
  --ok: #55d98d;
  --bad: #ff5f6d;
  --radius: 18px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
p { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ===== Splash ===== */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .35s ease;
}
#splash.gone { opacity: 0; pointer-events: none; }
.splash-mark {
  width: 72px; height: 72px; border-radius: 24px;
  background: var(--acc); color: #0c0d10;
  display: grid; place-items: center;
  font-size: 38px; font-weight: 800;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(.92); } }

/* ===== Layout ===== */
#app {
  max-width: 620px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 20px) var(--pad) calc(96px + var(--safe-b));
}
@media (min-width: 900px) {
  #app { max-width: 960px; padding-bottom: 48px; padding-top: 32px; }
}

.view-head { margin-bottom: 20px; }
.view-head h1 { font-size: 30px; }
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--txt-3); margin-bottom: 2px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 900px) {
  .stack { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .stack > .wide { grid-column: 1 / -1; }
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title {
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--txt-3); margin-bottom: 14px;
}
.card.accent { background: linear-gradient(160deg, #1d2410, var(--card) 60%); border-color: #33401a; }

/* ===== Números ===== */
.big-num {
  font-size: 46px; font-weight: 700; letter-spacing: -0.035em;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.big-num .unit { font-size: 18px; font-weight: 600; color: var(--txt-2); margin-left: 4px; letter-spacing: 0; }
.sub { color: var(--txt-2); font-size: 14px; margin-top: 8px; }

.delta { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--txt-3); }

/* trio semana/mês/ano */
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.trio .cell {
  background: var(--card-2); border-radius: 14px; padding: 12px 10px; text-align: center;
}
.trio .cell .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--txt-3); }
.trio .cell .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 3px; }
.trio .cell .d { font-size: 11px; font-weight: 600; margin-top: 2px; }

/* ===== Barra de progresso ===== */
.bar { height: 10px; border-radius: 99px; background: var(--card-2); overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--acc); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar .ghost { position: absolute; top: 0; height: 100%; width: 2px; background: var(--txt-3); }
.bar-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--txt-3); margin-top: 8px; }

/* ===== Termômetro de pace ===== */
.thermo { position: relative; height: 46px; margin: 18px 0 6px; }
.thermo .track {
  position: absolute; top: 18px; left: 0; right: 0; height: 8px; border-radius: 99px;
  background: linear-gradient(90deg, var(--cool), var(--acc) 50%, var(--warm));
  opacity: .35;
}
.thermo .target {
  position: absolute; top: 10px; width: 2px; height: 24px; background: var(--txt);
  transform: translateX(-1px);
}
.thermo .target::after {
  content: 'alvo'; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--txt-2);
}
.thermo .you {
  position: absolute; top: 12px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--acc); border: 3px solid var(--bg); transform: translateX(-10px);
  transition: left .6s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 0 0 1px var(--acc-dim);
}

/* ===== Heatmap ===== */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 11px; height: 11px; border-radius: 3px; background: var(--card-2); display: block; }
.heat i[data-l="1"] { background: #35441a; }
.heat i[data-l="2"] { background: #5c7526; }
.heat i[data-l="3"] { background: #93bd30; }
.heat i[data-l="4"] { background: var(--acc); }
.heat-legend { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--txt-3); margin-top: 10px; }
.heat-legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }

/* ===== Listas ===== */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  width: 100%; text-align: left;
}
.row:last-child { border-bottom: 0; }
.row .r-main { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r-sub { font-size: 13px; color: var(--txt-3); margin-top: 1px; }
.row .r-val { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; font-size: 15px; }
.row .r-val small { display: block; font-weight: 500; font-size: 12px; color: var(--txt-3); }

.thumb-route { width: 46px; height: 46px; flex: 0 0 46px; background: var(--card-2); border-radius: 12px; padding: 4px; }
.thumb-route svg { width: 100%; height: 100%; display: block; }

/* ===== Chips / badges ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 13px; font-size: 13px; font-weight: 550;
}
.chip.on { background: var(--acc); color: #0c0d10; border-color: var(--acc); }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge {
  background: var(--card-2); border-radius: 14px; padding: 14px 8px; text-align: center;
  border: 1px solid var(--line);
}
.badge .b-ico { font-size: 26px; line-height: 1; }
.badge .b-name { font-size: 11px; margin-top: 6px; color: var(--txt-2); font-weight: 600; }
.badge.locked { opacity: .3; }
.badge.locked .b-ico { filter: grayscale(1); }

/* ===== Botões ===== */
.btn-primary {
  background: var(--acc); color: #0c0d10; font-weight: 650;
  border-radius: 14px; padding: 14px 18px; width: 100%; font-size: 15px;
}
.btn-primary:active { transform: scale(.985); }
.btn-ghost {
  background: var(--card-2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 11px 16px; font-weight: 600; font-size: 14px;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1; min-width: 130px; }

.import-box { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.import-box.wide { grid-column: 1 / -1; }
.hint { color: var(--txt-3); font-size: 13px; margin-top: 10px; text-align: center; }
#import-status { font-size: 13px; margin-top: 12px; }
#import-status .ln { padding: 3px 0; color: var(--txt-2); }
#import-status .ln.err { color: var(--bad); }
#import-status .ln.ok { color: var(--ok); }

/* ===== Segmented ===== */
.segmented { display: flex; background: var(--card-2); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 16px; }
.seg { flex: 1; padding: 9px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--txt-2); }
.seg.active { background: var(--card); color: var(--txt); box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ===== Momentos ===== */
.moments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.moments img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; border-radius: 8px; }
.moment-hero img { width: 100%; border-radius: 14px; display: block; aspect-ratio: 4/3; object-fit: cover; }

/* ===== Detalhe da corrida ===== */
.route-hero { background: var(--card-2); border-radius: 14px; padding: 12px; }
.route-hero svg { width: 100%; height: 190px; display: block; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.metrics-grid .m .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--txt-3); }
.metrics-grid .m .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

.splits { margin-top: 8px; }
.split { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.split .n { width: 26px; color: var(--txt-3); font-size: 13px; }
.split .b { flex: 1; height: 20px; background: var(--card-2); border-radius: 6px; overflow: hidden; }
.split .b > i { display: block; height: 100%; background: var(--acc-dim); border-radius: 6px; }
.split .b > i.best { background: var(--acc); }
.split .p { width: 62px; text-align: right; font-size: 13px; font-weight: 600; }

/* ===== Formulários ===== */
label.fld { display: block; margin-bottom: 14px; }
label.fld .lb { font-size: 13px; color: var(--txt-2); margin-bottom: 6px; display: block; font-weight: 550; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--card-2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 16px;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acc-dim); outline-offset: 1px; }

.mood-row { display: flex; gap: 8px; }
.mood { flex: 1; aspect-ratio: 1; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); font-size: 22px; display: grid; place-items: center; }
.mood.on { background: var(--acc); border-color: var(--acc); }

/* ===== Insight ===== */
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.insight:last-child { border-bottom: 0; padding-bottom: 0; }
.insight .i-ico { font-size: 20px; line-height: 1.2; flex: 0 0 24px; }
.insight .i-txt { font-size: 14px; color: var(--txt-2); }
.insight .i-txt b { color: var(--txt); font-weight: 650; }

/* ===== Vazio ===== */
.empty { text-align: center; padding: 40px 16px; color: var(--txt-3); }
.empty .e-ico { font-size: 40px; opacity: .5; }
.empty p { margin-top: 10px; font-size: 14px; }

/* ===== Tabbar ===== */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: rgba(12,13,16,.9);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + var(--safe-b));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; color: var(--txt-3); padding: 4px 0;
}
.tab .ico { font-size: 18px; line-height: 1; }
.tab.active { color: var(--acc); }

/* ===== Sheet ===== */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); animation: fade .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--bg-2); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  padding: 8px var(--pad) calc(28px + var(--safe-b));
  animation: up .28s cubic-bezier(.2,.8,.2,1);
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 900px) {
  .sheet-panel { max-width: 620px; margin: 0 auto; border-radius: 22px; bottom: 4vh; max-height: 88vh; }
}
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: var(--line); margin: 6px auto 14px; }
.sheet-content h2 { font-size: 22px; margin-bottom: 4px; }
.sheet-content .sheet-sub { color: var(--txt-3); font-size: 13px; margin-bottom: 18px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-b)); transform: translateX(-50%);
  background: var(--txt); color: var(--bg); padding: 11px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 600; z-index: 80; animation: fade .2s ease;
  max-width: 90vw; text-align: center;
}

.sep { height: 1px; background: var(--line); margin: 4px 0; }
.nowrap { white-space: nowrap; }
