:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --card: #ffffff; --text: #1c2230; --muted: #667085; --line: #e2e5ea;
  --primary: #2f5fd0; --primary-text: #ffffff; --danger: #c0362c; --warn-bg: #fff4e5; --notice-bg: #eef3ff;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #13161c; --card: #1c2029; --text: #e8ebf1; --muted: #9aa3b5; --line: #2c3240;
    --primary: #5b86ee; --primary-text: #0d1220; --danger: #ff8a80; --warn-bg: #3a2c14; --notice-bg: #1d2740; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; font-size: 16px; line-height: 1.55; }
h1, h2 { margin: 0 0 12px; line-height: 1.3; }
h2 { font-size: 18px; }
p { margin: 0 0 12px; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.hidden { display: none; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.lead { color: var(--muted); }

.auth { max-width: 420px; margin: 0 auto; padding: 48px 16px; }
.brand { font-size: 22px; text-align: center; margin-bottom: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); padding: 4px; border-radius: 8px; margin-bottom: 16px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 6px; font: inherit; cursor: pointer; }
.tab.on { background: var(--card); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 700; font-size: 14px; }
.field-hint { color: var(--muted); font-size: 13px; }
input, select { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; width: 100%; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; min-height: 1px; }
.form-error:empty { display: none; }
.notice { background: var(--notice-bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0; }
.notice.warn { background: var(--warn-bg); margin-bottom: 12px; }

.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 10px 16px; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
.btn.wide { width: 100%; padding: 12px 16px; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .6; cursor: default; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; text-decoration: underline; }

.topbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 700; font-size: 18px; }
.topbar-user { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.page { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { font-size: 24px; font-variant-numeric: tabular-nums; }

.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.menu-item { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 2px; }
.menu-item.off { color: var(--muted); }
.menu-item span { font-size: 13px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > input, .row > select { flex: 1 1 180px; width: auto; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0; }
.request { display: grid; gap: 8px; }

/* ── 틀: 메뉴 줄 ── */
a { color: var(--primary); }
.topbar-title { color: inherit; text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.nav-link { padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--text); }
.nav-link.on { background: var(--notice-bg); font-weight: 700; }
.nav-link.off { color: var(--muted); opacity: .6; }
.page.slim { padding-top: 0; padding-bottom: 0; }
.page.slim:empty { display: none; }
.page.slim > .card { margin-top: 20px; margin-bottom: 0; }
.page { max-width: 1120px; }
h1 { font-size: 22px; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.grow { flex: 1 1 220px; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }

/* ── 표 ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-link { text-decoration: none; }
.clip { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.neg { color: var(--danger); }

/* ── 작은 표시들 ── */
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; margin-right: 4px; }
.badge.good { background: #e3f5e8; border-color: #b7e0c2; color: #17643a; }
.badge.warn { background: #fff1d6; border-color: #f0d39a; color: #8a5a00; }
.badge.bad { background: #fde7e5; border-color: #f2bdb8; color: #a12a21; }
.badge.soft { background: transparent; }
@media (prefers-color-scheme: dark) {
  .badge.good { background: #17341f; border-color: #26573a; color: #8fdba8; }
  .badge.warn { background: #3a2c14; border-color: #5f4a1f; color: #f2c672; }
  .badge.bad { background: #3d1c19; border-color: #6a2e29; color: #ff9d94; }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.chip.static { cursor: default; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 2; }
.stat strong.small { font-size: 18px; }

/* ── 기획서의 "이름: 값" 줄과 고치는 칸 ── */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.kv-label { color: var(--muted); font-size: 14px; padding-top: 2px; }
.kv-value { min-width: 0; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } }
.editable { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: flex-start; min-width: 0; }
.editable > span, .editable > a { min-width: 0; overflow-wrap: anywhere; }
.editable .empty { color: var(--muted); font-style: italic; }
.editable textarea, .editable input { flex: 1 1 100%; }
.editable.compact { justify-content: flex-end; }
td:not(.num) .editable.compact { justify-content: flex-start; }
.edit-btn { font: inherit; font-size: 12px; border: 0; background: none; color: var(--primary); cursor: pointer; padding: 2px 4px; opacity: .75; }
.edit-btn:hover { opacity: 1; text-decoration: underline; }
textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; resize: vertical; }
textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
select.compact { padding: 6px 8px; width: auto; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 12px; margin: 8px 0 0; max-height: 420px; overflow: auto; }
.url { word-break: break-all; }
.toggle { display: inline-flex; gap: 8px; align-items: center; }
.toggle input { width: auto; }
details > summary { cursor: pointer; color: var(--primary); }
.subcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.subcard .kv:first-of-type { margin-top: 10px; }
.big { font-size: 17px; }
.svc-group { margin-top: 12px; display: grid; gap: 6px; }
.list.tight { gap: 0; }
.list.tight li { padding: 6px 0; font-size: 14px; }
.knowledge { display: grid; gap: 6px; }

/* ── 눌러서 복사하는 값, 가격 계산 ── */
.copy { font: inherit; color: inherit; text-align: inherit; background: var(--bg); border: 1px dashed var(--line); border-radius: 6px; padding: 3px 8px; cursor: copy; max-width: 100%; overflow-wrap: anywhere; }
.copy:hover { border-color: var(--primary); }
.copy.done { border-style: solid; border-color: #2e9e5b; }
.copy.done::after { content: " ✓ 복사됨"; color: #2e9e5b; font-size: 12px; }
.register { margin-top: 24px; padding-top: 4px; border-top: 2px solid var(--line); }
input.short { width: 72px; flex: 0 0 auto; text-align: right; }
.row > input.short { flex: 0 0 72px; }

/* ── 바로 고치는 칸 (적으면 저절로 저장) ── */
.editable { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; min-width: 0; width: 100%; }
.editable.compact { justify-content: stretch; }
.cell { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); font: inherit; transition: border-color .15s, background-color .15s; }
.cell::placeholder { color: var(--muted); opacity: .7; }
.cell:hover { border-color: var(--muted); }
.cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell.saving { border-color: var(--primary); }
.cell.saved { border-color: #2e9e5b; background-color: rgba(46, 158, 91, .12); }
.cell.error { border-color: var(--danger); background-color: rgba(192, 54, 44, .10); }
textarea.cell { resize: vertical; line-height: 1.5; }
.editable.pct::after { content: "%"; color: var(--muted); font-size: 13px; }
.open-link { font-size: 13px; white-space: nowrap; }
.table.sheet td { padding: 6px 8px; vertical-align: middle; }
.table.sheet td.num .cell { min-width: 76px; }
.table.sheet td:first-child { min-width: 150px; }
.table.sheet select.compact { padding: 7px 8px; }

/* ── 이미지 판 ── */
.img-board { display: grid; gap: 12px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.img-grid:empty { display: none; }
.img-card { position: relative; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); display: grid; }
.img-card img { display: block; width: 100%; height: 160px; object-fit: cover; background: var(--bg); }
.img-card figcaption { padding: 6px; }
.img-remove { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; color: var(--muted); cursor: pointer; }
.dropzone:focus, .dropzone.over { border-color: var(--primary); outline: none; background: var(--notice-bg); }
.dropzone strong { color: var(--text); }
details.subcard { margin-top: 12px; }
details.subcard > summary { font-weight: 700; }
details.subcard[open] > summary { margin-bottom: 10px; }

/* ── 여러 줄 묶음, 복사 버튼, 진행 체크 ── */
.rows { display: grid; gap: 8px; }
.rows-line { display: grid; gap: 8px; align-items: start; }
.rows-head { color: var(--muted); font-size: 13px; font-weight: 700; }
.rows > .btn { justify-self: start; }
@media (max-width: 640px) { .rows-line { grid-template-columns: 1fr !important; } .rows-head { display: none; } }
.with-copy { display: flex; gap: 8px; align-items: flex-start; }
.with-copy > .editable { flex: 1 1 auto; }
.copy-btn { flex: 0 0 auto; }
.checklist { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.checklist .chip.on::before { content: "✓ "; }
.draft { border-left: 3px solid #e0a11b; padding-left: 12px; }
