/* Monthly plan tab — additive styles for public/month.js.
 * Every selector is prefixed .month- so nothing here touches the rest of the
 * app. Mobile-first: the grid is legible at 360px and grows from there.
 * Colours come from the theme variables in styles.css, with fallbacks so the
 * tab still looks sane if a theme omits them.
 */

.month-section {
  display: grid;
  gap: .85rem;
  margin: 1rem 0 2rem;
  min-width: 0;
}

/* ------------------------------------------------------------------ header */
.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  flex-wrap: wrap;
}

.month-header h2 {
  font-size: clamp(1.05rem, 4.4vw, 1.35rem);
  line-height: 1.2;
}

.month-nav {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-left: auto;
}

.month-nav button {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  min-width: 2.4rem;
  padding: .35rem .6rem;
  color: var(--text, #f1f5f9);
  background: var(--bg-card, #1e2430);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius-sm, 10px);
  font: inherit;
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease;
}

.month-nav button:hover {
  border-color: var(--accent, #5BCEFA);
}

.month-nav button:focus-visible {
  outline: 2px solid var(--accent, #5BCEFA);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ budget */
.month-budget {
  display: grid;
  gap: .6rem;
  min-width: 0;
}

.month-budget-card {
  display: grid;
  gap: .5rem;
  padding: .85rem .9rem;
  background: var(--bg-card, #1e2430);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius, 14px);
  min-width: 0;
}

.month-budget-figures {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}

.month-budget-used {
  font-size: clamp(1.35rem, 6vw, 1.85rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.month-budget-flag {
  padding: .1rem .5rem;
  border-radius: 999px;
  color: var(--danger, #e57373);
  background: rgba(229, 115, 115, .14);
  border: 1px solid rgba(229, 115, 115, .4);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.month-budget-track {
  position: relative;
  height: .5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}

.month-budget-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent, #5BCEFA), var(--partner, #F5A9B8));
  transition: width .35s ease;
}

.month-budget-card.is-over {
  border-color: rgba(229, 115, 115, .45);
}

.month-budget-card.is-over .month-budget-fill {
  background: linear-gradient(90deg, var(--danger, #e57373), var(--pride-orange, #FF8C00));
}

.month-budget-card.is-over .month-budget-remaining {
  color: var(--danger, #e57373);
  font-weight: 600;
}

.month-budget-meta {
  display: flex;
  justify-content: space-between;
  gap: .35rem .9rem;
  flex-wrap: wrap;
  color: var(--text-muted, #9aa7bd);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- week list */
.month-weeks {
  display: grid;
  gap: .35rem;
  min-width: 0;
}

.month-weeks-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted, #9aa7bd);
}

.month-weeks-list {
  display: grid;
  gap: .3rem;
}

.month-week {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: .5rem;
  padding: .35rem .55rem;
  background: var(--bg-elevated, #181c24);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius-sm, 10px);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.month-week-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-week-hours {
  color: var(--accent, #5BCEFA);
  font-weight: 700;
}

.month-week-days {
  color: var(--text-muted, #9aa7bd);
  font-size: .75rem;
  white-space: nowrap;
}

/* -------------------------------------------------------------------- grid */
.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  padding: 0 .1rem;
  color: var(--text-muted, #9aa7bd);
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: center;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}

.month-grid.is-loading {
  opacity: .55;
  transition: opacity .2s ease;
}

.month-cell {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  align-items: stretch;
  min-width: 0;
  min-height: 3.9rem;
  padding: .28rem .22rem;
  color: var(--text, #f1f5f9);
  background: var(--bg-elevated, #181c24);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: 8px;
  font: inherit;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.month-cell:hover {
  border-color: var(--accent, #5BCEFA);
}

.month-cell:focus-visible {
  outline: 2px solid var(--accent, #5BCEFA);
  outline-offset: 2px;
}

.month-cell-blank {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
  cursor: default;
}

.month-cell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .15rem;
  min-width: 0;
}

.month-cell-day {
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.month-cell-count {
  color: var(--text-muted, #9aa7bd);
  font-size: .6rem;
  font-weight: 600;
  line-height: 1;
}

.month-cell-hours {
  color: var(--accent, #5BCEFA);
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.month-cell-range {
  display: flex;
  flex-direction: column;
  gap: 0;
  color: var(--text-muted, #9aa7bd);
  font-size: .6rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.month-cell-dash {
  display: none;
}

.month-cell-time {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-cell-events {
  display: none;
  list-style: none;
  margin: .1rem 0 0;
  padding: 0;
  min-width: 0;
  color: var(--text-muted, #9aa7bd);
  font-size: .58rem;
  line-height: 1.25;
}

.month-cell-event {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-cell-more {
  color: var(--accent, #5BCEFA);
  font-weight: 600;
}

.month-cell-flag {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--text-muted, #9aa7bd);
  align-self: flex-end;
  margin-top: auto;
}

/* muted states: no worked block, weekends */
.month-cell.is-quiet {
  background: rgba(255, 255, 255, .015);
  border-color: rgba(91, 206, 250, .1);
}

.month-cell.is-quiet .month-cell-day {
  color: var(--text-muted, #9aa7bd);
  font-weight: 500;
}

.month-cell.is-weekend {
  background: rgba(255, 255, 255, .03);
}

.month-cell.is-weekend.is-quiet {
  background: rgba(255, 255, 255, .02);
}

/* today + selection */
.month-cell.is-today {
  border-color: var(--accent, #5BCEFA);
  box-shadow: inset 0 0 0 1px var(--accent, #5BCEFA);
}

.month-cell.is-today .month-cell-day {
  padding: 0 .28rem;
  border-radius: 999px;
  color: #0f1218;
  background: var(--accent, #5BCEFA);
  font-weight: 700;
}

.month-cell.is-selected {
  border-color: var(--partner, #F5A9B8);
  box-shadow: inset 0 0 0 2px var(--partner, #F5A9B8);
  background: var(--partner-soft, rgba(245, 169, 184, .18));
}

/* ------------------------------------------------------------------ detail */
.month-detail {
  display: grid;
  gap: .45rem;
  padding: .85rem .9rem;
  background: var(--bg-card, #1e2430);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius, 14px);
  min-width: 0;
}

.month-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem .75rem;
  flex-wrap: wrap;
}

.month-detail-head h3 {
  font-size: .95rem;
  line-height: 1.25;
}

.month-detail-block {
  color: var(--accent, #5BCEFA);
  font-size: .82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.month-detail-block.is-quiet {
  color: var(--text-muted, #9aa7bd);
  font-weight: 500;
}

.month-detail-note {
  color: var(--text-muted, #9aa7bd);
  font-size: .75rem;
}

.month-detail-events {
  display: grid;
  gap: .4rem;
  list-style: none;
  margin: .15rem 0 0;
  padding: 0;
}

.month-detail-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .05rem .6rem;
  padding: .4rem .55rem;
  background: var(--bg-elevated, #181c24);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius-sm, 10px);
  min-width: 0;
}

.month-detail-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: .86rem;
}

.month-detail-hours {
  color: var(--accent, #5BCEFA);
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.month-detail-time {
  grid-column: 1 / -1;
  color: var(--text-muted, #9aa7bd);
  font-size: .74rem;
  font-variant-numeric: tabular-nums;
}

.month-detail-empty {
  color: var(--text-muted, #9aa7bd);
  font-size: .82rem;
}

/* ------------------------------------------------------- status / messages */
.month-status {
  display: grid;
  gap: .35rem;
  justify-items: start;
  padding: .85rem .9rem;
  background: var(--bg-card, #1e2430);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius, 14px);
  color: var(--text-muted, #9aa7bd);
  font-size: .85rem;
}

.month-status strong {
  color: var(--text, #f1f5f9);
  font-size: .92rem;
}

.month-status-error {
  border-color: rgba(229, 115, 115, .45);
}

.month-retry {
  appearance: none;
  -webkit-appearance: none;
  padding: .35rem .75rem;
  color: var(--text, #f1f5f9);
  background: var(--bg-elevated, #181c24);
  border: 1px solid var(--border, rgba(91, 206, 250, .2));
  border-radius: var(--radius-sm, 10px);
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}

.month-retry:hover {
  border-color: var(--accent, #5BCEFA);
}

.month-retry:focus-visible {
  outline: 2px solid var(--accent, #5BCEFA);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- wide view */
@media (min-width: 560px) {
  .month-section {
    gap: 1rem;
  }

  .month-weekdays {
    gap: 5px;
    font-size: .68rem;
  }

  .month-grid {
    gap: 5px;
  }

  .month-cell {
    min-height: 5.4rem;
    padding: .4rem .35rem;
    gap: .15rem;
  }

  .month-cell-day {
    font-size: .85rem;
  }

  .month-cell-count {
    display: none;
  }

  .month-cell-hours {
    font-size: .8rem;
  }

  .month-cell-range {
    flex-direction: row;
    gap: .15rem;
    font-size: .68rem;
    white-space: nowrap;
  }

  .month-cell-dash {
    display: inline;
  }

  .month-cell-events {
    display: grid;
    font-size: .64rem;
  }

  .month-budget-card {
    padding: 1rem 1.1rem;
  }

  .month-week {
    font-size: .85rem;
  }

  .month-detail {
    padding: 1rem 1.1rem;
  }
}

@media (min-width: 900px) {
  .month-cell {
    min-height: 6.2rem;
  }

  .month-cell-events {
    font-size: .7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .month-budget-fill,
  .month-cell,
  .month-nav button,
  .month-grid.is-loading {
    transition: none;
  }
}
/* Stub day: bookend events only, excluded from hours. */
.month-cell.is-stub { opacity: .65; }
.month-cell-stub {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 .35rem;
}
