/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-alpha: rgba(37, 99, 235, 0.1);
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --sidebar-width: 240px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== App Layout ===== */
#app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.logo svg {
    width: 28px;
    height: 28px;
    fill: var(--primary);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
}

.sidebar-toggle:hover {
    background: var(--bg-primary);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* ===== Navigation ===== */
.nav-menu {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    cursor: pointer;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-alpha);
    color: var(--primary);
    font-weight: 600;
}

/* 메뉴 아이콘 색상 (페이지별 고정 — active/hover 무관) */
.nav-item[data-page="dashboard"]      svg { fill: #3b82f6; color: #3b82f6; } /* 블루 */
.nav-item[data-page="taobao"]         svg { fill: #f97316; color: #f97316; } /* 오렌지 (타오바오) */
.nav-item[data-page="products"]       svg { fill: #8b5cf6; color: #8b5cf6; } /* 퍼플 */
.nav-item[data-page="shops"]          svg { fill: #10b981; color: #10b981; } /* 그린 */
.nav-item[data-page="inventory"]      svg { fill: #06b6d4; color: #06b6d4; } /* 시안 */
.nav-item[data-page="shipping"]       svg { fill: #eab308; color: #eab308; } /* 옐로우 */
.nav-item[data-page="thebay"]         svg { fill: #ec4899; color: #ec4899; } /* 핑크 */
.nav-item[data-page="purchase-order"] svg { fill: #6366f1; color: #6366f1; } /* 인디고 */
.nav-item[data-page="scan-inbound"]   svg { fill: #14b8a6; color: #14b8a6; } /* 틸 */
.nav-item[data-page="customscj"]      svg { fill: #d946ef; color: #d946ef; } /* 푸시아 */
.nav-item[data-page="settings"]       svg { fill: #6b7280; color: #6b7280; } /* 그레이 */

/* ===== User Section ===== */
.user-section {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-alpha);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar svg {
    width: 20px;
    height: 20px;
    fill: var(--primary);
}

.user-details {
    line-height: 1.3;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #fef2f2;
    color: var(--danger);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== Sidebar Overlay (Mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

#content {
    padding: 24px;
    max-width: 100%;
}

/* ===== Mobile Header ===== */
.mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

.mobile-menu-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
}

.mobile-menu-btn:hover {
    background: var(--bg-primary);
}

.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.mobile-logo svg {
    width: 22px;
    height: 22px;
    fill: var(--primary);
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Stats Grid (Dashboard) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-pending .stat-value { color: var(--text-muted); }
.stat-ready .stat-value { color: var(--warning); }
.stat-registered .stat-value { color: var(--success); }
.stat-failed .stat-value { color: var(--danger); }

/* ===== Status Tabs ===== */
.status-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.tab-count {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.06);
}

.tab-btn.active .tab-count {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ===== Status Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending {
    background: #f1f5f9;
    color: #64748b;
}

.badge-editing {
    background: #dbeafe;
    color: #2563eb;
}

.badge-ready {
    background: #fef3c7;
    color: #d97706;
}

.badge-registering {
    background: #ffedd5;
    color: #ea580c;
}

.badge-registered {
    background: #d1fae5;
    color: #059669;
}

.badge-failed {
    background: #fee2e2;
    color: #dc2626;
}

/* ===== Product List ===== */
.product-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.product-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.product-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.product-thumbnail {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-title-cn {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-prices {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.price-cny {
    color: var(--text-secondary);
    font-weight: 500;
}

.price-arrow {
    color: var(--text-muted);
    font-size: 11px;
}

.price-krw {
    color: var(--primary);
    font-weight: 700;
}

.product-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.product-date {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-taobao-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 6px;
    background: #ff6600;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-taobao-link:hover {
    background: #e55b00;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-alpha);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

/* ===== Detail Page ===== */
.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 24px;
}

.detail-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.detail-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.detail-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.input-readonly {
    background: var(--bg-primary) !important;
    color: var(--text-secondary) !important;
    cursor: default;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-suffix {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 4px;
}

.link {
    color: var(--primary);
    font-size: 13px;
    word-break: break-all;
}

.link:hover {
    text-decoration: underline;
}

/* ===== Image Grid ===== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.image-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image Edit Mode */
.image-item.edit-mode {
    cursor: grab;
    position: relative;
    border: 2px solid var(--primary);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.image-item.edit-mode:active {
    cursor: grabbing;
}

.image-item.dragging {
    opacity: 0.3;
}

.image-item.drag-insert-before {
    transform: translateX(6px);
    box-shadow: -3px 0 0 0 var(--primary);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.image-item.drag-insert-after {
    transform: translateX(-6px);
    box-shadow: 3px 0 0 0 var(--primary);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.img-drag-handle {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 2;
    pointer-events: none;
}

.img-edit-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220,53,69,0.85);
    color: #fff;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.img-edit-delete:hover {
    background: rgba(220,53,69,1);
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: var(--bg-primary);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--primary-alpha);
}

/* 마지막 행 구분선 제거 — 일반 테이블만. 모바일 카드(responsive-table)는 마지막 카드도 셀 구분선 유지 */
.data-table:not(.responsive-table) tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Settings ===== */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 24px;
}

.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
}

.cafe24-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

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

.status-indicator.connected {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.status-indicator.disconnected {
    background: var(--text-muted);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease forwards;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

.toast-info {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-left: 4px solid var(--info);
}

.toast-success {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid var(--success);
}

.toast-warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.toast-error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* ===== Responsive: Tablet (≤1024px) ===== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 200px;
    }

    .detail-section {
        padding: 20px;
    }

    .settings-section {
        padding: 20px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* ===== Responsive: Mobile (≤768px) ===== */
@media (max-width: 768px) {
    /* 사이드바: 숨김 → 오버레이 */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        width: 260px;
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }

    .main-content {
        padding-top: 56px; /* mobile-header 높이 보상 */
    }

    #content {
        padding: 16px;
    }

    /* 대시보드 통계 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-label {
        font-size: 12px;
    }

    /* 상품 목록 카드 */
    .product-card {
        flex-wrap: wrap;
        padding: 12px;
        gap: 10px;
    }

    .product-checkbox {
        padding: 0 4px 0 0;
    }

    .product-info {
        flex: 1;
        min-width: 0;
    }

    .product-meta {
        flex-direction: row;
        align-items: center;
        width: 100%;
        padding-left: 30px;
        gap: 6px;
    }

    .product-date {
        margin-left: auto;
    }

    /* 상태 탭 */
    .status-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .status-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* 검색 바 */
    .search-bar {
        flex-direction: column;
    }

    .search-bar .btn {
        width: 100%;
    }

    /* 일괄 처리 툴바 */
    .bulk-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 12px;
    }

    .bulk-toolbar .btn-sm {
        padding: 5px 8px;
        font-size: 11px;
    }

    .bulk-count {
        font-size: 13px;
    }

    /* 폼 */
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* iOS 줌 방지 */
    }

    /* 상세 페이지 */
    .detail-section {
        padding: 16px;
    }

    .detail-section h3 {
        font-size: 15px;
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .detail-actions {
        flex-direction: column;
        gap: 8px;
    }

    .detail-actions .btn {
        width: 100%;
    }

    /* 이미지 그리드 */
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
    }

    /* 데이터 테이블 */
    .data-table {
        font-size: 12px;
    }

    .data-table thead th {
        padding: 8px 6px;
        font-size: 11px;
    }

    .data-table tbody td {
        padding: 8px 6px;
    }

    /* 반응형 테이블 → 모바일에서 카드 형태 (1줄에 2개 항목씩) */
    .responsive-table-wrap { overflow: visible; }
    .responsive-table {
        display: block;
    }
    .responsive-table thead {
        display: none;
    }
    .responsive-table tbody {
        display: block;
        width: 100%;
    }
    .responsive-table tr {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        box-sizing: border-box;
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 4px;
        background: var(--bg-secondary);
    }
    .responsive-table td {
        width: 50%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 6px 8px !important;
        border-bottom: 1px dashed var(--border);
        word-break: break-word;
        font-size: 12px;
    }
    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 10px;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: left;
        flex-shrink: 0;
    }
    /* 각 카드의 마지막 줄(맨끝 td + 홀수개면 마지막 왼쪽)만 구분선 제거 */
    .responsive-table tbody td:last-child,
    .responsive-table tbody td:nth-last-child(2):nth-child(odd) {
        border-bottom: none;
    }
    /* 전체폭으로 표시할 항목 (긴 텍스트 — 카페24 상품명 등) */
    .responsive-table td[data-label="상품"],
    .responsive-table td[data-label="상품명"] {
        width: 100%;
    }

    /* 카드 컨테이너 배경 제거 → tr 카드만 떠 보이도록 */
    .card:has(.responsive-table) {
        background: transparent;
        border: none;
        box-shadow: none;
    }
    /* 모바일 셀/행 탭 효과 제거 */
    .responsive-table tbody tr:hover {
        background: var(--bg-secondary);
    }
    .responsive-table,
    .responsive-table tr,
    .responsive-table td {
        -webkit-tap-highlight-color: transparent;
    }

    /* 페이지 헤더 */
    .page-header {
        margin-bottom: 16px;
    }

    .page-header h1 {
        font-size: 20px;
    }

    /* 페이지네이션 */
    .pagination {
        gap: 3px;
    }

    .page-btn {
        min-width: 34px;
        height: 34px;
    }

    /* 토스트 */
    .toast-container {
        top: 16px;
        right: 12px;
        left: 12px;
    }

    .toast {
        max-width: 100%;
        font-size: 13px;
        padding: 12px 16px;
    }

    /* 모달 */
    .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .modal {
        max-height: 85vh;
        border-radius: 12px 12px 0 0;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 16px 20px;
    }

    .modal-footer {
        padding: 12px 20px;
    }

    /* 설정 */
    .settings-section {
        padding: 16px;
    }

    .settings-section h3 {
        font-size: 15px;
    }

    .api-key-row {
        flex-direction: column;
    }

    .api-key-row .btn {
        width: 100%;
    }

    /* 미리보기 */
    .preview-actions {
        flex-wrap: wrap;
    }

    .preview-actions .btn {
        flex: 1;
        min-width: 0;
    }

    /* 카드 */
    .card {
        padding: 16px;
    }
}

/* ===== Sync Spinner ===== */
.sync-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sync-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes sync-spin {
    to { transform: rotate(360deg); }
}

/* ===== 재고관리 모바일 카드 레이아웃 ===== */

/* 모바일 전용 셀은 기본 숨김 */
.td-mobile { display: none !important; }

@media (max-width: 768px) {
    /* 데스크탑 셀 숨기고 모바일 셀 표시 */
    .inv-table .td-desktop { display: none !important; }
    .inv-table .td-mobile { display: block !important; }

    /* 재고 현황 테이블 → 카드 */
    .inv-table thead { display: none; }
    .inv-table,
    .inv-table tbody,
    .inv-table tr,
    .inv-table td { display: block; width: 100%; }

    .inv-table tr {
        padding: 12px;
        margin-bottom: 8px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--bg-secondary);
        position: relative;
        overflow: hidden;
    }

    .inv-table td { padding: 2px 0; border: none; overflow: hidden; }
    .inv-table td:empty { display: none; }

    /* 카드 내부 레이아웃 */
    .inv-card-row {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .inv-card-header {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
    }

    .inv-card-thumb {
        width: 48px !important;
        height: 48px !important;
        border-radius: 6px;
        overflow: hidden;
        flex-shrink: 0;
        background: var(--bg-primary);
    }

    .inv-card-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .inv-card-info {
        flex: 1;
        min-width: 0;
    }

    .inv-card-name {
        font-weight: 600;
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }

    .inv-card-code {
        font-size: 11px;
        color: var(--text-secondary);
        font-family: monospace;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .inv-card-details {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 16px;
        font-size: 12px;
        color: var(--text-secondary);
        margin-bottom: 8px;
    }

    .inv-card-detail {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .inv-card-detail-label {
        color: var(--text-muted);
        font-size: 11px;
    }

    .inv-card-detail-value {
        font-weight: 600;
        color: var(--text-primary);
    }

    .inv-card-stock {
        font-weight: 700;
        font-size: 16px;
    }

    .inv-card-actions {
        display: flex;
        gap: 6px;
        margin-top: 8px;
    }

    .inv-card-actions .btn {
        flex: 1;
        text-align: center;
        padding: 8px 0;
        font-size: 13px;
    }

    /* 입출고 이력 카드 */
    .tx-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
    }

    .tx-card-body {
        display: flex;
        gap: 10px;
        align-items: center;
        margin-bottom: 6px;
    }

    .tx-card-qty {
        font-size: 18px;
        font-weight: 700;
        margin-left: auto;
    }

    .tx-card-meta {
        font-size: 11px;
        color: var(--text-muted);
    }

    /* 바코드 카드 */
    .bc-card-barcode {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 8px 0;
        padding: 8px;
        background: var(--bg-primary);
        border-radius: 6px;
    }

    .bc-card-barcode img {
        height: 36px;
    }

    .bc-card-barcode span {
        font-family: monospace;
        font-size: 12px;
        font-weight: 600;
    }
}

/* ===== Responsive: Small Phone (≤480px) ===== */
@media (max-width: 480px) {
    #content {
        padding: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 11px;
    }

    /* 상품 카드 */
    .product-card {
        padding: 10px;
        gap: 8px;
    }

    .product-thumbnail {
        width: 56px;
        height: 56px;
    }

    .product-title {
        font-size: 13px;
    }

    .product-title-cn {
        font-size: 11px;
    }

    .product-prices {
        font-size: 12px;
    }

    /* 페이지네이션 */
    .pagination {
        gap: 2px;
    }

    .page-btn {
        min-width: 30px;
        height: 30px;
        font-size: 11px;
    }

    /* 이미지 */
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    /* 버튼 */
    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 11px;
    }

    .page-header h1 {
        font-size: 18px;
    }
}

/* ===== Bulk Toolbar ===== */
.bulk-toolbar-select,
.bulk-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.bulk-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface, #f8fafc);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
}

.bulk-count {
    font-size: 14px;
    color: var(--text);
    margin-right: auto;
}

/* ===== Checkbox ===== */
.product-checkbox {
    display: flex;
    align-items: center;
    padding: 0 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.product-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===== Image Badge ===== */
.image-item {
    position: relative;
}

.img-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    z-index: 1;
}

.img-local {
    background: var(--success);
    color: white;
}

.img-remote {
    background: var(--warning, #f59e0b);
    color: white;
}

.img-ratio {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 500;
    z-index: 1;
    pointer-events: none;
}

.img-preview-btn {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.image-item:hover .img-preview-btn {
    opacity: 1;
}

.image-item.edit-mode .img-preview-btn {
    display: none;
}

.img-checkbox {
    position: absolute;
    inset: 0;
    z-index: 2;
    cursor: pointer;
    margin: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 4px;
}

.img-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
}

.image-item:has(input:checked) {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
}

/* ===== Custom Options ===== */

.custom-opt-group {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    color: var(--text-secondary);
    line-height: 1;
}

.btn-icon:hover {
    background: var(--bg-secondary);
}

.custom-opt-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    user-select: none;
}

.custom-opt-btn:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}

.custom-opt-label {
    font-weight: 500;
}

.custom-opt-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.custom-opt-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-primary);
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ===== Preview Section ===== */
.preview-actions {
    display: flex;
    gap: 8px;
}

/* ===== Button sizes ===== */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== Image Correction Panel ===== */
.img-correction-panel {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.img-correction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.img-correction-slider {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.img-correction-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.img-correction-label {
    width: 40px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.img-correction-slider input[type="range"] {
    flex: 1;
    height: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

.img-correction-value {
    width: 32px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.img-correction-preview {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.img-correction-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.img-correction-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

.img-correction-filename {
    font-size: 10px;
    color: var(--text-secondary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Correction Large Preview ===== */
.corr-preview-large-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    justify-items: center;
}

.corr-preview-large-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.corr-preview-large-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

/* ===== Extension Install Guide ===== */
.extension-install-guide {
    margin-top: 12px;
}

.extension-download {
    margin-bottom: 20px;
}

.install-steps {
    background: var(--surface, #f8fafc);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

.install-steps h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
}

.install-steps ol {
    margin: 0;
    padding-left: 20px;
}

.install-steps li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.install-steps li strong {
    color: var(--text);
}

.install-steps code {
    background: var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SF Mono', Monaco, monospace;
}

/* ===== API Key ===== */
.api-key-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.api-key-input {
    flex: 1;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    letter-spacing: 0.5px;
}
