:root{
  --ground:#F5F6F8; --surface:#FFFFFF; --line:#E3E6EB; --line2:#C5CBD3; --row:#F0F2F5;
  --text:#1A1D21; --text2:#3A424D; --muted:#5A6370;
  --accent:#2357D9; --accent-d:#1A43AA; --accent-w:#EAF0FD; --ok:#1E7F4F; --err:#B42318;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:'Pretendard','Malgun Gothic','Noto Sans KR',system-ui,sans-serif;color:var(--text);background:var(--ground);font-size:14px}
button,input,select{font:inherit;color:inherit}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.muted{color:var(--muted)} .small{font-size:12px}
.app{display:flex;min-height:100vh}

/* sidebar */
.side{width:248px;flex:none;background:var(--surface);border-right:1px solid var(--line);padding:24px 16px;display:flex;flex-direction:column;gap:24px;position:sticky;top:0;height:100vh}
.brand{display:flex;gap:10px;align-items:center;padding:0 8px}
.logo{width:32px;height:32px;border-radius:8px;background:var(--accent);display:flex;align-items:center;justify-content:center}
.brand-name{font-weight:700;font-size:16px}
.brand-sub{font-size:12px;color:var(--muted);max-width:160px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}
.step{width:100%;display:flex;align-items:center;gap:12px;padding:12px;border-radius:8px;border:0;background:transparent;color:var(--text2);text-align:left;cursor:pointer;min-height:44px}
.step:hover{background:#F3F5F8}
.step .num{width:24px;height:24px;border-radius:12px;border:1px solid var(--line2);display:flex;align-items:center;justify-content:center;font-size:12px;flex:none}
.step[aria-current="step"]{background:var(--accent-w);color:var(--accent-d);font-weight:700}
.step[aria-current="step"] .num{background:var(--accent);border-color:var(--accent);color:#fff}
.step.done .num{background:#E6F4EC;border-color:#9CCDB0;color:var(--ok)}
.conn{margin-top:auto;display:flex;flex-direction:column;gap:8px;padding:12px;border:1px solid var(--line);border-radius:8px}
.conn-state{display:flex;align-items:center;gap:8px;font-weight:500}
.dot{width:8px;height:8px;border-radius:4px;background:#C5CBD3}
.dot.on{background:var(--ok)}
.link{border:0;background:none;padding:0;color:var(--accent);cursor:pointer;text-align:left;font-size:13px}
.link:hover{color:var(--accent-d);text-decoration:underline}

/* main */
.main{flex:1;min-width:0;padding:28px 32px 16px;display:flex;flex-direction:column;gap:16px}
.page{display:flex;flex-direction:column;gap:18px}
.page[hidden]{display:none}
.page-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px}
.eyebrow{margin:0 0 4px;font-size:13px;color:var(--muted)}
h1{margin:0;font-size:24px} h2{margin:0;font-size:18px}
.row-gap{display:flex;gap:8px;flex-wrap:wrap}
.row-gap.end{justify-content:flex-end}
.btn{height:40px;padding:0 14px;border-radius:8px;border:1px solid var(--line2);background:var(--surface);cursor:pointer;white-space:nowrap}
.btn:hover{background:#F7F8FA}
.btn:disabled{opacity:.5;cursor:default}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:700}
.btn.primary:hover{background:var(--accent-d)}
.btn.lg{height:48px;font-size:15px}
.btn.icon{width:32px;height:32px;padding:0;display:inline-flex;align-items:center;justify-content:center}

.filters{display:flex;flex-wrap:wrap;gap:12px}
.field{display:flex;align-items:center;gap:8px;height:44px;padding:0 12px;background:var(--surface);border:1px solid var(--line2);border-radius:8px}
.field.grow{flex:1 1 320px}
.field input[type=search]{flex:1;border:0;outline:none;background:transparent;min-width:0}
.field select{border:0;background:transparent;max-width:220px}
.field.check{cursor:pointer}
input[type=checkbox]{width:18px;height:18px;accent-color:var(--accent)}

.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{height:36px;padding:0 14px;border-radius:6px;border:1px solid var(--line2);background:var(--surface);cursor:pointer}
.chip .n{color:var(--muted);margin-left:4px}
.chip[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:500}
.chip[aria-pressed="true"] .n{color:#DCE5FB}

.split{display:flex;flex-wrap:wrap;gap:20px;align-items:flex-start}
.card{background:var(--surface);border:1px solid var(--line);border-radius:12px}
.table-card{flex:999 1 560px;min-width:0;overflow:hidden}
.thead,.trow{display:grid;grid-template-columns:44px 124px minmax(0,1fr) 170px 56px 44px;align-items:center;padding:0 16px}
.thead{height:40px;background:#F9FAFB;border-bottom:1px solid var(--line);font-size:12px;color:var(--muted);font-weight:500}
.tbody{height:calc(100vh - 360px);min-height:300px;overflow-y:auto}
.trow{min-height:44px;border-bottom:1px solid var(--row);cursor:pointer}
.trow:hover{background:#FAFBFC}
.trow.on{background:#F4F7FE}
.trow .code{font-variant-numeric:tabular-nums;color:var(--text2)}
.trow .nm{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.trow .g,.trow .v{font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.trow .got{color:var(--ok);font-size:13px}
.empty{padding:40px;text-align:center;color:var(--muted)}
.more{padding:12px 16px;color:var(--muted);font-size:13px}

.summary{flex:1 1 280px;max-width:340px;padding:20px;display:flex;flex-direction:column;gap:14px;position:sticky;top:20px}
.big{margin:4px 0 0;font-size:28px;font-weight:700}
.big-sub{font-size:15px;font-weight:500;color:var(--muted)}
.sum-groups{display:flex;flex-direction:column;gap:12px;max-height:280px;overflow-y:auto}
.sg-head{display:flex;justify-content:space-between;font-weight:700}
.sg-sub{font-size:13px;color:var(--text2);padding-left:12px}
.progress .bar{height:8px;border-radius:4px;background:#EEF0F3;overflow:hidden}
.progress .bar span{display:block;height:100%;width:0;background:var(--accent);transition:width .2s}
.progress p{margin:6px 0 0}

/* step 2 */
.plan{display:flex;flex-direction:column;gap:14px}
.series{padding:16px 18px;display:flex;flex-direction:column;gap:10px}
.series-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.badge{font-size:12px;font-weight:700;color:#fff;background:var(--text);border-radius:4px;padding:3px 7px}
.series-head input{flex:1 1 220px;height:38px;border:1px solid var(--line2);border-radius:6px;padding:0 10px;font-weight:700}
.series-head .code{color:var(--muted);font-size:13px}
.grp{display:grid;grid-template-columns:120px minmax(0,1fr) auto auto;gap:10px;align-items:center;padding:8px 0 8px 28px;border-top:1px solid var(--row)}
.grp input{height:36px;border:1px solid var(--line2);border-radius:6px;padding:0 10px;min-width:0}
.grp .members{grid-column:2 / 4;display:flex;flex-wrap:wrap;gap:4px 18px;font-size:12.5px;color:var(--text,#1F2329)}
.grp .mem{white-space:nowrap}
.grp .mem .mc{color:var(--muted);margin-right:2px;font-variant-numeric:tabular-nums}
.grp .code{font-variant-numeric:tabular-nums;color:var(--text2)}

/* forms */
.form{flex:999 1 520px;min-width:0;padding:20px 22px;display:flex;flex-direction:column;gap:16px}
.frow{display:flex;flex-direction:column;gap:6px}
.frow>label,.lbl{font-weight:500}
.frow input{height:40px;border:1px solid var(--line2);border-radius:8px;padding:0 12px;min-width:0}
.pick{display:flex;gap:8px}
.pick input{flex:1;background:#F9FAFB;color:var(--text2)}
.repl{display:flex;flex-direction:column;gap:8px}
.repl-row{display:grid;grid-template-columns:minmax(0,1fr) 20px minmax(0,1fr) 36px;gap:8px;align-items:center}
.repl-row input{height:38px;border:1px solid var(--line2);border-radius:8px;padding:0 10px;min-width:0}
.check-row{display:flex;gap:10px;align-items:center;cursor:pointer;min-height:40px}
.merged{display:grid;grid-template-columns:minmax(0,1fr) 80px 60px;gap:0;font-size:13px}
.merged div{padding:6px 4px;border-bottom:1px solid var(--row)}
.merged .h{color:var(--muted);font-weight:500}

/* log */
.log{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:10px 16px;margin-top:auto}
.log summary{cursor:pointer;font-weight:500;min-height:28px;display:flex;align-items:center;gap:8px}
.log ol{list-style:none;margin:8px 0 0;padding:0;max-height:180px;overflow-y:auto;font-size:12px;font-family:Consolas,monospace}
.log li{padding:2px 0;color:var(--text2)}
.log li.error{color:var(--err)} .log li.ok{color:var(--ok);font-weight:700}

dialog{border:0;border-radius:12px;padding:0;box-shadow:0 20px 60px rgba(20,24,30,.25)}
dialog::backdrop{background:rgba(20,24,30,.35)}
.dlg{width:460px;padding:24px;display:flex;flex-direction:column;gap:14px}
.dlg p{margin:0}

@media (max-width:900px){.side{position:static;height:auto;width:100%}.app{flex-direction:column}.summary{max-width:none;position:static}}

/* ---- step 3: 양식·문구 */
.stack{flex:999 1 560px;min-width:0;display:flex;flex-direction:column;gap:16px}
.stack .form{flex:none}
.sec-title{font-size:15px;font-weight:700;margin:0}
.sec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
.btn.small{height:32px;padding:0 10px;font-size:13px}
.btn.ghost{border-color:transparent;background:transparent;color:var(--accent)}
.btn.ghost:hover{background:var(--accent-w)}
code{font-family:Consolas,'D2Coding',monospace;font-size:12.5px;background:#F1F3F6;border:1px solid var(--line);border-radius:4px;padding:0 4px;color:var(--text2)}
.tpl-rows{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.tpl-row{display:grid;grid-template-columns:150px minmax(0,1fr) auto;align-items:center;gap:12px;padding:8px 12px;border-bottom:1px solid var(--row)}
.tpl-row:last-child{border-bottom:0}
.tpl-row.off .tpl-file,.tpl-row.off .tpl-btns{opacity:.45}
.tpl-use{display:flex;align-items:center;gap:8px;font-weight:500;cursor:pointer}
.tpl-use.fixed{cursor:default;padding-left:26px}
.tpl-file{color:var(--text2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
.tpl-btns{display:flex;gap:6px}
.tok-help{background:#F9FAFB;border:1px solid var(--line);border-radius:8px;padding:12px 14px;font-size:13px;line-height:1.7}
.tok-help p{margin:0 0 6px}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px 16px}
.toks{display:inline-flex;flex-wrap:wrap;gap:6px;margin-left:4px;vertical-align:middle}
.tok{height:26px;padding:0 10px;border:1px solid var(--line2);border-radius:6px;background:var(--surface);font-size:12.5px;cursor:pointer;color:var(--accent-d)}
.tok:hover{background:var(--accent-w);border-color:var(--accent)}
.ov-head,.ov-row{display:grid;grid-template-columns:130px minmax(0,1fr) 140px 108px;gap:8px;align-items:start}
.ov-head{font-size:12px;color:var(--muted);padding:0 2px}
.ov-rows{display:flex;flex-direction:column;gap:6px}
.ov-row input,.ov-row textarea{border:1px solid var(--line2);border-radius:8px;padding:8px 10px;min-width:0;font:inherit;line-height:1.45}
.ov-row input{height:38px}
.ov-row textarea{resize:vertical;min-height:38px}
.ov-btns{display:flex;gap:4px;padding-top:3px}
.fold summary{cursor:pointer;list-style:none}
.fold summary::-webkit-details-marker{display:none}
.fold summary::before{content:'▸';display:inline-block;width:16px;color:var(--muted)}
.fold[open] summary::before{content:'▾'}

/* ---- web version */
.pdf-opts{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px}
.pdf-opt{border:1px solid var(--line);border-radius:10px;padding:14px 16px;display:flex;flex-direction:column;gap:8px;align-items:flex-start}
.pdf-opt.off{background:#F7F8FA}
.pdf-opt ol{margin:0;padding-left:18px;line-height:1.7}
.pdf-h{margin:0;font-weight:700;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.tag{font-size:11.5px;font-weight:600;padding:2px 8px;border-radius:10px;background:var(--accent-w);color:var(--accent-d)}
.tag.gray{background:#ECEEF1;color:var(--text2)}
.order-list{display:flex;flex-direction:column;gap:4px;max-height:420px;overflow:auto}
.order-list div{display:grid;grid-template-columns:24px minmax(0,1fr);gap:6px;color:var(--text2)}
.order-list b{color:var(--muted);font-weight:500;font-variant-numeric:tabular-nums}
a.btn{display:inline-flex;align-items:center;text-decoration:none;color:inherit}
a.btn.disabled{pointer-events:none;opacity:.5}
