:root { --navy:#1e3a5f; --navy2:#2c5282; --bg:#f2f4f7; --line:#e3e7ee; --text:#1f2937; --muted:#8a94a6;
         --ok:#0f9d58; --wait:#d97706; --bad:#dc2626; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; background: var(--bg);
       color: var(--text); font-size: 16px; padding-bottom: env(safe-area-inset-bottom); }
body.tablet { font-size: 18px; }
a { color: var(--navy2); }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px;
             background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 800; font-size: 19px; text-decoration: none; }
header nav a { color: #cfe0f5; margin-left: 16px; text-decoration: none; font-weight: 600; white-space: nowrap; }
header nav a.sm { opacity: .7; }
.cnt { display: none; background: #f59e0b; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
main { max-width: 1180px; margin: 0 auto; padding: 18px; }
footer { text-align: center; color: #b0b7c3; font-size: 12px; padding: 24px; }

.card { background: #fff; border-radius: 14px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin: 40px auto; }
h2.pagetitle { font-size: 21px; margin: 6px 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2.pagetitle small { font-size: 14px; font-weight: 500; color: var(--muted); }
h3 { margin: 0 0 12px; font-size: 16px; color: #374151; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 14px; }
.muted { color: var(--muted); } .center { text-align: center; } .sm { font-size: 13px; } .mono { font-family: ui-monospace, Consolas, monospace; }
.big { font-size: 1.15em; font-weight: 700; } .break { word-break: break-all; }
.err { color: var(--bad); } .warn { color: var(--wait); font-size: 14px; margin: 10px 0 0; }
.req { color: var(--bad); } .hint { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; }

/* 홈 */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.tile { background: #fff; border-radius: 16px; padding: 24px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px;
        box-shadow: 0 1px 3px rgba(0,0,0,.06); position: relative; transition: transform .1s; }
.tile:active { transform: scale(.98); }
.tile .ico { font-size: 30px; color: var(--navy); } .tile b { font-size: 19px; } .tile span { color: var(--muted); font-size: 14px; }
.tile.accent { background: var(--navy); color: #fff; } .tile.accent .ico, .tile.accent span { color: #cfe0f5; }
.badge-big { position: absolute; top: 18px; right: 18px; background: #f59e0b; color: #fff; font-style: normal; font-weight: 700; padding: 4px 10px; border-radius: 12px; }

/* 양식 선택 */
.forms { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.formcard { background: #fff; border-radius: 14px; padding: 14px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px;
            box-shadow: 0 1px 3px rgba(0,0,0,.06); border: 2px solid transparent; position: relative; }
.formcard:hover { border-color: var(--navy2); }
.formcard .th { background: #eef1f5; border-radius: 8px; height: 260px; overflow: hidden; display: grid; place-items: start center; }
.formcard .th img { width: 92%; margin-top: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.formcard b { font-size: 17px; } .formcard span { color: var(--muted); font-size: 13px; }
.tag { position: absolute; top: 20px; right: 20px; font-style: normal; font-size: 11px; background: var(--navy); color: #fff; padding: 2px 7px; border-radius: 6px; }

/* 입력 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; margin-bottom: 4px; }
.grid label.full { grid-column: 1 / -1; }
label span { display: block; font-size: 13px; color: #6b7280; margin-bottom: 4px; font-weight: 600; }
input, textarea, select { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 9px; background: #fff; color: inherit; }
input:focus, textarea:focus, select:focus { outline: 2px solid #3b82f6; border-color: transparent; }
textarea { resize: vertical; line-height: 1.5; }
.seg { display: flex; gap: 6px; } .seg button { flex: 1; font: inherit; padding: 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
table.items { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
table.items th { font-size: 12px; color: #6b7280; text-align: left; padding: 6px 4px; border-bottom: 2px solid var(--line); }
table.items td { padding: 3px; } table.items input { padding: 8px; font-size: 15px; }
table.items .no { width: 34px; text-align: center; color: var(--muted); } table.items .x { width: 40px; }
.del { border: 0; background: #fee2e2; color: #b91c1c; width: 34px; height: 34px; border-radius: 8px; font-size: 18px; cursor: pointer; }

.btn { display: inline-block; font: inherit; font-weight: 700; padding: 11px 20px; border-radius: 10px; border: 0; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--navy); color: #fff; } .btn.ghost { background: #e9eef5; color: var(--navy); }
.btn.danger { color: var(--bad); } .btn.sm { padding: 7px 12px; font-size: 14px; } .btn.big { padding: 15px 34px; font-size: 1.1em; }
.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.actions.col { flex-direction: column; } .actions.center { justify-content: center; }
.actions.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 calc(10px + env(safe-area-inset-bottom)); margin: 0; }
.row { display: flex; gap: 8px; margin-top: 12px; } .row input { max-width: 340px; }

/* 문서 상세 */
.docwrap { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.side { position: sticky; top: 76px; } .docno { margin: 4px 0; font-family: ui-monospace, Consolas, monospace; font-size: 19px; }
.stbox { border-radius: 12px; padding: 14px; margin: 14px 0; text-align: center; }
.stbox p { margin: 6px 0; font-size: 14px; } .stbox.wait { background: #fff7ed; color: #9a3412; } .stbox.ok { background: #ecfdf5; color: #065f46; }
.qr { width: 170px; height: 170px; background: #fff; border-radius: 8px; margin: 8px auto; display: block; }
.qr.sm { width: 110px; height: 110px; display: inline-block; vertical-align: middle; margin-left: 12px; }
.mailbox { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.mailbox h4 { margin: 0 0 8px; display: flex; gap: 8px; align-items: center; } .mailbox label { display: block; margin-bottom: 8px; }
.pages { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.pages img { width: 100%; max-width: 860px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); border-radius: 4px; }
.pages.single { margin-bottom: 22px; }

/* 상태 */
.st { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.st.ok { background: #dcfce7; color: #166534; } .st.wait { background: #fef3c7; color: #92400e; } .st.bad { background: #fee2e2; color: #991b1b; }
.st.muted { background: #f1f5f9; color: #64748b; }

/* 목록 */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; background: #f6f8fa; padding: 9px 8px; font-size: 13px; color: #6b7280; }
table.list td { padding: 9px 8px; border-bottom: 1px solid #f0f2f5; }
tr.click { cursor: pointer; } tr.click:hover { background: #f8fafc; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; } .filters select { width: auto; } .filters input { flex: 1; min-width: 200px; }
table.kv { width: 100%; border-collapse: collapse; } table.kv th { text-align: left; width: 170px; color: #6b7280; font-weight: 600; padding: 8px 4px; vertical-align: top; }
table.kv td { padding: 8px 4px; }

/* 서명 */
.plist { display: flex; flex-direction: column; gap: 10px; }
.pitem { background: #fff; border-radius: 14px; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
         text-decoration: none; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.06); border-left: 6px solid #f59e0b; }
.pitem b { display: block; font-size: 1.15em; } .pitem span { color: var(--muted); font-size: .85em; }
.pitem .r { text-align: right; display: flex; flex-direction: column; }
.sigblock { margin-top: 18px; } .sighead { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; } .sighead .clr { margin-left: auto; }
.padwrap { position: relative; border: 2px dashed #9ca3af; border-radius: 12px; background: #fff; }
.padwrap canvas { display: block; width: 100%; height: 230px; touch-action: none; cursor: crosshair; }
.padhint { position: absolute; inset: 0; display: grid; place-items: center; color: #c5cad3; font-size: 22px; pointer-events: none; }
.okmark { width: 74px; height: 74px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 42px; display: grid; place-items: center; margin: 0 auto 10px; }

.busy { position: fixed; inset: 0; background: rgba(255,255,255,.8); display: none; place-items: center; align-content: center; gap: 14px;
        font-size: 18px; font-weight: 700; z-index: 50; }
.busy.on { display: grid; }
.spin { width: 44px; height: 44px; border: 4px solid #cbd5e1; border-top-color: var(--navy); border-radius: 50%; animation: sp 0.8s linear infinite; margin: 0 auto; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .tiles { grid-template-columns: 1fr; } .docwrap { grid-template-columns: 1fr; } .side { position: static; }
  header nav a { margin-left: 10px; font-size: 14px; }
  table.items { font-size: 13px; }
}
