/* =========================================
   4. 레이아웃 - 헤더, 사이드바, 메인 콘텐츠 (모바일 완벽 대응)
   ========================================= */

/* ========== 전체 앱 레이아웃 ========== */
#app, #mainContent {
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* ✅ overflow: hidden 제거 - 모바일 버튼 클릭 활성화 */
}

/* ========== 헤더 (고정) ========== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-left {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    flex: 0 0 auto;
}

.header-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.header-left h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-name {
    font-size: 15px;
    color: var(--gray-600);
    font-weight: 500;
}

.btn-logout {
    padding: 0.5rem 1.25rem;
    background: var(--gray-100);
    color: var(--gray-700);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: var(--gray-200);
}

/* ========== 모바일 햄버거 메뉴 버튼 ========== */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    gap: 5px;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.3s ease;
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn:hover span {
    background: var(--gray-900);
}

.hamburger-btn:active {
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

/* 햄버거 버튼 활성화 시 X 모양으로 변환 */
.hamburger-btn.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* 레거시 지원 - 14-mobile-menu.css에서 관리 */
/* .mobile-menu-toggle 스타일은 14-mobile-menu.css 참조 */

/* ========== 앱 컨테이너 ========== */
.app-container {
    display: flex;
    height: 100vh;
    padding-top: 70px;
}

/* ========== 사이드바 오버레이 (모바일용) ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ========== 사이드바 (고정) ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: 70px;
    bottom: 0;
    width: 260px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    overflow-y: auto;
    border-right: 1px solid var(--gray-700);
    z-index: 95;
    transition: transform 0.3s ease;
}

.main-menu {
    padding: 1.5rem 1rem;
}

.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    color: var(--gray-300);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.menu-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
    flex: none;
    line-height: 1.5;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.menu-label {
    flex: 1;
}

/* ========== 메뉴 그룹 라벨 ========== */
.menu-group-label {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.75rem 1rem;
}

/* ========== 메뉴 묶음 접기 (2026-09-22, js/menu-groups.js) ==========
   2026-09-23 "눈에 잘 안 들어온다" — 묶음 이름을 또렷하게, 묶음 사이에 가는 선, 고정 핀,
   접힌 묶음은 안쪽 이름 한 줄. 지금 탭은 파란 바탕. PC 는 줄을 촘촘하게(아래 min-width 블록). */
.menu-group { display: flex; flex-direction: column; }
.menu-group + .menu-group { border-top: 1px solid rgba(255, 255, 255, 0.09); margin-top: 8px; padding-top: 6px; }
.menu-group .menu-group-label {
    padding: 4px 10px 6px; font-size: 12.5px; font-weight: 700; color: #e2e8f0;
    letter-spacing: 0; text-transform: none;
}
.menu-group-head { display: flex; align-items: center; gap: 2px; }
.menu-group-toggle {
    display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
    padding: 6px 10px; border: 0; border-radius: 6px; background: transparent;
    color: #e2e8f0; font-size: 12.5px; font-weight: 700; font-family: inherit;
    letter-spacing: 0; text-transform: none; cursor: pointer; text-align: left;
}
.menu-group-toggle:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }
.menu-group-name { flex: 1; }
.menu-group-count { color: #8b98ad; font-size: 12px; font-weight: 500; }
.menu-group-chev { display: inline-block; font-size: 15px; line-height: 1; color: #8b98ad; transition: transform 0.15s; }
.menu-group.collapsible:not(.collapsed) .menu-group-chev { transform: rotate(90deg); }
.menu-group.collapsed .menu-group-items { display: none; }
.menu-group-pin {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent;
    color: #64748b; cursor: pointer; opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.menu-group-head:hover .menu-group-pin, .menu-group-pin:focus-visible,
.menu-group.pinned .menu-group-pin { opacity: 1; }
.menu-group-pin:hover { background: rgba(255, 255, 255, 0.06); color: #cbd5e1; }
.menu-group.pinned .menu-group-pin { color: #93c5fd; }
.menu-group.pinned .menu-group-pin svg { fill: currentColor; }
.menu-group-summary {
    display: none; padding: 0 12px 4px 10px; font-size: 12px; line-height: 1.5; color: #8b98ad;
    word-break: keep-all;
}
.menu-group.collapsed .menu-group-summary { display: block; }
.menu-group-badge {
    background: #ef4444; color: #fff; border-radius: 999px; font-size: 10.5px; font-weight: 700;
    padding: 1px 6px; min-width: 18px; text-align: center; line-height: 1.5; letter-spacing: 0;
}
/* 지금 탭 — 파란 바탕 + 굵게. 나머지 아이콘은 한 톤 낮춰 글자가 먼저 읽히게 */
.menu-item.active { background: rgba(59, 130, 246, 0.28); color: #ffffff; font-weight: 700; }
.menu-item:not(.active) .menu-icon { opacity: 0.72; filter: saturate(0.6); }
.menu-item:hover .menu-icon { opacity: 1; filter: none; }
/* 선 아이콘(Lucide, index.html applyMenuIcons) — 지금 탭은 밝은 파랑 */
.menu-icon svg { width: 18px; height: 18px; display: block; }
.menu-item.active .menu-icon { color: #93c5fd; }
/* 설정은 맨 아래 (관리자 메뉴의 menu-divider-bottom) */
.main-menu { display: flex; flex-direction: column; min-height: 100%; box-sizing: border-box; }
.main-menu > .menu-item { flex: none; }
.menu-divider-bottom { margin-top: auto; }
/* PC — 한 줄 56px → 38px */
@media (min-width: 769px) {
    /* 2026-09-23 "살짝 크게, 여백도 — 너무 촘촘" → 한 줄 38 → 42px, 글씨 15px, 아이콘 20px */
    .main-menu { padding: 16px 12px; }
    .menu-item { padding: 10px 12px; margin-bottom: 2px; gap: 12px; font-size: 15px; border-radius: 9px; }
    .menu-icon { font-size: 18px; width: 22px; }
    .menu-icon svg { width: 20px; height: 20px; }
    .menu-divider-bottom { margin: auto 6px 8px; }
    .menu-group:has(+ .menu-divider-bottom) { margin-bottom: 12px; }   /* 다 펼쳐 넘쳐도 설정이 판에 붙지 않게 */
    /* 2026-09-23 "PC 로 보니 카테고리가 없어 보인다" — 묶음마다 옅은 판 + 색 점 */
    .menu-group {
        background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 14px; padding: 8px;
    }
    .menu-group + .menu-group { border-top: 1px solid rgba(255, 255, 255, 0.06); margin-top: 14px; padding-top: 8px; }
    .menu-group .menu-group-label, .menu-group-toggle { font-size: 13.5px; color: #f1f5f9; }
    .menu-group .menu-group-label { display: flex; align-items: center; gap: 8px; padding: 6px 10px 8px; }
    .menu-group-toggle { padding: 6px 10px 8px; }
    .menu-group .menu-group-label::before, .menu-group-name::before {
        content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
        margin-right: 8px; vertical-align: 1px; background: #60a5fa;
    }
    .menu-group .menu-group-label::before { margin-right: 0; }
    .menu-group[data-group="sales"] .menu-group-name::before { background: #fbbf24; }
    .menu-group[data-group="docs"] .menu-group-name::before { background: #34d399; }
    .menu-group .menu-item:last-child { margin-bottom: 0; }
}
@media (max-width: 768px) {
    .menu-group-toggle { padding: 10px 10px; font-size: 13px; }
    .menu-group-pin { opacity: 1; width: 40px; height: 40px; }
}

/* ========== 메인 영역 (스크롤) ========== */
.main-area {
    margin-left: 260px;
    width: calc(100% - 260px);
    height: calc(100vh - 70px);
    overflow-y: auto;
    background: white !important;
    padding: 2rem;
    /* box-sizing이 없으면 padding 2rem(64px)이 width에 더해져 화면 밖으로 밀린다.
       모든 관리 탭이 오른쪽 64px만큼 잘려 보이던 원인. */
    box-sizing: border-box;
}

/* ========== 콘텐츠 섹션 ========== */
.content-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
    padding: 0 1rem;  /* ✅ 기본 좌우 여백 */
}

/* ✅ 모바일에서 콘텐츠 여백 */
@media (max-width: 768px) {
    .content-section {
        padding: 0.5rem;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 페이지 헤더 ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.page-header h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--gray-900);
    margin: 0;
}

/* ========== 콘텐츠 헤더 ========== */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-6);
    gap: var(--spacing-4);
}

.content-header h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--gray-900);
    margin: 0;
}

.content-actions {
    display: flex;
    gap: var(--spacing-3);
    flex-wrap: wrap;
}

/* ========== 그리드 시스템 ========== */
.grid {
    display: grid;
    gap: var(--spacing-6);
}

.grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-cols-auto {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ========== Flexbox 유틸리티 ========== */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-start {
    align-items: flex-start;
}

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

.items-end {
    align-items: flex-end;
}

.justify-start {
    justify-content: flex-start;
}

.justify-center {
    justify-content: center;
}

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

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

.gap-1 { gap: var(--spacing-1); }
.gap-2 { gap: var(--spacing-2); }
.gap-3 { gap: var(--spacing-3); }
.gap-4 { gap: var(--spacing-4); }
.gap-6 { gap: var(--spacing-6); }
.gap-8 { gap: var(--spacing-8); }

/* ========== 컨테이너 ========== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-6);
}

.container-sm {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--spacing-6);
}

.container-lg {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 var(--spacing-6);
}

/* ========== 섹션 ========== */
.section {
    padding: var(--spacing-12) 0;
}

.section-title {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--spacing-8);
    text-align: center;
}

/* ========================================
   반응형 - 태블릿 (1024px 이하)
   ======================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main-area {
        margin-left: 220px;
        width: calc(100% - 220px);
        padding: 1.5rem;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   반응형 - 태블릿 & 갤럭시 폴드 펼침 (769px ~ 1200px)
   ======================================== */
@media (min-width: 769px) and (max-width: 1200px) {
    /* 사이드바 너비 축소 */
    .sidebar {
        width: 200px;
    }
    
    .main-area {
        margin-left: 200px;
        width: calc(100% - 200px);
        padding: 1.5rem;
    }
    
    /* 그리드 최적화 */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 햄버거 메뉴 숨김 */
    .hamburger-btn,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    /* 사이드바 항상 표시 */
    .sidebar {
        transform: translateX(0) !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}

/* ========================================
   반응형 - 모바일 (768px 이하)
   ======================================== */
@media (max-width: 768px) {
    /* 헤더 */
    .app-header {
        height: 56px !important; /* 60px → 56px */
        padding: 0 0.5rem !important; /* 0.75rem → 0.5rem */
        justify-content: space-between !important;
        display: flex !important;
        align-items: center !important;
    }
    
    .header-left {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 0.25rem !important; /* 0.4rem → 0.25rem 더 좁게! */
        margin-right: auto !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
    
    .header-logo {
        width: 32px !important; /* 34px → 32px */
        height: 32px !important;
        margin: 0 !important;
    }
    
    .header-left h1 {
        font-size: 15px !important; /* 16px → 15px */
        margin: 0 !important;
        padding: 0 !important;
        font-weight: 600 !important;
    }
    
    .header-right {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 0.5rem !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        padding-right: 0 !important;
    }
    
    .user-name {
        display: none !important;
    }
    
    .btn-logout {
        padding: 0.35rem 0.75rem !important; /* 더 작게 */
        font-size: 12px !important; /* 13px → 12px */
    }
    
    /* 햄버거 메뉴 - 위치 및 크기 조정 */
    .hamburger-btn {
        display: flex !important;
        order: -1 !important;
        margin-right: 0.25rem !important; /* 0.4rem → 0.25rem */
        margin-left: 0 !important;
        align-self: center !important;
        flex-shrink: 0 !important;
        width: 36px !important; /* 40px → 36px */
        height: 36px !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important;
    }
    
    /* 레거시 지원 - mobile-menu-toggle */
    .mobile-menu-toggle {
        display: flex !important;
        order: -1 !important;
        margin-right: 0.25rem !important; /* 0.4rem → 0.25rem */
        margin-left: 0 !important;
        align-self: center !important;
        flex-shrink: 0 !important;
        width: 36px !important; /* 40px → 36px */
        height: 36px !important;
        font-size: 18px !important; /* 20px → 18px */
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }
    
    /* 사이드바 - 기본 숨김 */
    .sidebar {
        top: 56px !important; /* 60px → 56px */
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }
    
    /* 사이드바 열림 */
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* 오버레이 표시 */
    .sidebar-overlay {
        display: block;
    }
    
    /* 앱 컨테이너 */
    .app-container {
        padding-top: 60px;
    }
    
    /* 메인 영역 - 전체 너비 */
    .main-area {
        margin-left: 0 !important;
        width: 100% !important;
        height: calc(100vh - 56px) !important; /* 60px → 56px */
        padding: 0.75rem !important; /* 1rem → 0.75rem */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* 메뉴 아이템 */
    .menu-item {
        padding: 0.875rem 1rem;
        font-size: 15px;
    }
    
    .menu-icon {
        font-size: 20px;
        width: 24px;
    }
    
    /* 페이지 헤더 */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
        padding: 8px 12px 0 12px !important;
    }
    
    .page-header h2 {
        font-size: 18px !important;
        margin: 0 !important;
    }
    
    /* 버튼 크기 축소 */
    .btn-primary {
        padding: 0.5rem 1rem !important;
        font-size: 13px !important;
        height: 36px !important;
    }
    
    /* 페이지 헤더 내 버튼 - 더 작게 */
    .page-header .btn-primary {
        height: 28px !important;
        min-height: 28px !important;
        padding: 0 12px !important;
        font-size: 12px !important;
    }
    
    /* 그리드 */
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 {
        grid-template-columns: repeat(1, 1fr);
    }
    
    /* 콘텐츠 헤더 */
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .content-actions {
        width: 100%;
    }
    
    .content-actions button {
        flex: 1;
        min-width: auto;
    }
    
    /* 사용자 이름 숨김 */
    .user-name {
        display: none;
    }
    
    /* 로그아웃 버튼 */
    .btn-logout {
        padding: 0.5rem 1rem;
        font-size: 13px;
    }
}

/* ========================================
   반응형 - 작은 모바일 (480px 이하)
   ======================================== */
@media (max-width: 480px) {
    /* 헤더 */
    .app-header {
        height: 56px;
        padding: 0 0.75rem;
    }
    
    .header-left h1 {
        font-size: 16px;
    }
    
    .header-left img {
        /* 가로형 로고(530×140) — 정사각 강제 시 찌그러짐, 비율 유지 */
        height: 30px !important;
        width: auto !important;
        margin-right: 0.5rem !important;
    }
    
    /* 햄버거 메뉴 */
    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    
    /* 사이드바 */
    .sidebar {
        top: 56px;
        width: 260px;
    }
    
    /* 앱 컨테이너 */
    .app-container {
        padding-top: 56px;
    }
    
    /* 메인 영역 */
    .main-area {
        height: calc(100vh - 56px);
        padding: 0.75rem;
    }
    
    /* 메뉴 */
    .main-menu {
        padding: 1rem 0.75rem;
    }
    
    .menu-item {
        padding: 0.75rem 0.875rem;
        font-size: 14px;
        gap: 0.625rem;
    }
    
    .menu-icon {
        font-size: 18px;
        width: 20px;
    }
    
    /* 페이지 헤더 */
    .page-header h2 {
        font-size: 1.25rem;
    }
    
    /* 로그아웃 버튼 */
    .btn-logout {
        padding: 0.375rem 0.75rem;
        font-size: 12px;
    }
}

/* ========================================
   반응형 - 초소형 모바일 (360px 이하)
   ======================================== */
@media (max-width: 360px) {
    .app-header {
        padding: 0 0.5rem;
    }
    
    .header-left h1 {
        font-size: 14px;
    }
    
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
        font-size: 20px;
        margin-right: 0.25rem;
    }
    
    .sidebar {
        width: 240px;
    }
    
    .main-area {
        padding: 0.625rem;
    }
    
    .btn-logout {
        padding: 0.375rem 0.625rem;
        font-size: 11px;
    }
}

/* ========================================
   터치 디바이스 최적화
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* 터치 타겟 최소 44px */
    .hamburger-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .mobile-menu-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    
    .menu-item {
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .menu-item:active {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .btn-logout {
        min-height: 40px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .btn-logout:active {
        background: var(--gray-300);
    }
    
    /* 스크롤 개선 */
    .sidebar,
    .main-area {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* ========================================
   가로 모드 최적화
   ======================================== */
@media (max-height: 600px) and (orientation: landscape) {
    .app-header {
        height: 50px;
    }
    
    .app-container {
        padding-top: 50px;
    }
    
    .sidebar {
        top: 50px;
    }
    
    .main-area {
        height: calc(100vh - 50px);
        padding: 1rem;
    }
    
    .menu-item {
        padding: 0.625rem 0.875rem;
        margin-bottom: 0.25rem;
    }
}

/* ========================================
   접근성 개선
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-overlay,
    .content-section {
        transition: none;
        animation: none;
    }
}

/* 고대비 모드 */
@media (prefers-contrast: high) {
    .sidebar {
        border-right-width: 2px;
    }
    
    .menu-item.active {
        outline: 2px solid white;
    }
}

/* ========================================
   사이드바 제어를 위한 JavaScript 헬퍼 클래스
   ======================================== */
body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    body.sidebar-open .sidebar-overlay {
        display: block;
    }
}

/* ============================================
   📱 모바일 컴팩트 버튼 (갤럭시 폴드 등)
   대시보드 인박스 · 회차 마감 카드 · 예약접수 상단 — 높이/여백만 축소, 기능 동일
   (인라인 스타일을 이겨야 해서 !important 사용)
   ============================================ */
/* 상단바 PC보기/로그아웃 — 터치 최적화 규칙(min-height 40px)이 과하게 키우던 것 축소 */
.header-right #viewModeToggle,
.header-right .btn-logout {
  height: 30px !important; min-height: 30px !important; max-height: 30px !important;
  padding: 0 12px !important; font-size: 12px !important;
  display: inline-flex !important; align-items: center !important; white-space: nowrap !important;
}

@media (max-width: 920px) {
  /* 예약접수 상단 액션: 월메모/날짜삭제/가져오기/회차마감/새예약
     — 기존 모바일 규칙이 옛 클래스(.btn-primary)만 겨냥해 .header-btn엔 안 먹던 것 보정 */
  .header-buttons .header-btn {
    height: 30px !important; min-height: 30px !important; max-height: 30px !important;
    padding: 0 10px !important; font-size: 12px !important;
    display: inline-flex !important; align-items: center !important; white-space: nowrap !important;
  }
  /* 날짜 내비게이션 (이전/다음/오늘/할일 + 날짜칸) */
  .date-navigation button, .date-navigation .date-nav-btn {
    height: 32px !important; min-height: 32px !important;
    padding: 0 10px !important; font-size: 12.5px !important; white-space: nowrap !important;
  }
  .date-navigation input[type="date"] {
    height: 32px !important; padding: 0 8px !important; font-size: 13px !important;
  }

  /* 대시보드 신규 예약 인박스: 전체 승인/삭제/새로고침 + 카드의 승인/시트복사/삭제 */
  #newOrderInboxBox .inbox-actions button {
    padding: 5px 4px !important; font-size: 11.5px !important; min-height: 0 !important;
  }
  #newOrderInboxBox .inbox-mobile-view button {
    padding: 5px 8px !important; font-size: 12px !important; min-height: 0 !important;
  }
  #newOrderInboxBox select {
    height: 32px !important; padding: 2px 8px !important; font-size: 12px !important;
  }

  /* 예약접수 상단: 버튼 4개(월메모/날짜삭제/회차마감/새예약)를 한 줄 4열로
     — 가져오기 제거 후 3열 격자에선 새예약만 둘째 줄로 밀렸다 (2026-08-31 지시) */
  .header-top { flex-wrap: wrap !important; row-gap: 8px !important; }
  .header-buttons {
    display: grid !important; grid-template-columns: repeat(4, 1fr) !important;
    gap: 5px !important; width: 100% !important; margin: 0 !important;
  }
  .header-buttons .header-btn {
    width: 100% !important; justify-content: center !important; font-size: 11.5px !important;
    padding: 0 2px !important; overflow: hidden !important; text-overflow: ellipsis !important;
  }

  /* 회차 마감 카드: 액션 4개(선택 마감/옵션 정리/뱃지 갱신/인원 재계산)를 2×2 격자로 */
  #stockCloseCard .sc-actions {
    display: grid !important; grid-template-columns: 1fr 1fr !important;
    gap: 6px !important; width: 100% !important;
  }
  #stockCloseCard .sc-actions button { width: 100% !important; text-align: center !important; }

  /* 대시보드 회차 마감 카드: 날짜 내비·선택 회차 마감·정리/뱃지/재계산·모두 선택 */
  #stockCloseCard button {
    padding: 5px 9px !important; font-size: 12px !important;
    min-height: 0 !important; white-space: nowrap !important;
  }
  /* 날짜 내비(.sc-navctl)는 제외 — 화살표·오늘 버튼과 높이를 맞추는 규칙이 이깁니다 */
  #stockCloseCard input[type="date"]:not(.sc-navctl), #stockCloseCard select {
    height: 32px !important; padding: 2px 8px !important; font-size: 13px !important;
  }
}
