/* ============================================
   메타광고 소재 관리 대시보드
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 13px;
  color: #1e293b;
  background: #f1f5f9;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== NAV — nav.css에서 관리 ===== */

.btn-primary {
  display: flex; align-items: center; gap: 5px;
  background: #6366f1; color: white;
  border: none; border-radius: 8px;
  padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
}
.btn-primary:hover  { background: #4f46e5; }
.btn-primary:active { transform: scale(.97); }
.btn-secondary {
  display: flex; align-items: center; gap: 5px;
  background: white; color: #64748b;
  border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 6px 12px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: #f8fafc; }

/* ===== LAYOUT ===== */
.main-wrap   { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.section-gap { display: flex; flex-direction: column; gap: 10px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
}
.section-title {
  font-size: 12.5px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 5px;
}
.section-title i { color: #6366f1; }

/* ===== BADGES ===== */
.badge-gray   { font-size: 11px; background: #f1f5f9; color: #94a3b8; padding: 3px 8px; border-radius: 20px; }
.badge-indigo { font-size: 11px; background: #eef2ff; color: #6366f1; padding: 3px 8px; border-radius: 20px; font-weight: 600; }

/* ===== SUMMARY CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (min-width: 1400px) { .cards-grid { grid-template-columns: repeat(8, 1fr); } }

.summary-card {
  background: white; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 12px 14px; position: relative; overflow: hidden;
  transition: box-shadow .2s, transform .15s; cursor: default;
}
.summary-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); }
.summary-card::before {
  content: ''; position: absolute; top:0; left:0; right:0; height: 3px; border-radius: 10px 10px 0 0;
}
.summary-card.indigo::before  { background: linear-gradient(90deg,#6366f1,#818cf8); }
.summary-card.emerald::before { background: linear-gradient(90deg,#10b981,#34d399); }
.summary-card.amber::before   { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.summary-card.rose::before    { background: linear-gradient(90deg,#f43f5e,#fb7185); }
.summary-card.violet::before  { background: linear-gradient(90deg,#8b5cf6,#a78bfa); }
.summary-card.sky::before     { background: linear-gradient(90deg,#0ea5e9,#38bdf8); }
.summary-card.orange::before  { background: linear-gradient(90deg,#ea580c,#f97316); }
.summary-card.teal::before    { background: linear-gradient(90deg,#14b8a6,#2dd4bf); }
.card-icon {
  position: absolute; top:12px; right:12px;
  width:30px; height:30px; border-radius:8px;
  display:flex; align-items:center; justify-content:center; font-size:13px;
}
.card-label { font-size:10.5px; font-weight:500; color:#94a3b8; text-transform:uppercase; letter-spacing:.05em; margin-bottom:3px; }
.card-value { font-size:18px; font-weight:700; color:#1e293b; line-height:1.2; }
.card-sub   { font-size:10px; color:#94a3b8; margin-top:2px; }

/* ===== CHART ===== */
.chart-section {
  background: white; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 14px 16px;
}
.chart-btns { display:flex; gap:4px; }
.chart-toggle-btn {
  font-size:11.5px; font-weight:500; padding:4px 10px;
  border-radius:6px; border:1px solid #e2e8f0; background:white; color:#64748b;
  cursor:pointer; transition:all .15s;
}
.chart-toggle-btn:hover  { background:#f8fafc; border-color:#a5b4fc; color:#4f46e5; }
.chart-toggle-btn.active { background:#6366f1; color:white; border-color:#6366f1; }

/* ===== TABLE SECTION ===== */
.table-section {
  background: white; border: 1px solid #e2e8f0;
  border-radius: 10px; overflow: hidden;
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid #f1f5f9;
  gap: 8px;
}
.table-toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-hint { font-size: 11px; color: #94a3b8; display:flex; align-items:center; gap:3px; }

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto; overflow-y: auto;
  max-height: 620px;
}
.data-table {
  border-collapse: separate; border-spacing: 0;
  width: max-content; min-width: 100%;
  font-size: 12.5px;
}

/* ── 헤더 ── */
.data-table thead th {
  position: sticky; top: 0; z-index: 10;
  background: #f8fafc;
  font-size: 11px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; text-align: center; white-space: nowrap;
  border-bottom: 2px solid #e2e8f0;
  user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { background: #f1f5f9; color: #4f46e5; }
.sort-icon { margin-left: 3px; font-size: 9px; opacity: .45; }
.data-table thead th.sort-asc  .sort-icon,
.data-table thead th.sort-desc .sort-icon { opacity:1; color:#6366f1; }
.data-table thead th.col-highlight { background: #fffbeb !important; color: #d97706 !important; }

/* ── 바디 ── */
.data-table tbody td {
  padding: 6px 10px; border-bottom: 1px solid #f1f5f9;
  vertical-align: middle; text-align: center; white-space: nowrap;
  color: #374151;
}
.data-table tbody tr:hover td { background: #fafbff !important; }
.data-table tbody tr.group-first > td { border-top: 2px solid #e2e8f0; }

/* ── Sticky 열 ── */
.sticky-col   { position: sticky; z-index: 5; }
.sticky-col-1 { left: 0; }
.sticky-col-2 { left: 110px; }

.data-table thead th.sticky-col { z-index: 20; }
.data-table thead th.sticky-col-1 { left: 0;     background: #f8fafc; z-index: 22; }
.data-table thead th.sticky-col-2 { left: 110px; background: #f8fafc; z-index: 22; }

/* sticky 그림자 */
.sticky-col-2::after,
.data-table thead th.sticky-col-2::after {
  content: ''; position: absolute; top:0; right:-8px; bottom:0; width:8px;
  background: linear-gradient(to right, rgba(0,0,0,.06), transparent);
  pointer-events: none;
}

/* ── 날짜 그룹 셀 ── */
.date-group-cell {
  background: #f8fafc !important;
  border-right: 2px solid #e2e8f0;
  vertical-align: middle !important;
  text-align: center;
}
.date-group-content {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.date-label {
  font-size: 12px; font-weight: 700; color: #374151;
  letter-spacing: .01em;
}
.add-sub-row-btn {
  width: 22px; height: 22px; border-radius: 6px;
  background: #eef2ff; border: 1px dashed #a5b4fc;
  color: #6366f1; font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.add-sub-row-btn:hover { background: #e0e7ff; border-color: #6366f1; }

/* ── 이미지 그룹 셀 ── */
.image-group-cell {
  background: #fafafa !important;
  border-right: 1px solid #e2e8f0;
  vertical-align: middle !important;
}
.img-group-cell {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 4px 0;
}
.img-thumb-wrap { position: relative; cursor: zoom-in; }
.img-thumb {
  width: 60px; height: 60px; object-fit: cover;
  border-radius: 8px; border: 2px solid #e2e8f0;
  display: block; transition: border-color .2s, transform .2s;
}
.img-thumb:hover { border-color: #6366f1; transform: scale(1.04); }
.img-extra-badge {
  position: absolute; bottom: 3px; right: 3px;
  background: rgba(0,0,0,.55); color: white;
  font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 20px;
}
.img-placeholder {
  width: 60px; height: 60px; border-radius: 8px;
  border: 2px dashed #e2e8f0; background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  color: #cbd5e1; font-size: 18px;
}
.img-add-btn {
  display: flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 500; color: #6366f1;
  background: #eef2ff; border: 1.5px dashed #a5b4fc;
  border-radius: 6px; padding: 3px 7px; cursor: pointer;
  white-space: nowrap; transition: all .15s;
}
.img-add-btn:hover { background: #e0e7ff; border-color: #6366f1; }

/* ── 편집 가능 셀 ── */
.editable-cell {
  display: inline-block; cursor: pointer; min-width: 20px;
  position: relative; border-radius: 4px;
  padding: 2px 4px; transition: background .12s;
}
.editable-cell:hover { background: #eef2ff; }
.editable-cell.editing { padding: 1px; }
.editable-cell input,
.editable-cell textarea {
  border: 1.5px solid #6366f1; border-radius: 4px;
  padding: 3px 6px; font-size: 12.5px; color: #1e293b;
  background: white; outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
  resize: none; font-family: inherit;
}
.editable-cell.copy-cell   { max-width: 200px; white-space: normal; text-align: left; line-height: 1.45; }
.editable-cell.remark-cell { max-width: 148px; white-space: normal; text-align: left; line-height: 1.45; }
.editable-cell.num-cell    { font-variant-numeric: tabular-nums; }
.editable-cell.delta-cell  { cursor: pointer; }

/* ── 숫자 셀 ── */
.num-cell { font-variant-numeric: tabular-nums; }
.null-val { color: #cbd5e1; font-size: 12px; }

/* ── KPI 색상 ── */
.kpi-cell { font-weight: 600; font-size: 12.5px; }
.kpi-good { color: #059669; }
.kpi-warn { color: #d97706; }
.kpi-bad  { color: #dc2626; }

/* ── Delta 배지 ── */
.delta-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 20px;
}
.delta-badge.up   { background: #fee2e2; color: #dc2626; }
.delta-badge.down { background: #dbeafe; color: #2563eb; }
.delta-badge.neu  { background: #f1f5f9; color: #94a3b8; }
.delta-badge i    { font-size: 9px; }

/* ── 컬럼 하이라이트 ── */
.col-highlight { background: #fffde7; }
.data-table thead th.col-highlight { background: #fffbeb !important; color: #b45309 !important; font-weight: 700; }

/* ── ROAS 바 ── */
.roas-cell {
  display: flex; align-items: center; gap: 6px; min-width: 80px;
}
.roas-bar-bg {
  flex: 1; height: 4px; background: #e2e8f0; border-radius: 99px; overflow: hidden;
}
.roas-bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg,#6366f1,#8b5cf6);
  transition: width .4s ease;
}
.roas-val { font-size: 12px; font-weight: 600; color: #4f46e5; min-width: 36px; text-align: right; }

/* ── 삭제 버튼 ── */
.row-del-btn {
  opacity: 0; background: none; border: none;
  color: #f87171; font-size: 13px; cursor: pointer;
  padding: 3px 6px; border-radius: 5px; transition: all .15s;
}
.row-del-btn:hover { background: #fee2e2; }
.data-table tbody tr:hover .row-del-btn { opacity: 1; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 56px 20px; gap: 8px;
}
.empty-icon {
  width: 56px; height: 56px; background: #f1f5f9; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #cbd5e1; font-size: 22px;
}
.empty-title { font-weight: 600; color: #64748b; }
.empty-desc  { font-size: 12px; color: #94a3b8; }

/* ===== PAGINATION ===== */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; background: #f8fafc; border-top: 1px solid #f1f5f9;
}
.page-info { font-size: 11px; color: #94a3b8; }
.page-controls { display: flex; gap: 3px; }
.page-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid #e2e8f0;
  background: white; color: #64748b; font-size: 11.5px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.page-btn:hover:not(:disabled) { background: #f1f5f9; border-color: #a5b4fc; color: #4f46e5; }
.page-btn.active { background: #6366f1; color: white; border-color: #6366f1; }
.page-btn:disabled { opacity: .35; cursor: default; }

/* ===== IMAGE MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
.modal-overlay.flex { display: flex; }
.modal-box {
  background: white; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-width: 420px; width: 100%; margin: 16px; overflow: hidden;
}
@keyframes modalIn {
  from { opacity:0; transform:scale(.95) translateY(-8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.animate-modal { animation: modalIn .2s ease-out; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #f1f5f9;
  font-size: 14px; font-weight: 600; color: #1e293b;
}
.modal-header button {
  background: none; border: none; color: #94a3b8; font-size: 16px; cursor: pointer;
}
.modal-body   { padding: 16px 18px; }
.modal-footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid #f1f5f9; }
.modal-footer .btn-secondary { flex: 1; justify-content: center; }
.modal-footer .btn-primary   { flex: 1; justify-content: center; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed #c7d2fe; background: #fafbff;
  border-radius: 10px; padding: 20px; cursor: pointer; transition: all .2s;
}
.upload-zone.drag-over { border-color: #6366f1; background: #eef2ff; }
.upload-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.upload-icon-wrap {
  width: 44px; height: 44px; background: #eef2ff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #6366f1; font-size: 18px;
}
.upload-title { font-size: 13px; font-weight: 500; color: #374151; }
.upload-hint  { font-size: 11px; color: #94a3b8; }
.btn-upload {
  background: #6366f1; color: white; border: none; border-radius: 7px;
  padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-upload:hover { background: #4f46e5; }

/* ── Preview Grid ── */
.preview-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 12px; }
.img-preview-item { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio:1; border:2px solid #e2e8f0; background:#f8fafc; }
.img-preview-item img { width:100%; height:100%; object-fit:cover; }
.remove-img-btn {
  position: absolute; top:3px; right:3px; width:18px; height:18px;
  background: rgba(0,0,0,.55); border: none; border-radius: 50%;
  color: white; font-size: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.remove-img-btn:hover { background: rgba(239,68,68,.85); }

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.82); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox.flex { display: flex; }
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: none; border: none; color: white; font-size: 22px; cursor: pointer;
}
.lightbox img {
  max-width: 90vw; max-height: 88vh;
  border-radius: 12px; object-fit: contain;
  box-shadow: 0 24px 80px rgba(0,0,0,.6); cursor: default;
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  display: flex; align-items: center; gap: 9px;
  background: #1e293b; color: white; font-size: 13px;
  padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
@keyframes toastIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.toast:not(.hidden) { animation: toastIn .22s ease-out; }

/* ===== FOCUS ===== */
button:focus-visible, input:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
