:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-hover: #1a2436;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --baemin: #2ac1bc;
  --baemin-bg: rgba(42, 193, 188, 0.14);
  --coupang: #3b82f6;
  --coupang-bg: rgba(59, 130, 246, 0.15);
  --positive: #34d399;
  --negative: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, #162038 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  backdrop-filter: blur(8px);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badges {
  display: flex;
  gap: 6px;
}

.badge-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.badge-dot.baemin, .dot.baemin { background: var(--baemin); }
.badge-dot.coupang, .dot.coupang { background: var(--coupang); }

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
  background: transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

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

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.preset-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

input, select, textarea {
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-family: inherit;
}

.goal-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.goal-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 10px;
}

.goal-numbers {
  font-size: 0.95rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--baemin), var(--coupang));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label { font-size: 0.84rem; color: var(--muted); }
.kpi-value { font-size: 1.55rem; letter-spacing: -0.02em; }
.kpi-sub { font-size: 0.8rem; color: var(--muted); }

.platform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.baemin-border { border-top: 3px solid var(--baemin); }
.coupang-border { border-top: 3px solid var(--coupang); }

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

.platform-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.platform-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.platform-pill.baemin { background: var(--baemin-bg); color: var(--baemin); }
.platform-pill.coupang { background: var(--coupang-bg); color: #60a5fa; }

.share-badge {
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 999px;
}

.platform-net { font-size: 1.35rem; }

.platform-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.platform-metrics div {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.platform-metrics span { font-size: 0.76rem; color: var(--muted); }
.platform-metrics strong { font-size: 0.94rem; }

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.muted { color: var(--muted); font-size: 0.85rem; }

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

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

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.legend {
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.chart-box {
  min-height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.donut-box {
  flex-direction: column;
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions-col { text-align: right; }

tbody tr:hover { background: var(--surface-hover); }

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden, .hidden { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 560px;
  z-index: 1;
}

.modal-wide {
  max-width: 640px;
}

.webhook-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.webhook-field, .webhook-test-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-row input {
  flex: 1;
  min-width: 0;
}

.webhook-guide {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.84rem;
}

.webhook-guide pre {
  margin: 0;
  padding: 10px;
  background: #020617;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8rem;
  color: #a5f3fc;
}

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

.modal-header h3 { margin: 0; font-size: 1.1rem; }

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.full-width { grid-column: 1 / -1; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.csv-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .platform-grid, .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .platform-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}
