.calendar-week table {
  min-width: 1320px;
}

.calendar-switcher {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
  padding: 16px 20px;
}

.calendar-switcher .eyebrow {
  margin-bottom: 3px;
}

.calendar-switches,
.calendar-directory-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.calendar-switches form,
.calendar-directory-actions form,
.inline-actions form,
.calendar-source form {
  margin: 0;
}

.calendar-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.calendar-switch i,
.calendar-directory-heading > i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--calendar-color);
  flex: 0 0 auto;
}

.calendar-switch span {
  color: var(--green);
  font-size: 10px;
}

.calendar-switch.inactive {
  opacity: .5;
  background: #f1f3f2;
}

.week-picker-wrap {
  position: relative;
}

.week-picker-trigger {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 5px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.week-picker-trigger:hover,
.week-picker-trigger[aria-expanded="true"] {
  background: var(--sage);
}

.week-picker-trigger:focus-visible {
  outline: 3px solid rgba(49, 92, 79, .2);
}

.week-picker-trigger .eyebrow {
  margin-bottom: 3px;
}

.week-range {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.01em;
}

.week-picker-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 30;
  width: 366px;
  padding: 15px;
  border: 1px solid rgba(49, 92, 79, .2);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 22px 55px rgba(23, 33, 29, .22);
}

.week-picker-header {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  text-align: center;
}

.week-picker-header strong {
  font-size: 16px;
  text-transform: capitalize;
}

.week-picker-month-button,
.week-picker-day {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.week-picker-month-button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--green);
  font-size: 18px;
}

.week-picker-month-button:hover,
.week-picker-day:hover {
  background: var(--sage);
}

.week-picker-popover table {
  width: 100%;
  table-layout: fixed;
}

.week-picker-popover th,
.week-picker-popover td {
  height: 38px;
  padding: 2px;
  border: 0;
  text-align: center;
}

.week-picker-popover thead th {
  height: 28px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.week-number {
  width: 28px;
  color: #9aa39f;
  font-size: 10px;
  font-weight: 700;
}

.week-picker-day {
  width: 32px;
  height: 32px;
  margin: auto;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}

.week-picker-day.outside-month {
  color: #aab1ae;
  font-weight: 500;
}

.week-picker-popover tr.selected-week td {
  background: rgba(49, 92, 79, .08);
}

.week-picker-popover tr.selected-week td:first-of-type {
  border-radius: 10px 0 0 10px;
}

.week-picker-popover tr.selected-week td:last-child {
  border-radius: 0 10px 10px 0;
}

.week-picker-day.selected-week-start,
.week-picker-day.today {
  background: var(--green);
  color: white;
}

.lesson-hover-tooltip {
  position: fixed;
  z-index: 100;
  width: min(330px, calc(100vw - 24px));
  padding: 16px 17px;
  border: 1px solid rgba(49, 92, 79, .2);
  border-radius: 13px;
  background: var(--card);
  box-shadow: 0 18px 45px rgba(23, 33, 29, .24);
  pointer-events: none;
}

.lesson-hover-tooltip .eyebrow {
  margin-bottom: 5px;
}

.lesson-hover-tooltip > strong {
  display: block;
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.3;
}

.lesson-tooltip-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lesson-hover-tooltip p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #43514c;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
}

.calendar-colored {
  border-left: 4px solid var(--calendar-color) !important;
}

.calendar-date {
  border-top: 4px solid var(--calendar-color);
}

.calendar-directory {
  display: grid;
  gap: 18px;
}

.calendar-directory-card {
  padding: 24px;
}

.calendar-directory-heading {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
}

.calendar-directory-heading > i {
  width: 16px;
  height: 16px;
}

.calendar-directory-heading h2,
.calendar-directory-heading .eyebrow,
.calendar-source h3,
.calendar-feeds h3 {
  margin-bottom: 0;
}

.calendar-directory-actions {
  margin: 18px 0;
}

.calendar-source,
.calendar-feeds {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.calendar-source + .calendar-feeds {
  margin-top: 18px;
}

.calendar-source .alert {
  margin: 10px 0;
}

.inline-actions a,
.inline-actions .link-button,
.feed > a {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.calendar-week thead > tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.calendar-overview-row th {
  height: 150px;
  padding: 7px !important;
  vertical-align: top;
  background: #f8faf8;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
}

.calendar-overview-row .overview-label {
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.calendar-day-overview {
  transition: background .15s ease, box-shadow .15s ease;
}

.calendar-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 5px;
  padding: 6px 7px;
  border: 1px solid #c9d8d0;
  border-radius: 7px;
  background: #e1ece6;
  color: var(--ink);
  overflow: hidden;
  text-align: left;
}

.calendar-item > span {
  color: var(--green);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.calendar-item > strong {
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.calendar-item > small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.type-holiday {
  border-color: #dfb5a8;
  background: #f4dfd8;
}

.type-holiday > span {
  color: #944734;
}

.type-meeting {
  border-color: #bacbe0;
  background: #e1eaf4;
}

.type-meeting > span {
  color: #365d86;
}

.type-excursion {
  border-color: #b8d9d0;
  background: #ddf0eb;
}

.type-deadline {
  border-color: #e1c29f;
  background: #f7e8d6;
}

.readonly-item {
  opacity: .78;
}

.empty-day {
  display: block;
  padding: 9px 2px;
  color: #9aa39f;
  font-size: 9px;
  font-weight: 500;
}

.calendar-cell {
  position: relative;
  vertical-align: top;
  transition: background .15s ease, box-shadow .15s ease;
}

.calendar-cell.out-of-field {
  background: #fff6df;
  border-color: #e7ca85;
}

.calendar-cell.out-of-field .calendar-lesson {
  border-left-color: #d29a2f;
}

.foreign-label {
  color: #8a641e !important;
}

.foreign-dot {
  background: #e9c56f;
}

.foreign-pill {
  margin-left: 6px;
  background: #fff0c9;
  color: #7c5a17;
}

.calendar-cell.assessment {
  background: #fff1f1;
  border-color: #d95454;
}

.calendar-cell.assessment .calendar-lesson {
  border-left: 6px solid #d42626;
  border-right: 6px solid #d42626;
  background: linear-gradient(90deg, rgba(255, 224, 91, .2), rgba(255, 255, 255, .45), rgba(255, 224, 91, .2));
}

.assessment-label {
  color: #b51f1f;
  font-size: 13px !important;
  font-weight: 950;
  font-variant-caps: all-small-caps;
  letter-spacing: .08em;
  line-height: 1 !important;
}

.assessment-dot {
  background: #d42626;
  box-shadow: inset -3px 0 #ffe05b;
}

.assessment-pill {
  margin-left: 6px;
  background: #f8d9d9;
  color: #a21f1f;
}

.cancellation-dot {
  background: #b7674f;
}

.shift-form .field:has(#id_limit_mode),
.shift-form .field:has(#id_mark_cancelled),
.shift-form .field:has(#id_reason) {
  grid-column: 1 / -1;
}

#id_limit_mode {
  display: grid;
  gap: 8px;
}

#id_limit_mode label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  font-weight: 600;
}

#id_limit_mode input {
  width: auto;
  margin: 0;
}

.shift-preview {
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.shift-preview .table-card {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.shift-preview .alert ul {
  margin-bottom: 0;
}

.shift-fixed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f3f1e8;
  color: var(--muted);
  font-size: 13px;
}

.shift-fixed strong {
  color: var(--ink);
  margin-bottom: 3px;
}

.operation-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.operation-summary > div:not(.alert) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.operation-summary > div span {
  color: var(--muted);
  font-size: 12px;
}

.operation-summary > div strong {
  font-size: 18px;
}

.operation-summary .alert {
  grid-column: 1 / -1;
}

.operation-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.operation-actions form {
  margin: 0;
}

.shift-history {
  margin-top: 24px;
}

@media(max-width:850px) {
  .operation-summary {
    grid-template-columns: 1fr;
  }

  .operation-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .week-picker-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(366px, calc(100vw - 28px));
    transform: translate(-50%, -50%);
  }
}

@media(hover:none) {
  .lesson-hover-tooltip {
    display: none !important;
  }
}

.form-post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.form-post-actions form {
  margin: 0;
}

.timed-event {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 3px 1px;
  padding: 5px 6px;
  border: 1px solid #b9ccdb;
  border-radius: 6px;
  background: #e3edf4;
  color: #294658;
}

.calendar-timeline-surface { position: relative; min-width: 1540px; }
.calendar-timeline-surface table { width: 100%; }
.timeline-duration { position: absolute; z-index: 3; overflow: hidden; }
.timeline-duration .calendar-item { height: 100%; margin: 0; box-sizing: border-box; overflow: hidden; text-align: left; }
.timeline-duration strong { overflow-wrap: anywhere; }
.timeline-duration .calendar-item > span { display: none; }
.timeline-duration .calendar-item strong { font-size: 12px; line-height: 1.3; }
.calendar-timeline-surface .calendar-lesson { box-sizing: border-box; overflow-wrap: anywhere; }
.calendar-lesson { position: relative; }
.calendar-lesson:has(.lesson-progress) { padding-right: 23px; }
.calendar-lesson .lesson-progress {
  position: absolute; top: 6px; right: 6px; width: 12px; height: 12px;
  min-width: 12px; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px #273a3440; background: #c63d3d;
}
.calendar-lesson .lesson-progress-partial { background: #f2c230; }
.calendar-lesson .lesson-progress-completed { background: #28844b; }
.progress-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #273a3440; }
.progress-pending { background: #c63d3d; }
.progress-partial { background: #f2c230; }
.progress-completed { background: #28844b; }

.timed-event strong {
  font-size: 10px;
  line-height: 1.2;
}

.timed-event small {
  font-size: 8px;
}

.calendar-draggable {
  cursor: grab;
}

.calendar-draggable:active {
  cursor: grabbing;
}

.calendar-draggable.dragging {
  opacity: .35;
}

.calendar-drop-zone.drag-over {
  box-shadow: inset 0 0 0 3px #4b8d75;
  background: #e3f2e9 !important;
}

.calendar-status {
  min-height: 0;
  margin-bottom: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
}

.calendar-status:not(:empty) {
  min-height: 34px;
  margin-bottom: 10px;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--sage);
}

.calendar-status.error {
  color: var(--red);
  background: #f3dddd;
}

.event-row[href]:hover,
.timeline-card[href]:hover {
  background: #f7faf8;
}

@media (max-width: 850px) {
  .calendar-switcher {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-week table {
    min-width: 1160px;
  }

  .calendar-overview-row th {
    height: 130px;
  }
}
