:root {
  color-scheme: light;
  --ink: #14231d;
  --muted: #66746e;
  --line: #dfe6e2;
  --panel: #ffffff;
  --canvas: #f4f7f5;
  --green: #127a53;
  --green-dark: #0d5f40;
  --green-soft: #e8f5ef;
  --lime: #b8e66a;
  --blue: #3b6eea;
  --orange: #ec8c35;
  --red: #cf4c4c;
  --shadow: 0 12px 30px rgba(28, 58, 45, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Pretendard, "Noto Sans KR", "Malgun Gothic", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.demo-banner { height: 38px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 18px; background: #1b2c25; color: #d9e7e1; font-size: 12px; letter-spacing: .01em; }
.demo-banner strong { color: var(--lime); font-size: 11px; letter-spacing: .12em; }
.app-shell { min-height: calc(100vh - 38px); display: grid; grid-template-columns: 220px 1fr; }
.sidebar { position: sticky; top: 0; height: calc(100vh - 38px); padding: 26px 18px; background: #fdfefd; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; margin: 0 10px 32px; font-size: 20px; }
.logo span, .brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: white; background: linear-gradient(145deg, #16855c, #0e6645); font-weight: 900; box-shadow: 0 8px 20px rgba(18, 122, 83, .22); }
nav { display: grid; gap: 8px; }
.nav-item { width: 100%; border: 0; border-radius: 12px; padding: 13px 14px; display: flex; gap: 10px; align-items: center; text-align: left; background: transparent; color: #5d6a65; font-weight: 700; }
.nav-item.active { color: var(--green-dark); background: var(--green-soft); }
.sidebar-note { margin-top: auto; border: 1px solid #f0d6a9; background: #fff9ee; padding: 14px; border-radius: 14px; display: grid; gap: 5px; }
.sidebar-note b { font-size: 13px; color: #8c5c18; }
.sidebar-note span { font-size: 11px; line-height: 1.55; color: #806c4d; }

main { min-width: 0; }
.topbar { min-height: 110px; padding: 28px 38px 22px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.8); border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: -.035em; }
.top-actions { display: flex; gap: 9px; align-items: center; font-size: 12px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #35b878; box-shadow: 0 0 0 4px #ddf5e9; }
.profile { margin-left: 12px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--ink); font-weight: 700; }
.content-view { padding: 28px 38px 60px; max-width: 1500px; margin: auto; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.step-grid { display: grid; grid-template-columns: .8fr 1fr 1.25fr; gap: 16px; align-items: stretch; }
.step-panel { padding: 20px; min-height: 310px; }
.step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.step-head > span { width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center; background: var(--green); color: white; font-weight: 800; font-size: 13px; }
.step-head h2 { margin: 1px 0 4px; font-size: 16px; }
.step-head p, .panel-title p { margin: 0; color: var(--muted); font-size: 12px; }
.choice-list { display: grid; gap: 8px; }
.choice { position: relative; display: flex; align-items: center; gap: 11px; min-height: 52px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: white; transition: .15s ease; }
.choice:hover { border-color: #9bcab7; }
.choice.selected { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.choice input { width: 18px; height: 18px; accent-color: var(--green); }
.choice-copy { min-width: 0; display: grid; gap: 3px; }
.choice-copy b { font-size: 14px; }
.choice-copy small { color: var(--muted); font-size: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #eef3f0; color: var(--green-dark); font-weight: 900; }

.source-list { display: grid; gap: 8px; }
.source-choice { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px; }
.source-choice.selected { border-color: var(--green); background: var(--green-soft); }
.source-choice.disabled { opacity: .65; background: #f8f8f8; }
.source-choice input { width: 17px; height: 17px; accent-color: var(--green); }
.source-copy { min-width: 0; display: grid; gap: 4px; }
.source-name { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 800; }
.badge { padding: 3px 7px; border-radius: 7px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.meta { color: #2850af; background: #e9efff; }
.badge.danggeun { color: #a9580a; background: #fff0df; }
.badge.advertiser_sheet { color: #4b5a55; background: #edf1ef; }
.source-meta { display: flex; gap: 8px; align-items: center; font-size: 10px; color: var(--muted); }
.health { display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.health.normal { color: var(--green); }
.health.normal::before { background: #35b878; }
.health.error { color: var(--red); }
.health.error::before { background: var(--red); }

.rule-card { margin: 20px 0 14px; padding: 22px 26px; border-radius: 18px; display: flex; align-items: center; gap: 18px; color: #eaf8f2; background: linear-gradient(120deg, #123d2e, #0e6545); box-shadow: 0 16px 30px rgba(13, 95, 64, .18); }
.rule-icon { width: 46px; height: 46px; flex: 0 0 auto; border-radius: 14px; display: grid; place-items: center; color: #183525; background: var(--lime); font-size: 20px; }
.rule-card p { margin: 0 0 7px; color: #a9d8c5; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.rule-card h2 { margin: 0; font-size: 19px; line-height: 1.45; letter-spacing: -.02em; }
.action-row { display: flex; gap: 10px; align-items: stretch; }
.button { border: 0; border-radius: 11px; padding: 12px 17px; font-weight: 800; font-size: 13px; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green-dark); background: white; border: 1px solid #9bcab7; }
.button.test { color: #294d8e; background: #eaf0ff; border: 1px solid #b9c9ef; }
.button.onboarding { color: #20360e; background: var(--lime); border: 1px solid #9bc94f; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.full { width: 100%; margin-top: 10px; }
.live-lock { margin-left: auto; min-width: 260px; padding: 9px 14px; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; border: 1px dashed #c8cecb; border-radius: 12px; color: #717b77; background: #eef1f0; }
.live-lock span { grid-row: 1 / 3; }
.live-lock b { font-size: 12px; }
.live-lock small { font-size: 9px; }

.result-panel { margin-top: 18px; padding: 24px; }
.result-head { display: flex; justify-content: space-between; align-items: center; }
.result-head h2 { margin: 0; font-size: 20px; }
.result-badge { padding: 7px 11px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 900; }
.stat-grid { margin: 20px 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat { padding: 14px; border-radius: 12px; background: #f7f9f8; border: 1px solid #e9eeeb; }
.stat b { display: block; margin-bottom: 4px; font-size: 23px; }
.stat span { font-size: 10px; color: var(--muted); }
.message-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.message-card { padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: #fbfcfb; }
.message-card header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: 12px; }
.message-card pre { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: 12px; line-height: 1.65; color: #43504b; }
.plan-state { color: var(--green); font-weight: 800; }
.plan-state.duplicate_stopped { color: var(--orange); }

.admin-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.summary-card { padding: 18px; border-radius: 16px; color: white; background: linear-gradient(145deg, #176b4b, #0f5139); box-shadow: var(--shadow); }
.summary-card span, .summary-card small { display: block; color: #c8e8da; font-size: 11px; }
.summary-card b { display: block; margin: 7px 0 3px; font-size: 26px; }
.summary-card.warning { background: linear-gradient(145deg, #a96324, #7a461a); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.admin-card, .source-admin, .wizard { padding: 22px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.panel-title h2 { margin: 0 0 5px; font-size: 16px; }
.mini-button, .icon-button { border: 1px solid var(--line); background: white; color: var(--green); border-radius: 9px; padding: 8px 10px; font-size: 11px; font-weight: 800; }
.admin-list { display: grid; gap: 8px; }
.quick-form { margin-top: 12px; padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: end; border: 1px solid #cfe2d9; border-radius: 12px; background: var(--green-soft); }
.quick-form label { display: grid; gap: 5px; color: #4e5c56; font-size: 10px; font-weight: 800; }
#recipientForm { grid-template-columns: 1.2fr 1fr 1fr 1.25fr auto; }
.admin-row { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-radius: 11px; background: #f7f9f8; }
.admin-row div { display: grid; gap: 3px; }
.admin-row b { font-size: 13px; }
.admin-row span { font-size: 10px; color: var(--muted); }
.advertiser-admin-row { width: 100%; border: 1px solid transparent; color: var(--ink); text-align: left; cursor: pointer; }
.advertiser-admin-row:hover { border-color: #a9cdbb; }
.advertiser-admin-row.selected { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.advertiser-admin-row[aria-disabled="true"] { opacity: .55; cursor: not-allowed; border-color: var(--line); }
.advertiser-admin-row .selected-label { color: var(--green); font-weight: 900; }
.recipient-target-notice { grid-column: 1 / -1; min-height: 16px; margin: 0; color: var(--green-dark); font-size: 10px; font-weight: 800; }
.recipient-target-notice.blocked { color: var(--red); }
.source-admin { margin-top: 16px; }
.source-table { display: grid; gap: 7px; }
.source-table-row { display: grid; grid-template-columns: 1.4fr .8fr .8fr .7fr; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid #edf0ee; font-size: 12px; }
.source-table-row.header { color: var(--muted); font-size: 10px; font-weight: 800; background: #f7f9f8; border-radius: 10px; }
.wizard { margin-top: 16px; border-color: #9bcab7; }
.wizard-head { display: flex; justify-content: space-between; align-items: flex-start; }
.wizard-head h2 { margin: 0; font-size: 20px; }
.icon-button { font-size: 21px; color: var(--muted); padding: 3px 10px; }
.wizard-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 20px 0; }
.wizard-progress span { padding: 8px; text-align: center; color: var(--muted); background: #f1f4f2; border-radius: 8px; font-size: 10px; font-weight: 800; }
.wizard-progress span.active { color: white; background: var(--green); }
.wizard-section { margin: 18px 0; }
.wizard-section h3 { font-size: 13px; }
.source-hero { display: flex; justify-content: space-between; gap: 24px; align-items: center; padding: 22px 24px; border-radius: 18px; color: white; background: linear-gradient(120deg, #123d2e, #0e6545); box-shadow: var(--shadow); }
.source-hero h2 { margin: 0 0 7px; font-size: 21px; }
.source-hero p:not(.eyebrow) { margin: 0; color: #cce7dc; font-size: 12px; }
.safety-pill { flex: 0 0 auto; padding: 10px 14px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; color: #effaf5; background: rgba(255,255,255,.1); font-size: 11px; font-weight: 800; }
.type-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.type-cards label { position: relative; display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.type-cards input { position: absolute; top: 12px; right: 12px; accent-color: var(--green); }
.type-cards b { font-size: 12px; color: var(--green-dark); }
.type-cards span { color: var(--muted); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.source-binding-grid { grid-template-columns: minmax(300px, 1.7fr) minmax(180px, .8fr) minmax(110px, .35fr); }
.form-grid label, .login-card label { display: grid; gap: 7px; color: #4e5c56; font-size: 11px; font-weight: 800; }
input, select { width: 100%; border: 1px solid #cdd6d1; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18,122,83,.1); }
.wizard-actions { display: flex; justify-content: flex-end; gap: 10px; }
.mapping-preview { margin-top: 18px; padding: 16px; border-radius: 13px; background: var(--green-soft); }
.mapping-preview h3 { margin: 0 0 10px; font-size: 13px; }
.mapping-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid #d5e8df; color: #385247; font-size: 11px; }
.anchor-warning { margin-top: 12px; padding: 13px 15px; display: grid; gap: 4px; border: 1px solid #efcf93; border-radius: 12px; color: #76521d; background: #fff8e9; }
.anchor-warning b { font-size: 12px; }
.anchor-warning span { font-size: 10px; line-height: 1.55; }
.sheet-connect { display: grid; gap: 12px; }
.share-email-card { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px; border: 1px solid #c9ddf4; border-radius: 13px; background: #f1f7ff; }
.share-email-card div { min-width: 0; display: grid; gap: 4px; }
.share-email-card small { color: #315c8f; font-size: 9px; font-weight: 900; }
.share-email-card b { overflow-wrap: anywhere; font-size: 13px; }
.share-email-card span { color: #667788; font-size: 10px; line-height: 1.45; }
.wizard-section-title, .length-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.wizard-section-title h3, .length-head h3 { margin: 0 0 4px; }
.wizard-section-title p, .length-head p { margin: 0; color: var(--muted); font-size: 10px; }
.business-field-list { margin-top: 12px; display: grid; gap: 8px; }
.business-field { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; }
.business-field.included { border-color: #9bcab7; background: var(--green-soft); }
.business-field.excluded { color: #7d8581; background: #f4f5f4; }
.business-field input { width: 17px; height: 17px; accent-color: var(--green); }
.business-field b { display: block; margin-bottom: 3px; font-size: 12px; }
.business-field small { display: block; color: var(--muted); font-size: 9px; }
.business-field > span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.recipient-inline-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr auto; gap: 9px; align-items: end; }
.safe-note { min-height: 16px; margin: 8px 0 0; color: var(--green); font-size: 10px; font-weight: 800; }
.onboarding-preview { margin: 18px 0; padding: 18px; border: 1px solid #b8d5c7; border-radius: 15px; background: #fbfdfc; }
.onboarding-preview pre { margin: 14px 0; padding: 15px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: #33483f; background: #f0f5f2; font: 12px/1.65 inherit; }
.length-badge { padding: 7px 10px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 10px; font-weight: 900; }
.length-badge.blocked { color: #9e3d3d; background: #fdeaea; }
.length-details { color: var(--muted); font-size: 10px; line-height: 1.6; }
.length-details.blocked { color: #a13f3f; font-weight: 800; }

.login-shell { min-height: calc(100vh - 38px); display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 20%, #effaf4 0, #f4f7f5 48%, #e8efeb 100%); }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 24px 60px rgba(23, 66, 47, .14); }
.login-card .brand-mark { margin-bottom: 26px; }
.login-card h1 { margin: 0 0 10px; font-size: 27px; letter-spacing: -.04em; }
.login-card > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.form-error { min-height: 18px; margin: 10px 0 0 !important; color: var(--red) !important; font-size: 11px !important; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 20; max-width: 390px; padding: 13px 16px; border-radius: 12px; color: white; background: #183c2e; box-shadow: 0 14px 35px rgba(0,0,0,.18); font-size: 12px; font-weight: 700; }

@media (max-width: 1120px) {
  .step-grid { grid-template-columns: 1fr 1fr; }
  .source-panel { grid-column: 1 / 3; }
  .source-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; flex-direction: row; align-items: center; }
  .logo { margin: 0 14px 0 0; }
  nav { display: flex; }
  .sidebar-note { display: none; }
  .topbar, .content-view { padding-left: 18px; padding-right: 18px; }
  .top-actions { display: none; }
  .step-grid, .admin-grid, .admin-summary, .type-cards, .form-grid, .source-binding-grid { grid-template-columns: 1fr; }
  .source-hero { display: grid; }
  .quick-form, #recipientForm { grid-template-columns: 1fr; }
  .recipient-inline-grid { grid-template-columns: 1fr; }
  .wizard-progress { grid-template-columns: 1fr; }
  .source-panel { grid-column: auto; }
  .source-list, .message-grid { grid-template-columns: 1fr; }
  .action-row { flex-wrap: wrap; }
  .live-lock { width: 100%; margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
