/* Desktop agenda rail. Mobile keeps its existing five-day overview. */
.schedule-rail-toggle {
  margin-left: auto;
}

.ops-actionbar:has(.schedule-rail-toggle) .ops-tools-menu {
  margin-left: 0;
}

.schedule-rail-toggle img,
.schedule-rail img {
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.schedule-rail[hidden],
.schedule-rail [hidden] {
  display: none !important;
}

.schedule-rail {
  --rail-muted: #64748b;
  --rail-title-size: 14px;
  --rail-body-size: 12px;
  --rail-meta-size: 11px;
  --rail-row-line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  width: 250px;
  min-width: 0;
  max-height: calc(100dvh - var(--app-header-height) - 100px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--heading);
  letter-spacing: 0;
}

.schedule-rail-agenda,
.schedule-rail-activity {
  flex-shrink: 0;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface, #fff);
}

.schedule-rail button {
  color: inherit;
  letter-spacing: 0;
}

.schedule-rail button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.schedule-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.schedule-rail-header > div {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px 6px;
  min-width: 0;
}

.schedule-rail-header h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--blue);
  font-size: var(--rail-title-size);
  font-weight: 800;
  line-height: 1.5;
}

.schedule-rail-header h2 img {
  display: none;
}

.schedule-rail-header small {
  color: var(--rail-muted);
  font-size: var(--rail-meta-size);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.schedule-rail-close,
.schedule-rail-add,
.schedule-rail-check {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.schedule-rail-close:hover,
.schedule-rail-add:hover,
.schedule-rail-check:hover {
  background: var(--surface-soft);
}

.schedule-rail-close {
  flex-basis: 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
}

.schedule-rail-close img,
.schedule-rail-add img {
  width: 14px;
  height: 14px;
  opacity: 0.65;
}

.schedule-rail-day {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.schedule-rail-day.is-today {
  border-top: 0;
  margin-top: 0;
}

.schedule-rail-day > header {
  display: flex;
  align-items: center;
  gap: 3px;
}

.schedule-rail-day-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.schedule-rail .schedule-rail-day-toggle b {
  flex: 1;
  min-width: 0;
  color: var(--rail-muted);
  font-size: var(--rail-body-size);
  font-weight: 600;
  line-height: var(--rail-row-line-height);
  font-variant-numeric: tabular-nums;
}

.schedule-rail-day-toggle b span {
  margin-left: 4px;
}

.schedule-rail-day.is-today .schedule-rail-day-toggle b {
  color: var(--blue);
}

.schedule-rail .schedule-rail-day-toggle small {
  color: var(--rail-muted);
  font-size: var(--rail-meta-size);
  white-space: nowrap;
}

.schedule-rail-day-toggle > img {
  width: 14px;
  height: 14px;
  transform: rotate(-90deg);
}

.schedule-rail-day[data-expanded="true"] .schedule-rail-day-toggle > img {
  transform: none;
}

.schedule-rail-day-preview {
  margin: 0;
  overflow: hidden;
  color: var(--rail-muted);
  font-size: var(--rail-body-size);
  line-height: var(--rail-row-line-height);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-rail-day[data-expanded="true"] .schedule-rail-day-preview {
  display: none;
}

.schedule-rail-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: start;
  gap: 6px;
  padding: 6px 3px 6px 0;
  border-bottom: 1px solid var(--line);
}

.schedule-rail-item + .schedule-rail-item {
  border-top: 0;
}

.schedule-rail-check,
.schedule-rail-linked {
  grid-column: 2;
  grid-row: 1;
  width: 28px;
  margin-top: 0;
}

.schedule-rail-linked {
  display: grid;
  height: 32px;
  place-items: center;
  opacity: 0.5;
}

.schedule-completion-control img,
.schedule-completion-status img {
  display: block;
  width: 20px;
  height: 20px;
}

.schedule-rail .schedule-completion-control img,
.schedule-rail .schedule-completion-status img {
  width: 16px;
  height: 16px;
  opacity: 0.65;
}

.schedule-rail .schedule-completion-control[aria-pressed="true"] img {
  opacity: 1;
}

.schedule-completion-control[aria-pressed="true"] {
  background: var(--green-soft);
}

.schedule-completion-control:disabled {
  cursor: progress;
  opacity: 0.5;
}

.schedule-completion-control:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.dashboard-schedule-summary-item {
  grid-template-columns: 32px auto minmax(0, 1fr);
}

.dashboard-schedule-summary-item > .schedule-completion-status {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
}

.dashboard-schedule-summary-item .schedule-completion-control {
  width: 32px;
  height: 32px;
}

.dashboard-schedule-summary-item > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.dashboard-schedule-summary-item.is-completed {
  background: #f3f5f7;
}

.dashboard-schedule-summary-item.is-completed strong {
  color: var(--muted-strong);
  text-decoration: line-through;
}

.schedule-rail-item-detail {
  display: grid;
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 4px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.schedule-rail-item-detail:hover strong {
  color: var(--blue);
}

.schedule-rail .schedule-rail-item-detail .schedule-rail-item-kind {
  align-self: start;
  padding-top: 0;
  color: var(--blue);
  font-size: var(--rail-body-size);
  font-weight: 700;
  line-height: var(--rail-row-line-height);
  white-space: nowrap;
}

.schedule-rail .schedule-rail-item-detail .schedule-rail-item-kind.sale {
  color: var(--green);
}

.schedule-rail .schedule-rail-item-detail strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--rail-muted);
  font-size: var(--rail-body-size);
  font-weight: 500;
  line-height: var(--rail-row-line-height);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-rail .schedule-rail-item-detail small {
  grid-column: 1 / -1;
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--heading);
  font-size: var(--rail-body-size);
  line-height: var(--rail-row-line-height);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-rail-item.is-completed {
  opacity: 0.65;
}

.schedule-rail-item.is-completed strong {
  text-decoration: line-through;
}

.schedule-rail-empty {
  margin: 8px 0;
  color: var(--rail-muted);
  font-size: 12px;
}

.schedule-rail-more,
.schedule-rail footer button {
  width: 100%;
  min-height: 32px;
  padding: 4px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.schedule-rail-more:hover,
.schedule-rail footer button:hover {
  background: var(--surface-soft);
}

.schedule-rail-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.schedule-rail-more img {
  width: 14px;
  height: 14px;
}

.schedule-rail-more[aria-expanded="true"] img {
  transform: rotate(180deg);
}

.schedule-rail-extra > .schedule-rail-item:first-child {
  border-top: 0;
}

.schedule-rail footer {
  padding: 4px 0;
}

.schedule-rail-days {
  max-height: min(300px, 30dvh);
  overflow-y: auto;
  scrollbar-width: thin;
  flex-shrink: 0;
}

.schedule-rail-activity > header {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.schedule-rail-activity > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.schedule-activity-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: baseline;
  gap: 6px;
}

.schedule-activity-title {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.schedule-activity-title small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-rail-activity h3 {
  margin: 0;
  color: var(--blue);
  font-size: var(--rail-title-size);
  line-height: 1.5;
}

.schedule-rail-activity header small,
.schedule-activity-title small,
.schedule-activity-heading time {
  color: var(--rail-muted);
  font-size: var(--rail-meta-size);
  line-height: 1.5;
}

.schedule-activity-list {
  max-height: min(240px, 28dvh);
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  list-style: none;
}

.schedule-activity-item {
  min-width: 0;
  padding: 6px 3px 6px 0;
  border-bottom: 1px solid var(--line);
}

.schedule-activity-heading b {
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  color: var(--blue);
  font-size: var(--rail-body-size);
  line-height: var(--rail-row-line-height);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-activity-heading time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.schedule-activity-item.create .schedule-activity-heading b { color: var(--green); }
.schedule-activity-item.delete .schedule-activity-heading b { color: var(--red); }

.schedule-activity-item p {
  margin: 3px 0 0;
  font-size: var(--rail-body-size);
  line-height: var(--rail-row-line-height);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 1200px) {
  .ops-dashboard:has(.ops-dashboard-shell[data-schedule-open="true"]) {
    width: min(100%, 1570px);
  }

  .ops-dashboard-shell[data-schedule-open="true"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    align-items: start;
    gap: 16px;
  }

  .schedule-rail {
    position: sticky;
    top: calc(var(--app-header-height) + 76px);
  }
}

@media (min-width: 721px) and (max-width: 1199px) {
  .ops-dashboard-shell[data-schedule-open="true"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .schedule-rail {
    position: static;
    grid-row: 1;
    width: 100%;
    max-height: min(500px, 75dvh);
  }

  .schedule-rail-days {
    max-height: min(170px, 24dvh);
  }

  .schedule-activity-list {
    max-height: min(160px, 22dvh);
  }
}

@media (max-width: 720px) {
  .schedule-rail,
  .schedule-rail-toggle { display: none; }
}
