:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #fc4c02; /* orange Strava */
  --accent-hover: #ff6b30;
  --border: #334155;
  --success: #22c55e;
  --warning: #eab308;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 1.8em;
}

h1 .logo {
  font-size: 1.4em;
  margin-right: 8px;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.2s;
  border: none;
  cursor: pointer;
  font-size: 1em;
}

.btn:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); }

.hero {
  text-align: center;
  padding: 60px 0;
}
.hero h2 {
  font-size: 2.5em;
  margin: 0 0 20px;
}
.hero p {
  font-size: 1.2em;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.activity {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  transition: border 0.2s;
}
.activity:hover { border-color: var(--accent); }

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.activity-title {
  font-size: 1.2em;
  font-weight: 600;
  margin: 0;
}
.activity-date {
  color: var(--text-muted);
  font-size: 0.9em;
}

.activity-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: rgba(0,0,0,0.2);
  padding: 12px;
  border-radius: 6px;
  text-align: center;
}
.stat-value {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  font-size: 0.8em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.analysis {
  background: rgba(0,0,0,0.2);
  padding: 20px;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  margin-top: 16px;
}
.analysis h2 {
  font-size: 1.1em;
  margin: 16px 0 8px;
  color: var(--accent);
}
.analysis h2:first-child { margin-top: 0; }
.analysis ul { padding-left: 20px; }
.analysis strong { color: var(--text); }

.no-analysis {
  color: var(--text-muted);
  font-style: italic;
  padding: 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}
.form-group select,
.form-group input {
  width: 100%;
  padding: 10px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1em;
}

.flash {
  background: var(--success);
  color: white;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
}

.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}
/* === Section titles === */
.section-title {
  margin: 40px 0 16px;
  font-size: 1.3em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* === Weekly load === */
.weekly-block { margin-bottom: 30px; }
.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.week-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}
.week-blue   { border-left-color: #3b82f6; }
.week-green  { border-left-color: #22c55e; }
.week-orange { border-left-color: #f59e0b; }
.week-red    { border-left-color: #ef4444; }

.week-dates {
  color: var(--text-muted);
  font-size: 0.8em;
  margin-bottom: 8px;
}
.week-suffer {
  font-size: 2em;
  font-weight: 700;
  color: var(--text);
}
.week-label {
  font-size: 0.75em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.week-meta {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.week-classif {
  font-size: 0.85em;
  font-weight: 600;
  margin-top: 6px;
}
.week-blue   .week-classif { color: #60a5fa; }
.week-green  .week-classif { color: #4ade80; }
.week-orange .week-classif { color: #fbbf24; }
.week-red    .week-classif { color: #f87171; }

/* === Badges === */
.badge {
  display: inline-block;
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
  vertical-align: middle;
}
.badge-pr {
  background: #fbbf24;
  color: #422006;
  font-weight: 600;
}

/* === Zones FC === */
.hr-zones {
  margin: 16px 0;
}
.hr-zones-label {
  font-size: 0.85em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.hr-zones-bar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
}
.hr-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75em;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  transition: filter 0.15s;
}
.hr-zone:hover { filter: brightness(1.2); cursor: help; }
.hr-zone-1 { background: #3b82f6; }
.hr-zone-2 { background: #22c55e; }
.hr-zone-3 { background: #eab308; }
.hr-zone-4 { background: #f97316; }
.hr-zone-5 { background: #ef4444; }

/* === Notes Strava === */
.activity-note {
  background: rgba(252, 76, 2, 0.1);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  margin: 12px 0;
  font-style: italic;
  color: var(--text-muted);
}
/* === Goals === */
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.goal-priority-A { border-left-color: var(--accent); }
.goal-priority-B { border-left-color: #eab308; }
.goal-priority-C { border-left-color: var(--text-muted); }

.goal-status-achieved { opacity: 0.65; }
.goal-status-abandoned { opacity: 0.5; }

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.goal-priority {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.goal-badge {
  display: inline-block;
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
}
.goal-badge-done { background: var(--success); color: white; }
.goal-badge-aban { background: var(--text-muted); color: white; }

.goal-countdown {
  font-size: 1.1em;
}

.goal-name {
  font-size: 1.3em;
  margin: 4px 0 12px;
}
.goal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.9em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.goal-notes {
  font-style: italic;
  color: var(--text-muted);
  margin: 10px 0;
}
.goal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85em;
}
.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.4); }

.add-goal-block {
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-top: 30px;
}
.add-goal-block h3 {
  margin-top: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-group textarea {
  width: 100%;
  padding: 10px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1em;
  resize: vertical;
}
/* === Équipement === */
.equip-group {
  margin-bottom: 20px;
}
.equip-group-title {
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.equip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: border 0.15s, background 0.15s;
}
.equip-item:hover {
  border-color: var(--accent);
}
.equip-item.equip-checked {
  background: rgba(252, 76, 2, 0.1);
  border-color: var(--accent);
}
.equip-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.equip-item span {
  font-size: 0.95em;
}
/* === Plan : contexte === */
.muted { color: var(--text-muted); }
.context-block { margin-bottom: 30px; }
.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.context-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.context-card h4 {
  margin: 0 0 8px;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.ctx-item { font-size: 0.9em; margin-bottom: 4px; }
.badge-mini {
  display: inline-block;
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 4px;
}
.badge-blue { background:#3b82f6; color:white; }
.badge-green { background:#22c55e; color:white; }
.badge-orange { background:#f59e0b; color:white; }
.badge-red { background:#ef4444; color:white; }

/* === Days grid === */
.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.day-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  transition: border 0.15s, background 0.15s;
}
.day-card.day-active {
  border-color: var(--accent);
  background: rgba(252, 76, 2, 0.05);
}
.day-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}
.day-toggle input { accent-color: var(--accent); }
.day-name { font-size: 1em; }
.day-details { margin-top: 12px; }
.day-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 0.85em;
}
.day-row label { color: var(--text-muted); }
.day-row select {
  padding: 6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9em;
}

/* === Plan : affichage === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.plan-meta {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}
.plan-meta-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85em;
  flex-wrap: wrap;
  gap: 4px;
}
.plan-focus {
  margin: 12px 0;
  font-size: 1.3em;
  color: var(--accent);
}
.plan-rationale summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.plan-rationale p {
  margin-top: 10px;
  font-style: italic;
  color: var(--text-muted);
}

.planned-day {
  margin-bottom: 18px;
}
.planned-day-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 10px;
}
.planned-day-header h3 {
  margin: 0;
  font-size: 1.05em;
}
.planned-session {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 8px;
}
.planned-session-empty {
  text-align: center;
  padding: 10px;
  border-style: dashed;
}
.planned-session-done { border-left: 3px solid var(--success); }
.planned-session-skipped { border-left: 3px solid #ef4444; opacity: 0.6; }
.planned-session-partial { border-left: 3px solid #f59e0b; }
.ps-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.ps-type {
  font-size: 0.75em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ps-title {
  margin: 4px 0 0;
  font-size: 1.05em;
}
.ps-meta { font-size: 0.85em; }
.ps-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  margin-left: 8px;
}
.ps-status-done { background: rgba(34,197,94,0.2); color: #4ade80; }
.ps-status-skipped { background: rgba(239,68,68,0.2); color: #f87171; }
.ps-status-partial { background: rgba(245,158,11,0.2); color: #fbbf24; }
.ps-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
}
.ps-target {
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85em;
}
.ps-objective {
  color: var(--text-muted);
  margin: 8px 0;
}
.ps-instructions summary {
  cursor: pointer;
  font-size: 0.9em;
  color: var(--accent);
  user-select: none;
}
.ps-instructions-body {
  margin-top: 10px;
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  font-size: 0.9em;
}
.ps-equip, .ps-linked {
  font-size: 0.85em;
  margin-top: 8px;
}

/* === Historique plans === */
.hist-plan {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
.hist-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.hist-header h3 { margin: 0; font-size: 1.05em; }
.hist-focus { color: var(--accent); font-size: 0.9em; margin: 4px 0 10px; }
.hist-sessions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hist-session {
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85em;
}
/* === Week nav === */
.week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  gap: 12px;
}
.week-nav-center {
  text-align: center;
  flex: 1;
}
@media (max-width: 600px) {
  .week-nav { flex-wrap: wrap; }
  .week-nav-center { width: 100%; order: -1; margin-bottom: 8px; }
}
.ps-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ps-linked-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.link-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.link-form select {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9em;
  min-width: 200px;
}
.ps-status-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
/* === Debrief === */
.rpe-display {
  text-align: center;
  font-size: 1.3em;
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.debrief-block {
  background: rgba(0,0,0,0.2);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 12px;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}
.activity-debrief-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.debrief-summary {
  font-size: 0.9em;
  color: var(--text-muted);
  flex: 1;
}
/* === Debrief dans séance planifiée === */
.ps-debrief {
  background: rgba(252, 76, 2, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 14px;
  margin: 12px 0;
}
.ps-debrief-header {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}
.ps-debrief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.ps-debrief-item {
  background: rgba(0,0,0,0.2);
  padding: 8px 12px;
  border-radius: 4px;
}
.ps-debrief-label {
  display: block;
  font-size: 0.75em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ps-debrief-value {
  display: block;
  font-weight: 600;
  margin-top: 2px;
}
.ps-debrief-pain { border-left: 3px solid #ef4444; }
.ps-debrief-cond { border-left: 3px solid #f59e0b; }
.ps-debrief-comment {
  margin-top: 10px;
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.95em;
}
.ps-debrief-empty {
  margin: 10px 0;
}
/* === Invitations admin === */
.invitation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
.invitation-card.inv-active { border-left-color: var(--success); }
.invitation-card.inv-used { border-left-color: var(--text-muted); opacity: 0.65; }
.invitation-card.inv-expired { border-left-color: var(--warning); opacity: 0.5; }
.invitation-card.inv-revoked { border-left-color: #ef4444; opacity: 0.5; }

.invitation-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.inv-status {
  margin-left: 10px;
  font-size: 0.85em;
  color: var(--text-muted);
}
.invitation-url {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
  align-items: center;
}
.invitation-link {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.9em;
  cursor: pointer;
  min-width: 280px;
}
/* === Admin users === */
.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
.user-card.user-admin {
  border-left-color: var(--accent);
}
.user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.user-card-meta code {
  background: rgba(0,0,0,0.2);
  padding: 1px 6px;
  border-radius: 4px;
}
/* === Zones d'allure (Phase B) === */
.pace-zones-table { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.pace-zone-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.pace-zone-row:last-child { border-bottom: none; }
.pace-zone-key { font-weight: 700; color: var(--accent); }
.pace-zone-name { color: var(--text); }
.pace-zone-range { font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; }
.pace-mode-tabs { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.pace-mode-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.pace-form { margin-bottom: 8px; }

/* === Répartition zones d'allure (débrief) === */
.pace-dist { margin-top: 12px; }
.pace-dist-label { font-size: 0.85em; margin-bottom: 6px; }
.pace-dist-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--bg-card); }
.pace-dist-seg { height: 100%; }
.pace-dist-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 0.8em; color: var(--text-muted); }
.pace-dist-leg-item { display: inline-flex; align-items: center; gap: 5px; }
.pace-dist-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }