:root{
  --bg:#f2f4f7; --panel:#ffffff; --ink:#1b2330; --muted:#6b7787; --line:#d8dee7;
  --accent:#2f6fd0; --accent-dark:#255ab0; --ok:#1f8b4d; --warn:#b8860b; --err:#c0392b;
  --head:#eef2f8; --sel:#e8f0fd; --mono:"Cascadia Mono","D2Coding",Consolas,"Courier New",monospace;
}
*{box-sizing:border-box}
/* display를 지정한 요소에서도 hidden 속성이 이기도록 */
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font:14px/1.5 "Malgun Gothic","Apple SD Gothic Neo",system-ui,sans-serif;
}
h2{margin:0 0 .25rem; font-size:1.15rem}
h3{margin:0 0 .5rem; font-size:1rem}
code{font-family:var(--mono); background:#eef1f6; padding:.05rem .3rem; border-radius:3px; font-size:.85em}
.muted{color:var(--muted); font-weight:400; font-size:.85rem}
.hint{color:var(--muted); font-size:.82rem}
.lead{color:var(--muted); margin:.1rem 0 1rem}
.grow{flex:1}
.strong{font-weight:600}

/* 상단 바 */
.topbar{
  display:flex; align-items:center; gap:1rem; padding:.5rem .9rem;
  background:linear-gradient(180deg,#3b4a5f,#2c3849); color:#fff;
}
.brand{display:flex; align-items:center; gap:.5rem}
.brand .logo{font-size:1.4rem}
.brand small{display:block; color:#c3ccd9; font-size:.75rem}
.steps{display:flex; gap:.35rem; flex:1; justify-content:center; flex-wrap:wrap}
.steps span{
  font-size:.78rem; padding:.15rem .5rem; border-radius:999px;
  background:rgba(255,255,255,.12); color:#dfe6ef;
}
.steps span.on{background:var(--accent); color:#fff}
.status{font-size:.8rem; color:#cdd6e2; max-width:22rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.logoutbtn{flex:none; background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.25); color:#dfe6ef; padding:.3rem .6rem; font-size:.8rem}
.logoutbtn:hover{background:rgba(255,255,255,.22)}

/* 레이아웃 */
.layout{display:flex; height:calc(100vh - 46px)}
.sidebar{
  width:190px; flex:none; background:#e7ebf1; border-right:1px solid var(--line);
  padding:.6rem .5rem; display:flex; flex-direction:column; gap:.2rem;
}
.nav{
  display:flex; align-items:center; gap:.45rem; width:100%; text-align:left;
  padding:.5rem .6rem; border:0; background:transparent; border-radius:6px;
  font:inherit; color:var(--ink); cursor:pointer;
}
.nav:hover{background:#dbe2ec}
.nav.on{background:var(--panel); box-shadow:0 1px 2px rgba(0,0,0,.12); font-weight:600}
.nav b{margin-left:auto; font-size:.75rem; background:#cdd6e3; color:#374151; border-radius:999px; padding:0 .4rem}
.sidefoot{margin-top:auto; font-size:.75rem; color:var(--muted); padding:.5rem .3rem; border-top:1px solid #d3dae4}
.main{flex:1; overflow:auto; padding:1rem 1.2rem 3rem}
.view{display:none}
.view.on{display:block}

/* 카드 */
.cards{display:grid; grid-template-columns:repeat(auto-fit,minmax(28rem,1fr)); gap:1rem}
.card{background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:.9rem; margin-bottom:1rem}
.card h3{margin-bottom:.2rem}

/* 입력 */
input[type=text],input[type=number],textarea,select{
  font:inherit; padding:.4rem .5rem; border:1px solid var(--line); border-radius:5px;
  background:#fff; color:var(--ink); min-width:0;
}
input[type=text]:focus,textarea:focus,select:focus{outline:2px solid #b9d0f2; border-color:var(--accent)}
textarea{width:100%; font-family:var(--mono); font-size:.85rem; resize:vertical}
label{display:inline-flex; align-items:center; gap:.35rem; font-size:.86rem}
label.block{display:block; margin:.4rem 0}
label.block input{width:100%; margin-top:.2rem}
label input[type=text]{flex:1}
.row{display:flex; gap:.5rem; align-items:center; margin:.4rem 0}
.row.wrap{flex-wrap:wrap}
.row > input[type=text]{flex:1}
.opts label{background:#f6f8fb; border:1px solid var(--line); border-radius:5px; padding:.25rem .5rem}
.fields label{background:#f6f8fb; border:1px solid var(--line); border-radius:5px; padding:.3rem .5rem}

/* 버튼 */
button,.btnlink{
  font:inherit; padding:.4rem .75rem; border:1px solid var(--line); background:#fff;
  border-radius:5px; cursor:pointer; color:var(--ink); text-decoration:none; display:inline-block;
}
button:hover,.btnlink:hover{background:#f0f4fa}
button.primary{background:var(--accent); border-color:var(--accent); color:#fff}
button.primary:hover{background:var(--accent-dark)}
button.ok{background:var(--ok); border-color:var(--ok); color:#fff}
button.big{padding:.6rem 1.2rem; font-size:1rem}
button.danger{color:var(--err)}
button:disabled{opacity:.5; cursor:not-allowed}

/* 도구 모음 */
.toolbar{display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin:.6rem 0}
.toolbar input[type=text]{min-width:16rem}
.counter{font-size:.85rem; color:var(--muted)}

/* 표 */
.tablewrap{background:var(--panel); border:1px solid var(--line); border-radius:8px; overflow:auto; max-height:52vh}
.tablewrap.short{max-height:30vh}
.tablewrap.tall{max-height:62vh}
table.grid{border-collapse:separate; border-spacing:0; width:100%; font-size:.85rem}
table.grid th{
  position:sticky; top:0; z-index:2; background:var(--head); text-align:left;
  padding:.45rem .5rem; border-bottom:1px solid var(--line); white-space:nowrap; font-weight:600;
}
table.grid td{padding:.35rem .5rem; border-bottom:1px solid #eef1f5; vertical-align:top}
table.grid tbody tr:nth-child(even){background:#fafbfd}
table.grid tbody tr:hover{background:var(--sel)}
table.grid td.cell{max-width:26rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer}
table.grid.wrapcells td.cell{white-space:pre-wrap; overflow:visible; max-width:34rem}
table.grid td.num{text-align:right; color:var(--muted); width:3rem}
th.chk,td.chk{width:2rem; text-align:center}
td a{color:var(--accent); text-decoration:none}
td a:hover{text-decoration:underline}
tr.err td{background:#fdf1f0}
.pill{font-size:.75rem; padding:.05rem .4rem; border-radius:999px; background:#e7ecf3; color:#465569}
.pill.ok{background:#e3f4e9; color:var(--ok)}
.pill.bad{background:#fbe7e5; color:var(--err)}

/* 항목 편집 표 */
.fieldgrid td{padding:.25rem .3rem}
.fieldgrid input[type=text]{width:100%; font-family:var(--mono); font-size:.8rem; padding:.25rem .35rem}
.fieldgrid input.plain{font-family:inherit}
.fieldgrid select{font-size:.8rem; padding:.25rem}
.fieldgrid input[type=number]{width:4rem; padding:.25rem}
.fieldgrid td.mk{min-width:14rem}

/* 실행 바 */
.runbar{
  display:flex; gap:1rem; align-items:flex-start; margin-top:.8rem; padding:.8rem;
  background:var(--panel); border:1px solid var(--line); border-radius:8px; flex-wrap:wrap;
}
.runbar > div:first-child{flex:1; min-width:20rem}
.picker{display:flex; flex-wrap:wrap; gap:.4rem; margin-top:.4rem}
.picker label{
  border:1px solid var(--line); border-radius:5px; padding:.3rem .55rem; background:#f6f8fb; cursor:pointer;
}
.picker label.on{background:var(--sel); border-color:var(--accent)}
.picker .cond{color:var(--muted); font-size:.75rem}
.runactions{text-align:right}

/* 진행 */
.progress{display:flex; align-items:center; gap:.6rem; margin:.5rem 0}
.bar{flex:1; height:8px; background:#dde3ec; border-radius:999px; overflow:hidden}
.bar > div{height:100%; width:0; background:var(--accent); transition:width .2s}

/* 시험 */
.testbox{margin-top:.8rem; padding:.7rem; background:#f7f9fc; border:1px solid var(--line); border-radius:8px}
.testbox .helper{border-top:1px dashed var(--line); padding-top:.5rem}
.testout{margin-top:.5rem; display:grid; gap:.35rem}
.testrow{background:#fff; border:1px solid var(--line); border-radius:6px; padding:.4rem .55rem}
.testrow .lbl{font-weight:600}
.testrow .val{font-family:var(--mono); font-size:.8rem; white-space:pre-wrap; word-break:break-all; color:#243044; margin-top:.2rem}
.testrow.empty{background:#fdf6f5; border-color:#f0cfcb}
pre{font-family:var(--mono); font-size:.78rem; white-space:pre-wrap; word-break:break-all;
    background:#fff; border:1px solid var(--line); border-radius:6px; padding:.5rem; max-height:24rem; overflow:auto}
.rules{margin:.2rem 0 0 1rem; padding:0; color:var(--muted); font-size:.85rem}
.rules li{margin:.2rem 0}

/* 모달 · 알림 */
.modal{position:fixed; inset:0; background:rgba(20,26,36,.45); display:flex; align-items:center; justify-content:center; z-index:50}
.modalbox{background:#fff; border-radius:8px; padding:.8rem; width:min(52rem,92vw); max-height:80vh; overflow:auto}
.toast{
  position:fixed; right:1rem; bottom:1rem; z-index:60; padding:.6rem .9rem; border-radius:6px;
  background:#2c3849; color:#fff; box-shadow:0 4px 14px rgba(0,0,0,.25); max-width:28rem;
}
.toast.err{background:var(--err)}
.toast.ok{background:var(--ok)}
