:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: #111214;
  color: #ebebeb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #141518 0%, #0e0f11 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border-radius: 6px;
}

.desktop-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  padding: 14px;
}

.desktop-shell.auth-locked {
  display: none;
}

.desktop-header,
.toolbar-band,
.panel {
  border: 1px solid #36383d;
  background: #1a1c20;
}

.desktop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.desktop-header h1,
.desktop-header p,
.month-controls h2,
.details-head h3,
.stats-head h3,
.panel h3,
.panel h4 {
  margin: 0;
}

.desktop-header h1 {
  font-size: 28px;
}

.desktop-header p,
.stats-head p,
.details-head p,
.notes p,
.legend p {
  color: #b8bbc2;
}

.header-actions,
.month-controls,
.selectors,
.actions-grid,
.trade-actions {
  display: flex;
  gap: 10px;
}

.desktop-header button,
.toolbar-band button,
.shortcut-list button,
.actions-grid button,
.type-grid button,
.trade-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #52565f;
  background: #2a2d33;
  color: #f4f4f4;
}

#settingsButton {
  min-width: 54px;
  font-weight: 800;
}

#availabilityButton {
  min-width: 54px;
  font-size: 22px;
  line-height: 1;
}

#availabilityButton.is-active {
  background: #4a5568;
  border-color: #7f8aa0;
}

#availabilityStatusLabel {
  align-self: center;
  min-width: 52px;
  font-size: 13px;
  font-weight: 800;
  color: #b8bbc2;
}

.desktop-header button:hover,
.toolbar-band button:hover,
.actions-grid button:hover,
.type-grid button:hover,
.trade-actions button:hover {
  background: #343841;
}

.toolbar-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
}

.selectors-band.is-hidden {
  display: none;
}

.month-controls {
  align-items: center;
}

.month-controls h2 {
  min-width: 200px;
  text-align: center;
  font-size: 24px;
}

.header-month-controls h2 {
  min-width: 170px;
  font-size: 22px;
}

.selectors {
  flex-wrap: wrap;
}

.selectors label,
.trade-card label {
  display: grid;
  gap: 6px;
  min-width: 160px;
  font-size: 14px;
  font-weight: 700;
}

.selectors select,
.trade-card select,
.trade-card input,
.trade-card textarea {
  min-height: 40px;
  border: 1px solid #4c4f57;
  background: #0f1115;
  color: #f1f1f1;
  padding: 8px 10px;
}

.selectors select:disabled {
  background: #15181d;
  color: #d5d8de;
  border-color: #3f434b;
  cursor: default;
  opacity: 1;
}

.desktop-grid {
  display: grid;
  grid-template-columns: minmax(860px, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 16px;
}

.details-panel {
  display: grid;
  gap: 18px;
}

.legend,
.notes,
.tour-card,
.actions-card,
.event-card,
.trade-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #31343a;
  background: #14161a;
}

.calendar-legend {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  border-top: 1px solid #31343a;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: #17191d;
  padding: 14px 16px 16px;
}

.calendar-legend h4 {
  grid-column: 1 / -1;
}

.calendar-legend p {
  margin: 0;
}

.day-list {
  display: grid;
  gap: 8px;
}

.day-list-empty {
  margin: 0;
  color: #b8bbc2;
  font-size: 14px;
}

.day-list-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #31343a;
  background: #1a1d22;
}

.day-list-item strong,
.day-list-item span {
  margin: 0;
}

.day-list-item span {
  color: #c4c8d0;
  font-size: 14px;
}

.day-list-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.day-list-item-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #52565f;
  background: #2a2d33;
  color: #f4f4f4;
}

.day-list-item-actions button:hover {
  background: #343841;
}

.legend-chip {
  display: inline-block;
  width: 26px;
  height: 12px;
  margin-right: 10px;
  vertical-align: middle;
}

.legend-chip.red {
  background: #f47179;
}

.legend-chip.blue {
  background: #7773f2;
}

.legend-chip.split {
  background: linear-gradient(to right, #f47179 0%, #f47179 50%, #7773f2 50%, #7773f2 100%);
}

.legend-chip.green {
  background: #84ff82;
}

.legend-chip.orange {
  background: #f6a623;
}

.legend-chip.gold {
  background: #d4af37;
}

.calendar-panel {
  padding: 0;
  overflow: hidden;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  background: #25282e;
}

.weekday-row span {
  display: grid;
  place-items: center;
  min-height: 42px;
  font-weight: 800;
  color: #e6e7ea;
}

.calendar-grid {
  border-top: 1px solid #4a4e56;
  border-left: 1px solid #4a4e56;
}

.day,
.blank-day {
  position: relative;
  min-height: 118px;
  border-right: 1px solid #4a4e56;
  border-bottom: 1px solid #4a4e56;
}

.blank-day {
  background: #f3f3f3;
}

.day {
  display: grid;
  grid-template-rows: 34px 1fr;
  align-items: start;
  padding: 0;
  background: #fbfbfb;
  color: #111;
  cursor: pointer;
  overflow: hidden;
}

.day:hover {
  outline: 2px solid #8ac7ff;
  outline-offset: -2px;
}

.day.selected {
  outline: 4px solid #2f335f;
  outline-offset: -4px;
}

.day::before,
.day::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  z-index: 0;
}

.day::before {
  top: 0;
  height: 50%;
}

.day::after {
  bottom: 0;
  height: 50%;
}

.day-number,
.day-label {
  z-index: 1;
}

.original-marker {
  position: absolute;
  inset-inline: 1px;
  z-index: 1;
  pointer-events: none;
  border: 2px dashed #111;
}

.original-marker-day {
  top: 1px;
  height: calc(50% - 2px);
}

.original-marker-night {
  bottom: 1px;
  height: calc(50% - 2px);
}

.tour-badge {
  position: absolute;
  z-index: 2;
  font-size: 13px;
  font-weight: 900;
  color: #111;
  pointer-events: none;
}

.tour-badge-day {
  right: 8px;
  top: 8px;
}

.tour-badge-night {
  right: 8px;
  bottom: 8px;
}

.tour-badge-roster {
  min-width: 20px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #f6a623;
  color: #111;
  text-align: center;
}

.tour-badge-vacation-time {
  left: 8px;
  right: auto;
  min-width: 54px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(212, 175, 55, 0.92);
  color: #111;
  text-align: center;
}

.tour-badge-warning {
  min-width: 18px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 0;
  background: #f4c542;
  color: #111;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  font-size: 11px;
  line-height: 1;
}

.tour-badge-warning.tour-badge-day {
  right: 34px;
  top: 7px;
}

.tour-badge-warning.tour-badge-night {
  right: 34px;
  bottom: 7px;
}

.day-number {
  justify-self: center;
  padding-top: 12px;
  font-size: 24px;
  font-weight: 900;
}

.availability-count {
  position: absolute;
  z-index: 3;
  font-size: 13px;
  font-weight: 900;
  color: #f4f4f4;
  min-width: 22px;
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
}

.availability-count-left {
  left: 8px;
  color: #ffb4b8;
}

.availability-count-right {
  right: 8px;
  color: #a5f3b3;
}

.availability-count-day {
  top: 10px;
}

.availability-count-night {
  bottom: 10px;
}

.day.availability-mode {
  cursor: crosshair;
}

.day.availability-mode.swap-request-source-day::before,
.day.availability-mode.swap-request-source-night::after {
  background: #f4c542 !important;
}

.day.availability-mode.swap-request-selected-day::before,
.day.availability-mode.swap-request-selected-night::after {
  background: #28d35f !important;
}

.swap-request-calendar-marker {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 50%;
  pointer-events: none;
  font-size: 10px;
  font-weight: 900;
  color: #111;
}

.swap-request-calendar-marker-source {
  left: 50%;
  top: 10px;
  width: 26px;
  height: 26px;
  transform: translateX(-50%);
  background: #f4c542;
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.35);
}

.swap-request-calendar-marker-work {
  right: 10px;
  bottom: 10px;
  width: 16px;
  height: 16px;
  background: #28d35f;
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.35);
  font-size: 8px;
}

.swap-request-calendar-marker-work-2 {
  right: 30px;
}

.day-label {
  align-self: center;
  justify-self: center;
  font-size: 15px;
  font-weight: 900;
}

.holiday {
  background: #84ff82;
}

.own-day::before {
  background: linear-gradient(to bottom, #f47179 0%, #f47179 70%, rgba(244, 113, 121, 0) 100%);
}

.own-night::after {
  background: linear-gradient(to bottom, rgba(244, 113, 121, 0) 0%, #f47179 30%, #f47179 100%);
}

.mutual-day::before {
  background: linear-gradient(to bottom, #7773f2 0%, #7773f2 70%, rgba(119, 115, 242, 0) 100%);
}

.mutual-night::after {
  background: linear-gradient(to bottom, rgba(119, 115, 242, 0) 0%, #7773f2 30%, #7773f2 100%);
}

.trade-day::before {
  background: linear-gradient(to bottom, #8f9399 0%, #8f9399 70%, rgba(143, 147, 153, 0) 100%);
}

.trade-night::after {
  background: linear-gradient(to bottom, rgba(143, 147, 153, 0) 0%, #8f9399 30%, #8f9399 100%);
}

.roster-day::before {
  background: linear-gradient(to bottom, #f6a623 0%, #f6a623 70%, rgba(246, 166, 35, 0) 100%);
}

.roster-night::after {
  background: linear-gradient(to bottom, rgba(246, 166, 35, 0) 0%, #f6a623 30%, #f6a623 100%);
}

.vacation-day::before,
.vacation-night::after {
  background: #d4af37;
}

.vacation-partial-day::before {
  background: repeating-linear-gradient(
    135deg,
    #d4af37 0 10px,
    rgba(212, 175, 55, 0.35) 10px 20px
  );
}

.vacation-partial-night::after {
  background: repeating-linear-gradient(
    135deg,
    #d4af37 0 10px,
    rgba(212, 175, 55, 0.35) 10px 20px
  );
}

.both-day::before,
.both-night::after {
  background: linear-gradient(to right, #f47179 0%, #f47179 50%, #7773f2 50%, #7773f2 100%);
}

.has-day-color.has-night-color.own-day::before,
.has-day-color.has-night-color.own-night::after {
  background: #f47179;
}

.has-day-color.has-night-color.mutual-day::before,
.has-day-color.has-night-color.mutual-night::after {
  background: #7773f2;
}

.has-day-color.has-night-color.trade-day::before,
.has-day-color.has-night-color.trade-night::after {
  background: #8f9399;
}

.has-day-color.has-night-color.roster-day::before,
.has-day-color.has-night-color.roster-night::after {
  background: #f6a623;
}

.has-day-color.has-night-color.vacation-day::before,
.has-day-color.has-night-color.vacation-night::after {
  background: #d4af37;
}

.mutual-override {
  box-shadow: inset 0 0 0 3px #f1f1f1;
}

.tour-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.actions-grid,
.trade-actions {
  flex-wrap: wrap;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.type-grid .is-active {
  border-color: #8fd5cf;
  color: #8fd5cf;
}

.stats-panel {
  display: grid;
  gap: 14px;
}

.stats-table {
  border: 1px solid #383c43;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid #31343a;
  background: #23262c;
}

.stats-row:last-child {
  border-bottom: 0;
}

.stats-row strong,
.stats-row span {
  font-size: 16px;
}

.stats-row .positive {
  color: #25e82f;
  font-weight: 900;
}

.stats-row .negative {
  color: #ff3b30;
  font-weight: 900;
}

.context-menu {
  position: fixed;
  display: none;
  min-width: 220px;
  border: 1px solid #454a54;
  background: #202329;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  z-index: 30;
  overflow: hidden;
}

.context-menu.is-open {
  display: grid;
}

.context-menu-title {
  min-height: 38px;
  padding: 10px 14px;
  border-bottom: 1px solid #383c43;
  background: #17191d;
  color: #e7e9ed;
  font-size: 13px;
  font-weight: 800;
}

.context-menu button {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f2f3f5;
  text-align: left;
}

.context-menu button:hover {
  background: #313641;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, 0.72);
  z-index: 40;
}

.modal-shell.is-open {
  display: grid;
}

#dateEntriesModal {
  z-index: 40;
}

#mutualTradeModal,
#mutualEditModal,
#tradeDateModal,
#rosterAdjustModal {
  z-index: 50;
}

#settingsModal,
#changePasswordModal {
  z-index: 50;
}

#loginModal {
  z-index: 80;
}

.modal-card {
  width: min(460px, calc(100vw - 40px));
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid #4a4e56;
  background: #1b1e23;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.modal-card-wide {
  width: min(720px, calc(100vw - 40px));
}

.modal-head,
.modal-field,
.modal-actions.vertical {
  display: grid;
  gap: 8px;
}

.modal-head h3,
.modal-head p {
  margin: 0;
}

.modal-head p {
  color: #b8bbc2;
}

.modal-field {
  font-size: 14px;
  font-weight: 700;
}

.modal-field span {
  color: #f1f1f1;
}

.modal-field select {
  min-height: 40px;
  border: 1px solid #4c4f57;
  background: #0f1115;
  color: #f1f1f1;
  padding: 8px 10px;
}

.modal-field input[type="date"] {
  min-height: 40px;
  border: 1px solid #4c4f57;
  background: #0f1115;
  color: #f1f1f1;
  padding: 8px 10px;
}

.settings-panel {
  display: grid;
  gap: 10px;
  min-height: 180px;
  padding: 14px;
  border: 1px solid #31343a;
  background: #14161a;
}

.settings-panel h4,
.settings-panel p {
  margin: 0;
}

.settings-panel p {
  color: #c4c8d0;
  line-height: 1.5;
}

.roster-table-wrap {
  overflow: auto;
  border: 1px solid #31343a;
  background: #101216;
}

.roster-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.roster-table th,
.roster-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #2e3238;
  text-align: left;
  white-space: nowrap;
}

.roster-table th {
  position: sticky;
  top: 0;
  background: #1d2026;
  color: #f1f3f5;
  font-size: 13px;
}

.roster-table td {
  color: #c4c8d0;
  font-size: 14px;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-form .modal-field {
  min-width: 0;
}

.settings-form .modal-field.full-width {
  grid-column: 1 / -1;
}

.settings-form input,
.settings-form select {
  min-height: 40px;
  border: 1px solid #4c4f57;
  background: #0f1115;
  color: #f1f1f1;
  padding: 8px 10px;
}

.settings-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.settings-panel-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #52565f;
  background: #2a2d33;
  color: #f4f4f4;
}

.settings-panel-actions button:hover {
  background: #343841;
}

.settings-message {
  min-height: 20px;
  margin: 0;
  color: #c4c8d0;
  font-size: 14px;
}

.settings-message.is-error {
  color: #ff7b72;
}

.settings-message.is-success {
  color: #7ee787;
}

.swap-request-date-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.swap-request-date-marker {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #31343a;
  background: #14161a;
}

.swap-request-date-marker span {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
}

.swap-request-date-marker-source span {
  background: #f4c542;
}

.swap-request-date-marker-work span {
  width: 10px;
  height: 10px;
  flex-basis: 10px;
  margin: 4px;
  background: #28d35f;
}

.swap-request-date-marker strong {
  font-size: 14px;
  color: #f1f1f1;
}

.toggle-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle-row button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #52565f;
  background: #23262c;
  color: #f4f4f4;
}

.toggle-row button.is-selected {
  border-color: #8fd5cf;
  background: #304445;
  color: #dffbf7;
}

.modal-actions,
.modal-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions button,
.modal-footer button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #52565f;
  background: #2a2d33;
  color: #f4f4f4;
}

.modal-actions button:hover,
.modal-footer button:hover,
.toggle-row button:hover {
  background: #343841;
}

.modal-footer button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal-footer {
  justify-content: flex-end;
}

@media (max-width: 1400px) {
  .desktop-grid {
    grid-template-columns: minmax(620px, 1fr) 340px;
  }

  .day,
  .blank-day {
    min-height: 102px;
  }
}

@media (max-width: 1180px) {
  .desktop-grid {
    grid-template-columns: 1fr;
  }

  .desktop-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-title-row {
    justify-content: space-between;
  }

  .toolbar-band {
    flex-direction: column;
    align-items: stretch;
  }

  .month-controls {
    justify-content: space-between;
  }

  .selectors {
    justify-content: stretch;
  }
}

@media (max-width: 900px) {
  .calendar-legend {
    grid-template-columns: 1fr;
  }
}
