/* style.css */
html, body {
    margin: 0;
    padding: 0;
    height: 100%; /* 브라우저 뷰포트에 화면 강제 고정 (상단 밀림 방지) */
    overflow: hidden; /* 바디 이중 스크롤 원천 차단 */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f3f4f6;
    color: #1e293b;
    overscroll-behavior-y: none; /* 아이폰 Safari 튕김(바운스) 현상 차단 */
}

.hidden { display: none !important; }

/* Login Overlay */
.login-overlay { position: fixed; inset: 0; background: #f3f4f6; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; width: 100%; max-width: 400px; padding: 2rem; border-radius: 0.75rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header .brand-logo { font-size: 2.5rem; color: #4f46e5; margin-bottom: 0.5rem; }
.login-header h2 { margin: 0 0 0.5rem 0; color: #0f172a; }
.login-header p { margin: 0; color: #64748b; font-size: 0.875rem; }

/* Layout */
.app-layout { 
    display: flex; 
    height: 100%; 
    height: 100dvh; /* 모바일 동적 뷰포트 높이 지원 (Safari 하단 바 높이 자동 계산) */
    width: 100%;
    overflow: hidden; 
}

/* Sidebar */
.sidebar { width: 280px; background-color: #1e1b4b; color: #fff; display: flex; flex-direction: column; }
.sidebar-brand { padding: 1.5rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-logo { font-size: 1.5rem; color: #818cf8; }
.brand-text { font-size: 1.25rem; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 1.5rem 0; overflow-y: auto; }
.nav-label { padding: 0 1.5rem; font-size: 0.75rem; text-transform: uppercase; color: #94a3b8; font-weight: 600; margin-bottom: 0.5rem; }
.nav-list { list-style: none; padding: 0; margin: 0 0 2rem 0; }
.nav-item { display: block; width: 100%; }
.nav-item a { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.5rem; width: 100%; box-sizing: border-box; color: #cbd5e1; text-decoration: none; font-size: 0.875rem; transition: 0.2s; }
.nav-item a:hover, .nav-item.active a { background-color: rgba(255,255,255,0.1); color: #fff; border-left: 3px solid #818cf8; }

.sidebar-footer { padding: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); }
.user-profile { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }

/* Header */
.top-header { 
    height: 70px; 
    flex-shrink: 0; /* 화면이 좁아질 때 헤더가 찌그러지는 현상 방지 */
    background: #fff; 
    border-bottom: 1px solid #e2e8f0; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 2rem; 
    z-index: 50; 
}
.header-search { display: flex; align-items: center; gap: 0.5rem; width: 400px; background: #f8fafc; padding: 0.5rem 1rem; border-radius: 9999px; border: 1px solid #e2e8f0; }
.header-search input { border: none; background: transparent; outline: none; width: 100%; font-size: 0.875rem; color: #1e293b; }
.search-icon { color: #94a3b8; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.divider-vertical { width: 1px; height: 24px; background: #e2e8f0; }

/* Notification Panel */
.notification-panel { position: absolute; top: 120%; right: 0; width: 340px; background: #fff; border-radius: 0.75rem; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1); border: 1px solid #e2e8f0; z-index: 1000; display: flex; flex-direction: column; overflow: hidden; transform-origin: top right; transition: opacity 0.2s, transform 0.2s; }
.notification-panel.hidden { opacity: 0; transform: scale(0.95); pointer-events: none; }
.noti-header { padding: 1rem; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.noti-header h3 { margin: 0; font-size: 0.95rem; color: #0f172a; font-weight: 600; }
.noti-body { max-height: 400px; overflow-y: auto; }
.noti-item { padding: 1rem; border-bottom: 1px solid #f1f5f9; display: flex; gap: 0.75rem; align-items: flex-start; transition: background 0.2s; }
.noti-item:hover { background: #f8fafc; }
.noti-item:last-child { border-bottom: none; }
.noti-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.875rem; }
.noti-icon.warning { background: #fee2e2; color: #ef4444; }
.noti-icon.success { background: #d1fae5; color: #10b981; }
.noti-icon.info { background: #e0e7ff; color: #4f46e5; }
.noti-content { flex: 1; min-width: 0; }
.noti-title { margin: 0 0 0.25rem 0; font-size: 0.875rem; font-weight: 600; color: #1e293b; }
.noti-desc { margin: 0 0 0.25rem 0; font-size: 0.8125rem; color: #64748b; line-height: 1.4; word-break: keep-all; }
.noti-time { font-size: 0.75rem; color: #94a3b8; }
@media (max-width: 768px) {
    .notification-panel { position: fixed; top: 70px; right: 1rem; left: 1rem; width: auto; max-width: none; }
}

/* Content Area */
.content-wrapper { 
    padding: 2rem; 
    overflow-y: auto; 
    flex: 1; 
    min-width: 0; 
    -webkit-overflow-scrolling: touch; /* 모바일 Safari 부드러운 스크롤 보장 */
    overscroll-behavior-y: contain; /* 내부 스크롤이 끝에 닿았을 때 부모 창이 딸려 올라가는 현상 방지 */
}
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-title { margin: 0 0 0.25rem 0; font-size: 1.5rem; font-weight: 700; color: #0f172a; }
.page-subtitle { margin: 0; font-size: 0.875rem; color: #64748b; }

/* API Guide Styles */
.guide-content { font-size: 0.95rem; color: #334155; line-height: 1.6; }
.guide-block { margin-bottom: 2rem; }
.guide-block h3 { color: #0f172a; margin-bottom: 0.75rem; font-size: 1.125rem; font-weight: 600; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.5rem; }
.code-box { background: #1e293b; color: #f8fafc; padding: 1rem; border-radius: 0.5rem; font-family: monospace; font-size: 0.85rem; overflow-x: auto; margin-top: 0.5rem; }
.code-box strong { color: #38bdf8; }
.code-box span { color: #a3e635; }

@media print {
    body * { visibility: hidden; }
    #section-api-guide, #section-api-guide * { visibility: visible; }
    #section-api-guide { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; padding: 0; border: none; }
    .header-tools, .top-header, .sidebar { display: none !important; }
    .code-box { background: #f1f5f9; color: #0f172a; border: 1px solid #cbd5e1; }
    .code-box strong { color: #0f172a; }
    .code-box span { color: #0f172a; }
    .badge-error { border: 1px solid #000; color: #000; background: transparent; }
}

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: #fff; border-radius: 0.75rem; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); display: flex; flex-direction: column; gap: 1rem; }
.stat-header { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-title { font-size: 0.875rem; font-weight: 500; color: #64748b; margin: 0 0 0.5rem 0; }
.stat-value { font-size: 1.875rem; font-weight: 700; color: #0f172a; margin: 0; }
.stat-icon { width: 48px; height: 48px; border-radius: 0.5rem; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.bg-indigo-light { background: #e0e7ff; color: #4f46e5; }
.bg-emerald-light { background: #d1fae5; color: #10b981; }
.bg-amber-light { background: #fef3c7; color: #f59e0b; }
.stat-footer { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.stat-trend { display: flex; align-items: center; gap: 0.25rem; font-weight: 600; }
.stat-trend.positive { color: #10b981; }
.stat-trend.neutral { color: #64748b; }
.stat-context { color: #94a3b8; }

/* Data Section */
.data-section { background: #fff; border-radius: 0.75rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 1.5rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.section-header h2 { margin: 0; font-size: 1.125rem; font-weight: 600; color: #0f172a; }
.table-filters { display: flex; gap: 1rem; flex-wrap: wrap; }
.filter-select { padding: 0.5rem 1rem; border: 1px solid #e2e8f0; border-radius: 0.375rem; font-size: 0.875rem; color: #475569; outline: none; background: #fff; }

/* View Toggle Buttons */
.view-toggle { display: flex; background: #f1f5f9; border-radius: 0.375rem; padding: 0.25rem; border: 1px solid #e2e8f0; }
.btn-view { background: transparent; border: none; padding: 0.375rem 0.75rem; cursor: pointer; border-radius: 0.25rem; color: #64748b; transition: 0.2s; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.btn-view:hover { color: #0f172a; }
.btn-view.active { background: #fff; color: #4f46e5; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* Table Card View (Desktop & Tablet) */
.table-card-view .data-table, .table-card-view .data-table tbody, .table-card-view .data-table tr, .table-card-view .data-table td { display: block !important; width: 100% !important; box-sizing: border-box !important; }
.table-card-view .data-table thead { display: none !important; }
.table-card-view .data-table tr { margin-bottom: 1rem !important; border: 1px solid #e2e8f0 !important; border-radius: 0.5rem !important; background: #fff !important; box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important; }
.table-card-view .data-table tr:hover { background: #fff !important; }
.table-card-view .data-table td { display: flex !important; justify-content: space-between !important; align-items: center !important; padding: 0.75rem 1rem !important; border-bottom: 1px solid #f1f5f9 !important; text-align: right !important; white-space: normal !important; word-break: break-all !important; }
.table-card-view .data-table td:last-child { border-bottom: none !important; }
    .table-card-view .data-table td::before { content: attr(data-label) !important; font-weight: 600 !important; color: #64748b !important; font-size: 0.75rem !important; text-transform: uppercase !important; margin-right: 1rem !important; text-align: left !important; flex-shrink: 0 !important; }
    .table-card-view .col-checkbox { display: flex !important; justify-content: flex-start !important; padding-bottom: 0 !important; border-bottom: none !important; }
    .table-card-view .col-checkbox::before { content: '' !important; display: none !important; }
.table-card-view .col-actions { justify-content: flex-end !important; gap: 0.75rem !important; }

@media (min-width: 769px) {
    .table-card-view .data-table tbody { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important; gap: 1.25rem !important; }
    .table-card-view .data-table tr { margin-bottom: 0 !important; height: 100% !important; }
}

/* Force List View Override for Mobile */
.table-list-view .data-table, .table-list-view .data-table tbody, .table-list-view .data-table tr, .table-list-view .data-table td { display: table-cell !important; width: auto !important; }
.table-list-view .data-table { display: table !important; width: 100% !important; }
.table-list-view .data-table tbody { display: table-row-group !important; }
.table-list-view .data-table tr { display: table-row !important; margin-bottom: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
.table-list-view .data-table thead { display: table-header-group !important; }
.table-list-view .data-table th { white-space: nowrap !important; word-break: keep-all !important; }
.table-list-view .data-table td { text-align: left !important; justify-content: flex-start !important; padding: 1rem !important; border-bottom: 1px solid #e2e8f0 !important; white-space: nowrap !important; word-break: keep-all !important; }
.table-list-view .data-table td::before { display: none !important; }
.table-list-view .col-actions { justify-content: flex-start !important; flex-wrap: nowrap !important; }

.table-container { overflow-x: auto; width: 100%; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
.data-table th { padding: 1rem; border-bottom: 1px solid #e2e8f0; font-size: 0.75rem; text-transform: uppercase; color: #64748b; font-weight: 600; background: #f8fafc; }
.data-table td { padding: 1rem; border-bottom: 1px solid #e2e8f0; font-size: 0.875rem; color: #1e293b; vertical-align: middle; }
.col-checkbox { width: 40px; text-align: center; }
.data-table tbody tr:hover { background: #f8fafc; }

.badge { padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; display: inline-block; text-align: center; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-success { background: #d1fae5; color: #047857; }
.badge-error { background: #fee2e2; color: #b91c1c; }

.text-red-500 { color: #ef4444 !important; }

.media-thumbnail { width: 60px; height: 60px; object-fit: cover; border-radius: 0.25rem; border: 1px solid #e2e8f0; display: block; }

.col-actions { white-space: nowrap; vertical-align: middle; text-align: left; }
.col-actions > * { display: inline-block; vertical-align: middle; margin-right: 0.5rem; }
.col-actions > *:last-child { margin-right: 0; }
.btn-action { background: transparent; border: none; cursor: pointer; color: #94a3b8; font-size: 1.125rem; transition: 0.2s; padding: 0.25rem; }
.btn-action:hover { color: #4f46e5; }
.btn-action.retry:hover { color: #10b981; }
.btn-action.delete-lead:hover, .btn-action.delete-form:hover, .btn-action.delete-landing:hover { color: #ef4444; }

.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; font-size: 0.875rem; color: #64748b; }
.page-controls { display: flex; gap: 0.25rem; }
.btn-page { border: 1px solid #e2e8f0; background: #fff; padding: 0.5rem 0.75rem; border-radius: 0.375rem; cursor: pointer; color: #475569; }
.btn-page:hover { background: #f8fafc; }
.btn-page.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.btn-page.disabled { opacity: 0.5; cursor: not-allowed; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-card { background: #fff; width: 100%; max-width: 500px; border-radius: 0.75rem; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); display: flex; flex-direction: column; animation: modalIn 0.3s ease-out; max-height: 90vh; overflow: hidden; }
.modal-lg { max-width: 750px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.modal-header { padding: 1.5rem; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-title-wrapper { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; margin-right: 1rem; }
.modal-title-wrapper h2 { margin: 0; font-size: 1.125rem; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-icon { width: 32px; height: 32px; background: #e0e7ff; border-radius: 0.375rem; display: flex; align-items: center; justify-content: center; color: #4f46e5; font-size: 1rem; flex-shrink: 0; }
.btn-close-modal { background: none; border: none; cursor: pointer; color: #94a3b8; font-size: 1.25rem; transition: 0.2s; }
.btn-close-modal:hover { color: #ef4444; }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; min-height: 0; }
.details-body-bg { background: #f8fafc; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; color: #334155; margin-bottom: 0.5rem; }
.form-control { width: 100%; min-width: 0; padding: 0.625rem; border: 1px solid #cbd5e1; border-radius: 0.375rem; font-family: inherit; font-size: 0.875rem; outline: none; box-sizing: border-box; transition: 0.2s; }
.form-control:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.input-with-icon { position: relative; }
.toggle-password { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: #94a3b8; }
.order-ctrl { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem; }
.order-ctrl .icon-btn { padding: 0.1rem 0.3rem; font-size: 1rem; color: #94a3b8; height: 18px; display: flex; align-items: center; justify-content: center; }
.order-ctrl .icon-btn:hover { color: #4f46e5; background: #f1f5f9; border-radius: 0.2rem; }
.mono-font { font-family: monospace; font-size: 0.8rem; }

/* Lead Details Grid Layout */
.details-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.detail-item { display: flex; align-items: flex-start; gap: 1rem; background: #fff; padding: 1.25rem; border-radius: 0.5rem; border: 1px solid #e2e8f0; box-shadow: 0 1px 2px rgba(0,0,0,0.03); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.detail-item:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.detail-item.full-width { grid-column: span 2; }
.detail-icon { width: 40px; height: 40px; flex-shrink: 0; background: #f1f5f9; color: #64748b; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.125rem; }
.detail-content { display: flex; flex-direction: column; gap: 0.25rem; overflow: hidden; }
.detail-label { font-size: 0.75rem; color: #94a3b8; text-transform: uppercase; font-weight: 600; letter-spacing: 0.05em; }
.detail-value { font-size: 0.95rem; color: #0f172a; font-weight: 600; word-break: break-word; }

.modal-footer { padding: 1.25rem 1.5rem; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 0.75rem; background: #fff; border-bottom-left-radius: 0.75rem; border-bottom-right-radius: 0.75rem; flex-shrink: 0; }

/* Buttons */
.btn { padding: 0.625rem 1.25rem; border-radius: 0.375rem; font-weight: 500; cursor: pointer; border: none; font-size: 0.875rem; display: inline-flex; align-items: center; gap: 0.5rem; transition: 0.2s; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8125rem; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #fff; border: 1px solid #cbd5e1; color: #475569; }
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }

.icon-btn { background: transparent; border: none; cursor: pointer; font-size: 1.25rem; color: #64748b; position: relative; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: #0f172a; }
.badge-indicator { position: absolute; top: 0; right: -2px; width: 8px; height: 8px; background: #ef4444; border-radius: 50%; }

/* Alerts */
.alert-box { padding: 1rem; border-radius: 0.375rem; display: flex; gap: 0.75rem; font-size: 0.875rem; margin-bottom: 1.25rem; }
.alert-box p { margin: 0; }
.info-alert { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.info-alert i { color: #3b82f6; font-size: 1.25rem; }

/* Responsive Design & Mobile Improvements */
.mobile-menu-btn { display: none; }
.header-left { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 0; }
.sidebar-overlay { display: none; }

@media (max-width: 1024px) {
    .header-search { width: 250px; }

    /* Sidebar Mobile & Tablet */
    .sidebar { position: fixed; height: 100vh; z-index: 1000; transform: translateX(-100%); transition: transform 0.3s ease; box-shadow: 4px 0 10px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 999; backdrop-filter: blur(2px); display: none; }
    .sidebar-overlay.active { display: block; }
    .mobile-sidebar-close { display: flex !important; }
    
    /* Header Mobile & Tablet */
    .mobile-menu-btn { display: flex; }
    .top-header { padding: 0 1rem; }
    .header-search { flex: 1; min-width: 0; margin-left: 0.5rem; }
    .header-search input { width: 100%; min-width: 0; }
    #btn-manual-transfer-open { font-size: 0; padding: 0.5rem; }
    #btn-manual-transfer-open i { font-size: 1rem; margin: 0; }
    .divider-vertical { display: none; }
}

@media (max-width: 768px) {
    /* Content Layout Mobile */
    .content-wrapper { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .table-filters, .header-tools, .pagination { width: 100% !important; display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; overflow-x: auto !important; gap: 0.5rem !important; padding-bottom: 4px !important; -webkit-overflow-scrolling: touch !important; justify-content: flex-start !important; }
    .table-filters::-webkit-scrollbar, .header-tools::-webkit-scrollbar, .pagination::-webkit-scrollbar { display: none !important; }
    .table-filters *, .header-tools *, .pagination * { flex-shrink: 0 !important; white-space: nowrap !important; }
    .pagination { gap: 1rem !important; justify-content: space-between !important; }
    
    /* Modals Mobile */
    .modal-card { margin: 1rem; max-height: calc(100vh - 4rem); max-height: calc(100dvh - 2rem); }
    .details-grid { grid-template-columns: 1fr; }
    .detail-item.full-width { grid-column: span 1; }
    
    .settings-tabs { flex-wrap: nowrap !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .settings-tabs::-webkit-scrollbar { display: none !important; }
    .settings-tabs button { flex-shrink: 0 !important; white-space: nowrap !important; }

    /* Responsive Data Table (Card View) */
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; box-sizing: border-box; }
    .data-table thead { display: none; }
    .data-table tr { margin-bottom: 1rem; border: 1px solid #e2e8f0; border-radius: 0.5rem; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
    .data-table tr:hover { background: #fff; }
    .data-table td { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9; text-align: right; white-space: normal; word-break: break-all; }
    .data-table td:last-child { border-bottom: none; }
    .data-table td::before { content: attr(data-label); font-weight: 600; color: #64748b; font-size: 0.75rem; text-transform: uppercase; margin-right: 1rem; text-align: left; flex-shrink: 0; }
    .col-checkbox { justify-content: flex-start; border-bottom: none; padding-bottom: 0; margin-bottom: -1rem; z-index: 1; }
    .col-checkbox::before { display: none; }
    .col-actions { justify-content: flex-end; gap: 0.75rem; }
    .col-actions > * { margin-right: 0; }

    /* 통계 테이블 모바일 카드뷰 변환 예외 처리 (가로 스크롤 및 원본 표 형태 강제 유지) */
    #stats-main-table, #stats-main-table tbody, #stats-main-table tr, #stats-main-table td, #stats-main-table th,
    #time-analysis-table, #time-analysis-table tbody, #time-analysis-table tr, #time-analysis-table td, #time-analysis-table th,
    #ad-schedule-table, #ad-schedule-table tbody, #ad-schedule-table tr, #ad-schedule-table td, #ad-schedule-table th { display: table-cell !important; width: auto !important; }
    
    #stats-main-table { display: table !important; min-width: 1000px !important; }
    #time-analysis-table, #ad-schedule-table { display: table !important; min-width: 900px !important; }
    
    #stats-main-table thead, #time-analysis-table thead, #ad-schedule-table thead { display: table-header-group !important; }
    #stats-main-table tbody, #time-analysis-table tbody, #ad-schedule-table tbody { display: table-row-group !important; }
    #stats-main-table tfoot, #time-analysis-table tfoot, #ad-schedule-table tfoot { display: table-footer-group !important; }
    
    #stats-main-table tr, #time-analysis-table tr, #ad-schedule-table tr { display: table-row !important; margin-bottom: 0 !important; border: none !important; background: transparent !important; box-shadow: none !important; }
    #stats-main-table td, #stats-main-table th, #time-analysis-table td, #time-analysis-table th, #ad-schedule-table td, #ad-schedule-table th { display: table-cell !important; text-align: center !important; justify-content: center !important; border: 1px solid #e2e8f0 !important; padding: 0.5rem !important; white-space: nowrap !important; word-break: keep-all !important; }
    #stats-main-table td::before, #time-analysis-table td::before, #ad-schedule-table td::before { display: none !important; }
}

/* AI Chatbot */
.ai-chat-fab { position: fixed; bottom: 2rem; right: 2rem; width: 60px; height: 60px; background: #4f46e5; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.5rem; cursor: pointer; box-shadow: 0 4px 12px rgba(79,70,229,0.4); z-index: 1000; transition: transform 0.2s, box-shadow 0.2s; }
.ai-chat-fab:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(79,70,229,0.6); }
.ai-chat-window { position: fixed; bottom: 5.5rem; right: 2rem; width: 350px; height: 500px; min-width: 250px; min-height: 300px; background: #fff; border-radius: 0.75rem; box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; flex-direction: column; z-index: 1000; overflow: hidden; transition: opacity 0.3s, transform 0.3s; transform-origin: bottom right; border: 1px solid #e2e8f0; resize: both; }
.ai-chat-window.hidden { opacity: 0; transform: scale(0.9); pointer-events: none; }
.ai-chat-header { background: #4f46e5; color: #fff; padding: 1rem; display: flex; justify-content: space-between; align-items: center; cursor: move; }
.ai-chat-messages { flex: 1; padding: 1rem; overflow-y: auto; background: #f8fafc; display: flex; flex-direction: column; gap: 1rem; }
.chat-message { position: relative; max-width: 85%; padding: 0.75rem 1rem; border-radius: 1rem; font-size: 0.875rem; line-height: 1.4; word-break: break-word; margin-bottom: 1.25rem; }
.chat-message.ai { background: #e0e7ff; color: #1e3a8a; align-self: flex-start; border-bottom-left-radius: 0.25rem; }
.chat-message.user { background: #4f46e5; color: #fff; align-self: flex-end; border-bottom-right-radius: 0.25rem; }
/* 채팅 말풍선에 가상의 확장 영역을 두어, 말풍선 주변 여백에 마우스를 올려도 hover가 부드럽게 유지되도록 설정 */
.chat-message::after { content: ''; position: absolute; top: -10px; bottom: -20px; left: -10px; right: -10px; z-index: -1; }
.msg-actions { display: flex; opacity: 0; visibility: hidden; position: absolute; bottom: -1.5rem; gap: 0.35rem; background: transparent; border: none; box-shadow: none; z-index: 10; align-items: center; transform: translateY(8px); transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s; padding: 0.5rem; margin: -0.5rem; }
.chat-message.ai .msg-actions { left: 0; }
.chat-message.user .msg-actions { right: 0; }
.chat-message:hover .msg-actions, .msg-actions:hover { opacity: 1; visibility: visible; transform: translateY(0); }
.msg-actions button { background: transparent; border: none; cursor: pointer; font-size: 0.9rem; color: #cbd5e1; padding: 0.25rem; transition: color 0.2s ease, transform 0.2s ease; display: flex; align-items: center; justify-content: center; }
.msg-actions button:hover { color: #6366f1; transform: scale(1.15); }
.msg-actions button.btn-delete-msg:hover { color: #f87171; }
.ai-chat-input-area { padding: 0.75rem; background: #fff; border-top: 1px solid #e2e8f0; display: flex; gap: 0.5rem; }
.ai-chat-input-area input { flex: 1; min-width: 0; padding: 0.5rem 0.75rem; border: 1px solid #cbd5e1; border-radius: 999px; outline: none; font-size: 0.875rem; }
.ai-chat-input-area input:focus { border-color: #4f46e5; }
.ai-chat-input-area button { background: #4f46e5; color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.ai-chat-input-area button:hover { background: #4338ca; }
@media (max-width: 768px) {
    .ai-chat-window { width: calc(100% - 2rem); right: 1rem; bottom: 5rem; height: 60vh; }
    .ai-chat-fab { bottom: 1rem; right: 1rem; width: 50px; height: 50px; font-size: 1.25rem; }
}