:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --brand: #2557d6; --brand-weak: #e8eefc;
  --ok: #1f8a4c; --ok-weak: #e6f4ec; --warn: #a15c00; --warn-weak: #fdf3e2;
  --err: #c0392b; --err-weak: #fbeaea; --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.layout { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
nav.side { background: #151a26; color: #cfd5e1; padding: 20px 12px; }
nav.side .brand { color: #fff; font-weight: 700; padding: 0 8px 16px; font-size: 15px; }
nav.side .brand small { display: block; color: #8b93a7; font-weight: 400; font-size: 11px; margin-top: 2px; }
nav.side a { display: block; color: #cfd5e1; padding: 8px; border-radius: 6px; }
nav.side a:hover, nav.side a.on { background: #263046; color: #fff; text-decoration: none; }
nav.side .sep { border-top: 1px solid #263046; margin: 10px 0; }
nav.side form { margin: 0; }
nav.side button.link { background: none; border: 0; color: #8b93a7; padding: 8px; cursor: pointer; font: inherit; }
main { padding: 24px 32px; max-width: 1200px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi .s { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px;
  border-radius: 6px; cursor: pointer; font: inherit; line-height: 1.4; }
.btn:hover { background: #f2f4f7; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d47b3; }
.btn.danger { color: var(--err); border-color: #f0c8c3; }
.btn.big { padding: 10px 20px; font-size: 15px; font-weight: 600; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }

label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 13px; }
label.check { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 6px 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { background: var(--ok-weak); border-color: #bfe3cd; color: #145c33; }
.flash.warn { background: var(--warn-weak); border-color: #f2d9ad; color: #6d3f00; }
.flash.error { background: var(--err-weak); border-color: #f0c8c3; color: #8c241a; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #eef0f3; color: #3b4252; white-space: nowrap; }
.badge.ok, .badge.delivered, .badge.opened, .badge.clicked, .badge.completed, .badge.final { background: var(--ok-weak); color: var(--ok); }
.badge.warn, .badge.paused, .badge.soft_bounced, .badge.pending { background: var(--warn-weak); color: var(--warn); }
.badge.err, .badge.bounced, .badge.failed, .badge.complained, .badge.cancelled { background: var(--err-weak); color: var(--err); }
.badge.running, .badge.sending, .badge.sent { background: var(--brand-weak); color: var(--brand); }

.bar { height: 10px; background: #eceff3; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); transition: width .4s; }

.checklist td:first-child { width: 40px; text-align: center; }
.checklist tr.eligible td { font-weight: 700; background: var(--ok-weak); }
.checklist tr.zero td { color: #a6adb9; }

.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.vars button { font-size: 12px; padding: 3px 8px; }
.login-box { max-width: 380px; margin: 12vh auto; }
.hours { display: flex; gap: 2px; align-items: flex-end; height: 80px; }
.hours div { flex: 1; background: var(--brand); min-height: 1px; border-radius: 2px 2px 0 0; }
pre.code { background: #f6f8fa; padding: 12px; border-radius: 6px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  nav.side .brand { width: 100%; padding-bottom: 6px; }
  nav.side .sep { display: none; }
  main { padding: 16px; }
  .grid.c2, .editor { grid-template-columns: 1fr; }
}
.nowrap { white-space: nowrap; }
.kv th { white-space: nowrap; width: 84px; }

/* 공유 주소 팝업·표시(라벨) */
dialog.modal { width: min(920px, 94vw); max-height: 86vh; border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
dialog.modal:focus { outline: none; }
dialog.modal::backdrop { background: rgba(15, 23, 42, .35); }
dialog.modal tr.current td { background: var(--brand-weak); }
button.badge { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
button.badge:hover { text-decoration: underline; }
.badge button.x { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; color: inherit; font: inherit; line-height: 1; }
.label-form { flex-wrap: nowrap; gap: 4px; }
.label-form select, .label-form input[type=text] { width: auto; max-width: 120px; padding: 3px 6px; font-size: 12px; }
details.act > summary { cursor: pointer; color: var(--brand); }
details.act[open] { margin: 4px 0; }
.btn.small { padding: 3px 8px; }
ul.cands { list-style: none; margin: 0; padding: 0; }
ul.cands > li { padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.cands > li:last-child { border-bottom: 0; }

/* 도움말: 칸 이름 옆 '?' 와 팝업 */
.label-row { display: flex; align-items: center; gap: 6px; margin: 14px 0 4px; }
.label-row label { margin: 0; }
.help-btn { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  color: var(--muted); font-size: 11px; font-weight: 700; line-height: 16px; padding: 0; cursor: pointer; }
.help-btn:hover, .help-btn:focus-visible { border-color: var(--brand); color: var(--brand); }
dialog.modal.help-modal { width: min(560px, 94vw); }
.help-body { font-size: 14px; line-height: 1.65; margin-top: 8px; }
.help-body p { margin: 6px 0; }
.help-body ul { margin: 6px 0; padding-left: 18px; }
.help-body table { margin: 8px 0; }
.help-body code { background: #f3f4f6; padding: 0 4px; border-radius: 4px; font-size: 13px; }

/* 화면 묶음(발송 설정의 기본 설정 / 발송 규칙) */
.section-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.group-tag { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--brand-weak); color: var(--brand); font-size: 12px; font-weight: 700; }
section.group { border-top: 3px solid var(--brand-weak); }
.savebar { display: flex; align-items: center; gap: 12px; margin: 4px 0 24px; }
