/* ─── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #21253a;
  --surface: #252942;
  --border: #2e3350;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --danger: #ff4757;
  --warn: #ffa502;
  --text: #e8eaf6;
  --text2: #8b90b8;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ─── Layout ────────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem;
  font-size: 1.1rem; font-weight: 700;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
  color: var(--accent);
}
.logo-icon { font-size: 1.4rem; }

.nav-links { list-style: none; padding: .75rem 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem 1.25rem; color: var(--text2);
  text-decoration: none; border-radius: 0 8px 8px 0;
  margin-right: .75rem; transition: all .15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }

.sidebar-user { padding: 1rem 1.25rem; border-top: 1px solid var(--border); color: var(--text2); font-size: .8rem; }

.main-content { flex: 1; padding: 1.5rem 2rem; overflow-x: hidden; max-width: calc(100vw - 220px); }

/* ─── Header ────────────────────────────────────────────────────── */
.top-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.header-date { font-size: .85rem; color: var(--text2); }
.header-actions { display: flex; gap: .5rem; }

/* ─── Tabs ──────────────────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }

/* ─── KPI Grid ──────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }

.kpi-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.kpi-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: .75rem; color: var(--text2); margin: .25rem 0 .5rem; }
.kpi-progress { display: flex; align-items: center; gap: .5rem; font-size: .75rem; color: var(--text2); }
.kpi-card-clickable { cursor: pointer; transition: border-color .15s; }
.kpi-card-clickable:hover { border-color: var(--accent); }
.kpi-edit-hint { font-size: .7rem; opacity: .5; }
.kpi-inline-input { width: 100%; padding: .25rem .4rem; font-size: 1.4rem; font-weight: 700; border-radius: 6px; border: 1px solid var(--accent); background: var(--bg3); color: var(--text1); outline: none; }

/* ─── Progress bars ─────────────────────────────────────────────── */
.progress-bar { flex: 1; height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; max-width: 100%; }
.calorie-fill { background: linear-gradient(90deg, var(--accent2), var(--accent)); }

/* ─── Macros ────────────────────────────────────────────────────── */
.macros-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: .75rem; }

.macro-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.macro-name { font-size: .85rem; font-weight: 600; }
.macro-progress-bar { height: 10px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.macro-fill { height: 100%; border-radius: 99px; transition: width .4s, background .4s; }

/* base colours (low / mid) */
.macro-card.protein .macro-fill { background: #4ade80; }
.macro-card.carbs   .macro-fill { background: #facc15; }
.macro-card.fat     .macro-fill { background: #f97316; }
/* bright (50-80%) */
.macro-card.protein .macro-fill[data-state="mid"] { background: #22c55e; }
.macro-card.carbs   .macro-fill[data-state="mid"] { background: #eab308; }
.macro-card.fat     .macro-fill[data-state="mid"] { background: #ea580c; }
/* good (80-100%) — all go green */
.macro-fill[data-state="good"] { background: #00d4aa; }
/* over (>100%) — all go red */
.macro-fill[data-state="over"] { background: #ef4444; }

.macro-values { font-size: .8rem; color: var(--text2); }
.macro-pct { font-size: .75rem; font-weight: 600; margin-left: .15rem; }
.macro-pct[data-state="low"]  { color: var(--text2); }
.macro-pct[data-state="mid"]  { color: #facc15; }
.macro-pct[data-state="good"] { color: #00d4aa; }
.macro-pct[data-state="over"] { color: #ef4444; }

.macro-remain { font-size: .72rem; margin-top: .2rem; font-weight: 600; }
.macro-remain[data-state="low"]     { color: var(--text2); }
.macro-remain[data-state="mid"]     { color: #facc15; }
.macro-remain[data-state="good"]    { color: #00d4aa; }
.macro-remain[data-state="over"]    { color: #ef4444; }
.macro-remain[data-state="reached"] { color: #4ade80; }

.act-summary-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem 1rem;
  margin-bottom: .75rem;
}
.act-summary-tabs { display: flex; gap: .4rem; margin-bottom: .65rem; }
.act-summary-tab {
  background: none; border: 1px solid var(--border); border-radius: 99px;
  color: var(--text2); font-size: .78rem; padding: .2rem .75rem;
  cursor: pointer; transition: background .2s, color .2s;
}
.act-summary-tab.active, .act-summary-tab:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.act-summary-values { display: flex; gap: 0; }
.act-summary-kpi {
  flex: 1; text-align: center;
  border-right: 1px solid var(--border);
}
.act-summary-kpi:last-child { border-right: none; }
.act-summary-val { font-size: 1.4rem; font-weight: 700; color: var(--text1); }
.act-summary-lbl { font-size: .72rem; color: var(--text2); margin-top: .1rem; }

.macro-tips {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1.1rem;
  margin-bottom: .75rem; display: flex; flex-direction: column; gap: .35rem;
}
.macro-tips p { margin: 0; font-size: .82rem; color: var(--text1); line-height: 1.4; }
.macro-tips p::before { content: '• '; color: var(--text2); }

/* ─── Charts ────────────────────────────────────────────────────── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }

.chart-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.chart-card canvas {
  height: 260px !important;
  max-height: 260px;
}
.chart-title { font-size: .9rem; font-weight: 600; margin-bottom: 1rem; color: var(--text2); }

/* ─── Section title ─────────────────────────────────────────────── */
.section-title { font-size: 1rem; font-weight: 600; margin: 1rem 0 .75rem; }

/* ─── Activities ────────────────────────────────────────────────── */
.activities-list { display: flex; flex-direction: column; gap: .5rem; }
.activities-full-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }

.activity-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1.1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.activity-item-clickable { cursor: pointer; transition: border-color .15s, background .15s; }
.activity-item-clickable:hover { border-color: var(--accent); background: var(--bg3); }
.activity-type-icon { font-size: 1.4rem; margin-right: .75rem; flex-shrink: 0; }
.activity-info { flex: 1; min-width: 0; }
.activity-name { font-weight: 600; font-size: .9rem; }
.activity-meta { font-size: .75rem; color: var(--text2); }
.activity-stats { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .8rem; }
.stat-pill { background: var(--bg3); padding: .2rem .6rem; border-radius: 99px; }

/* ─── Activity detail modal ─────────────────────────────────────── */
.modal-wide { max-width: 640px; }
.detail-section { margin-bottom: 1.25rem; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); margin-bottom: .6rem; }
.detail-metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; }
.detail-metric { background: var(--bg3); border-radius: var(--radius); padding: .6rem .75rem; text-align: center; }
.detail-metric-icon { font-size: 1.1rem; margin-bottom: .15rem; }
.detail-metric-val { font-size: .95rem; font-weight: 700; }
.detail-metric-label { font-size: .68rem; color: var(--text2); margin-top: .1rem; }
.rpe-row { display: flex; align-items: center; gap: .75rem; }
.rpe-bar-wrap { flex: 1; height: 8px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.rpe-bar-fill { height: 100%; border-radius: 99px; transition: width .3s; }
.rpe-value { font-size: 1rem; font-weight: 700; min-width: 2.5rem; text-align: right; }
.detail-cond-list { display: flex; flex-direction: column; gap: .4rem; }
.detail-cond-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; font-size: .85rem; padding: .4rem .6rem; background: var(--bg3); border-radius: 6px; }
.detail-cond-row span:first-child { color: var(--text2); font-size: .78rem; white-space: nowrap; }
.detail-cond-row strong, .detail-cond-row span:last-child { font-weight: 600; text-align: right; }
.detail-note { font-size: .85rem; color: var(--text2); background: var(--bg3); border-radius: 6px; padding: .6rem .75rem; line-height: 1.5; }
.danger-note { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--bg3)); }
.btn-danger-outline { color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger); color: #fff; }

/* ─── Meal groups ───────────────────────────────────────────────── */
.nutrition-action-bar {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: .85rem; flex-wrap: wrap;
}
.food-search-wrap { position: relative; flex: 1; min-width: 0; }
.food-search-input {
  width: 100%; box-sizing: border-box;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text1);
  padding: .55rem .85rem; font-size: .88rem;
}
.food-search-input:focus { outline: none; border-color: var(--accent); }
.food-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  z-index: 200; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-height: 300px; overflow-y: auto;
}
.food-search-item { padding: .55rem .85rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.food-search-item:last-child { border-bottom: none; }
.food-search-item:hover { background: var(--bg3); }
.food-search-item-name { font-weight: 600; font-size: .87rem; color: var(--text1); }
.food-search-item-brand { font-weight: 400; color: var(--text2); }
.food-search-item-meta { font-size: .74rem; color: var(--text2); margin-top: .1rem; }
.btn-link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: .83rem; padding: .4rem .1rem; white-space: nowrap;
}
.btn-link:hover { text-decoration: underline; }

.meal-groups { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.meal-group { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.meal-group-header { padding: .75rem 1rem; background: var(--bg3); font-weight: 600; display: flex; justify-content: space-between; }
.meal-item { padding: .65rem 1rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.meal-item-name { font-size: .9rem; }
.meal-item-cals { font-size: .8rem; color: var(--text2); }
.meal-item-macros { font-size: .75rem; color: var(--text2); }
.meal-item-per100 { font-size: .7rem; color: var(--text2); opacity: .65; margin-top: .15rem; }
.meal-delete { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: .2rem .4rem; }

/* ─── Training Plan ─────────────────────────────────────────────── */
.plan-header { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.plan-name { font-size: 1.1rem; font-weight: 700; }
.plan-goal { font-size: .85rem; color: var(--text2); margin-top: .25rem; }

.plan-actions { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.sessions-grid { display: flex; flex-direction: column; gap: .5rem; }

.session-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  display: flex; gap: 1rem; align-items: flex-start;
}
.session-date { min-width: 80px; text-align: center; }
.session-day { font-size: .7rem; color: var(--text2); text-transform: uppercase; }
.session-dd { font-size: 1.3rem; font-weight: 700; }
.session-info { flex: 1; }
.session-title { font-weight: 600; }
.session-desc { font-size: .8rem; color: var(--text2); margin-top: .25rem; line-height: 1.4; }
.session-meta { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.session-status { padding: .15rem .5rem; border-radius: 99px; font-size: .7rem; font-weight: 600; }
.status-planned { background: rgba(108,99,255,.2); color: var(--accent); }
.status-completed { background: rgba(0,212,170,.2); color: var(--accent2); }
.status-skipped { background: rgba(255,71,87,.2); color: var(--danger); }
.status-modified { background: rgba(255,165,2,.2); color: var(--warn); }
.session-intensity { padding: .15rem .5rem; border-radius: 99px; font-size: .7rem; background: var(--bg3); }

/* ─── Workout suggestion ────────────────────────────────────────── */
.workout-suggestion { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.workout-phase { margin-bottom: 1rem; }
.workout-phase-title { font-weight: 600; font-size: .85rem; color: var(--accent2); margin-bottom: .5rem; }
.workout-exercise { display: flex; gap: .75rem; align-items: baseline; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.ex-name { font-weight: 600; min-width: 160px; }
.ex-params { font-size: .8rem; color: var(--text2); }
.ex-note { font-size: .75rem; color: var(--text2); font-style: italic; }

/* ─── Health form ───────────────────────────────────────────────── */
.health-form.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
.health-form h3 { font-size: 1rem; margin-bottom: 1rem; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.card h3 { font-size: 1rem; margin-bottom: 1rem; }

/* ─── Date nav ──────────────────────────────────────────────────── */
.date-nav { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.date-label { font-weight: 600; }

/* ─── Forms ─────────────────────────────────────────────────────── */
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; min-width: 120px; flex: 1; }
.form-group label { font-size: .8rem; color: var(--text2); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: .55rem .75rem;
  font-size: .9rem; width: 100%; outline: none; font-family: inherit;
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; }
.hint { font-size: .8rem; color: var(--text2); margin-top: .25rem; }

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: 8px; border: none;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: all .15s; text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #5a52e0; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg3); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Modals ────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 100; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: block; }
.modal {
  display: none; position: fixed; top: 50%; left: 50%;
  transform: translate(-50%,-50%); z-index: 101;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); width: 90%; max-width: 560px;
  box-shadow: var(--shadow);
}
.modal.open { display: block; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal-body { padding: 1.25rem; max-height: 60vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

/* ─── Goals ─────────────────────────────────────────────────────── */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.goals-overview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1rem; }

.goal-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.goal-card-icon { font-size: 1.6rem; margin-bottom: .5rem; }
.goal-card-title { font-size: .8rem; color: var(--text2); margin-bottom: .25rem; }
.goal-card-value { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.goal-card-sub { font-size: .75rem; color: var(--text2); margin-bottom: .75rem; }
.goal-card-bar { height: 8px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.goal-card-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.fill-weight { background: linear-gradient(90deg, #a78bfa, #6c63ff); }
.fill-cycling { background: linear-gradient(90deg, #34d399, #00d4aa); }
.fill-running { background: linear-gradient(90deg, #fb923c, #f97316); }
.fill-steps { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.goal-card-pct { font-size: .7rem; color: var(--text2); text-align: right; margin-top: .3rem; }

.goals-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
.goal-form-block { background: var(--bg3); border-radius: 8px; padding: 1rem; }
.goal-form-title { font-size: .85rem; font-weight: 600; margin-bottom: .75rem; }

/* ─── Forma & Affaticamento ─────────────────────────────────────── */
.chart-wrap { position: relative; height: 240px; }
.chart-wrap.chart-tall { height: 300px; }
.chart-subtitle { font-size: .78rem; color: var(--text2); margin: .1rem 0 .75rem; }
.charts-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.card-header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.card-header-row h3 { margin: 0; }
.chart-legend-row { display: flex; align-items: center; gap: .25rem; font-size: .75rem; color: var(--text2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.fitness-status-card { padding: 1.25rem; }
.fitness-status-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.fitness-status-main { display: flex; align-items: flex-start; gap: 1rem; flex: 1; min-width: 200px; }
.fitness-status-icon { font-size: 2rem; line-height: 1; }
.fitness-status-label { font-size: 1.2rem; font-weight: 700; }
.fitness-status-advice { font-size: .85rem; color: var(--text2); margin-top: .2rem; }
.fitness-status-power { font-size: .82rem; margin-top: .4rem; }
.fitness-status-metrics { display: flex; gap: 1rem; }
.fitness-metric-box { text-align: center; background: var(--bg3); border-radius: var(--radius); padding: .75rem 1.25rem; min-width: 80px; }
.fitness-metric-val { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.fitness-metric-lbl { font-size: .68rem; color: var(--text2); margin-top: .2rem; text-transform: uppercase; letter-spacing: .04em; }

/* ─── Coach ─────────────────────────────────────────────────────── */
.coach-tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.coach-container { display: flex; gap: 1rem; }
.coach-history-panel { flex-direction: column; width: 240px; min-width: 240px; max-height: calc(100vh - 180px); background: var(--bg2); border-radius: var(--radius); overflow-y: auto; }
.coach-history-title { font-size: .72rem; font-weight: 700; color: var(--text2); padding: .75rem 1rem .4rem; text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; background: var(--bg2); }
.history-session { padding: .6rem 1rem; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.04); transition: background .12s; }
.history-session:hover { background: var(--bg3); }
.history-session-date { font-size: .78rem; font-weight: 600; color: var(--accent); }
.history-session-preview { font-size: .74rem; color: var(--text2); margin-top: .15rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-session-count { font-size: .7rem; color: var(--text2); margin-top: .2rem; opacity: .7; }
.coach-wrap { display: flex; flex-direction: column; flex: 1; min-width: 0; height: calc(100vh - 180px); min-height: 420px; background: var(--bg2); border-radius: var(--radius); overflow: hidden; }
.coach-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.coach-typing { display: flex; align-items: center; gap: .5rem; padding: .5rem 1.5rem; font-size: .82rem; color: var(--text2); }
.coach-input-row { display: flex; gap: .75rem; padding: 1rem 1.5rem; background: var(--bg3); border-top: 1px solid rgba(255,255,255,.06); }
.coach-textarea { flex: 1; background: var(--bg2); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; color: var(--text1); padding: .6rem .9rem; font-size: .9rem; resize: none; font-family: inherit; line-height: 1.5; }
.coach-textarea:focus { outline: none; border-color: var(--accent); }
.coach-send-btn { align-self: flex-end; white-space: nowrap; }

.chat-msg { display: flex; max-width: 82%; }
.coach-msg { align-self: flex-start; }
.user-msg { align-self: flex-end; }
.chat-bubble { padding: .75rem 1rem; border-radius: 14px; font-size: .9rem; line-height: 1.55; word-break: break-word; }
.coach-msg .chat-bubble { background: var(--bg3); color: var(--text1); border-bottom-left-radius: 3px; }
.user-msg .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble strong { font-weight: 700; }
.chat-bubble code { background: rgba(0,0,0,.3); padding: .1em .35em; border-radius: 3px; font-size: .83em; font-family: monospace; }

.typing-indicator { display: flex; gap: 4px; align-items: center; }
.typing-indicator span { width: 6px; height: 6px; background: var(--text2); border-radius: 50%; animation: typing-bounce 1.2s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.btn-coach { display: inline-block; background: rgba(108,99,255,.12); color: var(--accent); border: 1px solid rgba(108,99,255,.28); font-size: .8rem; padding: .35rem .85rem; border-radius: 20px; cursor: pointer; margin-top: .75rem; transition: background .15s; }
.btn-coach:hover { background: rgba(108,99,255,.24); }

/* ─── Weekly Plan ───────────────────────────────────────────────── */
.days-checkbox-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.day-check { display: flex; align-items: center; gap: .3rem; background: var(--bg3); border: 1px solid rgba(255,255,255,.08); border-radius: 6px; padding: .35rem .6rem; cursor: pointer; font-size: .85rem; transition: border-color .12s; }
.day-check:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.day-check input { display: none; }

.weekly-plan-sessions { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; margin-top: .5rem; }
.wp-session { background: var(--bg3); border-radius: 8px; padding: .85rem 1rem; border-left: 3px solid var(--accent); }
.wp-rest { border-left-color: rgba(255,255,255,.12); opacity: .6; }
.wp-strength { border-left-color: #f9844a; }
.wp-mobility { border-left-color: #90e0ef; }
.wp-day { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); }
.wp-date { font-weight: 400; opacity: .7; margin-left: .3rem; }
.wp-type { font-size: .9rem; font-weight: 600; margin: .3rem 0 .15rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.wp-name { font-size: .82rem; font-weight: 600; color: var(--text1); }
.wp-desc { font-size: .78rem; color: var(--text2); margin-top: .25rem; line-height: 1.45; }
.wp-segments { font-size: .72rem; color: var(--text2); margin-top: .4rem; background: rgba(0,0,0,.2); border-radius: 4px; padding: .3rem .5rem; font-family: monospace; }
.wp-badge { font-size: .68rem; background: rgba(108,99,255,.15); color: var(--accent); border-radius: 4px; padding: .1rem .35rem; }
.wp-outdoor { background: rgba(0,212,170,.1); color: #00d4aa; }
.wp-power { font-size: .78rem; color: var(--accent); font-weight: 700; margin-left: auto; }
.wp-actions { display: flex; gap: .35rem; margin-top: .5rem; }
.wp-btn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 5px; color: var(--text1); font-size: .8rem; padding: .2rem .45rem; cursor: pointer; transition: background .12s; }
.wp-btn:hover { background: rgba(255,255,255,.14); }
.wp-btn-del:hover { background: rgba(255,80,80,.2); border-color: var(--danger); }

/* ─── Exercise Detail Modal ─────────────────────────────────────── */
.exercise-item { background: var(--bg3); border-radius: 8px; padding: .85rem 1rem; margin-bottom: .75rem; border-left: 3px solid var(--accent); }
.exercise-header { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .45rem; }
.exercise-num { background: var(--accent); color: #fff; border-radius: 50%; width: 1.4rem; height: 1.4rem; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.exercise-name { font-weight: 600; font-size: .95rem; flex: 1; }
.exercise-equip-badge { font-size: .7rem; background: rgba(108,99,255,.18); color: var(--accent); border-radius: 4px; padding: .1rem .4rem; white-space: nowrap; }
.exercise-sets { font-size: .8rem; color: var(--text2); background: rgba(255,255,255,.06); border-radius: 4px; padding: .1rem .4rem; white-space: nowrap; }
.exercise-desc { font-size: .875rem; color: var(--text1); line-height: 1.55; margin-bottom: .4rem; }
.exercise-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--text2); }
.exercise-notes { color: #f9c74f; }

/* ─── Calorie burn row ──────────────────────────────────────────── */

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .charts-grid-2 { grid-template-columns: 1fr; }
  .fitness-status-inner { flex-direction: column; }
}
@media (max-width: 600px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span + *, .sidebar-user { display: none; }
  .main-content { padding: 1rem; max-width: calc(100vw - 60px); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .macros-row { grid-template-columns: 1fr; }
}
