/* PALACIO 마케팅 대시보드 — 공통 스타일
   색은 검증된 데이터비주얼 팔레트를 쓰고, 라이트/다크 모두 별도로 지정합니다.
   (다크는 라이트를 뒤집은 게 아니라 다크 표면에 맞춰 따로 고른 단계입니다.) */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;   /* 기본 단일 계열 */
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --seq-200: #9ec5f4;
  --seq-450: #2a78d6;

  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --delta-up: #006300;
  --delta-down: #d03b3b;

  --track: #eeede8;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --seq-200: #184f95;
    --seq-450: #3987e5;
    --delta-up: #0ca30c;
    --delta-down: #e66767;
    --track: #262624;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --seq-200: #184f95;
  --seq-450: #3987e5;
  --delta-up: #0ca30c;
  --delta-down: #e66767;
  --track: #262624;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── 헤더 ─────────────────────────────────────────── */
header.top {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.brand span { color: var(--text-muted); font-weight: 400; margin-left: 8px; font-size: 13px; }
nav.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
nav.tabs a {
  padding: 6px 14px; border-radius: 999px; text-decoration: none;
  color: var(--text-secondary); font-weight: 500;
}
nav.tabs a:hover { background: var(--track); }
nav.tabs a[aria-current="page"] { background: var(--text-primary); color: var(--surface-1); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }

/* ── 카드 / 섹션 ──────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h2 {
  margin: 0 0 4px; font-size: 14px; font-weight: 620; letter-spacing: -0.01em;
}
.card .sub { margin: 0 0 16px; color: var(--text-muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
}

/* ── 스탯 타일 ────────────────────────────────────── */
.tile .label { color: var(--text-secondary); font-size: 12.5px; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.tile .value.hero { font-size: 48px; line-height: 1.1; }
.tile .delta { font-size: 12.5px; margin-top: 2px; color: var(--text-muted); }
.tile .delta.up { color: var(--delta-up); }
.tile .delta.down { color: var(--delta-down); }

/* ── 가로 막대 ────────────────────────────────────── */
.hbar { display: grid; grid-template-columns: minmax(84px, auto) 1fr auto; gap: 6px 12px; align-items: center; }
.hbar .name { color: var(--text-secondary); font-size: 12.5px; text-align: right; white-space: nowrap; }
.hbar .track { background: var(--track); border-radius: 4px; height: 18px; position: relative; overflow: visible; }
.hbar .fill {
  height: 100%; background: var(--series-1);
  border-radius: 0 4px 4px 0;   /* 데이터 끝만 둥글게, 기준선 쪽은 각지게 */
  min-width: 2px; transition: width .2s ease;
}
.hbar .fill.neg { background: var(--critical); }
.hbar .val { font-variant-numeric: tabular-nums; color: var(--text-primary); font-size: 12.5px; min-width: 34px; text-align: right; }

/* ── 세로 막대(추이) ──────────────────────────────── */
.cols { display: flex; align-items: flex-end; gap: 2px; height: 130px; border-bottom: 1px solid var(--baseline); padding-bottom: 0; }
.cols .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.cols .bar { background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; max-width: 24px; width: 100%; margin: 0 auto; }
.cols .bar.zero { background: var(--track); }
.colaxis { display: flex; gap: 2px; margin-top: 6px; }
.colaxis span { flex: 1; text-align: center; font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; overflow: hidden; }

/* ── 퍼널 ─────────────────────────────────────────── */
.funnel { display: grid; gap: 10px; }
.funnel .step { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; }
.funnel .step .name { color: var(--text-secondary); font-size: 12.5px; }
.funnel .step .track { background: var(--track); height: 26px; border-radius: 4px; }
.funnel .step .fill { height: 100%; border-radius: 0 4px 4px 0; }
.funnel .step:nth-child(1) .fill { background: var(--seq-450); }
.funnel .step:nth-child(2) .fill { background: var(--series-1); opacity: .78; }
.funnel .step:nth-child(3) .fill { background: var(--seq-200); }
.funnel .step .val { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── 표 ───────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--gridline); }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--track); }
.table-wrap { overflow-x: auto; }

.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--track); color: var(--text-secondary); font-size: 11.5px; white-space: nowrap;
}
.chip + .chip { margin-left: 4px; }
.idx { font-weight: 620; font-variant-numeric: tabular-nums; }
.idx.hi { color: var(--delta-up); }
.idx.lo { color: var(--text-muted); }

/* ── 알림 배너 ────────────────────────────────────── */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius); padding: 12px 16px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface-1);
}
.banner .icon { font-size: 15px; line-height: 1.4; }
.banner.warn { border-left: 3px solid var(--warning); }
.banner.crit { border-left: 3px solid var(--critical); }
.banner.info { border-left: 3px solid var(--series-1); }

/* ── 폼 ───────────────────────────────────────────── */
.form { display: grid; gap: 14px; }
.form .row { display: grid; gap: 6px; }
.form label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.form label .req { color: var(--critical); }
.form .hint { font-size: 11.5px; color: var(--text-muted); }
input, select, textarea, button {
  font-family: inherit; font-size: 13.5px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--baseline);
  border-radius: 7px; padding: 8px 10px; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: -1px; border-color: transparent; }
button { cursor: pointer; width: auto; font-weight: 560; }
button.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; padding: 9px 20px; }
button.primary:hover { filter: brightness(1.07); }
button.ghost { background: transparent; color: var(--text-secondary); }
button.ghost:hover { background: var(--track); }
button.danger { background: transparent; border-color: transparent; color: var(--critical); padding: 4px 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px;
  border: 1px solid var(--baseline); border-radius: 999px; cursor: pointer; font-size: 12.5px;
}
.checks input { width: auto; }
.checks label:has(input:checked) { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.actions { display: flex; gap: 8px; align-items: center; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* ── 도구모음 ─────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.empty { color: var(--text-muted); text-align: center; padding: 28px 0; font-size: 13px; }

/* ── 툴팁 ─────────────────────────────────────────── */
#tip {
  position: fixed; z-index: 100; pointer-events: none; opacity: 0;
  background: var(--text-primary); color: var(--surface-1);
  padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.45;
  transition: opacity .12s ease; max-width: 260px;
}
#tip.on { opacity: 1; }
#tip b { font-variant-numeric: tabular-nums; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--text-primary); color: var(--surface-1);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: all .2s ease; pointer-events: none; z-index: 200;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
