/* --- NEW: Font Face Definitions --- */
@font-face {
    font-family: 'KoPubWorld Dotum';
    font-weight: 300; /* Light */
    src: url('../fonts/KoPubWorld Dotum Light.ttf') format('truetype');
}

@font-face {
    font-family: 'KoPubWorld Dotum';
    font-weight: 500; /* Medium */
    src: url('../fonts/KoPubWorld Dotum Medium.ttf') format('truetype');
}

@font-face {
    font-family: 'KoPubWorld Dotum';
    font-weight: 700; /* Bold */
    src: url('../fonts/KoPubWorld Dotum Bold.ttf') format('truetype');
}
/* --- END: Font Face Definitions --- */


/* General and Body Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    /* UPDATED: Font Family with KoPubWorld Dotum as primary */
    font-family: 'KoPubWorld Dotum', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 500; /* Set Medium as the default weight */
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0f1419 100%);
    color: #e8eaf6;
    min-height: 100vh;
}

/* Container for Centering Content (like Login) */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Login Card */
.login-card {
    background: rgba(26, 31, 58, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5),
                0 0 80px rgba(139, 92, 246, 0.15);
}

.logo h1 {
    color: #ffffff;
    font-size: 28px;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 700; /* Use Bold font */
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #e1e1e1;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: rgba(70, 130, 180, 0.6);
}

/* Button Styles */
.login-btn, .btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 700; /* Use Bold font */
    cursor: pointer;
    margin: 10px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* Quick Date Selection Buttons */
.quick-date-btn {
    padding: 10px 20px;
    background: rgba(139, 92, 246, 0.2);
    border: 2px solid rgba(139, 92, 246, 0.4);
    border-radius: 8px;
    color: #c4b5fd;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.quick-date-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.6);
    transform: translateY(-2px);
}

.quick-date-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border-color: #8b5cf6;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.login-btn:hover, .btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6);
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.btn-secondary, .btn-success, .btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: white;
    transition: background-color 0.2s ease-in-out;
}

.btn-secondary { background-color: #6b7280; }
.btn-secondary:hover { background-color: #4b5563; }
.btn-success { background-color: #16a085; }
.btn-success:hover { background-color: #138d75; }
.btn-danger { background-color: #e74c3c; }
.btn-danger:hover { background-color: #c0392b; }

/* Sidebar Styles */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    background: linear-gradient(180deg, rgba(26, 31, 58, 0.98) 0%, rgba(15, 20, 41, 0.98) 100%);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(139, 92, 246, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed {
    transform: translateX(-250px);
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    text-align: center;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, transparent 100%);
}

.sidebar-header h3 {
    color: #ffffff;
    margin: 0;
    font-weight: 700; /* Use Bold font */
    font-size: 20px;
    line-height: 1.4;
}

.sidebar-toggle {
    position: fixed;
    left: 250px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border: none;
    color: white;
    padding: 12px 10px;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    box-shadow: 2px 0 15px rgba(139, 92, 246, 0.4);
}

.sidebar-toggle:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    box-shadow: 4px 0 20px rgba(139, 92, 246, 0.6);
    transform: translateY(-50%) translateX(3px);
}

.sidebar.collapsed + .sidebar-toggle {
    left: 0;
}

.sidebar-toggle:hover {
    background: rgba(70, 130, 180, 1);
}

/* Navigation Menu */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.nav-item {
    border-bottom: 1px solid rgba(70, 130, 180, 0.2);
}

.nav-link {
    display: block;
    padding: 15px 20px;
    color: #e8eaf6;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.2) 0%, transparent 100%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.nav-link:hover::before {
    width: 100%;
}

.nav-link:hover {
    color: #ffffff;
    padding-left: 25px;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.3) 0%, transparent 100%);
    border-left: 3px solid #8b5cf6;
    color: #ffffff;
    font-weight: 700;
}

/* Main Content Area */
.main-content {
    transition: margin-left 0.3s ease;
    margin-left: 250px;
    flex: 1;
    padding: 20px;
}

.main-content.expanded {
    margin-left: 0;
}

/* Dashboard & Sections */
.dashboard {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard:first-of-type {
    display: block;
}

.section-card {
    background: rgba(26, 31, 58, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-card:hover {
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.2);
    transform: translateY(-2px);
}

.section-title {
    color: #ffffff;
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 700;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(139, 92, 246, 0.3);
    padding-bottom: 10px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.5) transparent;
}

.tabs-container::-webkit-scrollbar {
    height: 6px;
}

.tabs-container::-webkit-scrollbar-track {
    background: transparent;
}

.tabs-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.5);
    border-radius: 3px;
}

.tabs-container::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.7);
}

.tab-button {
    padding: 12px 24px;
    background: rgba(26, 31, 58, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px 12px 0 0;
    color: #e8eaf6;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: none;
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-button::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6 0%, #6366f1 100%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-button:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

.tab-button:hover::after {
    width: 100%;
}

.tab-button.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(99, 102, 241, 0.3) 100%);
    border-color: rgba(139, 92, 246, 0.5);
    color: #fff;
    font-weight: 700;
}

.tab-button.active::after {
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6 0%, #6366f1 100%);
}

.add-sheet-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(99, 102, 241, 0.3) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 10px;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: auto;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

.add-sheet-btn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.5) 0%, rgba(99, 102, 241, 0.5) 100%);
    border-color: rgba(139, 92, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* File Upload Section */
.upload-section {
    background: linear-gradient(135deg, rgba(26, 31, 58, 0.4) 0%, rgba(15, 20, 41, 0.4) 100%);
    backdrop-filter: blur(10px);
    border: 2px dashed rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    padding: 40px;
    margin: 20px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.upload-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-section:hover::before {
    opacity: 1;
}

.upload-section:hover {
    border-color: rgba(139, 92, 246, 0.6);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.2);
}

.upload-section.drag-over {
    border-color: #a78bfa;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(99, 102, 241, 0.3) 100%);
    transform: scale(1.02);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.4);
}

.file-input {
    display: none;
}

.file-label {
    display: inline-block;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    padding: 12px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    position: relative;
    z-index: 1;
}

.file-label:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.drag-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin-top: 10px;
}

.error-message {
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
}

/* Date Input Style */
input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 40px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
    padding-left: 10px;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    overflow-x: auto;
    display: block;
}

.results-table table {
    width: 100%;
    min-width: 1200px;
}

.results-table th,
.results-table td {
    border: 1px solid rgba(70, 130, 180, 0.3);
    padding: 12px 15px;
    text-align: left;
    white-space: nowrap;
}

/* NEW: Style for material name cell */
.material-name-cell {
    font-family: monospace;
    font-size: 12px; /* Increased font size */
}

.results-table th {
    background: rgba(70, 130, 180, 0.2);
    font-weight: 700;
    position: sticky;
    top: 0;
    cursor: pointer;
    user-select: none;
}

.results-table th:hover {
    background: rgba(70, 130, 180, 0.3);
}

.sort-indicator {
    display: inline-block;
    margin-left: 5px;
    font-size: 12px;
    opacity: 0.7;
}

.roas-good { color: #4ade80; font-weight: 700; }
.roas-average { color: #fbbf24; font-weight: 700; }
.roas-poor { color: #f87171; font-weight: 700; }


/* --- UPDATED: Metric Card Styles for Single Row --- */
.metrics-grid {
    display: grid;
    /* Create 8 equal columns, they will wrap if space is not enough */
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.metric-card {
    background: linear-gradient(135deg, rgba(26, 31, 58, 0.8) 0%, rgba(15, 20, 41, 0.8) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid #8b5cf6;
    min-height: 90px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.metric-card:hover {
    transform: translateY(-5px);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}
.metric-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px; /* Reduced font size */
    color: #a0aec0; /* Lighter text for the label */
    font-weight: 500;
}
.metric-card-icon {
    font-size: 14px; /* Reduced icon size */
    opacity: 0.7;
}
.metric-card-value {
    font-size: 20px; /* Reduced value size */
    font-weight: 700;
    color: #ffffff;
    text-align: right;
}
/* Color accents for specific metrics */
.metric-card.clicks { border-left-color: #a78bfa; }
.metric-card.cpc { border-left-color: #f6ad55; }
.metric-card.ctr { border-left-color: #48bb78; }
.metric-card.cost { border-left-color: #f56565; }
.metric-card.conversions { border-left-color: #38b2ac; }
.metric-card.revenue { border-left-color: #4ade80; }
.metric-card.roas { border-left-color: #ed8936; }
.metric-card.cvr { border-left-color: #9f7aea; }
/* --- END: Updated Metric Card Styles --- */


/* Filter Sections */
.filter-section, .saved-data-section {
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.filter-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group input, .filter-group select {
    padding: 10px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
}

/* Crawling Data Analysis */
.crawling-textarea {
    width: 100%;
    min-height: 300px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 8px;
    color: #ffffff;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
}

.crawling-textarea:focus {
    outline: none;
    border-color: rgba(70, 130, 180, 0.6);
}

.account-filter {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.account-checkbox {
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.account-checkbox:hover {
    background: rgba(70, 130, 180, 0.2);
}

.account-checkbox.active {
    background: rgba(70, 130, 180, 0.4);
    border-color: #4682b4;
    font-weight: 700;
}

/* --- NEW: AI Analysis Section Styles --- */
.ai-analysis-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}
.ai-section-title {
    font-weight: 700;
    color: #a0aec0;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(70, 130, 180, 0.3);
    padding-bottom: 10px;
}
.prompt-textarea {
    width: 100%;
    min-height: 250px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 8px;
    color: #ffffff;
    padding: 15px;
    font-family: 'KoPubWorld Dotum', sans-serif;
    font-size: 14px;
    resize: vertical;
}
.prompt-textarea:focus {
    outline: none;
    border-color: rgba(70, 130, 180, 0.6);
}
.markdown-body {
    background: rgba(20,20,20,0.5);
    padding: 20px;
    border-radius: 8px;
    line-height: 1.7;
}
/* --- END: AI Analysis Section Styles --- */


/* Footer */
.footer {
    background: linear-gradient(180deg, rgba(26, 31, 58, 0.95) 0%, rgba(15, 20, 41, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    padding: 40px 30px;
    text-align: center;
    margin-top: 50px;
    width: 100%;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.footer h3 {
    background: linear-gradient(135deg, #ffffff 0%, #c4b5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: 700;
}

.footer p {
    color: rgba(232, 234, 246, 0.8);
    margin-bottom: 12px;
    font-size: 15px;
}

.footer a {
    color: #8b5cf6;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #8b5cf6 0%, #6366f1 100%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer a:hover {
    color: #a78bfa;
}

.footer a:hover::after {
    width: 100%;
}

/* Debug Info Box */
.debug-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 350px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    font-family: monospace;
    color: #00ff00;
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

/* Logout Button - 이제 사이드바 하단에 위치 */

/* Save Dialog & Overlay */
.save-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.98);
    border: 1px solid rgba(70, 130, 180, 0.5);
    border-radius: 12px;
    padding: 30px;
    z-index: 2000;
    display: none;
    min-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.save-dialog h3 {
    color: #ffffff;
    margin-bottom: 20px;
}

.save-dialog input {
    width: 100%;
    padding: 10px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 6px;
    color: #ffffff;
    margin-bottom: 20px;
}

.save-dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1999;
    display: none;
}

/* Media/Crawling Input Sections */
.media-input-section {
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.media-input-group {
    border: 1px solid rgba(70, 130, 180, 0.3);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    background: rgba(25, 25, 25, 0.5);
}

.media-input-group .grid-pair {
    display: grid;
    gap: 15px;
    margin-bottom: 10px;
    align-items: center;
}

.media-input-group .grid-pair:last-child {
    margin-bottom: 0;
}

.media-input-group .grid-name-patterns {
    grid-template-columns: 1fr 2fr;
}

.media-input-group .grid-cost-cpc {
    grid-template-columns: 1fr 1fr;
}

.media-input-group input[type="text"],
.media-input-group input[type="number"] {
    width: 100%;
    padding: 10px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    box-sizing: border-box;
}

.media-input-group input:focus {
    outline: none;
    border-color: rgba(70, 130, 180, 0.6);
}

.media-input-group label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin-bottom: 5px;
}

.add-media-btn {
    background: rgba(70, 130, 180, 0.4);
    border: 1px solid rgba(70, 130, 180, 0.6);
    border-radius: 6px;
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
}

.add-media-btn:hover {
    background: rgba(70, 130, 180, 0.6);
}

/* Responsive Styles */
@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .filter-group,
    .media-input-group .grid-name-patterns,
    .media-input-group .grid-cost-cpc,
    .metrics-grid,
    .ai-analysis-container {
        grid-template-columns: 1fr;
    }

    .debug-info {
        width: calc(100% - 20px);
        max-width: 280px;
        font-size: 10px;
        bottom: 5px;
        right: 5px;
    }

    /* 모바일 사이드바 오버레이 */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(3px);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar:not(.collapsed) ~ .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    /* 모바일에서 사이드바 기본 숨김 */
    .sidebar {
        width: 250px;
        z-index: 999;
    }

    /* 모바일에서 collapsed 클래스가 있을 때 숨김 */
    .sidebar.collapsed {
        transform: translateX(-250px);
    }

    /* 모바일에서 collapsed 클래스가 없을 때 표시 */
    .sidebar:not(.collapsed) {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.6);
    }

    .sidebar-toggle {
        position: fixed;
        left: 250px;
        top: 15px !important;
        transform: none !important;
        background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
        border: none;
        border-radius: 0 8px 8px 0;
        z-index: 1100;
        padding: 10px 8px;
        font-size: 16px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, box-shadow 0.3s ease;
        box-shadow: 2px 0 15px rgba(139, 92, 246, 0.4);
        color: white;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-toggle:hover {
        background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
        box-shadow: 3px 0 20px rgba(139, 92, 246, 0.6);
        transform: none !important;
    }

    .sidebar.collapsed ~ .sidebar-toggle {
        left: 0;
        transform: none !important;
    }

    /* 헤더 조정 */
    .main-header {
        left: 0 !important;
        padding: 0 15px;
        background: rgba(26, 31, 58, 0.98);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(139, 92, 246, 0.3);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 15px;
        padding-top: 80px;
    }

    .login-card {
        padding: 30px 25px;
        border-radius: 16px;
    }

    .section-card {
        padding: 20px;
        border-radius: 12px;
    }

    .results-table {
        font-size: 11px;
    }
    .results-table th, .results-table td {
        padding: 6px 4px;
        font-size: 11px;
    }
    .results-table table {
        min-width: 600px;
    }

    .metric-card {
        padding: 12px;
    }
    .metric-card-value {
        font-size: 18px;
    }
    .metric-card-header {
        font-size: 11px;
    }

    /* 버튼 그룹 모바일 최적화 */
    .btn-group {
        flex-direction: column;
        gap: 8px;
    }

    .btn-group button {
        width: 100%;
    }

    /* 탭 컨테이너 모바일 최적화 */
    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .tab-button {
        white-space: nowrap;
        font-size: 14px;
        padding: 10px 18px;
        flex-shrink: 0;
    }

    .add-sheet-btn {
        font-size: 14px;
        padding: 10px 16px;
    }

    /* 로그아웃 버튼 조정 */
    .logout-btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    /* AI 분석 컨테이너 */
    .ai-analysis-container {
        gap: 20px;
    }

    /* 버튼 스타일 모바일 */
    .btn, .login-btn {
        border-radius: 10px;
    }

    .btn-secondary, .btn-success, .btn-danger {
        border-radius: 8px;
    }

    /* Save Dialog 모바일 조정 */
    .save-dialog {
        min-width: 90%;
        max-width: 400px;
        padding: 25px 20px;
        border-radius: 16px;
        background: rgba(26, 31, 58, 0.98);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(139, 92, 246, 0.3);
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 15px;
    }

    .login-card {
        padding: 25px 20px;
        border-radius: 16px;
    }

    /* 모바일 터치 영역 - 768px와 동일하게 유지 */
    .sidebar-toggle {
        width: 36px;
        height: 36px;
        padding: 10px 8px;
        font-size: 16px;
    }

    .logo h1 {
        font-size: 24px;
        background: linear-gradient(135deg, #ffffff 0%, #c4b5fd 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .section-title {
        font-size: 20px;
    }

    /* 업로드 영역 모바일 */
    .upload-section {
        padding: 30px 20px;
        min-height: 150px;
        border-radius: 12px;
    }

    /* 탭 버튼 */
    .tab-button {
        padding: 10px 16px;
        font-size: 14px;
        border-radius: 10px 10px 0 0;
    }

    .form-group input {
        font-size: 16px; /* 모바일 자동 줌 방지 */
    }

    /* 필터 그룹 모바일 최적화 */
    .filter-group {
        gap: 10px;
    }

    .filter-group input,
    .filter-group select {
        font-size: 14px;
    }

    /* 테이블 더 작게 */
    .results-table {
        font-size: 10px;
    }

    .results-table th,
    .results-table td {
        padding: 4px 2px;
    }

    /* 버튼 패딩 조정 */
    .btn, .login-btn {
        padding: 13px;
        font-size: 15px;
        box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    }

    .btn-secondary, .btn-success, .btn-danger {
        padding: 10px 18px;
        font-size: 14px;
        border-radius: 8px;
    }

    .file-label {
        padding: 12px 24px;
        font-size: 15px;
        border-radius: 10px;
    }

    /* 메트릭 카드 */
    .metric-card {
        border-radius: 10px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
}
/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #4682b4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingText {
    color: #ffffff;
    margin-top: 20px;
    font-size: 16px;
}

/* Main Header */
.main-header {
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    height: 60px;
    background: rgba(26, 31, 58, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed ~ .main-header {
    left: 0;
}

/* User Info - 헤더용 (현재 미사용) */
.main-header .user-info {
    color: #ffffff;
    font-size: 14px;
}

.main-header .user-info strong {
    color: #8b5cf6;
}

/* Sidebar toggle button adjustment - 제거됨 (독립 버튼으로 변경) */

/* Main content adjustment for header */
.main-content {
    padding-top: 80px; /* Add space for fixed header */
}

/* Form actions */
.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.form-actions button {
    width: 100%;
}

/* Subtitle in login */
.login-card .subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    text-align: center;
    margin-top: -20px;
    margin-bottom: 20px;
}

/* Sidebar header update */
.sidebar-header p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin-top: 5px;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, transparent 100%);
}

.sidebar-footer .user-info {
    color: #e8eaf6;
    font-size: 13px;
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 8px;
    text-align: center;
}

.sidebar-footer .user-info strong {
    color: #a78bfa;
    display: block;
    margin-top: 4px;
}

.sidebar-footer .logout-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.8) 0%, rgba(220, 38, 38, 0.8) 100%);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-footer .logout-btn:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.9) 0%, rgba(185, 28, 28, 0.9) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Logout button position update - 제거됨 (사이드바 하단으로 이동) */
/* style.css에 추가할 스타일 */

/* Form footer for login/signup toggle */
.form-footer {
    text-align: center;
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.form-footer a {
    color: #4682b4;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.form-footer a:hover {
    color: #5a9fd4;
    text-decoration: underline;
}

/* Error message styling update */
.error-message {
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 6px;
    display: none;
}

/* Success message for signup */
.success-message {
    color: #4ade80;
    font-size: 14px;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: rgba(74, 222, 128, 0.1);
    border-radius: 6px;
    display: none;
}

/* AI 보고서 스타일 */
.ai-report-container {
    background: white;
    color: #333;
    padding: 40px;
    border-radius: 8px;
    max-width: 210mm; /* A4 width */
    margin: 0 auto;
    font-family: 'KoPubWorld Dotum', 'Noto Sans KR', sans-serif;
    line-height: 1.6;
}

.report-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #4682b4;
}

.report-header h2 {
    color: #2c5282;
    font-size: 24px;
    margin-bottom: 10px;
}

.report-period {
    color: #666;
    font-size: 16px;
}

.report-section {
    margin-bottom: 30px;
    page-break-inside: avoid;
}

.report-section h3 {
    color: #2c5282;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e0e0e0;
}

.ai-summary {
    background: #f5f7fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #4682b4;
}

.insights-list,
.anomaly-list,
.recommendations-list {
    list-style: none;
    padding: 0;
}

.insights-list li,
.anomaly-list li,
.recommendations-list li {
    background: #f9f9f9;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    position: relative;
    padding-left: 35px;
}

.insights-list li::before {
    content: "💡";
    position: absolute;
    left: 12px;
    top: 12px;
}

.anomaly-list li::before {
    content: "⚠️";
    position: absolute;
    left: 12px;
    top: 12px;
}

.recommendations-list li::before {
    content: "✅";
    position: absolute;
    left: 12px;
    top: 12px;
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
}

.metrics-table th,
.metrics-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.metrics-table th {
    background-color: #f0f4f8;
    color: #2c5282;
    font-weight: 600;
}

.metrics-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.metrics-table tr:hover {
    background-color: #f0f4f8;
}

/* 백업 이력 테이블 스타일 */
.backup-history-table {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
}

.backup-history-table table {
    width: 100%;
    border-collapse: collapse;
}

.backup-history-table th,
.backup-history-table td {
    border: 1px solid rgba(70, 130, 180, 0.3);
    padding: 10px;
    text-align: left;
}

.backup-history-table th {
    background: rgba(70, 130, 180, 0.2);
    font-weight: 600;
}

.backup-history-table tr:hover {
    background: rgba(70, 130, 180, 0.1);
}

/* 작은 버튼 스타일 */
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-sm.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-sm.btn-danger:hover {
    background-color: #c0392b;
}

/* 일별 백업 섹션 */
.daily-backup-section {
    background: rgba(20, 20, 20, 0.6);
    border-radius: 8px;
    padding: 20px;
}

/* 커스텀 상품명 입력 */
#customProductName {
    width: 100%;
    padding: 10px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(70, 130, 180, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
}

/* PDF 생성 시 스타일 */
@media print {
    .ai-report-container {
        padding: 20mm;
        margin: 0;
        background: white;
        color: black;
    }
    
    .btn-group {
        display: none;
    }
    
    .report-section {
        page-break-inside: avoid;
    }
}

/* AI 보고서 매체 정보 스타일 추가 */
.report-media {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

/* 매체별 성과 테이블을 위한 추가 스타일 */
#mediaMetricsContainer {
    margin-bottom: 20px;
}

#mediaMetricsContainer h4 {
    color: #2c5282;
    font-size: 16px;
    margin-bottom: 10px;
}

/* AI 보고서 매체 정보 스타일 추가 */
.report-media {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

/* 매체별 성과 테이블을 위한 추가 스타일 */
#mediaMetricsContainer {
    margin-bottom: 20px;
}

#mediaMetricsContainer h4 {
    color: #2c5282;
    font-size: 16px;
    margin-bottom: 10px;
}

/* 보고서 섹션의 select 요소가 비활성화되지 않도록 명시 */
#reportMediaSelect {
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    background-color: rgba(20, 20, 20, 0.8) !important;
}