/* ============================================================
   FitBridge — Screen 2 · Month
   ============================================================ */
.month { width: 100%; display: flex; min-width: 0; gap: 20px; padding: 22px; align-items: stretch; }
.month-card {
  flex: 1; min-width: 0;
  background: #fff; border: 1px solid var(--card-border); border-radius: 24px;
  box-shadow: var(--card-shadow-soft); padding: 26px 28px 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.month-rail {
  width: 38%; flex: 0 0 38%; padding: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.month-title { margin: 0; font-size: 60px; font-weight: 800; letter-spacing: -0.03em; line-height: 0.92; }

.month-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.mstat .k { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.mstat .v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.mstat .delta { font-size: 12.5px; font-weight: 600; margin-top: 3px; display: inline-flex; align-items: center; gap: 4px; color: var(--good); }
.mstat .delta.is-down { color: var(--crit); }
.mstat .delta .tri { font-size: 9px; }
.mstat .delta .from { color: var(--dim); font-weight: 500; }

/* calendar grid — compact wall-calendar: small near-square cells, hairline seams, small radius */
.mcal { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; gap: 2px; }
.mcell {
  position: relative; border-radius: 3px; overflow: hidden;
  background: var(--card-bg); border: 1px solid var(--card-border);
  padding: 6px 7px; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 0;
}
.mcell.is-blank { background: transparent; border: none; }
.mcell.is-fill { border-color: transparent; background-size: cover; background-position: center; }
.mcell .m-split { position: absolute; inset: 0; display: flex; z-index: 0; }
.mcell .m-half { flex: 1; background-size: cover; background-position: center; }
/* a future two-a-day reads as "planned, not done" — dim the split tiles */
.mcell.is-split.is-future .m-half { opacity: .42; }
.mcell.is-rest { background: #E9F1F7; border-color: transparent; }
.mcell.is-empty-future { background: #F4F7FB; }
.mcell.is-hatch {
  border-color: transparent;
  background-color: #fff;
  background-image: repeating-linear-gradient(135deg, var(--hatch) 0, var(--hatch) 2.5px, transparent 2.5px, transparent 10px);
}
.mcell.is-today { border: 3.5px solid var(--crit); border-radius: 5px; z-index: 1; }
/* V2 — bottom-up TQI fill: the un-filled top shows a muted base so the fill HEIGHT
   reads as "how much / how well" (= that day's TQI). Used on the whole cell or a half. */
/* the un-filled top of a partial cell = the NOT-completed part of the plan → sport-colour
   dashed hatch (was a flat grey #EAEEF4). The bottom-up .m-fill (solid) overlays the done part;
   a 100%-done cell is fully covered so the hatch never shows. */
.mcell.is-tqi, .mcell .m-half.is-tqi {
  position: relative; background-color: #fff;
  background-image: repeating-linear-gradient(135deg, var(--hatch, #cbd2dd) 0, var(--hatch, #cbd2dd) 2.5px, transparent 2.5px, transparent 10px);
}
.mcell .m-fill { position: absolute; left: 0; right: 0; bottom: 0; z-index: 0;
  background-size: cover; background-position: center bottom; border-radius: 0 0 3px 3px; }
.mcell.is-split .m-fill { border-radius: 0; }
/* missed → dashed hatch in the SPORT'S OWN theme colour (--hatch); a planned session
   in that sport that wasn't executed. Denser stripes + a thin sport-colour border so
   it reads as "missed" vs the lighter "upcoming" future hatch. No "?" badge. */
.mcell.is-missed-fill, .mcell .m-half.is-missed-fill {
  border-color: transparent; border-radius: 3px; background-color: #fff;
  /* D7: render a past-missed day IDENTICALLY to a future undone day (.is-hatch) — same
     stripe density, and NO inset border (the "extra pink frame" the user asked to drop).
     The .is-today red border is a separate `border` property and stays intact. */
  background-image: repeating-linear-gradient(135deg, var(--hatch) 0, var(--hatch) 2.5px, transparent 2.5px, transparent 10px); }
.mcell.is-missed-fill .m-num, .mcell.is-missed-fill .m-label, .mcell.is-missed-fill .m-dow { color: var(--ink); }
/* pending today → planned, not yet done → the sport's dashed hatch (not a flat grey block).
   NB only drop the border off-today — on today the .is-today red border must survive (equal
   specificity + later source order would otherwise paint it transparent). */
.mcell.is-pending-fill {
  background-color: #fff;
  background-image: repeating-linear-gradient(135deg, var(--hatch, #cbd2dd) 0, var(--hatch, #cbd2dd) 2.5px, transparent 2.5px, transparent 10px);
}
.mcell.is-pending-fill:not(.is-today) { border-color: transparent; }
/* two-a-day half: hatch for a FUTURE half */
.mcell .m-half.is-hatch { background-color: #fff;
  background-image: repeating-linear-gradient(135deg, var(--hatch) 0, var(--hatch) 2.5px, transparent 2.5px, transparent 10px); }
.mcell .m-wm { position: absolute; right: 5px; bottom: 4px; width: 30%; height: 30%; opacity: .15; z-index: 0; color: #1B2438; }
.mcell .m-wm svg { width: 100%; height: 100%; }
.mcell .m-wm.on-dark-wm { color: #fff; opacity: .26; }
.mcell.is-hatch .m-wm { opacity: .12; }
/* short life-event lines (cell bottom-left; RED = urgent, AMBER = important).
   z-index above the sport-tile fill + a white outline so the colour never gets
   drowned by a sport theme colour underneath. */
.mcell .m-redlines { position: absolute; left: 6px; bottom: 5px; display: flex; gap: 2.5px; align-items: flex-end; z-index: 3; }
.mcell .m-redlines i { width: 3.5px; height: 16px; border-radius: 2px; background: var(--crit);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .95), 0 1px 2px rgba(0, 0, 0, .28); }
.mcell .m-redlines i.is-urgent { background: var(--crit); }
.mcell .m-redlines i.is-important { background: var(--crit-important); }
.mcell .m-top { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; }
.mcell .m-label { font-size: 14px; font-weight: 800; font-style: italic; letter-spacing: -0.01em; line-height: 1.0; color: var(--ink); flex: 1; min-width: 0; }
.mcell .m-label-sp { display: inline-block; flex: 1; }
.mcell .m-dow { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; color: var(--dim); text-transform: uppercase; flex: 0 0 auto; }
.mcell .m-num { position: relative; z-index: 1; align-self: flex-end; font-size: 31px; font-weight: 800; font-style: italic; letter-spacing: -0.03em; line-height: 1; color: #0E1422; }
.mcell.on-dark .m-label, .mcell.on-dark .m-num, .mcell.on-dark .m-dow { color: #fff; }
.mcell.is-race .m-wm { opacity: .22; color: #fff; }

/* completion status (A1) — elapsed cells reflect plan-vs-actual; mirrors the
   Home timeline theme (done = green check via --good, missed = grey "?" via
   --dim-2, partial = faded tile). pending / future / rest are left untouched. */
.mcell.is-missed { background-color: #E7EBF1 !important; border-color: transparent; }
.mcell.is-missed.is-fill { background-image: none !important; }
.mcell.is-missed .m-split { display: none; }              /* drop vibrant two-a-day tiles */
.mcell.is-missed .m-num, .mcell.is-missed .m-label, .mcell.is-missed .m-dow { color: var(--dim-2); }
.mcell.is-partial.is-fill::after,
.mcell.is-partial .m-split::after {
  content: ""; position: absolute; inset: 0; z-index: 0; background: rgba(255, 255, 255, .5);
}
.mcell .mc-badge {
  position: absolute; top: 5px; left: 6px; z-index: 3;
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; line-height: 1;
}
.mcell .mc-badge.mc-done { background: var(--good); color: #fff; }
.mcell .mc-badge.mc-done svg { width: 11px; height: 11px; }
.mcell .mc-badge.mc-missed { color: var(--dim-2); border: 1.5px solid var(--dim-2); background: rgba(255, 255, 255, .8); }

/* bottom completion viz */
.mcompletion { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding-top: 6px; }
.mcompletion .mc-left .k { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.mcompletion .mc-left .v { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; margin-top: 3px; }
.mcompletion .mc-left .delta { font-size: 12.5px; font-weight: 600; color: var(--crit); display: inline-flex; gap: 4px; align-items: center; margin-top: 4px; }
.mcompletion .mc-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 26px; flex: 1; max-width: 520px; align-content: center; }
.mc-prog { display: flex; align-items: stretch; gap: 2.5px; height: 13px; }
.mc-prog i { flex: 1; border-radius: 3px; background: #E4EAF2; }
.mc-prog i.on { background: var(--seg-on, var(--accent)); }

/* right rail — analysis panels */
.mpanel {
  background: #fff; border: 1px solid var(--card-border); border-radius: 18px;
  padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; flex: 1;
  position: relative; overflow: hidden; box-shadow: var(--card-shadow-soft);
}
.mpanel .mp-h { font-size: 18px; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
/* E1·E — previous-training card: dark photo-placeholder bg, white italic 2×3
   metrics (col 1: distance/duration/max bpm · col 2: pace/cal/min bpm), orange
   route trace on the right. The solid #3A3A3C is the stand-in for the user-
   supplied background photo. */
.mp-prev { flex: 1.45; background: #3A3A3C; border-color: #3A3A3C; }
.mp-prev .mp-h { color: rgba(255, 255, 255, 0.92); }
/* D3: sport-type label under the recap title (the metric set below is sport-specific) */
.mp-prev .mp-sport { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6); margin-top: -10px; }
.mp-prev-body { display: flex; flex: 1; gap: 12px; min-height: 0; align-items: center; }
.mp-prev .mp-metrics {
  display: grid; grid-auto-flow: column;
  /* W5: rows set per sport via --mp-rows = ceil(metric_count / 2) so a 4-metric sport
     fills a symmetric 2×2 instead of an orphaned 3+1; 6-metric sports stay 2×3. */
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(var(--mp-rows, 3), auto);
  gap: 16px 10px; align-content: center; flex: 1.15; min-width: 0;
}
.mp-metric { font-style: italic; color: #fff; white-space: nowrap; line-height: 1; }
.mp-metric .mm-v { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.mp-metric .mm-u { font-size: 13px; font-weight: 700; opacity: 0.85; }
.mp-metric .mm-sup { font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.6); vertical-align: super; font-style: normal; margin-left: 1px; }
.mp-route { flex: 1; align-self: stretch; display: flex; align-items: center; min-width: 0; }
.mp-route svg { width: 100%; height: 100%; max-height: 160px; }
.mp-route path { fill: none; stroke: #FF7A1A; stroke-width: 1.15; stroke-linejoin: round; stroke-linecap: round; }
.mp-empty { color: rgba(255, 255, 255, 0.66); font-size: 13.5px; font-weight: 600; line-height: 1.45; margin: auto 0; }
.mp-stub { justify-content: flex-start; gap: 10px; }
.mp-stub .mp-sample { font-size: 26px; font-weight: 800; font-style: italic; color: var(--ink); letter-spacing: -0.02em; }
.mp-add {
  flex: 0 0 auto; min-height: 60px; align-items: center; justify-content: center;
  flex-direction: row; gap: 0; background: #EEF0F6; border: 1px solid transparent; box-shadow: none;
  font-size: 16px; font-weight: 800; color: var(--ink-2); cursor: pointer; transition: background .12s;
}
.mp-add:hover { background: #E4E7F0; }

/* A3 — lifted dashboard_modules cards + picker */
.mpanel.mp-dash { flex: 0 0 auto; gap: 9px; border-left: 4px solid var(--card-border); }
.mp-dash.band-good { border-left-color: var(--good); }
.mp-dash.band-warning { border-left-color: var(--warn); }
.mp-dash.band-critical { border-left-color: var(--crit); }
.mp-dash .mp-x { position: absolute; top: 10px; right: 12px; z-index: 2; border: 0; background: none;
  cursor: pointer; font-size: 18px; line-height: 1; color: var(--dim-2); padding: 2px 5px; border-radius: 6px; }
.mp-dash .mp-x:hover { background: var(--bg); color: var(--ink); }
.dash-primary { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.dash-primary .dp-v { font-size: 30px; font-weight: 800; font-style: italic; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.dash-primary .dp-u { font-size: 14px; font-weight: 700; color: var(--dim); }
.dash-primary .dp-s { font-size: 12.5px; font-weight: 600; color: var(--dim); margin-left: auto; }
.dash-spark { height: 26px; }
.dash-spark svg { width: 100%; height: 100%; display: block; }
.dash-spark path { fill: none; stroke: var(--accent-strong); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dash-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.dash-row .dr-k { color: var(--dim); font-weight: 600; }
.dash-row .dr-v { color: var(--ink); font-weight: 700; }

.mp-picker-overlay { position: fixed; inset: 0; z-index: 9500; background: rgba(20, 26, 40, .35);
  display: flex; align-items: center; justify-content: center; }
.mp-picker { background: #fff; border-radius: 18px; box-shadow: 0 18px 60px rgba(20, 30, 50, .28);
  width: min(420px, 86vw); max-height: 70vh; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.mp-picker-h { font-size: 15px; font-weight: 800; color: var(--ink); padding: 6px 8px 10px; }
.mp-pick-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; font: inherit; text-align: left;
  border: 1px solid var(--card-border); background: #fff; border-radius: 12px; padding: 12px 14px; cursor: pointer;
  transition: background .12s, border-color .12s; }
.mp-pick-item:hover { background: var(--hover-tint); border-color: var(--accent); }
.mp-pick-item .pi-t { font-size: 14px; font-weight: 700; color: var(--ink); }
.mp-pick-item .pi-v { font-size: 13px; font-weight: 800; color: var(--accent-strong); font-variant-numeric: tabular-nums; }

/* A2 — Estimated Recovery Time gauge */
.mp-recovery { display: flex; flex-direction: column; gap: 13px; margin-top: 4px; }
.mp-recovery .rec-head { display: flex; align-items: baseline; gap: 4px; }
.mp-recovery .rec-h { font-size: 38px; font-weight: 800; font-style: italic; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.mp-recovery .rec-u { font-size: 16px; font-weight: 700; color: var(--dim); }
.mp-recovery .rec-tag { margin-left: auto; align-self: center; font-size: 11.5px; font-weight: 800; padding: 3px 11px; border-radius: 999px; }
.rec-tag.rec-good { color: var(--good); background: rgba(22, 168, 120, .12); }
.rec-tag.rec-warn { color: var(--warn); background: rgba(245, 158, 11, .15); }
.rec-tag.rec-crit { color: var(--crit); background: rgba(214, 58, 106, .12); }
.mp-recovery .rec-bar { height: 10px; border-radius: 999px; background: #E4EAF2; overflow: hidden; }
.mp-recovery .rec-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.rec-fill.rec-good { background: var(--good); }
.rec-fill.rec-warn { background: var(--warn); }
.rec-fill.rec-crit { background: var(--crit); }

/* A2 — Physical Condition PMC dual-line (fitness CTL vs fatigue ATL) */
.pmc-chart { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; margin-top: 4px; }
.pmc-plot { flex: 1; min-height: 84px; }
.pmc-svg { width: 100%; height: 100%; display: block; }
.pmc-svg path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pmc-svg .pmc-ctl { stroke: var(--accent-strong); }
.pmc-svg .pmc-atl { stroke: var(--dim-2); stroke-dasharray: 3.5 2.5; }
.pmc-legend { display: flex; align-items: center; gap: 14px; font-size: 12px; font-weight: 600; color: var(--dim); }
.pmc-legend .pmc-k { display: inline-flex; align-items: center; gap: 5px; }
.pmc-legend .pmc-k b { color: var(--ink); font-weight: 800; }
.pmc-dot { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.pmc-dot.ctl { background: var(--accent-strong); }
.pmc-dot.atl { background: var(--dim-2); }
.pmc-form { margin-left: auto; font-weight: 800; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; }
.pmc-form.pmc-fresh { color: var(--good); background: rgba(22, 168, 120, .12); }
.pmc-form.pmc-neutral { color: var(--dim); background: var(--bg); }
.pmc-form.pmc-fatigued { color: var(--crit); background: rgba(214, 58, 106, .12); }

/* TQI bar chart (inside the TQI analysis panel) — D4: one column per DAY + date labels */
.tqi-chart { position: relative; flex: 1; min-height: 140px; margin-top: 6px; padding-left: 28px; display: flex; }
.tqi-y { position: absolute; left: 0; top: 0; bottom: 18px; width: 24px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--dim-2); text-align: right; }
.tqi-plotwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tqi-plot { position: relative; flex: 1; min-height: 0; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--hairline); }
.tqi-plot::before, .tqi-plot::after { content: ""; position: absolute; left: 0; right: 0; border-top: 1px dashed var(--hairline); }
.tqi-plot::before { top: 0; }
.tqi-plot::after { top: 50%; }
.tqi-cell { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; }
.tqi-bar { width: 100%; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, #8FE26A 0%, #37CDBE 100%); min-height: 4px; }
.tqi-labels { display: flex; gap: 3px; margin-top: 4px; height: 13px; }
.tqi-lab { flex: 1; min-width: 0; font-size: 8px; font-weight: 600; color: var(--dim-2); text-align: center; line-height: 1; overflow: hidden; }

/* D9 — day-detail popup: a lightweight floating card over a TRANSPARENT backdrop (the
   page is NOT dimmed). The backdrop intercepts the close-click so it can't pass through. */
.mcell.is-clickable { cursor: pointer; }
.day-pop-backdrop { position: fixed; inset: 0; z-index: 9600; display: flex; align-items: center; justify-content: center; background: transparent; }
.day-pop { background: #fff; border: 1px solid var(--card-border); border-radius: 16px;
  box-shadow: 0 22px 64px rgba(20, 30, 50, .34); padding: 16px 18px; width: min(360px, 82vw);
  max-height: 72vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.day-pop .dp-date { font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.day-pop .dp-session { display: flex; flex-direction: column; gap: 7px; }
.day-pop .dp-shead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.day-pop .dp-sport { font-size: 14.5px; font-weight: 800; color: var(--ink); }
.day-pop .dp-meta { font-size: 12.5px; font-weight: 600; color: var(--dim); text-transform: capitalize; }
.day-pop .dp-charts { display: flex; flex-direction: column; gap: 8px; }
.day-pop .dp-charts .kebab { height: 84px; }

/* V4 D5: a Month cell whose training clashes with a busy life event that day. */
.mcell.is-conflict { position: relative; outline: 2px solid #D63A6A; outline-offset: -2px; }
.mcell.is-conflict::after {
  content: "!"; position: absolute; top: 2px; right: 3px; z-index: 4;
  width: 13px; height: 13px; border-radius: 50%; background: #D63A6A; color: #fff;
  font-size: 10px; font-weight: 800; line-height: 13px; text-align: center;
}
