:root {
  --ui-bg: #f8fafc;
  --ui-surface: #ffffff;
  --ui-border: #e2e8f0;
  --ui-text: #1f2937;
  --ui-muted: #64748b;
  --ui-primary: #3b82f6;
  --ui-primary-strong: #2563eb;
  --ui-radius: 8px;
  --ui-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

#calendar {
  width: 70%;
  max-width: 70%;
  margin: 20px 0;
  padding: 14px;
  min-height: 520px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

#calendar .fc,
#calendar .fc-view-harness {
  min-height: 470px;
}

.legacy-calendar-wrap {
  width: 100%;
  margin: 0 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.legacy-calendar-wrap:active {
  cursor: grabbing;
}

.legacy-calendar-wrap #calendar {
  width: 100% !important;
  max-width: 100% !important;
}

.fc .fc-toolbar.fc-header-toolbar {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ui-border);
}

.fc .fc-toolbar-title {
  color: var(--ui-text);
  font-size: 20px;
  font-weight: 700;
}

.fc .fc-button {
  height: 34px;
  padding: 0 12px !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius) !important;
  background: #fff !important;
  color: #334155 !important;
  text-transform: none !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

.fc .fc-button.fc-button-active {
  color: #fff !important;
  border-color: var(--ui-primary-strong) !important;
  background: linear-gradient(180deg, var(--ui-primary) 0%, var(--ui-primary-strong) 100%) !important;
}

.fc .fc-scrollgrid {
  border-radius: var(--ui-radius);
  border: 1px solid var(--ui-border) !important;
  overflow: hidden;
}

.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--ui-border) !important;
}

.fc .fc-col-header-cell {
  background: #f8fafc;
}

.fc .fc-col-header-cell-cushion {
  color: var(--ui-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 9px 0;
}

.fc-daygrid-day {
  position: relative;
  height: 68px !important;
}

.fc-daygrid-day-frame {
  position: relative;
  overflow: visible !important;
}

.fc .fc-daygrid-day-number {
  margin: 5px 6px 0;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #1f2937;
  font-weight: 700;
  border: 1px solid transparent;
  background: rgba(248, 250, 252, 0.95);
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.85);
  transition: all 0.18s ease;
}

#calendar .fc-daygrid-day:hover:not(.fc-day-today) {
  cursor: pointer;
  background: #f1f5f9 !important;
}

#calendar .fc-daygrid-day:hover .fc-daygrid-day-number {
  background: #eaf2ff;
  color: var(--ui-primary);
  border-color: #bfdbfe;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.18);
}

.fc .fc-daygrid-day.fc-day-today {
  background: transparent !important;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  border: 2px solid #93c5fd;
  color: var(--ui-primary-strong);
  background: #eff6ff;
}

#calendar .fc-daygrid-day.selected-date:not(.fc-day-today) {
  background: #eff6ff !important;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

#calendar .fc-daygrid-day.selected-date .fc-daygrid-day-number {
  color: #fff;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.fc-daygrid-day.alt-selected {
  background: #fff7ed !important;
  box-shadow: inset 0 0 0 1px #fed7aa;
}

.fc-daygrid-day.alt-selected .fc-highlight {
  background: transparent !important;
}

.fc-event {
  position: relative;
  margin: 2px 4px 0 !important;
  padding: 2px 6px !important;
  border: 1px solid rgba(15, 23, 42, 0.08) !important;
  border-radius: 6px !important;
  background: #ffffff !important;
  color: #0f172a !important;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: normal;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.fc-event .fc-event-main,
.fc-event .fc-event-main * {
  color: #0f172a !important;
  white-space: normal;
}

.fc-h-event .fc-event-main {
  padding: 0;
  border: none !important;
  background: transparent !important;
}

.cell-input-container {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 70%;
  max-width: 100px;
  z-index: 5;
}

.cell-input {
  width: 100%;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  background: #fff;
  color: #0f172a;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1100px) {
  #calendar {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  #calendar {
    padding: 10px;
    min-height: 420px;
  }

  .legacy-calendar-wrap #calendar {
    min-width: 760px;
  }

  .fc-daygrid-day {
    height: 60px !important;
  }

  #calendar .fc,
  #calendar .fc-view-harness {
    min-height: 380px;
  }

  .fc .fc-toolbar-title {
    font-size: 16px;
  }
}