* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    padding: 10px 20px 20px 20px; /* 상단만 10px로 줄임 */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

header h1 {
    font-size: 24px;
    color: #333;
}

/* 날짜 범위 네비게이션 */
.date-range-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-today {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s;
}

.btn-today:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.nav-btn {
    padding: 8px 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.nav-btn:hover {
    background: #e0e0e0;
}

.date-range-display {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    letter-spacing: 0.5px;
    min-width: 180px;
    text-align: center;
}

/* 뷰 모드 토글 */
.view-mode-toggle {
    position: relative;
}

.toggle-btn {
    padding: 8px 16px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s;
}

.toggle-btn:hover {
    background: #1976d2;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: #333;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 5px 0;
}

nav {
    display: flex;
    gap: 15px;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: #2196f3;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background 0.3s;
}

nav a:hover {
    background: #e3f2fd;
}

.btn-compact {
    padding: 8px 16px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-compact:hover {
    background: #f57c00;
}

.btn-compact.active {
    background: #e65100;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
}

.btn-refresh {
    padding: 8px 16px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-refresh:hover {
    background: #45a049;
}

/* 우측 상단 중복 예약 알림 배지 */
.conflict-info {
    position: fixed;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 10px 18px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    cursor: pointer;
    user-select: none;
}

.conflict-info.visible {
    opacity: 1;
    transform: translateY(0);
}

.conflict-info:hover {
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.5);
}

.conflict-info:active {
    transform: translateY(0) scale(0.95);
}

/* 검색 및 필터 (컴팩트 레이아웃) */
.search-filter-container {
    margin-bottom: 12px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.search-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.type-bulk-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-type-bulk {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #1976d2;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-type-bulk:hover {
    background: #bbdefb;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    padding: 8px 30px 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #2196f3;
}

.search-box input::placeholder {
    color: #999;
}

.clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    transition: background 0.3s;
}

.clear-btn:hover {
    background: #e0e0e0;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    padding: 0;
    margin: 0;
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #ff4444;
}

.filter-checkbox span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.filter-checkbox:hover span {
    color: #ff4444;
}

.legend-compact {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-left: auto;
    padding-left: 12px;
    border-left: 2px solid #e0e0e0;
}

.filter-result {
    flex-basis: 100%;
    min-height: 18px;
    font-size: 13px;
    color: #666;
    padding-top: 4px;
}

.legend {
    display: none; /* 컴팩트 버전으로 대체 */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    white-space: nowrap;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-yanolza { background: #e8c96a; }
.dot-naver { background: #6aad8e; }
.dot-agoda { background: #6a9eca; }
.dot-here { background: #d4845a; }
.dot-airbnb { background: #c97a7e; }
.dot-conflict { background: #f44336; border: 2px solid #c62828; }

.loading {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #666;
}

.calendar-container {
    background: white;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.calendar-grid {
    display: grid;
    /* grid-template-columns는 JavaScript에서 동적 설정 */
    gap: 1px;
    background: #e0e0e0;
    min-width: 1200px;
}

.calendar-header {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    z-index: 10;
}

.type-header {
    /* grid-column은 JavaScript에서 동적 설정 */
    background: #e3f2fd;
    padding: 10px 15px;
    font-weight: bold;
    color: #1976d2;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.type-header:hover {
    background: #bbdefb;
}

.type-toggle {
    font-size: 12px;
    color: #1976d2;
    transition: transform 0.3s;
}

.type-header.collapsed .type-toggle {
    transform: rotate(-90deg);
}

.room-label {
    padding: 12px 10px;
    background: #fafafa;
    font-weight: 500;
    position: sticky;
    left: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-right: 2px solid #e0e0e0;
}

.date-header {
    padding: 8px 6px;
    background: #f5f5f5;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    min-width: 50px;
}

.date-header.today {
    background: #fff3e0;
    color: #f57c00;
    font-weight: bold;
}

.date-header .day {
    display: block;
    font-size: 10px;
    color: #999;
}

.calendar-cell {
    /* 글자 cqmin용(막대 크기는 예전과 동일) */
    container-type: size;
    container-name: cal-cell;
    padding: 4px;
    background: white;
    min-height: 60px;
    min-width: 50px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.calendar-cell:hover {
    background: #f9f9f9;
}

.calendar-cell.vacant {
    background: #f5f5f5;
}

.reservation-block {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 4px;
    /* 막대(셀) 크기는 구버전과 동일, 글자만 cqmin */
    font-size: clamp(13px, 40cqmin, 20px);
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: start;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    z-index: 1;
}

.reservation-block:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 100;
}

/* ============================================================================
   연속 예약 연결 바 (bar) 스타일
   ============================================================================ */

/* 1박짜리 단독 예약 */
.reservation-block.res-single {
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}

/* 연속 예약 시작일: 텍스트는 막대 시작(여러날) 쪽, overflow는 유지 */
.reservation-block.res-start {
    border-radius: 6px 0 0 6px;
    overflow: visible;
    z-index: 2;
    margin-right: -5px;
    padding-right: 0;
    width: calc(100% + 5px);
    box-shadow: inset 1px 1px 0 rgba(0,0,0,0.15), inset 0 -1px 0 rgba(0,0,0,0.15);
}

/* 연속 예약 중간일: 배경색만, 텍스트 없음 */
.reservation-block.res-middle {
    border-radius: 0;
    z-index: 1;
    margin-left: -5px;
    margin-right: -5px;
    padding-left: 0;
    padding-right: 0;
    width: calc(100% + 10px);
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.15), inset 0 -1px 0 rgba(0,0,0,0.15);
}

/* 연속 예약 마지막 날: 배경색만, 텍스트 없음 */
.reservation-block.res-end {
    border-radius: 0 6px 6px 0;
    z-index: 1;
    margin-left: -5px;
    padding-left: 0;
    width: calc(100% + 5px);
    box-shadow: inset -1px 1px 0 rgba(0,0,0,0.15), inset 0 -1px 0 rgba(0,0,0,0.15);
}

.reservation-block.야놀자 { background: #e8c96a; color: #3d2a00; text-shadow: 0 0 0.5px rgba(255, 255, 255, 0.6); }
.reservation-block.네이버 { background: #5a9d7a; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); }
.reservation-block.아고다 { background: #5b8eb8; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); }
.reservation-block.여기어때 { background: #c47348; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); }
.reservation-block.에어비앤비 { background: #b86a6e; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); }
.reservation-block.conflict {
    background: repeating-linear-gradient(
        45deg,
        #f44336,
        #f44336 10px,
        #c62828 10px,
        #c62828 20px
    );
    color: white;
    font-weight: 800;
    font-size: clamp(12px, 36cqmin, 19px);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

/* ============================================================================
   컴팩트 모드
   ============================================================================ */
.calendar-container.compact .calendar-cell {
    min-height: 35px !important;
    padding: 2px;
}

.calendar-container.compact .room-label {
    padding: 6px 8px;
    font-size: 12px;
}

.calendar-container.compact .type-header {
    padding: 6px 12px;
    font-size: 13px;
}

.calendar-container.compact .date-header {
    padding: 4px 3px;
    font-size: 11px;
}

.calendar-container.compact .date-header strong {
    font-size: 12px;
}

.calendar-container.compact .date-header .day {
    font-size: 9px;
}

.calendar-container.compact .reservation-block {
    font-size: clamp(9px, 32cqmin, 13px);
    font-weight: 600;
    line-height: 1.3;
    padding: 2px;
    letter-spacing: 0.015em;
}

/* 컴팩트 모드: cell padding=2px이므로 margin 재계산 (2px + 1px gap = 3px) */
.calendar-container.compact .reservation-block.res-start {
    margin-right: -3px;
    width: calc(100% + 3px);
}
.calendar-container.compact .reservation-block.res-middle {
    margin-left: -3px;
    margin-right: -3px;
    width: calc(100% + 6px);
}
.calendar-container.compact .reservation-block.res-end {
    margin-left: -3px;
    width: calc(100% + 3px);
}

/* ============================================================================
   타입 접기
   ============================================================================ */
/* .room-row[data-type-name] 기본적으로 표시 */

/* 타입 접기/펼치기는 calendar.js의 toggleTypeCollapse()에서 data-type-name으로 제어 */

/* 모달 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-airbnb-actions {
    margin: 0 0 4px 0;
}

.modal .btn-airbnb-external {
    display: inline-block;
    padding: 8px 14px;
    background: #ff5a5f;
    color: #fff !important;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.modal .btn-airbnb-external:hover {
    background: #e04a4e;
    color: #fff !important;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

#modalBody {
    margin-top: 20px;
}

#modalBody p {
    margin: 10px 0;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
}

#modalBody strong {
    display: inline-block;
    min-width: 100px;
}

.modal-res-edit-toggle-wrap {
    margin-top: 12px;
}

.btn-open-res-edit {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #3182f6;
    color: #3182f6;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.btn-open-res-edit:hover {
    background: #f0f7ff;
}

.modal-res-edit-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.btn-cancel-res-edit {
    padding: 9px 14px;
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel-res-edit:hover {
    background: #eee;
}

.modal-res-edit-form {
    margin-top: 14px;
    padding: 12px;
    background: #f0f7ff;
    border: 1px solid #cfe8fc;
    border-radius: 8px;
}

.modal-res-edit-form p.modal-res-edit-title {
    margin: 0 0 10px 0;
    padding: 0;
    background: transparent !important;
    font-size: 14px;
}

.modal-res-edit-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    padding: 0 !important;
    background: transparent !important;
}

.modal-res-edit-label .modal-res-input {
    display: block;
    margin-top: 4px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.btn-save-reservation-meta {
    margin-top: 0;
    padding: 9px 16px;
    background: #3182f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.btn-save-reservation-meta:hover {
    background: #1c6ef3;
}

.modal-delete-area {
    margin-top: 16px;
    padding: 12px;
    background: #fff8f8;
    border: 1px solid #f0caca;
    border-radius: 6px;
}
.modal-delete-hint {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #666;
    background: transparent !important;
    padding: 0 !important;
}
.btn-open-delete-confirm {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #c62828;
    color: #b71c1c;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.btn-open-delete-confirm:hover {
    background: #ffebee;
}
.modal-delete-panel {
    margin-top: 12px;
}
.modal-delete-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    background: transparent !important;
    padding: 0 !important;
}
.modal-delete-room-input {
    width: 100%;
    max-width: 280px;
    padding: 8px 10px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}
.modal-delete-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-execute-delete {
    padding: 8px 14px;
    background: #c62828;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.btn-execute-delete:hover {
    background: #b71c1c;
}
.btn-cancel-delete {
    padding: 8px 14px;
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
}

/* 반응형 레이아웃 */
@media (max-width: 1024px) {
    .search-filter-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .search-controls {
        width: 100%;
    }
    
    .search-box {
        flex: 1;
        width: auto;
    }
    
    .legend-compact {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid #e0e0e0;
        width: 100%;
    }
    
    /* 날짜 범위 네비게이션 조정 */
    .date-range-nav {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .date-range-display {
        min-width: 150px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-left {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    /* 날짜 범위 네비게이션 모바일 최적화 */
    .date-range-nav {
        width: 100%;
        justify-content: space-between;
    }
    
    .btn-today {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .nav-btn {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .date-range-display {
        font-size: 13px;
        padding: 6px 12px;
        min-width: 120px;
    }
    
    .toggle-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    /* 컴팩트 모드 버튼 모바일 */
    .btn-compact,
    .btn-refresh {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    nav {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .search-box {
        width: 100%;
    }
    
    .calendar-grid {
        font-size: 10px;
    }
    
    .room-label {
        font-size: 12px;
    }
    
    /* 드롭다운 메뉴 모바일 조정 */
    .dropdown-menu {
        right: auto;
        left: 0;
    }
    
    /* 중복 예약 배지 모바일 조정 */
    .conflict-info {
        top: 70px;
        right: 10px;
        font-size: 12px;
        padding: 8px 14px;
    }
}
