/* ============================================================
 *  관리자 공통 스타일 (모든 템플릿 공통 — 수정하지 마세요)
 * ============================================================ */
:root {
  --a-bg: #f5f6f8;
  --a-panel: #ffffff;
  --a-text: #1d2129;
  --a-soft: #6b7280;
  --a-line: #e5e7eb;
  --a-primary: #3f5efb;
  --a-primary-soft: #eef1ff;
  --a-danger: #e5484d;
  --a-ok: #12a150;
  --a-warn: #f5a524;
  --a-radius: 10px;
  --a-side: 232px;
  --a-head: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px; line-height: 1.55; color: var(--a-text); background: var(--a-bg);
  -webkit-font-smoothing: antialiased; word-break: keep-all;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--a-primary); }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100%; color: var(--a-soft); }

/* ---------- 버튼 ---------- */
.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--a-line); background: var(--a-panel); white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s; text-decoration: none; color: var(--a-text);
}
.a-btn:hover { background: #f9fafb; }
.a-btn:disabled { opacity: .5; cursor: default; }
.a-btn--primary { background: var(--a-primary); border-color: var(--a-primary); color: #fff; }
.a-btn--primary:hover { background: #2f4ee8; }
.a-btn--danger { color: var(--a-danger); }
.a-btn--sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.a-btn--icon { width: 30px; padding: 0; }
.a-btn--block { width: 100%; height: 46px; font-size: 15px; }

/* ---------- 로그인 ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login__box { width: 100%; max-width: 380px; padding: 36px 28px; background: var(--a-panel); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.06); }
.login__box h1 { font-size: 22px; margin-bottom: 4px; }
.login__box > p { color: var(--a-soft); font-size: 14px; margin-bottom: 24px; }
.login__err { color: var(--a-danger); font-size: 13px; min-height: 20px; margin: 8px 0; }
.demo-note { margin-top: 18px; padding: 12px 14px; border-radius: 8px; background: #fff8e6; color: #8a5a00; font-size: 13px; line-height: 1.6; }

/* ---------- 레이아웃 ---------- */
.shell { display: grid; grid-template-columns: var(--a-side) 1fr; grid-template-rows: var(--a-head) 1fr; height: 100%; }
.head {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: var(--a-panel); border-bottom: 1px solid var(--a-line); z-index: 5;
}
.head__title { font-weight: 700; font-size: 16px; margin-right: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.head__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #fff1d6; color: #9a6400; }
.badge--ok { background: #e3f7eb; color: var(--a-ok); }
.save-state { font-size: 12px; color: var(--a-soft); }
.save-state.is-dirty { color: var(--a-warn); font-weight: 600; }

.side { background: var(--a-panel); border-right: 1px solid var(--a-line); overflow-y: auto; padding: 14px 10px 40px; }
.side__group { font-size: 11px; font-weight: 700; color: var(--a-soft); letter-spacing: .04em; padding: 16px 10px 6px; }
.side__group:first-child { padding-top: 4px; }
.side a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--a-text); text-decoration: none; font-size: 14px;
}
.side a:hover { background: #f3f4f6; }
.side a.is-active { background: var(--a-primary-soft); color: var(--a-primary); font-weight: 600; }
.side a .ico { width: 20px; text-align: center; }
.side a .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--a-danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }

.body { display: grid; grid-template-columns: minmax(0, 1fr) auto; overflow: hidden; }
.main { overflow-y: auto; padding: 28px 32px 120px; }
.main__inner { max-width: 760px; margin: 0 auto; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--a-soft); font-size: 14px; margin-bottom: 24px; white-space: pre-line; }

/* 미리보기 */
.preview { width: 430px; border-left: 1px solid var(--a-line); background: #eceef2; display: flex; flex-direction: column; align-items: center; padding: 16px 0; }
.preview__bar { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--a-soft); margin-bottom: 12px; }
.preview__frame { width: 390px; flex: 1; border-radius: 28px; overflow: hidden; background: #fff; border: 8px solid #1d2129; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.preview__frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-toggle { display: none; }

/* ---------- 카드 / 폼 ---------- */
.card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 22px; margin-bottom: 16px; }
.card__title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.row > .field:has(> .switch) { align-self: end; padding-bottom: 9px; }
.field > label:not(.switch), .field__label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--a-danger); margin-left: 2px; }
.field__help { font-size: 12px; color: var(--a-soft); margin-top: 6px; line-height: 1.5; white-space: pre-line; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--a-line); border-radius: 8px;
  background: #fff; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input[readonly] { background: #f3f4f6; color: var(--a-soft); cursor: not-allowed; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--a-primary); box-shadow: 0 0 0 3px rgba(63,94,251,.15); }
.field.is-invalid .input, .field.is-invalid .textarea { border-color: var(--a-danger); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }
.group { padding: 16px; border: 1px dashed var(--a-line); border-radius: var(--a-radius); margin-bottom: 18px; }
.group__title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

/* 토글 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #d1d5db; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--a-primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(63,94,251,.3); }

/* 선택 카드 (테마 등) */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.choice { position: relative; border: 2px solid var(--a-line); border-radius: var(--a-radius); padding: 12px; cursor: pointer; text-align: center; font-size: 14px; font-weight: 600; background: #fff; }
.choice input { position: absolute; opacity: 0; }
.choice .swatch { display: flex; height: 36px; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.choice .swatch span { flex: 1; }
.choice:has(input:checked) { border-color: var(--a-primary); background: var(--a-primary-soft); }
.choice small { display: block; font-weight: 400; color: var(--a-soft); font-size: 12px; }

/* 이미지 */
.img-one { display: flex; gap: 14px; align-items: flex-start; }
.thumb { position: relative; width: 104px; height: 104px; border-radius: 8px; overflow: hidden; background: #f3f4f6; border: 1px solid var(--a-line); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__empty { display: grid; place-items: center; height: 100%; font-size: 12px; color: var(--a-soft); }
.img-actions { display: flex; flex-direction: column; gap: 6px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.img-grid .thumb { width: auto; height: auto; aspect-ratio: 1; cursor: grab; }
.img-grid .thumb.is-drag { opacity: .4; }
.img-grid .thumb.is-over { outline: 3px solid var(--a-primary); }
.thumb__no { position: absolute; top: 4px; left: 4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.thumb__tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.thumb__tools button { width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,.92); font-size: 13px; line-height: 1; }
.thumb__tools .del { color: var(--a-danger); }
.uploader { display: grid; place-items: center; aspect-ratio: 1; border: 2px dashed var(--a-line); border-radius: 8px; color: var(--a-soft); font-size: 13px; text-align: center; cursor: pointer; background: #fafafa; }
.uploader:hover, .uploader.is-over { border-color: var(--a-primary); color: var(--a-primary); background: var(--a-primary-soft); }
.uploader b { display: block; font-size: 22px; line-height: 1; margin-bottom: 4px; }

/* 반복 항목 */
.list { display: grid; gap: 10px; }
.item { border: 1px solid var(--a-line); border-radius: var(--a-radius); background: #fff; }
.item__head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; cursor: pointer; }
.item__head .t { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__head .n { color: var(--a-soft); font-size: 12px; font-weight: 700; width: 22px; }
.item__body { padding: 4px 14px 16px; border-top: 1px solid var(--a-line); }
.item:not(.is-open) .item__body { display: none; }
.add-btn { width: 100%; height: 42px; border: 1px dashed #c7cbd3; border-radius: 8px; color: var(--a-primary); font-weight: 600; font-size: 14px; background: #fff; }
.add-btn:hover { background: var(--a-primary-soft); border-color: var(--a-primary); }

/* ---------- 대시보드 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 18px; border-radius: var(--a-radius); background: var(--a-panel); border: 1px solid var(--a-line); }
.stat small { color: var(--a-soft); font-size: 13px; }
.stat b { display: block; font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat em { font-style: normal; font-size: 13px; color: var(--a-soft); margin-left: 4px; font-weight: 500; }

/* ---------- 접수함 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.tabs { display: flex; gap: 4px; }
.tabs button { padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--a-soft); }
.tabs button.is-active { background: var(--a-text); color: #fff; }
.entries { display: grid; gap: 10px; }
.entry { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 16px 18px; }
.entry.is-new { border-left: 4px solid var(--a-primary); }
.entry__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.entry__head b { font-size: 16px; }
.entry__head time { margin-left: auto; color: var(--a-soft); font-size: 12px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #f3f4f6; color: #374151; }
.tag--blue { background: #e8eeff; color: #3b54d8; }
.tag--pink { background: #ffe8ef; color: #c2185b; }
.tag--green { background: #e3f7eb; color: #0f7a3d; }
.tag--gray { background: #f1f1f1; color: #888; }
.entry__fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.entry__fields dt { color: var(--a-soft); }
.entry__fields dd { white-space: pre-line; word-break: break-word; }
.entry__foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--a-line); }
.entry__foot .select { width: auto; height: 32px; font-size: 13px; padding: 0 8px; }
.entry__foot .input { height: 32px; font-size: 13px; flex: 1; min-width: 140px; }
.empty { padding: 48px 20px; text-align: center; color: var(--a-soft); background: var(--a-panel); border: 1px dashed var(--a-line); border-radius: var(--a-radius); }

/* ---------- 토스트 / 모달 ---------- */
.a-toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 200; padding: 12px 18px; border-radius: 10px; background: #1d2129; color: #fff; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; }
.a-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.a-toast.is-error { background: var(--a-danger); }

/* ---------- 모바일 ---------- */
@media (max-width: 1180px) {
  .preview { display: none; position: fixed; inset: var(--a-head) 0 0 0; width: auto; z-index: 20; border: 0; }
  .preview.is-open { display: flex; }
  .preview-toggle { display: inline-flex; }
}
@media (max-width: 760px) {
  :root { --a-head: 56px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: var(--a-head) auto 1fr; }
  .side { display: flex; overflow-x: auto; padding: 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--a-line); white-space: nowrap; scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .side__group { display: none; }
  .side a { padding: 7px 12px; flex: none; }
  .main { padding: 20px 16px 120px; }
  .card { padding: 18px 16px; }
  .head .save-state { display: none; }
  .head__title { font-size: 15px; }
  .hide-sm { display: none !important; }
  .preview__frame { width: min(390px, 92vw); }
}
