/* Money Planning — aligné sur le design system Workers (light + dark).
   Toutes les couleurs viennent des tokens globaux (style.css).
   Full-bleed sur mobile, centré et max-width sur desktop. */

main.app-content:has(.wg-planning) {
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
}

.wg-planning {
  --wg-radius: var(--r-lg);
  --wg-radius-md: var(--r-md);

  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: 16px var(--gutter) calc(var(--save-h, 4.5rem) + 24px);
  width: 100%;
  max-width: var(--site-width-md);
  margin: 0 auto;
  font-family: var(--font);
}
.wg-planning * { box-sizing: border-box; }

/* Header */
.wg-planning__head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 14px;
}
.wg-planning__title {
  font-family: var(--display);
  font-size: clamp(22px, 6.4vw, 26px); font-weight: 700; margin: 0;
  letter-spacing: -0.02em; color: var(--text);
}
.wg-planning__more {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border-c);
  color: var(--text); font-size: 20px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--e1);
}
.wg-planning__more-wrap { position: relative; }
.wg-planning__menu {
  position: absolute; right: 0; top: 42px; z-index: var(--z-popover);
  background: var(--surface); border: 1px solid var(--border-c);
  border-radius: var(--r-md); padding: 6px; min-width: 180px;
  box-shadow: var(--e2);
}
.wg-planning__menu button {
  width: 100%; text-align: left; padding: 10px 12px; border: 0;
  background: transparent; color: var(--text); font-size: 14px;
  border-radius: 8px; cursor: pointer; font-family: var(--font);
}
.wg-planning__menu button:hover { background: var(--surface-2); }
.wg-planning__menu button.danger { color: var(--danger); }

/* Stat bar */
.wg-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px;
  margin-bottom: 14px;
}
.wg-stat {
  background: var(--surface); border: 1px solid var(--border-c);
  border-radius: var(--wg-radius); padding: 14px 10px; text-align: center;
  color: var(--text);
  box-shadow: var(--e1);
}
.wg-stat__value {
  font-family: var(--display);
  font-size: clamp(18px, 5vw, 22px); font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.wg-stat__label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-2); margin-top: 4px;
}
.wg-stat--money .wg-stat__value { color: var(--money-ink); }
.wg-stat--opp   .wg-stat__value {
  color: var(--opp);
  /* Hypothetical money must not weigh as much as confirmed money. */
  font-size: clamp(15px, 4.2vw, 18px);
  font-weight: 700;
}
.wg-stat__label { display: inline-flex; align-items: center; gap: 4px; justify-content: center; }
.wg-stat__help {
  position: relative; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--border-c); background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer; padding: 0;
  display: inline-grid; place-items: center; font-family: var(--font);
}
.wg-stat__help::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}
.wg-stats__period {
  font-size: 12px; font-weight: 700; text-transform: capitalize;
  color: var(--text-3); margin: 0 0 6px 2px;
}

/* Typical-week button */
.wg-typical-btn {
  width: 100%; margin-bottom: 12px; border: 1px solid var(--primary);
  background: var(--primary-tint);
  color: var(--primary-ink); border-radius: var(--wg-radius); padding: 13px 14px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s ease;
}
.wg-typical-btn:hover { background: var(--surface-2); }

/* Calendar */
.wg-cal {
  background: var(--surface); border: 1px solid var(--border-c);
  border-radius: var(--wg-radius); padding: 16px 14px; margin-bottom: 14px;
  box-shadow: var(--e1);
}
.wg-cal__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.wg-cal__title {
  font-size: 16px; font-weight: 700; text-transform: capitalize;
  color: var(--text); font-family: var(--font);
}
.wg-cal__nav { display: flex; gap: 6px; }
.wg-cal__arrow {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border-c);
  color: var(--text); cursor: pointer; font-size: 14px; padding: 0;
  display: grid; place-items: center;
}
.wg-cal__arrow:hover { background: var(--surface-3); }
.wg-cal__arrow:disabled { opacity: 0.35; cursor: not-allowed; }

.wg-cal__legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 12px; color: var(--text-2); margin-bottom: 12px;
}
.wg-cal__legend span { display: inline-flex; align-items: center; gap: 5px; }
.wg-cal__legend i {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.wg-cal__legend .l-avail { background: var(--primary); }
.wg-cal__legend .l-shift { background: var(--money); }

.wg-cal__wd {
  display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-3); text-align: center; margin-bottom: 4px;
  letter-spacing: 0.06em;
}
.wg-cal__grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
  user-select: none;
}
.wg-cal__cell {
  aspect-ratio: 1; border: 0; background: transparent; color: var(--text);
  border-radius: 10px; cursor: pointer; padding: 0; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: inherit; font-size: 13px; min-height: 40px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.wg-cal__cell:disabled { color: var(--text-3); opacity: 0.4; cursor: not-allowed; }
.wg-cal__cell.past { color: var(--text-2); opacity: 0.85; }
.wg-cal__cell.today { outline: 1.5px solid var(--primary); outline-offset: -1.5px; }
.wg-cal__cell.has-avail {
  background: var(--primary-tint); color: var(--primary-ink); font-weight: 700;
}
.wg-cal__cell.has-shift {
  background: var(--money-tint); color: var(--money-ink); font-weight: 700;
}
.wg-cal__cell.has-shift.has-avail {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.wg-cal__cell.selected {
  background: var(--primary); color: #fff; font-weight: 700;
}
.wg-cal__cell.dim { opacity: 0.45; }
.wg-cal__cell .amt {
  font-size: 11px; line-height: 1; font-weight: 700; color: var(--money-ink);
  margin-top: 2px;
}
.wg-cal__cell.selected .amt { color: #fff; }
.wg-cal__dots {
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px;
}
.wg-cal__dots i { width: 5px; height: 5px; border-radius: 50%; }
.wg-cal__dots i.d-avail { background: var(--primary); }
.wg-cal__dots i.d-shift { background: var(--money); }
.wg-cal__dots i.d-opp   { background: var(--opp-solid); }

/* Tabs */
.wg-tabs {
  display: flex; gap: 4px; background: var(--surface); padding: 4px;
  border-radius: var(--r-md); border: 1px solid var(--border-c); margin-bottom: 12px;
  box-shadow: var(--e1);
}
.wg-tabs button {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text-2);
  white-space: nowrap; overflow: hidden;
  padding: 9px 6px; font-size: 12px; font-weight: 700; border-radius: 10px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--font);
  transition: background 0.15s ease, color 0.15s ease;
}
.wg-tabs button:hover { color: var(--text); }
.wg-tabs button.is-active { background: var(--primary); color: #fff; }
.wg-tab-label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wg-tab-count {
  flex: 0 0 auto; font-size: 12px; background: rgba(255,255,255,0.22); padding: 1px 6px; border-radius: 999px;
  color: inherit;
}
.wg-tabs button:not(.is-active) .wg-tab-label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wg-tab-count {
  background: var(--surface-3); color: var(--text-2);
}

/* Panels */
.wg-panel {
  background: var(--surface); border: 1px solid var(--border-c);
  border-radius: var(--wg-radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--e1);
}
.wg-empty {
  text-align: center; padding: 24px 12px; color: var(--text-2); font-size: 13px;
}
.wg-empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

.wg-day-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border-c);
}
.wg-day-row:last-child { border-bottom: 0; }
.wg-day-row__label { font-size: 13px; font-weight: 700; text-transform: capitalize; color: var(--text); }
.wg-day-row__slots { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.wg-day-row__edit {
  border: 1px solid var(--border-c); background: transparent; color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
}
.wg-day-row__edit:hover { background: var(--surface-2); }
.wg-day-row-wrap { border-bottom: 1px solid var(--border-c); }
.wg-day-row-wrap:last-child { border-bottom: 0; }
.wg-day-row-wrap .wg-day-row { border-bottom: 0; }
.wg-day-row__toggle {
  flex: 1; min-width: 0; text-align: left; border: 0; background: transparent;
  padding: 0; cursor: pointer; font-family: var(--font); color: var(--text);
}

/* Selection action bar under the calendar */
.wg-selbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-c);
}
.wg-selbar__count { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--text); }
.wg-selbar__cta {
  border: 0; border-radius: 999px; background: var(--grad); color: #fff;
  padding: 10px 16px; font-size: 13px; font-weight: 800; cursor: pointer;
  font-family: var(--font); min-height: 44px;
}

.wg-shift-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 0; border-bottom: 1px solid var(--border-c);
  border-left: 0; border-right: 0; border-top: 0;
  background: transparent; color: var(--text); text-align: left;
  font-family: var(--font); cursor: pointer; min-height: 44px;
}
.wg-shift-row:hover { background: var(--surface-2); }
.wg-shift-row:last-child { border-bottom: 0; }
.wg-shift-row__logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center; font-weight: 800; color: var(--text);
  font-size: 14px; flex-shrink: 0;
}
.wg-shift-row__body { flex: 1; min-width: 0; }
.wg-shift-row__title { font-size: 14px; font-weight: 700; color: var(--text); }
.wg-shift-row__meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.wg-shift-row__amt {
  color: var(--money-ink); font-weight: 800; font-size: 15px;
  font-family: var(--display); font-variant-numeric: tabular-nums;
}

.wg-opp-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border-c);
}
.wg-opp-row:last-child { border-bottom: 0; }
.wg-opp-row__body { flex: 1; min-width: 0; }
.wg-opp-row__title { font-size: 14px; font-weight: 700; color: var(--text); }
.wg-opp-row__meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.wg-opp-row__gain {
  color: var(--opp); font-weight: 800; font-size: 14px; margin-top: 4px;
  font-family: var(--display); font-variant-numeric: tabular-nums;
}
.wg-opp-row__cta {
  background: var(--opp-solid); color: #1a1000; border: 0;
  padding: 9px 14px; border-radius: 999px; font-size: 12px; font-weight: 800; cursor: pointer;
  font-family: var(--font);
}
.wg-opp-row__cta:hover { filter: brightness(1.05); }

/* Day-slot editor inside "Mes dispos" tab */
.wg-slot-editor { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.wg-slot-editor__row { display: flex; align-items: center; gap: 6px; }
.wg-slot-editor__row input[type="time"] {
  background: var(--surface-2); border: 1px solid var(--border-c);
  color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 16px;
  font-family: var(--font);
}
.wg-slot-editor__row .x {
  border: 0; background: transparent; color: var(--danger); cursor: pointer;
  font-size: 16px; margin-left: auto;
}
.wg-slot-editor__empty { font-size: 12px; color: var(--text-2); }
.wg-slot-editor__row .x { min-width: 44px; min-height: 44px; }
.wg-slot-editor__add {
  align-self: flex-start; border: 1px dashed var(--primary);
  background: transparent; color: var(--primary-ink); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
}

/* Save bar */
.wg-save {
  position: fixed; bottom: calc(var(--bottomnav-h) + 12px);
  left: 50%; transform: translateX(-50%);
  z-index: var(--z-actionbar);
  width: min(100% - (2 * var(--gutter)), calc(var(--site-width-md) - (2 * var(--gutter))));
  border: 0; border-radius: var(--wg-radius);
  background: var(--grad);
  color: #fff; padding: 14px 16px; cursor: pointer;
  box-shadow: var(--glow);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--font);
  transition: transform 0.15s ease;
}
.wg-save:active { transform: translateX(-50%) scale(0.99); }
.wg-save__main { font-size: 15px; font-weight: 800; }
.wg-save__sub  { font-size: 12px; font-weight: 500; opacity: 0.9; }
.wg-save:disabled { opacity: 0.5; cursor: not-allowed; }
/* Nothing to save: neutral surface, no gradient, no glow. */
.wg-save.is-clean {
  background: var(--surface-2);
  color: var(--text-2);
  box-shadow: none;
  border: 1px solid var(--border-c);
  opacity: 1;
}

/* Load failure inside the panel */
.wg-loaderr { padding: 18px 12px; text-align: center; }
.wg-loaderr strong {
  display: block; color: var(--text); font-size: 14px; font-weight: 700; margin-bottom: 10px;
}
.wg-loaderr__retry {
  border: 1px solid var(--border-c); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 10px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--font); min-height: 44px;
}



/* Typical-week modal */
.wg-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: var(--z-sheet);
  padding: 12px; backdrop-filter: blur(4px);
}
.wg-modal__card {
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-c);
  border-radius: var(--r-xl) var(--r-xl) var(--r-md) var(--r-md);
  padding: 20px 18px; color: var(--text);
  box-shadow: var(--e2);
}
.wg-modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.wg-modal__title {
  font-size: 18px; font-weight: 700; font-family: var(--display); color: var(--text);
}
.wg-modal__close {
  border: 0; background: transparent; color: var(--text-2);
  font-size: 24px; cursor: pointer; line-height: 1;
}
.wg-modal__hint { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.wg-modal__day { border-top: 1px solid var(--border-c); padding: 12px 0; }
.wg-modal__day-label { font-size: 13px; font-weight: 700; text-transform: capitalize; margin-bottom: 8px; color: var(--text); }
.wg-modal__quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.wg-modal__quick button {
  border: 1px solid var(--border-c); background: var(--surface-2);
  color: var(--text); border-radius: 999px; padding: 6px 12px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
}
.wg-modal__quick button:hover { border-color: var(--border-strong); }
.wg-modal__quick button.on {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.wg-modal__apply {
  width: 100%; margin-top: 14px; border: 0; border-radius: var(--r-md);
  background: var(--grad); color: #fff; padding: 13px;
  font-size: 14px; font-weight: 800; cursor: pointer;
  font-family: var(--font);
  box-shadow: var(--glow);
}
.wg-modal__apply:disabled { opacity: 0.5; cursor: not-allowed; }
.wg-modal__warn { color: var(--text-2); font-size: 12px; margin: 12px 0 0; }
.wg-modal__count { color: var(--text-2); font-size: 12px; margin: 8px 0 0; text-align: center; }

/* Typical-week sheet: scrollable body + anchored footer */
.wg-modal__card--typ { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 12px; }
.wg-modal__card--typ .wg-modal__scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; }
.wg-modal__foot {
  flex: 0 0 auto; padding-top: 10px; margin-top: 4px;
  border-top: 1px solid var(--border-c); background: var(--surface);
}
.wg-modal__foot .wg-modal__apply { margin-top: 8px; }
.wg-modal__foot .wg-modal__warn { margin: 8px 0 0; }

.wg-typ-slots { display: flex; gap: 8px; margin-bottom: 12px; }
.wg-typ-slot {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border-c); background: var(--surface-2); color: var(--text);
  border-radius: var(--r-md); padding: 10px 8px; cursor: pointer;
  font-family: var(--font); text-align: left; position: relative;
}
.wg-typ-slot::after { content: ''; position: absolute; inset: -6px; }
.wg-typ-slot__name { font-size: 13px; font-weight: 800; }
.wg-typ-slot__hours { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.wg-typ-slot.on { border-color: var(--primary); background: var(--primary-soft, var(--surface-2)); }
.wg-typ-slot.on .wg-typ-slot__name { color: var(--primary); }

.wg-typ-shortcuts { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.wg-typ-shortcuts button {
  flex: 1 1 auto; min-width: 0; min-height: 44px;
  border: 1px solid var(--border-c); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wg-typ-shortcuts .wg-typ-clear { color: var(--text-2); }

.wg-typ-day {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--border-c); background: var(--surface-2); color: var(--text);
  border-radius: var(--r-md); cursor: pointer; font-family: var(--font); text-align: left;
}
.wg-typ-day.on { border-color: var(--primary); }
.wg-typ-day__label { font-size: 13px; font-weight: 700; text-transform: capitalize; min-width: 0; }
.wg-typ-day__slots {
  font-size: 12px; color: var(--text-2); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}

.wg-typ-mode { display: flex; gap: 8px; }
.wg-typ-mode button {
  flex: 1 1 0; min-width: 0; min-height: 44px;
  border: 1px solid var(--border-c); background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 8px 10px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
  line-height: 1.2; text-align: center;
}
.wg-typ-mode button.on { border-color: var(--primary); color: var(--primary); }



/* Confirm dialog */
.wg-confirm {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: var(--z-sheet);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(4px);
}
.wg-confirm__card {
  background: var(--surface); border: 1px solid var(--border-c);
  border-radius: var(--r-lg); padding: 22px; max-width: 340px; width: 100%;
  text-align: center; box-shadow: var(--e2);
}
.wg-confirm__card p { margin: 0 0 16px; color: var(--text); }
.wg-confirm__actions { display: flex; gap: 8px; }
.wg-confirm__actions button {
  flex: 1; padding: 11px; border-radius: var(--r-md); font-weight: 700;
  cursor: pointer; border: 0; font-family: var(--font);
}
.wg-confirm__cancel { background: var(--surface-2); color: var(--text); }
.wg-confirm__cancel:hover { background: var(--surface-3); }
.wg-confirm__ok { background: var(--danger); color: #fff; }
.wg-confirm__ok:hover { filter: brightness(0.95); }

/* ---- Post-save transition (reuses .wg-mcel from mission.css) ---- */
.wg-mcel__card--plain { padding-top: 1.4rem; }

/* ---- Empty state action ---- */
.wg-empty__cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; min-height: 44px; padding: 10px 16px;
  border: 1px solid var(--primary); background: transparent; color: var(--primary);
  border-radius: 999px; font-size: 13px; font-weight: 800;
  font-family: var(--font); cursor: pointer;
}

/* ---- Calendar highlight after "pick my first days" ---- */
.wg-cal.is-highlight { box-shadow: 0 0 0 2px var(--primary) inset; }
@media (prefers-reduced-motion: no-preference) {
  .wg-cal { transition: box-shadow 0.25s ease; }
}

/* ---- Loading skeleton: same blocks, same sizes, no page jump ---- */
.wg-skel {
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-c);
}
@media (prefers-reduced-motion: no-preference) {
  .wg-skel { animation: wg-skel-pulse 1.2s ease-in-out infinite; }
}
@keyframes wg-skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.wg-skel--period { height: 14px; width: 120px; margin: 0 0 8px; border: 0; }
.wg-skel--stat { height: 72px; }
.wg-skel--cta { height: 46px; margin: 12px 0; border-radius: 999px; }
.wg-skel--cal { height: 300px; margin-bottom: 14px; }
.wg-skel--tabs { height: 44px; border-radius: 999px; margin-bottom: 12px; }
.wg-skel--panel { height: 220px; }
