:root {
  --brand: #F2552C;
  --brand-dark: #D6431D;
  --brand-soft: #FFF0EB;
  --ink: #242428;
  --ink-2: #494950;
  --muted: #6d6d78;
  --line: #E4E4E8;
  --bg: #F7F7FA;
  --card: #FFFFFF;
  --ok: #1E9E5A;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --run: #F2552C;
  --ride: #2E7BD6;
  --walk: #1E9E5A;
  --hike: #8A5A2B;
  --swim: #1BA3B8;
  --other: #7A5AF8;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
a.link { color: var(--brand); font-weight: 600; }
a.link:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 16px; gap: 8px;
}
.topbar .inner { max-width: 1180px; width: 100%; margin: 0 auto; display: flex; align-items: center; gap: 4px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .08em; color: var(--brand); font-size: 22px; margin-right: 16px; }
.logo svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 18px 12px; font-weight: 500; color: var(--ink-2); border-bottom: 3px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--brand); }
.spacer { flex: 1; }
.search { position: relative; }
.search input { width: 220px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px 7px 32px; background: var(--bg); }
.search svg { position: absolute; left: 10px; top: 9px; width: 15px; height: 15px; color: var(--muted); }
.avatar {
  --size: 36px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: calc(var(--size) * .38);
  background: var(--c, #888); user-select: none;
}
.avatar.lg { --size: 64px; }
.avatar.xl { --size: 112px; border: 4px solid #fff; box-shadow: var(--shadow); }
.avatar.sm { --size: 28px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--bg); }
.plus { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--brand); color: var(--brand); display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.plus:hover { background: var(--brand); color: #fff; }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 200px; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 6px 0; display: none;
}
.menu.open .menu-pop { display: block; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 8px 16px; border: 0; background: none; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg); }

/* ---------- Layout ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.grid-3 { display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.sticky { position: sticky; top: 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-pad { padding: 16px; }
.card h3 { font-size: 16px; font-weight: 700; }
.section-title { font-size: 28px; font-weight: 700; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.divider { border-top: 1px solid var(--line); margin: 12px 0; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 600;
  padding: 8px 16px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink-2); }
.btn.outline { background: #fff; color: var(--brand); }
.btn.outline:hover { background: var(--brand-soft); }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
label.field { display: block; }
label.field span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid #cfcfd6; border-radius: 4px; padding: 9px 11px; background: #fff;
}
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea.input { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--ink-2); }
.error { color: #c62828; font-size: 13px; min-height: 18px; }

/* ---------- Landing / auth ---------- */
.landing {
  min-height: calc(100vh - 56px); margin: -24px -16px -64px; display: grid; grid-template-columns: 1fr minmax(320px, 480px) 1fr;
}
.landing .side { background: linear-gradient(160deg, #2b3a2e, #5a7d4e 60%, #c7d6a8); position: relative; overflow: hidden; }
.landing .side.right { background: linear-gradient(200deg, #3a2b26, #a65a3c 55%, #f2c79a); }
.landing .side svg { position: absolute; inset: auto 0 0 0; width: 100%; opacity: .5; }
.landing .center { background: #fff; padding: 72px 40px; text-align: center; }
.landing h1 { font-size: 34px; font-weight: 700; margin-bottom: 12px; }
.landing p.lead { color: var(--ink-2); margin: 0 0 28px; }
.auth-card { max-width: 420px; margin: 32px auto; }
.auth-card h1 { font-size: 26px; margin-bottom: 18px; }

/* ---------- Profile card (dashboard left) ---------- */
.profile-card { text-align: center; padding-top: 24px; }
.profile-card .name { font-size: 20px; font-weight: 700; margin-top: 10px; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); margin-top: 16px; }
.counts div { padding: 10px 4px; }
.counts div + div { border-left: 1px solid var(--line); }
.counts .k { font-size: 12px; color: var(--muted); }
.counts .v { font-size: 18px; font-weight: 600; }
.latest { text-align: left; border-top: 1px solid var(--line); padding: 12px 16px; }
.week-bars { display: flex; align-items: flex-end; gap: 6px; height: 54px; margin-top: 8px; }
.week-bars div { flex: 1; background: var(--brand); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.week-days { display: flex; gap: 6px; font-size: 11px; color: var(--muted); }
.week-days span { flex: 1; text-align: center; }

/* ---------- Feed ---------- */
.feed-entry { padding: 16px 16px 0; }
.feed-entry .head { display: flex; gap: 12px; }
.feed-entry .athlete { font-weight: 700; }
.feed-entry .meta { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.feed-entry .title { font-size: 20px; font-weight: 700; margin: 8px 0 4px; display: block; }
.feed-entry .title:hover { color: var(--brand); }
.feed-entry .desc { margin: 4px 0 8px; color: var(--ink-2); }
.stats { display: flex; gap: 28px; margin: 10px 0 12px; flex-wrap: wrap; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 400; }
.stat .v small { font-size: 13px; color: var(--ink-2); margin-left: 1px; }
.feed-map { height: 260px; margin: 0 -16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #e9eef0; }
.feed-noMap { height: 120px; margin: 0 -16px; display: grid; place-items: center; background: linear-gradient(135deg, #e7f3f6, #d6eaf0); color: var(--swim); font-weight: 600; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.feed-actions { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.feed-actions .count { color: var(--muted); font-size: 13px; flex: 1; }
.feed-actions .count button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; }
.kudo-btn { border: 1px solid var(--line); background: #fff; width: 38px; height: 34px; border-radius: 4px; cursor: pointer; display: grid; place-items: center; }
.kudo-btn:hover { border-color: var(--ink-2); }
.kudo-btn.on { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.kudo-btn svg { width: 18px; height: 18px; }
.sport-ico { width: 18px; height: 18px; color: var(--sc, var(--muted)); }

/* ---------- Activity detail ---------- */
.activity-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.activity-header > div { padding: 20px; }
.activity-header > div + div { border-left: 1px solid var(--line); }
.activity-header h1 { font-size: 26px; font-weight: 700; margin: 8px 0; }
.big-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.big-stats .v { font-size: 28px; font-weight: 300; }
.big-stats .k { font-size: 12px; color: var(--muted); }
.more-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 24px; margin-top: 16px; font-size: 13px; justify-content: start; }
.more-stats b { font-weight: 600; }
.detail-map { height: 420px; }
.chart-wrap { padding: 16px 20px; height: 200px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: 0; }
.pace-bar { height: 10px; background: var(--brand); border-radius: 2px; opacity: .75; }
.comment { display: flex; gap: 10px; padding: 10px 0; }
.comment + .comment { border-top: 1px solid var(--line); }
.comment .body { flex: 1; }
.kudoers { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Athlete profile ---------- */
.cover { height: 180px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(120deg, #33415c, #5c677d 45%, var(--brand)); position: relative; }
.profile-head { display: flex; gap: 20px; align-items: flex-end; padding: 0 24px 20px; margin-top: -56px; position: relative; flex-wrap: wrap; }
.profile-head h1 { font-size: 28px; }
.totals-table td:first-child { color: var(--muted); }
.totals-table td { padding: 6px 0; }
.totals-table td:last-child { text-align: right; font-weight: 600; }

/* ---------- Training log ---------- */
.log { display: grid; grid-template-columns: 110px repeat(7, 1fr) 110px; border-top: 1px solid var(--line); }
.log > div { border-bottom: 1px solid var(--line); min-height: 72px; display: grid; place-items: center; padding: 6px; }
.log .hdr { min-height: 36px; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.log .wk { justify-items: start; font-size: 12px; color: var(--muted); }
.log .tot { font-size: 12px; text-align: right; justify-items: end; }
.bubble { border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; background: var(--sc); opacity: .9; }

/* ---------- Clubs / challenges ---------- */
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.club-badge { width: 52px; height: 52px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800; flex: none; background: var(--sc, var(--brand)); }
.challenge { display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: center; padding: 16px; }
.challenge + .challenge { border-top: 1px solid var(--line); }
.trophy { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 30% 30%, #ffd8a8, var(--brand)); color: #fff; }
.trophy svg { width: 34px; height: 34px; }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; background: var(--brand); border-radius: 999px; }
.leader td:first-child { width: 32px; color: var(--muted); }

/* ---------- Routes ---------- */
.route-builder { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - 56px - 48px); min-height: 520px; }
.route-builder .panel { padding: 16px; border-right: 1px solid var(--line); overflow: auto; }
.route-builder .map { height: 100%; }
.route-card-map { height: 160px; border-radius: var(--radius) var(--radius) 0 0; }
.routes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.routes-grid .card + .card { margin-top: 0; }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed #c9c9d2; border-radius: 8px; padding: 36px 16px; text-align: center; cursor: pointer; background: #fcfcfd; }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Funciones observadas en Strava con REA ---------- */
.private-note { background: #FFF8E1; border: 1px solid #F3E2A9; border-radius: 4px; padding: 8px 10px; font-size: 13px; margin: 8px 0; display: flex; gap: 6px; align-items: baseline; }
.tag-set { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tag-set legend { font-weight: 600; font-size: 13px; margin-bottom: 6px; padding: 0; }
.tag-set label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.chip.pr { background: #FFF4D6; color: #8A5A00; }
.chip.filter { border: 1px solid var(--line); background: #fff; padding: 5px 12px; font-size: 13px; }
.chip.filter:hover { border-color: var(--ink-2); }
.chip.filter.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }
.zone { display: grid; grid-template-columns: 100px 120px 1fr 44px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.zbar { height: 12px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.zbar div { height: 100%; background: var(--brand); }
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; margin-top: 12px; }
.trophy-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.trophy-item .trophy { width: 56px; height: 56px; }
.trophy-item .trophy svg { width: 26px; height: 26px; }
.sort-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.sort-btn.on { color: var(--ink); }
.stat-table td:first-child { color: var(--muted); }
.act-tabs button { padding: 12px 14px; }
@media (max-width: 560px) { .zone { grid-template-columns: 90px 1fr 40px; } .zone .zrange { display: none; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px; transition: .2s; pointer-events: none; z-index: 2000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.leaflet-container { font: inherit; }
.mini-map .leaflet-control-container { display: none; }

@media (max-width: 1060px) {
  .grid-3 { grid-template-columns: 240px minmax(0, 1fr); }
  .grid-3 > .right { display: none; }
}
@media (max-width: 800px) {
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 > .left { display: none; }
  .nav a { padding: 18px 8px; }
  .search { display: none; }
  .activity-header { grid-template-columns: 1fr; }
  .activity-header > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .landing { grid-template-columns: 1fr; }
  .landing .side { display: none; }
  .route-builder { grid-template-columns: 1fr; height: auto; }
  .route-builder .map { height: 60vh; }
  .log { grid-template-columns: 70px repeat(7, 1fr); }
  .log .tot { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .logo span { display: none; }
  .nav a { font-size: 13px; padding: 18px 6px; }
}
