:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --brand: #1f6feb;
  --brand-soft: #e8f0fe;
  --ok: #0f8a53;
  --ok-soft: #e6f5ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --err: #c02b2b;
  --err-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --border: #2c3239;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --brand: #6ea8fe;
    --brand-soft: #1e2a3d;
    --ok: #4ade80;
    --ok-soft: #16281f;
    --warn: #fbbf24;
    --warn-soft: #2b2416;
    --err: #f87171;
    --err-soft: #2c1a1a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); }

/* ---------- 레이아웃 ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
}

.brand span { color: var(--brand); }

.topbar nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }

.topbar nav a {
  padding: 6px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
}

.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }
.wrap.narrow { max-width: 640px; }

/* ---------- 공통 요소 ---------- */

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 14px; font-size: 15px; letter-spacing: -.01em; }
.card h2 .muted { font-weight: 400; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn-danger { color: var(--err); border-color: var(--border); }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
label .opt { font-weight: 400; color: var(--muted); }

input[type=text], input[type=password], input[type=tel], input[type=email],
input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}

textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 16px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
.check input { width: auto; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--err-soft); color: var(--err); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------- 통계 ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 2px; }
.stat .v small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .n { font-size: 12px; color: var(--muted); margin-top: 2px; }

.progress { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.progress i.over { background: var(--err); }

.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* 지역별/기수별 가로 막대 */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 88px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.bar-row .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg); border-radius: 5px; height: 10px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
.bar-row .vl { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 58px; text-align: right; }
.bar-row .vl small { font-weight: 400; color: var(--muted); }

/* 일자별 세로 막대 */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 72px; }
.spark div { flex: 1; background: var(--brand-soft); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.spark div i { position: absolute; inset: auto 0 0 0; background: var(--brand); border-radius: 3px 3px 0 0; display: block; }
.spark-x { display: flex; gap: 4px; margin-top: 6px; }
.spark-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

/* ---------- 표 ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--bg); font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap-cell { white-space: normal; min-width: 180px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- 링크 복사 ---------- */

.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- 공개 접수 폼 ---------- */

.event-hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.event-hero h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.02em; }
.event-hero .meta { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.event-hero .meta b { color: var(--text); font-weight: 600; margin-right: 6px; }
.event-hero .desc { margin-top: 12px; white-space: pre-wrap; font-size: 14px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; }
.filters select, .filters input { min-width: 130px; width: auto; }

@media (max-width: 640px) {
  .wrap { padding: 16px 14px 48px; }
  .card { padding: 15px; }
  .bar-row { grid-template-columns: 72px 1fr auto; }
  .topbar nav a { padding: 6px 8px; }
}

/* ---------- 2단계 접수 진행 표시 ---------- */

.steps { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.step {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--border); font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.step.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.done { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.step-line { flex: 0 0 30px; height: 1px; background: var(--border); }

/* 1단계에서 확인해 잠긴 값 */
.locked-row { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 14px; background: var(--bg); border-radius: 8px; margin-bottom: 10px; }
.locked-row .k { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }

.sep { height: 1px; background: var(--border); margin: 16px 0; }

/* 인원 합계 — 입력이 아니라 계산 결과 */
.total {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; border-radius: 8px; margin-bottom: 16px;
  background: var(--brand-soft); color: var(--brand); font-size: 13.5px; font-weight: 600;
}
.total b { font-size: 19px; font-variant-numeric: tabular-nums; }
.total .muted { font-weight: 400; }

/* 읽기 전용 접수 내역 */
.reg-view { display: flex; flex-direction: column; gap: 9px; font-size: 14px; }
.reg-view > div { display: flex; gap: 12px; }
.reg-view .k { flex: 0 0 96px; color: var(--muted); font-size: 13px; }

.event-hero .hero-meta { display: flex; flex-direction: column; gap: 5px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.event-hero .hero-meta b { color: var(--text); font-weight: 600; margin-right: 7px; }

/* ---------- 위지윅 본문 ---------- */

/* 본문은 새니타이즈를 거친 HTML 이 그대로 들어온다. 여기서는 보이기만 다듬는다. */
.rich { font-size: 14.5px; line-height: 1.75; margin-top: 12px; }
.rich h3 { font-size: 15.5px; margin: 16px 0 7px; }
.rich h4 { font-size: 14.5px; margin: 14px 0 6px; }
.rich p { margin: 0 0 10px; }
.rich ul, .rich ol { margin: 0 0 10px; padding-left: 20px; }
.rich li { margin-bottom: 4px; }
.rich blockquote { margin: 0 0 10px; padding: 8px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.rich table { width: auto; margin-bottom: 10px; }
.rich th, .rich td { border: 1px solid var(--border); padding: 6px 10px; }
.rich > *:last-child { margin-bottom: 0; }

.wys { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.wys-tb { display: flex; gap: 2px; flex-wrap: wrap; padding: 6px 8px; background: var(--bg); border-bottom: 1px solid var(--border); }
.wys-b {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.wys-b:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.wys-sep { width: 1px; height: 18px; background: var(--border); margin: 5px 5px; align-self: center; }
.wys-area { padding: 14px 16px; min-height: 180px; outline: none; font-size: 14.5px; line-height: 1.75; }
.wys-area:focus { box-shadow: inset 0 0 0 2px var(--brand); }
.wys-area:empty::before { content: attr(data-placeholder); color: var(--faint, var(--muted)); }
.wys-area h3 { font-size: 15.5px; margin: 14px 0 6px; }
.wys-area p { margin: 0 0 9px; }
.wys-area ul, .wys-area ol { margin: 0 0 9px; padding-left: 20px; }
