:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 60px;
    --header-height: 55px;
    --primary-color: #3f6ad8;
    --secondary-color: #6c757d;
    --success-color: #3ac47d;
    --info-color: #16aaff;
    --warning-color: #f7b924;
    --danger-color: #d92550;
    --light-bg: #f1f4f6;
    --sidebar-bg: #fff;
    --border-color: #e9ecef;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.88rem;
    background-color: var(--light-bg);
    color: #495057;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    box-shadow: 0 0.46875rem 2.1875rem rgba(4,9,20,0.03), 0 0.9375rem 1.40625rem rgba(4,9,20,0.03), 0 0.25rem 0.53125rem rgba(4,9,20,0.05), 0 0.125rem 0.1875rem rgba(4,9,20,0.03);
    transition: all 0.2s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Logo Area */
.logo-area {
    height: var(--header-height);
    padding: 0 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    /* background: linear-gradient(135deg, #3f6ad8 0%, #3ac47d 100%); */
}

.logo {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
}

.logo-title {
    margin-left: 0px;
    height: 20px;
    width: 60px;
}

.logo-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 2px;
}

.logo-icon i {
    font-size: 16px;
}

.sidebar.collapsed .logo-title {
    display: none;
}

/* Menu Scrollable Area */
.sidebar-menu-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 0;
    scrollbar-gutter: stable;
}

.sidebar-menu-wrapper {
    /* Firefox 브라우저를 위한 설정 */
    scrollbar-width: none;
    /* IE/Edge 브라우저를 위한 설정 */
    -ms-overflow-style: none;
}

/* Chrome, Safari, Edge 등 Webkit 기반 브라우저를 위한 설정 */
.sidebar-menu-wrapper::-webkit-scrollbar {
    display: none; /* 스크롤바를 보이지 않게 숨깁니다. */
}

.sidebar-menu-wrapper::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu-wrapper::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 4px;
}

/* Menu Section */
.menu-section {
    padding: 0 10px;
    margin-bottom: 20px;
}

.menu-section-title {
    color: #3f6ad8;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 5px 10px;
    margin-bottom: 5px;
    position: relative;
}

.sidebar.collapsed .menu-section-title {
    text-align: center;
    padding: 5px 0;
}

.sidebar.collapsed .menu-section-title span {
    display: none;
}

.sidebar.collapsed .menu-section-title::after {
    content: '•••';
    display: block;
    text-align: center;
    font-size: 1rem;
    line-height: 1;
    letter-spacing: 2px;
}

/* Menu Items */
.menu-item {
    margin-bottom: 2px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.88rem;
}

.menu-link:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

.menu-link.active {
    background: rgba(63,106,216,0.1);
    color: var(--primary-color);
}

.menu-link.has-arrow::after {
    content: '\F282';
    font-family: 'Bootstrap-icons';
    position: absolute;
    right: 10px;
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}

.menu-link.collapsed::after {
    transform: rotate(-90deg);
}

.sidebar.collapsed .menu-link.has-arrow::after {
    display: none;
}

.menu-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 7px;
    /* border-radius: 30%; */
    /* background: linear-gradient(135deg, #3f6ad8 0%, #3ac47d 100%); */
    font-size: 1.2rem;
    flex-shrink: 0;
}


.menu-icon.icon-gradient-success {
    /* background: linear-gradient(135deg, #3ac47d 0%, #16aaff 100%); */
}

.menu-icon.icon-gradient-warning {
    /* background: linear-gradient(135deg, #f7b924 0%, #d92550 100%); */
}

.menu-icon.icon-gradient-info {
    /* background: linear-gradient(135deg, #16aaff 0%, #3f6ad8 100%); */
}

.menu-icon.icon-gradient-danger {
    /* background: linear-gradient(135deg, #d92550 0%, #f7b924 100%); */
}

.menu-text {
    flex: 1;
}

.sidebar.collapsed .menu-text {
    display: none;
}

.menu-badge {
    background: var(--danger-color);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    margin-right: 5px;
}

.sidebar.collapsed .menu-badge {
    display: none;
}

/* Submenu */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.submenu.show {
    max-height: 500px;
}

.submenu .menu-link {
    padding-left: 48px;
    font-size: 0.85rem;
}

.submenu .menu-link::before {
    content: '';
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #adb5bd;
}

.submenu .menu-link:hover::before {
    background: var(--primary-color);
    width: 6px;
    height: 6px;
}

.sidebar.collapsed .submenu {
    display: none;
}

/* Dotted Separator */
.menu-separator {
    border: none;
    border-top: 1px dotted #dee2e6;
    margin: 15px 25px;
}

.sidebar.collapsed .menu-separator {
    margin: 15px 10px;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: white;
    box-shadow: 0 0.46875rem 2.1875rem rgba(4,9,20,0.03), 0 0.9375rem 1.40625rem rgba(4,9,20,0.03);
    display: flex;
    align-items: center;
    padding: 0 15px;
    transition: left 0.2s ease;
    z-index: 999;
}

.sidebar.collapsed ~ .main-wrapper .header {
    left: var(--sidebar-collapsed-width);
}

.header-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.toggle-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 15px;
}

.toggle-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.search-wrapper {
    position: relative;
    max-width: 300px;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 6px 35px 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(63,106,216,0.1);
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.9rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    color: var(--secondary-color);
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
}

.header-btn .badge-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: var(--danger-color);
    border-radius: 50%;
    border: 2px solid white;
}

.user-menu {
    display: flex;
    align-items: center;
    padding: 4px 12px 4px 4px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.user-menu:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 5px;
}

/* Main Content */
.main-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s ease, width 0.2s ease;
    padding-top: var(--header-height); 
}

.sidebar.collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

.main-content {
    padding: 20px;
    padding-top: var(--header-height);
    flex: 1; /* 남은 공간을 모두 차지하도록 설정 */
    display: flex;
    position: relative;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* --- 콘텐츠 래퍼 --- */
.content-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* 평소엔 모두 숨김 */
    padding: 20px;
    overflow: auto; /* 내용이 길어지면 스크롤 */
}
.content-wrapper.active {
    display: block; /* active 클래스가 붙은 영역만 보임 */
}

/* --- Iframe 래퍼 및 로딩 --- */
#iframeContent.content-wrapper {
    padding: 0; /* iframe은 패딩 없이 꽉 채움 */
}
.iframe-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: none;
}
.iframe-loading.show {
    display: block;
}
#contentFrame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.content-area {
    flex: 1; /* 헤더를 제외한 나머지 공간을 모두 차지 */
    position: relative;
    padding: 20px;
    overflow-y: auto; /* 필요 시 스크롤 */
}

/* iframe wrapper는 content-area를 기준으로 100% 크기를 가집니다. */
.iframe-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px; /* content-area의 패딩과 동일하게 적용 */
}

/* Page Header */
.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 400;
    color: #3f6ad8;
    margin-bottom: 5px;
}

.page-subtitle {
    color: #6c757d;
    font-size: 0.85rem;
}

/* Small Stat Cards */
.mini-stat-card {
    background: white;
    border-radius: 4px;
    padding: 15px;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.mini-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

.mini-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3f6ad8 0%, #3ac47d 100%);
}

.mini-stat-card.gradient-success::before {
    background: linear-gradient(90deg, #3ac47d 0%, #16aaff 100%);
}

.mini-stat-card.gradient-warning::before {
    background: linear-gradient(90deg, #f7b924 0%, #ff6b6b 100%);
}

.mini-stat-card.gradient-info::before {
    background: linear-gradient(90deg, #16aaff 0%, #3f6ad8 100%);
}

.mini-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mini-stat-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #3f6ad8 0%, #3ac47d 100%);
    color: white;
}

.mini-stat-icon.bg-success {
    background: linear-gradient(135deg, #3ac47d 0%, #16aaff 100%);
}

.mini-stat-icon.bg-warning {
    background: linear-gradient(135deg, #f7b924 0%, #ff6b6b 100%);
}

.mini-stat-icon.bg-info {
    background: linear-gradient(135deg, #16aaff 0%, #3f6ad8 100%);
}

.mini-stat-content {
    flex: 1;
    text-align: right;
}

.mini-stat-label {
    color: #6c757d;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.mini-stat-value {
    font-size: 1.5rem;
    font-weight: 300;
    color: #495057;
    line-height: 1;
}

/* Content Cards */
.content-card {
    background: white;
    border-radius: 4px;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.content-card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    margin: 0;
}

.card-actions {
    display: flex;
    gap: 5px;
}

.card-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #adb5bd;
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.card-action-btn:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

.card-body {
    padding: 20px;
}

/* Chart placeholder */
.chart-container {
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 4px;
    color: #6c757d;
}

/* Small badges and pills */
.badge-pill {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .header {
        left: 0;
    }
    
    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }
    
    .search-wrapper {
        display: none;
    }
    
    .user-name {
        display: none;
    }

    .sidebar-header .sidebar-toggle {
        display: none;
    }
}

/* --- 사이드바 개선 코드 (최종 완성본) --- */

/* 1. 접혔을 때 링크(버튼) 모양을 아이콘에 맞게 네모난 버튼처럼 만듭니다 */
.sidebar.collapsed .menu-link {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    margin: 4px auto;
    padding: 0;
    justify-content: center;
}

/* 2. 접혔을 때 아이콘의 불필요한 오른쪽 여백을 제거합니다 */
.sidebar.collapsed .menu-icon {
    margin-right: 0;
}

/* 3. 마우스 오버 시 확장 기능 (데스크탑 전용) */
@media (min-width: 769px) {

    .sidebar.collapsed:hover {
        width: var(--sidebar-width);
        box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    }

    .sidebar.collapsed:hover .menu-link {
        width: auto;
        height: auto;
        border-radius: 4px;
        padding: 8px 10px;
        justify-content: flex-start;
    }

    .sidebar.collapsed:hover .menu-icon {
        margin-right: 10px;
    }
    
    .sidebar.collapsed:hover .logo-title,
    .sidebar.collapsed:hover .menu-text,
    .sidebar.collapsed:hover .menu-badge,
    .sidebar.collapsed:hover .menu-link.has-arrow::after,
    .sidebar.collapsed:hover .submenu,
    .sidebar.collapsed:hover .menu-section-title span {
        display: block;
    }

    .sidebar.collapsed:hover .menu-section-title::after {
        display: none;
    }

    .sidebar.collapsed:hover .menu-section-title {
        text-align: left;
        padding: 5px 10px;
    }

    .sidebar.collapsed:hover .submenu .menu-link {
        padding-left: 48px;
    }
}

/* --- 다크 모드 테마 --- */
[data-bs-theme="dark"] {
    /* 기본 배경/글자/테두리 색상 재정의 */
    --light-bg: #16191c;
    --sidebar-bg: #1c2024;
    --border-color: #32383e;
    
    /* 기본 텍스트 색상을 밝게 변경 */
    body {
        color: #adb5bd;
    }

    /* 헤더, 카드 등 흰색 배경 요소들을 어둡게 변경 */
    .header,
    .content-card,
    .mini-stat-card {
        background-color: var(--sidebar-bg);
        box-shadow: none;
    }

    /* 카드 제목 등 일부 텍스트 색상도 밝게 변경 */
    .card-title,
    .mini-stat-value {
        color: #e9ecef;
    }

    /* 메뉴 링크 텍스트 색상 변경 */
    .menu-link {
        color: #adb5bd;
    }
    
    /* 메뉴 링크 호버/활성 상태 색상 변경 */
    .menu-link:hover {
        background: rgba(255, 255, 255, 0.05);
        color: white;
    }

    .menu-link.active {
        background: rgba(63,106,216,0.2);
        color: white;
    }
    
    /* 검색창 스타일 변경 */
    .search-input {
        background-color: #212529;
        border-color: var(--border-color);
        color: white;
    }

    /* 헤더 버튼과 사용자 메뉴 스타일 추가 */
    .header-btn,
    .user-menu {
        background-color: transparent;
        color: #adb5bd;
    }

    .header-btn:hover,
    .user-menu:hover {
        background-color: rgba(255, 255, 255, 0.1);
        border-color: #495057;
        color: white;
    }
}

/* --- 사용자 드롭다운 메뉴(로그인이후) --- */
.user-dropdown-wrapper {
    position: relative; /* 드롭다운 메뉴의 기준점이 됩니다. */
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px); /* 사용자 메뉴 바로 아래에 위치 */
    right: 0;
    min-width: 180px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 8px;
    z-index: 1001;

    /* 평소에는 숨겨져 있다가... */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease-in-out;
}

/* .show 클래스가 추가되면 나타납니다. */
.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
}

.dropdown-item i {
    margin-right: 10px;
    font-size: 1rem;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

/* --- 다크 모드 스타일 --- */
[data-bs-theme="dark"] .user-dropdown-menu {
    background-color: #2a2e34; /* 어두운 배경색 */
    border-color: #32383e;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #adb5bd;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* 이미지가 아이콘 영역에 맞게 크기 조절 */
.logo-icon img {
    width: 24px; /* 아이콘 크기에 맞게 조절 */
    height: 24px;
}

/* 평소(라이트 모드)에는 다크 모드용 로고를 숨깁니다. */
.dark-mode-item {
    display: none;
}
.light-mode-item {
    display: block;
}

/* 다크 모드가 활성화되면 (html 태그에 data-bs-theme="dark" 속성이 있으면) */
[data-bs-theme="dark"] .dark-mode-item {
    display: block; /* 다크 모드용 로고를 보여줍니다. */
}
[data-bs-theme="dark"] .light-mode-item {
    display: none;  /* 라이트 모드용 로고를 숨깁니다. */
}

/* ===== 업그레이드된 추가 CSS ===== */

/* 서비스 헤더 - 상단 헤더 아래 위치 */
.service-header {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    padding: 10px 20px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 998;
    transition: left 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sidebar.collapsed ~ .main-wrapper .service-header {
    left: var(--sidebar-collapsed-width);
}

.service-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary-color);
    margin: 0;
}

/* 콘텐츠 래퍼 위치 조정 */
.content-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: auto;
}

.content-wrapper.active {
    display: block;
}

/* iframe 사용 시 서비스 헤더 공간 확보 */
#iframeContent.content-wrapper.with-header {
    padding-top: var(--header-height); 
}

#tabsContainer.with-header {
    padding-top: 45px;
}

/* Rhymix 콘텐츠는 패딩 유지 */
#rhymixContent.content-wrapper {
    padding: 20px;
}

/* iframe 콘텐츠는 패딩 제거 */
#iframeContent.content-wrapper {
    padding: 0;
}

/* 서비스 헤더 액션 버튼 */
.service-header-actions {
    display: flex;
    gap: 8px;
}

.service-header .btn-sm {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: white;
    color: #6c757d;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.service-header .btn-sm:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* 반응형 - 모바일에서 서비스 헤더 조정 */
@media (max-width: 768px) {
    .service-header {
        left: 0;
        padding: 8px 15px;
    }
    
    .service-title {
        font-size: 1rem;
    }
    
    .service-header-actions {
        display: none; /* 모바일에서는 액션 버튼 숨김 */
    }

    #iframeContent.content-wrapper.with-header {
        padding-top: 35px;
    }
}

/* 다크모드에서 서비스 헤더 버튼 */
[data-bs-theme="dark"] .service-header .btn-sm {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
    color: #adb5bd;
}

[data-bs-theme="dark"] .service-header .btn-sm:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.service-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
}

/* 뷰 모드 스위처 개선 */
.view-mode-switcher {
    display: flex;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 2px;
    margin-right: 8px;
}

.view-mode-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6c757d;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.view-mode-btn:hover {
    color: var(--primary-color);
}

.view-mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* 탭 컨테이너 개선 */
.tabs-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* 기본적으로 숨김 */
    flex-direction: column;
}

.tabs-container.active {
    display: flex; /* active 클래스가 있을 때만 표시 */
}

/* with-header 클래스가 있을 때 패딩 추가 */
.tabs-container.with-header {
    padding-top: 45px;
}

.tabs-header {
    display: flex;
    align-items: center;
    background: white;
    border-bottom: 2px solid #e9ecef;
    padding: 0 10px;
    height: 42px;
    overflow-x: auto;
    scrollbar-width: thin;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0; /* 높이 고정 */
}

.tabs-header::-webkit-scrollbar {
    height: 3px;
}

.tabs-header::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* 탭 버튼 개선 */
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    position: relative;
    min-width: 100px;
    max-width: 200px;
}

.tab-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.tab-btn:hover {
    background: #f8fafc;
    color: #334155;
}

.tab-btn.active {
    background: #f8fafc;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn .close-tab {
    font-size: 0.65rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: auto;
    padding: 2px;
    flex-shrink: 0;
}

.tab-btn:hover .close-tab {
    opacity: 0.5;
}

.tab-btn .close-tab:hover {
    opacity: 1;
    color: var(--danger-color);
}

/* 탭 콘텐츠 영역 */
.tabs-content {
    flex: 1;
    position: relative;
    background: #f8fafc;
    overflow: hidden; /* 스크롤 방지 */
}

.tab-pane {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.tab-pane.active {
    display: block;
}

.tab-pane iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* 탭 내부 로딩 */
.tab-pane .iframe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tab-pane .iframe-loading.show {
    opacity: 1;
    visibility: visible;
}

/* 로딩 인디케이터 개선 */
.iframe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.iframe-loading.show {
    opacity: 1;
    visibility: visible;
}

.iframe-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

.iframe-loading p {
    margin-top: 15px;
    color: #64748b;
    font-size: 0.9rem;
}

/* iframe 트랜지션 */
#contentFrame {
    transition: opacity 0.3s ease;
}

/* 반응형 탭 */
@media (max-width: 768px) {
    .service-actions {
        display: none !important;
    }
    
    .tabs-header {
        height: 38px;
    }
    
    .tab-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: 80px;
    }
}

/* 다크모드 지원 */
[data-bs-theme="dark"] .service-header {
    background: var(--sidebar-bg);
    border-bottom-color: var(--border-color);
}

[data-bs-theme="dark"] .service-title {
    color: #e9ecef;
}

[data-bs-theme="dark"] .view-mode-switcher {
    background: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .view-mode-btn.active {
    background: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .tabs-header {
    background: var(--sidebar-bg);
    border-bottom-color: var(--border-color);
}

[data-bs-theme="dark"] .tab-btn {
    color: #94a3b8;
}

[data-bs-theme="dark"] .tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e0;
}

[data-bs-theme="dark"] .tab-btn.active {
    background: rgba(63, 106, 216, 0.1);
    color: white;
}

[data-bs-theme="dark"] .tabs-content {
    background: #1a1d21;
}

[data-bs-theme="dark"] .iframe-loading {
    background: rgba(28, 32, 36, 0.95);
}

[data-bs-theme="dark"] .iframe-loading p {
    color: #94a3b8;
}

/* 애니메이션 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-btn {
    animation: slideIn 0.3s ease;
}

/* 헤더 버튼 개선 */
.header-btn {
    position: relative;
    overflow: hidden;
}

.header-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(63, 106, 216, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.header-btn:hover::before {
    width: 100%;
    height: 100%;
}

/* 사이드바 메뉴 활성화 표시 개선 */
.menu-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background: var(--primary-color);
    border-radius: 0 3px 3px 0;
}

/* 서브메뉴 애니메이션 개선 */
.submenu {
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.submenu.show {
    animation: slideDown 0.3s ease;
}

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

/* 툴팁 스타일 */
.tooltip {
    font-size: 0.75rem;
}

.tooltip-inner {
    padding: 6px 12px;
    border-radius: 6px;
}

/* 포커스 스타일 개선 */
.header-btn:focus,
.view-mode-btn:focus,
.tab-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 스크롤바 스타일링 */
.content-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.content-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.content-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.content-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

[data-bs-theme="dark"] .content-wrapper::-webkit-scrollbar-track {
    background: #1e293b;
}

[data-bs-theme="dark"] .content-wrapper::-webkit-scrollbar-thumb {
    background: #475569;
}

[data-bs-theme="dark"] .content-wrapper::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}