/* Schedule (S16): the Day timeline, the Week board and the Month calendar, laid out like iOS Calendar.
   Tokens only. Chips and bars set --job (the job colour); Day tracks set --hours and --lanes; bars set --lane.
   Phones and iPad portrait get the week strip and the day's agenda instead of the board; phones also
   get the agenda instead of the Day timeline. */
.sched-small { font-size: var(--fs-xs); line-height: var(--lh-xs); }

/* ---- the header: Day · Week · Month, the period stepper, the filter pills ---- */
.sched-views.segmented { max-width: 420px; margin: 0 0 var(--s3); }
.sched-nav { display: flex; align-items: center; gap: var(--s1); margin: 0 0 var(--s2); }
.sched-label { flex: 1; min-width: 0; margin: 0; font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-step-btn {
  flex: none; order: 2; display: grid; place-items: center; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%;
  background: transparent; color: var(--accent); cursor: pointer;
}
.sched-step-btn:first-child { order: 1; }
.sched-label { order: 0; }
.sched-step-btn:active { opacity: .55; }
@media (hover: hover) { .sched-step-btn:hover { background: var(--fill); } }
.sched-step-btn:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: -2px; }
.sched-filters { margin-bottom: var(--s4); }
.sched-dot { margin: 0 9px; background: var(--job, var(--tile-gray)); }
.sched-tip { margin: var(--s3) var(--s4) 0; }

/* drag to move */
.sched-draggable { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
@media (hover: hover) { .sched-draggable { cursor: grab; } }
.sched-dragging-src { opacity: .35; }
.sched-drop-on { outline: 2px dashed var(--accent-fill); outline-offset: -3px; background: var(--accent-soft) !important; }
body.sched-dragging, body.sched-dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }

/* ---- event chips (Week board): a tinted block with the job colour down the left, like a calendar event ---- */
.sched-chip {
  font: inherit; display: flex; flex-direction: column; gap: 1px; width: 100%; min-height: 44px; text-align: left;
  padding: 5px 8px 5px 9px; border: 0; border-radius: 6px; box-shadow: inset 3px 0 0 var(--job, var(--tile-gray));
  background: color-mix(in srgb, var(--job, var(--tile-gray)) 14%, var(--surface)); color: var(--text);
  font-size: var(--fs-xs); line-height: var(--lh-xs); cursor: pointer;
}
.sched-chip:focus-visible, .sched-bar:focus-visible, .sched-mday:focus-visible, .sched-board-day:focus-visible, .sched-strip-day:focus-visible, .sched-cell:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 1px; }
.sched-chip-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sched-chip-num { font-weight: 700; flex: none; }
.sched-chip-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.sched-chip-time { display: flex; justify-content: space-between; gap: 6px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sched-chip-hrs { font-weight: 600; color: var(--text); }
.sched-hold { display: inline-flex; flex: none; color: var(--danger); }
.sched-chips { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

.sched-person { display: flex; align-items: center; gap: var(--s2); padding: 10px var(--s3); min-width: 0; }
.sched-person-text { min-width: 0; }
.sched-person-name { font-weight: 600; font-size: var(--fs-subhead); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Week board (iPad and desktop): an inset group, hairlines only ---- */
.sched-board { background: var(--surface); border-radius: var(--r-group); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sched-board-head, .sched-board-row { display: grid; grid-template-columns: 150px repeat(7, minmax(112px, 1fr)) 76px; min-width: 1010px; }
.sched-board-head > * {
  font: inherit; padding: 8px 10px; border: 0; border-bottom: .5px solid var(--separator); background: var(--surface);
  font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--text-muted); font-weight: 600; text-align: left;
}
.sched-board-corner { position: sticky; left: 0; z-index: 2; display: flex; align-items: flex-end; }
.sched-board-day { display: flex; flex-direction: column; align-items: flex-start; gap: 0; cursor: pointer; border-left: .5px solid var(--separator) !important; text-transform: uppercase; letter-spacing: .02em; }
.sched-board-day > .sched-small { text-transform: none; letter-spacing: 0; }
@media (hover: hover) { .sched-board-day:hover { background: var(--surface-2); } }
.sched-board-day strong { color: var(--text); font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 600; display: inline-grid; place-items: center; min-width: 32px; height: 32px; margin-left: -4px; padding: 0 4px; border-radius: var(--r-pill); }
.sched-board-day.today { color: var(--accent); }
.sched-board-day.today strong { background: var(--accent-fill); color: var(--on-accent); }
.sched-board-row > * { border-bottom: .5px solid var(--separator); border-left: .5px solid var(--separator); }
.sched-board-row > .sched-person { border-left: 0; position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: .5px 0 0 var(--separator); }
.sched-board-row:last-child > * { border-bottom: 0; }
.sched-cell { min-height: 76px; padding: 6px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.sched-cell.today { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.sched-cell.editable { cursor: pointer; }
@media (hover: hover) { .sched-cell.editable:hover { background: var(--surface-2); } }
.sched-cell-add { margin: auto; color: var(--text-muted); opacity: 0; transition: opacity var(--t-fast); display: inline-flex; }
.sched-chip ~ .sched-cell-add { margin: 0 auto; }
.sched-cell:hover .sched-cell-add, .sched-cell:focus-visible .sched-cell-add { opacity: 1; }
@media (hover: none) { .sched-cell .sched-cell-add { opacity: .5; } }
.sched-board-total { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; padding: 6px; font-size: var(--fs-subhead); }
.sched-board-head > .sched-board-total { justify-content: flex-end; font-size: var(--fs-footnote); }
.sched-board-total.over { color: var(--danger); }
.sched-board-total .muted { color: var(--text-muted); font-weight: 500; }

/* ---- phones: week strip + agenda ---- */
.sched-daylist { display: none; }
/* The week board needs about 1000px: phones and iPad portrait get the strip and one day instead.
   The Day timeline scrolls on its own, so it stays down to 761px. */
@media (max-width: 1023px) {
  .sched-board { display: none; }
  .sched-daylist.is-week { display: block; }
}
@media (max-width: 760px) {
  .sched-day { display: none; }
  .sched-daylist.is-day { display: block; }
  .sched-views.segmented { max-width: none; }
}
.sched-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; margin: 0 0 var(--s4); padding: var(--s1) 2px; border-radius: var(--r-group); background: var(--surface); }
.sched-strip-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; min-height: 64px; padding: 6px 0 4px;
  border: 0; border-radius: var(--r-md); background: none; color: var(--text); font: inherit; cursor: pointer;
}
.sched-strip-wd { font-size: 11px; line-height: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.sched-strip-num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: var(--fs-body); font-weight: 600; font-variant-numeric: tabular-nums; }
.sched-strip-day.today .sched-strip-num, .sched-strip-day.today .sched-strip-wd { color: var(--accent); }
.sched-strip-day[aria-selected="true"] .sched-strip-num { background: var(--text); color: var(--surface); }
.sched-strip-day.today[aria-selected="true"] .sched-strip-num { background: var(--accent-fill); color: var(--on-accent); }
.sched-strip-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.sched-strip-dot.on { background: var(--text-muted); }
.sched-strip-day:active .sched-strip-num { background: var(--fill-strong); }

.sched-agenda .ios-group-header { margin-left: var(--s2); min-height: 32px; align-items: center; }
.sched-agenda .ios-group-header h2 { text-transform: none; letter-spacing: 0; font-size: var(--fs-subhead); color: var(--text); }
.sched-free .ios-group-header h2 { color: var(--text-muted); }
.sched-agenda-head { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.sched-agenda-head .avatar { width: 26px; height: 26px; font-size: 10px; }
.sched-agenda-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.sched-agenda-hrs { flex: none; margin-left: auto; color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.sched-agenda-add { flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); margin: -8px -8px -8px 0; border: 0; border-radius: 50%; background: none; color: var(--accent); cursor: pointer; }
.sched-agenda-add:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: -4px; }
.sched-evbar { flex: none; align-self: stretch; width: 4px; margin: 8px 0; border-radius: 2px; background: var(--job, var(--tile-gray)); }
.sched-agenda .ios-row-value { font-size: var(--fs-subhead); font-weight: 600; color: var(--text); }
.sched-agenda .avatar { width: 30px; height: 30px; font-size: 11px; }
.sched-free-add { display: grid; color: var(--accent); margin-right: var(--s1); }
.sched-agenda-empty { margin: 0 0 var(--s4); border-radius: var(--r-group); background: var(--surface); }

/* ---- Day timeline (iPad and desktop) ---- */
.sched-day { background: var(--surface); border-radius: var(--r-group); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sched-day-head, .sched-day-row { display: grid; grid-template-columns: 160px 1fr; width: max-content; min-width: 100%; }
.sched-day-head > *, .sched-day-row > * { border-bottom: .5px solid var(--separator); }
.sched-day-row:last-child > * { border-bottom: 0; }
.sched-day-corner {
  position: sticky; left: 0; z-index: 3; display: flex; align-items: center; padding: 0 var(--s3); background: var(--surface);
  font-size: var(--fs-footnote); font-weight: 600; color: var(--text-muted); box-shadow: .5px 0 0 var(--separator);
}
.sched-day-row > .sched-person { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: .5px 0 0 var(--separator); }
.sched-track {
  position: relative; min-width: calc(var(--hours, 12) * 60px); height: calc(var(--lanes, 1) * 52px + 8px);
  background-image: repeating-linear-gradient(to right, var(--separator) 0 .5px, transparent .5px calc(100% / var(--hours, 12)));
}
.sched-track.editable { cursor: pointer; }
@media (hover: hover) { .sched-track.editable:hover { background-color: var(--surface-2); } }
.sched-axis { height: 34px; background-color: var(--surface); }
.sched-hour { position: absolute; top: 9px; padding-left: 4px; font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sched-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); pointer-events: none; z-index: 3; }
.sched-axis .sched-now::before { content: ""; position: absolute; top: 0; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.sched-bar {
  font: inherit; position: absolute; top: calc(var(--lane, 0) * 52px + 4px); height: 48px; min-width: 28px;
  display: flex; flex-wrap: wrap; align-content: center; column-gap: 6px; padding: 2px 8px 2px 10px; overflow: hidden; text-align: left;
  border: 0; border-radius: 6px; box-shadow: inset 3px 0 0 var(--job, var(--tile-gray));
  background: color-mix(in srgb, var(--job, var(--tile-gray)) 16%, var(--surface)); color: var(--text);
  font-size: var(--fs-xs); line-height: var(--lh-xs); cursor: pointer; z-index: 2;
}
.sched-bar-num { font-weight: 700; flex: none; }
.sched-bar-title { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.sched-bar-time { flex-basis: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-variant-numeric: tabular-nums; }
.sched-bar.carried { border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: inset 3px 0 0 color-mix(in srgb, var(--job, var(--tile-gray)) 50%, transparent); opacity: .85; }
.sched-bar.continues { border-top-right-radius: 0; border-bottom-right-radius: 0; box-shadow: inset 3px 0 0 var(--job, var(--tile-gray)), inset -3px 0 0 color-mix(in srgb, var(--job, var(--tile-gray)) 50%, transparent); }

/* ---- Month calendar: day numbers on hairlines, today in a filled circle ---- */
.sched-month { background: var(--surface); border-radius: var(--r-group); overflow: hidden; }
.sched-month-head, .sched-month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.sched-month-head > div { padding: 8px; font-size: var(--fs-footnote); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em; border-bottom: .5px solid var(--separator); }
.sched-mday {
  font: inherit; display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; min-height: 104px; padding: 6px;
  border: 0; border-bottom: .5px solid var(--separator); background: var(--surface); color: var(--text);
  text-align: left; cursor: pointer;
}
.sched-month-row:last-child > .sched-mday { border-bottom: 0; }
@media (hover: hover) { .sched-mday:hover { background: var(--surface-2); } }
.sched-mday:active { background: var(--fill); }
.sched-mday.out { color: var(--text-muted); }
.sched-mday.out .sched-mjob { opacity: .6; }
.sched-mday-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sched-mday-num { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: var(--r-pill); font-weight: 600; font-variant-numeric: tabular-nums; }
.sched-mday.today .sched-mday-num { background: var(--accent-fill); color: var(--on-accent); }
.sched-mday-crew { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sched-mday-jobs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sched-mjob {
  display: flex; align-items: center; gap: 4px; min-width: 0; padding: 1px 5px; border-radius: 4px;
  background: color-mix(in srgb, var(--job, var(--tile-gray)) 14%, transparent); font-size: var(--fs-xs); line-height: var(--lh-xs);
}
.sched-mjob-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--job, var(--tile-gray)); flex: none; }
.sched-mjob-num { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sched-mjob-n { margin-left: auto; flex: none; color: var(--text-muted); }
.sched-mjob-more { font-size: var(--fs-xs); color: var(--text-muted); }
@media (max-width: 760px) {
  .sched-month-head > div { padding: 6px 2px; text-align: center; font-size: 11px; }
  .sched-mday { min-height: 60px; padding: 6px 2px; align-items: center; }
  .sched-mday-top { flex-direction: column; }
  .sched-mday-crew { display: none; }
  .sched-mday-jobs { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .sched-mjob { padding: 0; background: none; }
  .sched-mjob-num, .sched-mjob-n, .sched-mjob-more { display: none; }
  .sched-mjob-dot { width: 6px; height: 6px; }
}

/* the assignment form's live hours */
.sched-hours-value { display: flex; align-items: center; min-height: 40px; font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.sched-hours-value.bad { color: var(--danger); }
.sched-hours .hint.warn { color: var(--warning); font-weight: 600; }

/* the chip or bar following the finger; last so it beats .sched-bar's absolute position */
.sched-ghost { position: fixed; z-index: 1000; margin: 0; pointer-events: none; opacity: .95; box-shadow: var(--shadow-pop); }
.ios-row.sched-ghost { border-radius: var(--r-md); }
@media print {
  .sched-filters, .sched-tip, .sched-nav .sched-step-btn, .sched-views, .sched-cell-add, .sched-agenda-add { display: none; }
}
