:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --active: #16a34a;
  --stopped: #9ca3af;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Hiragino Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 18px; margin: 0; }

.meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

.save-indicator { min-width: 60px; font-weight: 600; }
.save-indicator.saving { color: var(--accent); }
.save-indicator.saved { color: var(--active); }
.save-indicator.error { color: #dc2626; }

.note {
  margin: 12px 24px;
  padding: 10px 14px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  color: #3730a3;
  font-size: 13px;
}

main { padding: 0 24px 40px; }

section { margin-top: 24px; }

section h2 {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

section:nth-of-type(1) h2::before { content: "●"; color: var(--active); }
section:nth-of-type(2) h2::before { content: "●"; color: var(--stopped); }

.count { font-weight: 400; color: var(--muted); font-size: 13px; }

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

table { border-collapse: collapse; width: 100%; min-width: 1100px; }

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  background: #fafbfc;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}

tbody tr:hover { background: #fafbff; }

.col-name { max-width: 320px; white-space: normal; font-weight: 500; }
.col-id { font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.col-medium { font-size: 12px; }
.col-cost { text-align: right; font-variant-numeric: tabular-nums; }

tr.month-divider td {
  background: #f1f3f6;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
  white-space: nowrap;
}

select, input[type="text"], input:not([type]) {
  width: 100%;
  min-width: 110px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}

.badge-medium {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-medium.google { background: #e8f0fe; color: #1a53c5; }
.badge-medium.meta { background: #eaf2ff; color: #1877f2; }
.badge-medium.yahoo { background: #fff0e0; color: #b45309; }

td.dirty input, td.dirty select { border-color: var(--accent); }

.col-name { cursor: pointer; text-decoration: underline dotted; text-decoration-color: var(--border); }
.col-name:hover { color: var(--accent); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,18,26,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--card); border-radius: 12px; width: min(560px, 90vw);
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15px; white-space: normal; }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 12px 18px; overflow-y: auto; font-size: 13px; }

.history-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: none; }
.history-field { font-weight: 600; min-width: 90px; }
.history-change { color: var(--muted); flex: 1; }
.history-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.history-empty { color: var(--muted); text-align: center; padding: 16px 0; }

.btn-header {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-header:hover { background: #f3f5f9; }
#btn-save-version:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(15,18,26,.35); z-index: 100;
}
.sidebar-overlay.hidden { display: none; }

.sidebar {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--card);
  box-shadow: -8px 0 30px rgba(0,0,0,.15);
  display: flex; flex-direction: column;
  padding: 0;
}
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.sidebar-header h3 { margin: 0; font-size: 15px; }

.version-list { overflow-y: auto; flex: 1; padding: 8px 0; }
.version-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.version-item-info { display: flex; flex-direction: column; gap: 2px; }
.version-item .v-time { font-weight: 600; }
.version-item .v-count { color: var(--muted); font-size: 12px; }
.btn-compare-item { flex-shrink: 0; white-space: nowrap; }

.btn-header:disabled {
  opacity: .45;
  cursor: not-allowed;
  background: #fff;
}
.btn-header.is-disabled {
  opacity: .45;
  cursor: not-allowed;
  background: #fff;
}

.compare-banner {
  margin: 0 24px 14px;
  padding: 10px 14px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1e40af;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compare-banner.hidden { display: none; }

/* 비교 모드: 새로 추가된 캠페인 행 = 초록색, 값이 바뀐 칸 = 이전값 취소선 + 현재값 */
tr.new-row td { background: #ecfdf5; }
tr.new-row .col-name::after { content: " (신규)"; color: #16a34a; font-weight: 600; font-size: 11px; }

td.diff-cell { background: #fffbeb; }
.diff-view { font-size: 12px; line-height: 1.4; display: flex; flex-direction: column; gap: 1px; }
.diff-old { text-decoration: line-through; color: var(--muted); }
.diff-new { font-weight: 700; color: #b45309; }

.tabs {
  display: flex; gap: 4px;
  padding: 10px 24px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel.hidden { display: none; }

.filter-bar {
  margin: 0 24px 16px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}
.filter-bar label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.filter-bar select { min-width: 140px; }

.option-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 0 24px 40px;
}
.option-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.option-group h3 { margin: 0 0 10px; font-size: 14px; }
.option-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; margin-bottom: 10px; }
.option-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.option-row .option-value { flex: 1; word-break: break-all; }
.option-row .option-value input { padding: 2px 6px; font-size: 13px; }
.option-actions { display: flex; gap: 6px; flex-shrink: 0; }
.option-actions button {
  border: none; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 4px;
}
.option-actions .btn-delete:hover { color: #dc2626; }
.option-actions .btn-rename:hover { color: var(--accent); }
.option-add { display: flex; gap: 8px; }
.option-add input { flex: 1; }
.option-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }
