/* =========================================================
   미라클먼트 광고주 대시보드 - 스타일
   라이트/다크 모드는 html[data-theme] 로 전환
   ========================================================= */
:root {
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eaf1fe;
  --primary-ink: #1e40af;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --good: #0f9f6e;
  --good-soft: #e6f6ef;
  --bad: #dc2e3f;
  --bad-soft: #fdecee;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --chart-line: #2563eb;
  --chart-prev: #94a3b8;
  --chart-grid: #e9edf3;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 248px;
  color-scheme: light;
}
[data-theme="dark"] {
  --primary: #4f8bff;
  --primary-strong: #6b9dff;
  --primary-soft: #16264a;
  --primary-ink: #a9c5ff;
  --bg: #0a0f1c;
  --surface: #111829;
  --surface-2: #151d31;
  --surface-3: #1b2540;
  --border: #222d45;
  --border-strong: #2f3c5a;
  --text: #e8edf7;
  --text-2: #c3cce0;
  --muted: #8d99b3;
  --good: #34c796;
  --good-soft: #0f2c24;
  --bad: #ff6b7a;
  --bad-soft: #35161d;
  --warn: #f5b454;
  --warn-soft: #33250f;
  --chart-line: #5b95ff;
  --chart-prev: #5d6b88;
  --chart-grid: #1e2840;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.ic { flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.select-all { user-select: all; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 테마 토글 ---------- */
.only-dark { display: none; }
[data-theme="dark"] .only-dark { display: inline-flex; }
[data-theme="dark"] .only-light { display: none; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-3); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger-ghost { background: transparent; border-color: var(--border); color: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
form.inline { display: inline; }

/* ---------- 폼 ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-section { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.form-section + .form-section { padding-top: 18px; border-top: 1px dashed var(--border); }
.form-section legend { float: left; width: 100%; font-size: 13px; font-weight: 700; color: var(--muted); padding: 0; margin: 0; letter-spacing: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.label small { font-weight: 400; margin-left: 4px; }
.req { color: var(--bad); font-style: normal; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input:disabled { background: var(--surface-2); color: var(--muted); }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--bad); }
input[aria-invalid=true]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 20%, transparent); }
.field-error { font-size: 12.5px; color: var(--bad); }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.ok { color: var(--good); }
.hint.bad { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.gap-lg { gap: 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex-shrink: 0; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.pw-toggle:hover { color: var(--text); }
.pw-meter { display: flex; align-items: center; gap: 4px; height: 16px; }
.pw-meter i { flex: 1; max-width: 40px; height: 4px; border-radius: 4px; background: var(--surface-3); }
.pw-meter em { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 6px; }
.pw-meter[data-level="1"] i:nth-child(-n+1) { background: var(--bad); }
.pw-meter[data-level="2"] i:nth-child(-n+2) { background: var(--primary); }
.pw-meter[data-level="3"] i:nth-child(-n+3) { background: var(--good); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.captcha-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.captcha-img { border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); display: block; width: 180px; height: 60px; }
.captcha-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; max-width: 180px; }
.captcha-row .captcha-input { flex: 1; min-width: 140px; height: 60px; font-size: 18px; text-align: center; }
.terms { font-size: 12.5px; color: var(--muted); margin-left: 28px; margin-top: -6px; }
.terms summary { cursor: pointer; width: fit-content; }
.terms p { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0 0; line-height: 1.7; }
.code-block { background: var(--surface-2); border: 1px solid var(--border); padding: 12px; border-radius: 8px; font-size: 12px; overflow: auto; }

/* ---------- 알림 ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.alert .ic { margin-top: 2px; }
.alert-success { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-info { background: var(--primary-soft); color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 20%, transparent); }
.alert span { color: var(--text); }
.alert b { font-weight: 700; }

/* ---------- 인증 화면 ---------- */
body.auth { background: var(--bg); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr; }
.auth-aside {
  position: relative; overflow: hidden; color: #fff; padding: 44px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(120% 90% at 0% 0%, #2f6bff 0%, #1d4ed8 45%, #0f2a78 100%);
}
[data-theme="dark"] .auth-aside { background: radial-gradient(120% 90% at 0% 0%, #1f4fd1 0%, #122f86 50%, #0a1640 100%); }
.auth-pitch { position: relative; z-index: 1; max-width: 420px; }
.auth-pitch h2 { font-size: 34px; line-height: 1.25; font-weight: 800; margin-bottom: 16px; }
.auth-pitch p { color: rgba(255,255,255,.82); font-size: 15px; margin: 0 0 28px; }
.auth-pitch ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-pitch li { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.92); font-size: 14px; }
.auth-pitch li .ic { width: 30px; height: 30px; padding: 7px; border-radius: 8px; background: rgba(255,255,255,.14); }
.auth-aside-foot { position: relative; z-index: 1; font-size: 12px; color: rgba(255,255,255,.6); }
.auth-deco { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 45%; color: #fff; opacity: .35; }
.auth-main { display: flex; flex-direction: column; align-items: center; padding: 20px 24px 48px; }
.auth-top { width: 100%; display: flex; justify-content: flex-end; }
.auth-card { width: 100%; max-width: 420px; margin: auto 0; padding-top: 16px; }
.auth-card.wide { max-width: 560px; }
.auth-head { margin-bottom: 24px; }
.auth-head h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.auth-head p { color: var(--muted); margin: 0; }
.auth-switch { text-align: center; margin: 22px 0 6px; color: var(--muted); }
.auth-switch a { font-weight: 700; }
.auth-note { text-align: center; font-size: 12.5px; color: var(--muted); margin: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand b { display: block; font-size: 15px; font-weight: 800; letter-spacing: .06em; line-height: 1.1; }
.brand small { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }
.brand-mark { display: inline-flex; }
.brand-invert { color: #fff; position: relative; z-index: 1; }
.brand-invert small { color: rgba(255,255,255,.7); }
.brand-invert .brand-mark rect { fill: #fff; }
.brand-invert .brand-mark path { stroke: #1d4ed8; }

.state-card { text-align: center; padding: 12px 0; }
.state-card h1 { font-size: 24px; margin: 18px 0 10px; }
.state-card p { color: var(--text-2); line-height: 1.8; }
.state-icon { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.state-contact { display: flex; justify-content: center; gap: 28px; margin: 22px 0; padding: 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.state-contact dt { font-size: 12px; color: var(--muted); }
.state-contact dd { margin: 0; font-weight: 700; }
.state-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- 앱 레이아웃 ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar .brand { padding: 4px 10px 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 14px 12px 6px; letter-spacing: .02em; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; text-decoration: none !important;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-ink); }
.nav-item.active .ic { color: var(--primary); }
.badge-count { margin-left: auto; font-style: normal; font-size: 11.5px; font-weight: 700; background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 7px; }
.help-card { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.help-card b { font-size: 13px; margin-bottom: 2px; }
.help-card span { font-weight: 700; font-size: 15px; }
.main-wrap { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.user-btn:hover { border-color: var(--border-strong); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-meta { text-align: left; line-height: 1.2; }
.user-meta b { display: block; font-size: 13px; }
.user-meta small { display: block; font-size: 11.5px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 170px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  display: none; z-index: 50;
}
.user-menu.open .dropdown { display: block; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--text-2); text-decoration: none !important; font-size: 13.5px; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); color: var(--text); }
.content { padding: 24px 28px 28px; flex: 1; width: 100%; max-width: 1480px; }
.app-foot { padding: 16px 28px 24px; font-size: 12px; color: var(--muted); }
.scrim { display: none; }

/* ---------- 카드 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head.wrap { flex-wrap: wrap; }
.card-head.pad { padding: 18px 20px 14px; margin: 0; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-head .muted { font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.back { margin: 0 0 14px; }
.back a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.back a .ic { transform: rotate(180deg); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .ic { color: var(--border-strong); }
.empty-lg { text-align: center; padding: 48px 24px; }
.empty-lg h2 { font-size: 18px; margin: 16px 0 8px; }
.empty-lg p { color: var(--muted); line-height: 1.8; margin: 0 0 18px; }
.kv { margin: 0; display: grid; gap: 8px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.plain-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; }

/* ---------- 칩 / 상태 ---------- */
.chip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); vertical-align: middle; }
.chip-primary { background: var(--primary-soft); color: var(--primary-ink); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-approved { background: var(--good-soft); color: var(--good); }
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-rejected, .status-suspended { background: var(--bad-soft); color: var(--bad); }
.dot-on, .dot-off { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot-on::before, .dot-off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.dot-on::before { background: var(--good); }
.dot-off::before { background: var(--border-strong); }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; line-height: 1.35; }
.table th small { font-weight: 500; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th.sorted { color: var(--primary); }
.table th.sorted::after { content: " ▼"; font-size: 9px; }
.table th.sorted.asc::after { content: " ▲"; }
.table-data td.name { min-width: 200px; }
.table-data th:first-child, .table-data td.name { position: sticky; left: 0; z-index: 1; }
.table-data td.name { background: var(--surface); }
.table-data tbody tr:hover td.name { background: var(--surface-2); }
.table-data tfoot td:first-child { position: sticky; left: 0; z-index: 1; }
@media (max-width: 640px) { .table-data td.name { min-width: 150px; max-width: 170px; } }
.table-data tr.clickable { cursor: pointer; }
.table-data tr.clickable .ent-name { color: var(--text); font-weight: 600; }
.table-data tr.clickable:hover .ent-name { color: var(--primary); text-decoration: underline; }
.ent-sub { display: flex; gap: 8px; align-items: center; margin-top: 3px; }
.sticky-col { position: sticky; left: 0; background: inherit; z-index: 1; }
.table th.sticky-col { background: var(--surface-2); }
.table td.sticky-col { background: var(--surface); }
.table tbody tr:hover td.sticky-col { background: var(--surface-2); }
.table-foot { padding: 12px 20px; border-top: 1px solid var(--border); }
.rank-hi { color: var(--primary); font-weight: 700; }

/* ---------- 툴바 / 탭 / 검색 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 13.5px; text-decoration: none !important; }
.tab em { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 2px; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--primary); color: #fff; }
.tab.active em { color: rgba(255,255,255,.8); }
.search-box { position: relative; display: flex; align-items: center; min-width: 260px; }
.search-box .ic { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 36px; }
.search-box.sm { min-width: 180px; }
.search-box.sm input { height: 34px; font-size: 13px; padding-left: 32px; }
.search-box.sm .ic { left: 10px; }
.select-wrap { display: inline-flex; }
.select-wrap select { cursor: pointer; font-weight: 600; min-width: 200px; }
.select-wrap.sm select { height: 34px; font-size: 13px; min-width: 130px; font-weight: 500; }

/* 세그먼트 버튼 */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.active { background: var(--primary-soft); color: var(--primary-ink); }
.seg-sm button { padding: 5px 10px; font-size: 12.5px; }

/* ---------- 대시보드 ---------- */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.date-range { display: inline-flex; align-items: center; gap: 6px; }
.date-range input { width: 148px; height: 38px; font-size: 13px; }
.date-range span { color: var(--muted); }
.filters .updated { margin-left: auto; }
.demo-banner { margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: 14px; font-weight: 700; margin-left: 2px; color: var(--text-2); }
.kpi-delta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.delta.up.good, .delta.down.good { color: var(--good); background: var(--good-soft); }
.delta.up.bad, .delta.down.bad { color: var(--bad); background: var(--bad-soft); }
.delta.neutral { color: var(--text-2); background: var(--surface-3); }
.skeleton { color: transparent !important; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; min-width: 60%; }
@keyframes sk { to { background-position: -200% 0; } }

.chart-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.chart { position: relative; height: 290px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin: -6px 0 8px; min-height: 18px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 16px; height: 0; border-top: 2px solid var(--chart-line); }
.chart-legend i.prev { border-top: 2px dashed var(--chart-prev); }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.prev { stroke: var(--chart-prev); stroke-dasharray: 4 4; stroke-width: 1.6; }
.chart .area { fill: url(#area-grad); }
.chart .cross { stroke: var(--border-strong); stroke-width: 1; }
.chart .dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; }
.chart .dot.prev { fill: var(--chart-prev); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; font-size: 12.5px; transform: translate(-50%, -100%); white-space: nowrap;
}
.chart-tip b { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.chart-tip div { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chart-tip div span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip div strong { font-variant-numeric: tabular-nums; }
.chart-tip i { width: 10px; border-top: 2px solid var(--chart-line); }
.chart-tip i.prev { border-top: 2px dashed var(--chart-prev); }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }

.share { display: flex; flex-direction: column; gap: 14px; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13px; }
.share-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.share-row .vl { font-variant-numeric: tabular-nums; font-weight: 700; }
.share-row .vl small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.share-bar { grid-column: 1 / -1; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--chart-line); border-radius: 0 4px 4px 0; }
.share-row:hover .share-bar i { background: var(--primary-strong); }
.share-total { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding-top: 10px; border-top: 1px dashed var(--border); }

.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 16px; font-weight: 700; }
.crumbs a { color: var(--muted); font-weight: 600; cursor: pointer; }
.crumbs a:hover { color: var(--primary); }
.crumbs .ic { color: var(--muted); }
.crumbs + p { margin: 4px 0 0; }
.footnote { margin: 14px 2px 0; }
.loading-row td { text-align: center; color: var(--muted); padding: 36px 14px !important; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 키워드 도구 ---------- */
.kw-search { padding: 22px; }
.kw-input { display: flex; align-items: center; gap: 10px; border: 2px solid var(--border-strong); border-radius: 14px; padding: 6px 6px 6px 16px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.kw-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.kw-input > .ic { color: var(--muted); }
.kw-input input { border: 0 !important; box-shadow: none !important; height: 46px; font-size: 16px; padding: 0; background: transparent; }
.kw-input .btn { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 10px; }
.kw-options { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.kw-recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; font-size: 12.5px; }
.kw-recent button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.kw-recent button:hover { border-color: var(--primary); color: var(--primary); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.kw-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 20px; }
.kw-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kw-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kw-card .big { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kw-card .big small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.kw-split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 12px 0 8px; background: var(--surface-3); gap: 2px; }
.kw-split i { display: block; height: 100%; }
.kw-split .pc { background: var(--chart-prev); }
.kw-split .mo { background: var(--chart-line); }
.kw-split-legend { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.kw-split-legend span { display: inline-flex; align-items: center; gap: 6px; }
.kw-split-legend i { width: 8px; height: 8px; border-radius: 2px; }
.kw-meta { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12.5px; }
.kw-meta div { display: flex; justify-content: space-between; gap: 10px; }
.kw-meta dt { color: var(--muted); }
.kw-meta dd { margin: 0; font-weight: 700; }
.kw-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comp { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12.5px; }
.comp i { display: inline-flex; gap: 2px; }
.comp i b { width: 4px; height: 10px; border-radius: 1px; background: var(--border-strong); }
.comp.lv3 i b { background: var(--bad); }
.comp.lv2 i b:nth-child(-n+2) { background: var(--warn); }
.comp.lv1 i b:nth-child(1) { background: var(--good); }
tr.hint-row td { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
tr.hint-row td.sticky-col { background: var(--primary-soft); }
.hint-tag { font-size: 10.5px; font-weight: 700; color: var(--primary-ink); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); padding: 0 5px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.lt10 { color: var(--muted); }

/* ---------- 관리자 ---------- */
.acct-edit { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.acct-row { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); flex-wrap: wrap; }
.acct-row input { flex: 1; min-width: 160px; height: 34px; font-size: 13px; }
.acct-id { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; min-width: 110px; }
.acct-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.acct-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.acct-list li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); flex-wrap: wrap; }
.acct-list .muted { margin-left: auto; font-size: 12.5px; }

/* ---------- 반응형 ---------- */
@media (max-width: 1200px) {
  .chart-grid { grid-template-columns: 1fr; }
  .share { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .share-total { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .filters .updated { margin-left: 0; width: 100%; }
}
@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 24px; }
  .app-foot { padding: 12px 16px 20px; }
  .user-meta { display: none; }
  .user-btn { padding: 4px; }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .topbar-title p { display: none; }
  .topbar-title h1 { font-size: 17px; }
  .select-wrap, .select-wrap select { width: 100%; min-width: 0; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 7px 6px; }
  .date-range { flex: 1; }
  .date-range input { width: auto; flex: 1; min-width: 0; }
  .chart { height: 240px; }
  .search-box { min-width: 0; width: 100%; }
  .kw-input { flex-wrap: wrap; padding: 6px 6px 6px 12px; }
  .kw-input input { flex: 1; min-width: 0; font-size: 15px; }
  .kw-input .btn { width: 100%; }
  .acct-add { grid-template-columns: 1fr; }
  .auth-main { padding: 12px 16px 36px; }
  .auth-head h1 { font-size: 22px; }
  .state-contact { flex-direction: column; gap: 10px; }
  .card { padding: 16px; }
  .card-head.pad { padding: 16px 16px 12px; }
  .kw-tools, .kw-tools .search-box.sm { width: 100%; }
  .kw-tools .search-box.sm { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .filters, .app-foot, #csv { display: none !important; }
  .main-wrap { margin: 0; }
}
#kw-table td.sticky-col { white-space: nowrap; min-width: 140px; }
@media (max-width: 640px) { #kw-table td.sticky-col { min-width: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; } }

/* =========================================================
   v1.011 - 파트너 대시보드
   ========================================================= */
.role-tag { display: inline-flex; align-items: center; font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; vertical-align: 1px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.role-tag.role-partner { background: var(--good-soft); color: var(--good); }
.role-tag.role-admin { background: var(--primary-soft); color: var(--primary-ink); }
.user-meta .role-tag { margin-left: 4px; }
.role-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.mt-sm { margin-top: 12px; }
.neg { color: var(--bad); }
.check-col { width: 40px; text-align: center !important; }
.check-col input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk select, .bulk input[type=date] { height: 32px; font-size: 13px; width: auto; }
.link-btn { border: 0; background: none; color: var(--primary); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0 4px; }
.link-btn:hover { text-decoration: underline; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.filter-bar .search-box.sm { min-width: 170px; flex: 0 1 200px; }
.filter-bar .check { margin-left: 4px; }

/* 정산 */
.chart-bar .bar { fill: var(--chart-line); transition: opacity .15s; }
.chart-bar .bar.dim { opacity: .35; }
.month-list { max-height: 330px; overflow-y: auto; }
.month-list tr.selected td { background: var(--primary-soft); }
.month-list tr.selected a { font-weight: 800; }
.kv.calc div { padding: 6px 0; }
.kv.calc .total { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; font-size: 16px; }
.kv.calc .total dd { color: var(--primary); font-size: 20px; font-weight: 800; }
.help-kv div { font-size: 12.5px; }
.help-kv dd { font-weight: 500; color: var(--text-2); text-align: right; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 34px 18px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--good); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-icon { width: 52px; height: 52px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); color: var(--primary); border: 1px solid var(--border); }

/* 키워드 도구 */
.kw-options .opt { display: inline-flex; align-items: center; gap: 8px; }
.kw-options .opt .label { font-size: 12.5px; color: var(--muted); }
.depth { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); }
.depth.d0 { background: var(--primary); color: #fff; }
.depth.d1 { background: var(--primary-soft); color: var(--primary-ink); }
.depth.d3 { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
td.from { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-bar { display: inline-block; width: 54px; height: 6px; border-radius: 3px; background: var(--surface-3); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--chart-line); border-radius: 0 3px 3px 0; }
.chip.area-title, .chip.area-meta { background: var(--primary-soft); color: var(--primary-ink); }
.chip.area-heading { background: var(--good-soft); color: var(--good); }
.tabs-inline { display: inline-flex; margin-bottom: 14px; }
.tabs-inline .tab { border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px; }
#xt-text { min-height: 150px; font-size: 14px; line-height: 1.7; }

/* 키워드 조합 */
.combine-inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.combine-col .label { display: flex; align-items: center; gap: 6px; }
.combine-col .label em { font-style: normal; font-weight: 500; }
.combine-col .link-btn { margin-left: auto; font-weight: 500; color: var(--muted); }
.combine-col textarea { font-size: 14px; line-height: 1.7; resize: vertical; min-height: 200px; }
.combine-opts { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.perm-group { padding: 14px 0; border-top: 1px dashed var(--border); }
.perm-group:first-of-type { border-top: 0; padding-top: 0; }
.perm-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.perm-head b { font-size: 13.5px; margin-right: 6px; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.perm { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; background: var(--surface); user-select: none; transition: border-color .12s, background .12s; }
.perm:hover { border-color: var(--border-strong); }
.perm input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.perm:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.perm.zero { opacity: .5; }
.combine-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.combine-bar b { font-size: 18px; color: var(--primary); font-variant-numeric: tabular-nums; }
.combine-preview { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.7; min-height: 320px; background: var(--surface-2); }

@media (max-width: 1100px) {
  .combine-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .combine-inputs { grid-template-columns: 1fr 1fr; gap: 10px; }
  .combine-col textarea { min-height: 140px; }
  .perm-list { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  .filter-bar { padding: 12px 16px; }
  .filter-bar .search-box.sm { flex: 1 1 100%; }
  .bulk { width: 100%; }
  .kw-options .opt { width: 100%; justify-content: space-between; }
}
.tabs-inline .tab.active { background: var(--primary); color: #fff; }
.month-list td { white-space: nowrap; }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.act { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.act-insert { background: var(--good-soft); color: var(--good); }
.act-update { background: var(--primary-soft); color: var(--primary-ink); }
.act-same { background: var(--surface-3); color: var(--muted); }
.act-delete { background: var(--bad-soft); color: var(--bad); }
tr.muted-row td { color: var(--muted); }
tr.del-row td { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); color: var(--muted); }
tr.del-row td:nth-child(2) { text-decoration: none; }
.steps { margin: 0 0 4px; padding-left: 20px; display: grid; gap: 10px; font-size: 13px; }
.steps b { display: block; }
.steps span { color: var(--muted); }
.steps em { font-style: normal; font-weight: 700; color: var(--text-2); }
