/* PersoStrava — dark sport */
:root {
  --bg: #0A0B0E;
  --card: #14171C;
  --card-2: #1B1F26;
  --line: #22262E;
  --line-2: #3A404B;
  --text: #F4F5F7;
  --text-2: #C9CED6;
  --muted: #9AA3B2;
  --dim: #5B6270;
  --accent: #FF6B2C;
  --accent-soft: rgba(255, 107, 44, 0.14);
  --accent-text: #FFB08C;
  --run: #FF6B2C;
  --ride: #4CC9F0;
  --other: #B79CFF;
  --good: #6EE7A8;
  --bad: #FF8A8A;
  --r-lg: 22px;
  --r-md: 18px;
  --r-sm: 14px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #FF8A55; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }
code { font-size: 0.9em; background: var(--card-2); padding: 2px 6px; border-radius: 6px; color: var(--accent-text); word-break: break-all; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.main { padding: 20px 16px calc(110px + var(--safe-b)); max-width: 1280px; margin: 0 auto; outline: none; }
.view { display: flex; flex-direction: column; gap: 16px; }
.sidebar { display: none; }
.app-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; font-size: 12px; color: var(--muted); }

.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + var(--safe-b)); z-index: 20;
  height: 68px; border-radius: var(--r-lg);
  background: rgba(20, 23, 28, 0.92); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar a.active { color: var(--accent); }

@media (min-width: 1024px) {
  .app { display: flex; }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 28px;
    position: sticky; top: 0; height: 100vh; width: 248px; flex-shrink: 0;
    padding: 28px 18px; border-right: 1px solid #1B1F26;
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
  .sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar-nav a { height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted); display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
  .sidebar-nav a:hover { color: var(--text); background: #111419; }
  .sidebar-nav a.active { background: var(--card); color: var(--text); }
  .sidebar-nav a.active svg { color: var(--accent); }
  .sidebar-sync { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
  .main { flex: 1; min-width: 0; padding: 28px 32px 40px; }
  .icon-btn.mobile-sync { display: none; }
}

/* ---------- Brand ---------- */
.brand-mark { background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ---------- Header de vue ---------- */
.vhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.vhead-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vhead-sub { font-size: 13px; color: var(--muted); }
.vhead-title { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; }
.vhead-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (min-width: 1024px) { .vhead-title { font-size: 32px; letter-spacing: -1px; } }

.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--card); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--line-2); }
.icon-btn:disabled { color: var(--dim); cursor: default; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Contrôles ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 1024px) { .toolbar { flex-direction: row; justify-content: space-between; align-items: center; } }
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.seg button { height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card);
  color: var(--text-2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0;
}
.chip .dot { width: 8px; height: 8px; border-radius: 4px; background: var(--c, var(--muted)); }
.chip[aria-pressed="true"] { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 15%, transparent); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.btn--primary { background: var(--accent); color: var(--bg); }
.btn--primary:hover { background: #FF7F47; color: var(--bg); }
.btn--ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn--ghost:hover { background: var(--card-2); color: var(--text); }
.btn--danger { background: transparent; border-color: #5A2A2A; color: var(--bad); }
.btn--strava { background: #FC4C02; color: #fff; }
.btn--strava:hover { background: #E34402; color: #fff; }
.btn--lg { height: 56px; border-radius: 16px; font-size: 16px; }
.btn--sm { height: 38px; font-size: 13px; border-radius: 10px; padding: 0 14px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.input {
  width: 100%; height: 48px; border-radius: var(--r-sm); border: 1.5px solid var(--line-2);
  background: var(--card); color: var(--text); padding: 0 14px; font: 500 15px var(--font); outline: none;
}
.input:focus { border-color: var(--accent); }
.input--lg { height: 56px; border-radius: 16px; font-size: 18px; padding-right: 56px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; min-width: 0; }
.card--tight { padding: 14px; border-radius: var(--r-sm); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 700; }
.card-meta { font-size: 12px; color: var(--muted); text-align: right; }
.card-meta strong { color: var(--text); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; }
.legend i.dash { height: 0; border-top: 2px dashed var(--muted); background: none; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .grid > * { grid-column: span 12; }
  .grid > .md-6 { grid-column: span 6; }
}
@media (min-width: 1100px) {
  .grid > .lg-3 { grid-column: span 3; }
  .grid > .lg-4 { grid-column: span 4; }
  .grid > .lg-5 { grid-column: span 5; }
  .grid > .lg-6 { grid-column: span 6; }
  .grid > .lg-7 { grid-column: span 7; }
  .grid > .lg-8 { grid-column: span 8; }
}

/* Hero */
.hero { display: flex; flex-direction: column; gap: 18px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.hero-value { display: flex; align-items: baseline; gap: 6px; margin: 4px 0; }
.hero-value .num { font-size: 56px; font-weight: 700; letter-spacing: -2px; line-height: 1; }
.hero-value .unit { font-size: 18px; font-weight: 600; color: var(--muted); }
@media (min-width: 1100px) { .hero-value .num { font-size: 72px; letter-spacing: -3px; } }
.trend { font-size: 13px; font-weight: 600; }
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }
.trend.flat { color: var(--muted); }
.ring { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label .num { font-size: 22px; font-weight: 700; }
.ring-label small { font-size: 10px; color: var(--muted); }
@media (min-width: 1100px) { .ring { width: 120px; height: 120px; } .ring-label .num { font-size: 26px; } }
.bar { height: 8px; border-radius: 4px; background: var(--line); position: relative; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; transition: width 0.6s cubic-bezier(.4,0,.2,1); }
.bar-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }
.bar-legend { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.bar-legend strong { color: var(--text); }
.tip { display: flex; gap: 8px; padding: 12px; border-radius: var(--r-sm); background: var(--card-2); font-size: 13px; color: var(--text-2); }
.tip strong { color: var(--text); }
.tip svg { flex-shrink: 0; margin-top: 1px; color: var(--accent-text); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-content: start; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-family: var(--font); font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; letter-spacing: 0; }
.kpi .trend { font-size: 12px; }
@media (min-width: 1100px) { .kpi { padding: 18px 20px; } .kpi-value { font-size: 32px; } }

/* Graphiques */
.chart-box { position: relative; height: 180px; }
.chart-box--lg { height: 220px; }
@media (min-width: 1100px) { .chart-box { height: 220px; } }

/* Heatmap */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, minmax(0, 1fr)); gap: 2px; }
.heat i { display: block; aspect-ratio: 1; border-radius: 2px; background: #1E222A; }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 32%, #1E222A); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 62%, #1E222A); }
.heat i.l3 { background: var(--accent); }
.heat i.pad { background: transparent; }
.heat i.future { background: #111419; }
.heat i.today { outline: 1.5px solid var(--text); outline-offset: -1px; }
@media (min-width: 1100px) { .heat { gap: 3px; } .heat i { border-radius: 3px; } }
.heat-legend { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 10px; }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Calendrier */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }
.cal-dow { font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal-day { aspect-ratio: 1; max-height: 64px; border-radius: 10px; background: var(--card-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; border: 1.5px solid transparent; }
.cal-day.pad { background: transparent; }
.cal-day.active { background: var(--accent-soft); }
.cal-day.today { border-color: var(--text); }
.cal-day.future { color: var(--dim); }
.cal-day.out { opacity: 0.45; }
.cal-day i { width: var(--s, 0); height: var(--s, 0); border-radius: 50%; background: var(--accent); }
.mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.mini { background: var(--card-2); border-radius: var(--r-sm); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini span { font-size: 12px; color: var(--muted); }
.mini strong { font-family: var(--display); font-size: 20px; font-weight: 700; }
.mini em { font-style: normal; font-size: 11px; color: var(--muted); }
.mini a { color: inherit; }

/* Répartition */
.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 3px; background: var(--line); }
.split-bar span { background: var(--c); }
.split-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.split-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.split-row i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.split-row span:nth-of-type(1) { flex: 1; }
.split-row strong { width: 48px; text-align: right; }

/* Records */
.records { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .records--wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .records--wide { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.record { background: var(--card-2); border-radius: var(--r-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; color: var(--text); min-width: 0; }
.record:hover { color: var(--text); background: #20252D; }
.record span { font-size: 12px; color: var(--muted); }
.record strong { font-family: var(--display); font-size: 22px; font-weight: 700; }
.record em { font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Activités */
.acts { display: flex; flex-direction: column; gap: 10px; }
.act { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; }
.act:hover { color: var(--text); border-color: var(--line-2); }
.act-icon { width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.act-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.act-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-right { text-align: right; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.act-right strong { font-family: var(--display); font-size: 18px; font-weight: 700; }
.act-right span { font-size: 12px; color: var(--muted); }
.acts--flat .act { background: transparent; border: 0; border-top: 1px solid #1E222A; border-radius: 0; padding: 12px 0; }
.acts--flat { gap: 0; }
.filters { display: flex; flex-direction: column; gap: 10px; }
.filters-row { display: flex; gap: 10px; }
.filters-row > * { flex: 1; min-width: 0; }
@media (min-width: 720px) { .filters { flex-direction: row; align-items: center; } .filters .chips { flex: 1; } .filters-row { flex: 0 0 420px; } }

/* Tableaux */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid #1E222A; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num { font-size: 15px; }
tr.current td { color: var(--accent-text); }

/* Réglages */
.settings-row { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--card-2); object-fit: cover; flex-shrink: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.goal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.goal-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-unit { position: relative; }
.field-unit .input { padding-right: 46px; }
.field-unit::after { content: "km"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }

/* États */
.empty { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty h2 { font-family: var(--display); font-size: 22px; }
.empty p { color: var(--muted); margin: 0; max-width: 420px; }
.skeleton { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--card) 0%, #191D23 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 50;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all 0.25s cubic-bezier(.4,0,.2,1); max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); }
@media (min-width: 1024px) { .toast { bottom: 32px; } }
.alert { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; }
.alert--error { background: rgba(255, 138, 138, 0.12); color: #FFC2C2; border: 1px solid rgba(255, 138, 138, 0.3); }
.alert--ok { background: rgba(110, 231, 168, 0.1); color: #B5F5D2; border: 1px solid rgba(110, 231, 168, 0.3); }
.pager { display: flex; justify-content: center; margin-top: 6px; }

/* ---------- Pages d'authentification ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; position: relative; overflow-x: hidden; }
.auth-deco { position: fixed; top: -170px; right: -200px; width: 520px; height: 520px; pointer-events: none; }
.auth-deco svg { width: 100%; height: 100%; fill: none; stroke-width: 2; }
.auth-deco circle { stroke: #1B1F26; }
.auth-deco circle:nth-child(3) { stroke: var(--line); }
.auth-deco path { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.auth-wrap { position: relative; width: 100%; max-width: 400px; padding: 40px 24px; display: flex; flex-direction: column; gap: 28px; }
.auth-wrap--wide { max-width: 520px; }
.auth-hero { display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 16px; }
.auth-title { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.05; }
.auth-title--xl { font-size: 40px; letter-spacing: -1.5px; }
.auth-sub { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.auth-foot { margin: 12px 0 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-group { border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.form-group legend { padding: 0 6px; font-weight: 700; font-size: 14px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.input-wrap { position: relative; }
.input-eye { position: absolute; right: 6px; top: 6px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500 !important; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 13px; }
.checklist .ok { color: var(--good); }
.checklist .ko { color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
