:root {
  --navy: #1F4488; --navy-deep: #16325F; --sky: #55A5DB; --sky-soft: #EAF4FB;
  --ink: #1B2433; --muted: #66728A; --line: #E3E8F0; --bg: #F5F7FB; --card: #fff;
  --ok: #1E8E5A; --ok-soft: #E7F6EE; --warn: #B7791F; --warn-soft: #FDF5E6; --bad: #C0392B; --bad-soft: #FCECEA;
  --side: 232px; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 레이아웃 */
.shell { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; }
.side .logo { padding: 0 8px 18px; }
.side .logo img { height: 40px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.side nav a:hover { background: var(--bg); }
.side nav a.on { background: var(--sky-soft); color: var(--navy); font-weight: 700; }
.side nav a .badge { margin-left: auto; }
.side .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.side .me { margin-top: auto; padding: 12px; font-size: 13px; color: var(--muted); }
.side .me button { border: 0; background: none; color: var(--navy); cursor: pointer; padding: 0; font-weight: 600; }
main.page { margin-left: var(--side); padding: 28px 32px 60px; max-width: 1240px; }
.mtop, .mnav { display: none; }

@media (max-width: 860px) {
  .side { display: none; }
  main.page { margin-left: 0; padding: 72px 16px 96px; }
  .mtop { display: flex; position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; padding: 0 16px; }
  .mtop img { height: 32px; }
  .mtop .who { font-size: 13px; color: var(--muted); }
  .mnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .mnav a { flex: 1; text-align: center; padding: 8px 0 9px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
  .mnav a svg { display: block; margin: 0 auto 2px; }
  .mnav a.on { color: var(--navy); }
  .mnav a.plus svg { background: var(--navy); color: #fff; border-radius: 50%; padding: 4px; width: 30px; height: 30px; margin-top: -4px; }
}

/* 공통 요소 */
h1 { font-size: 24px; margin: 0 0 18px; letter-spacing: -.3px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: -10px 0 18px; font-size: 14px; line-height: 1.5; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .g2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat small { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat b { display: block; font-size: 30px; margin-top: 4px; letter-spacing: -.5px; }
.stat.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.stat.navy small { color: rgba(255,255,255,.75); }

label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 12px; }
input[type=text], input[type=password], input[type=date], input[type=email], input[type=tel], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 15px;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); border-color: transparent; }
@media (max-width: 860px) { input, select, textarea { font-size: 16px !important; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--navy); background: var(--navy); color: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; text-decoration: none; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn.sm { padding: 6px 10px; font-size: 13px; font-weight: 600; }
.btn.block { width: 100%; padding: 13px; font-size: 15px; }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--line); }
.linkbtn { border: 0; background: none; color: var(--navy); cursor: pointer; padding: 0; font-weight: 600; font-size: 13px; }

.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--sky-soft); color: var(--navy); white-space: nowrap; }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.hold, .chip.review, .chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.cancelled, .chip.failed { background: var(--bad-soft); color: var(--bad); }
.chip.internal { background: var(--bg); color: var(--muted); }
.chip.published, .chip.customer { background: var(--ok-soft); color: var(--ok); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--navy); color: #fff; }

/* 목록 */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--bg); }
.prog { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.prog .bar { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), var(--navy)); }
.prog span { font-size: 12px; color: var(--muted); }

.items .it { display: block; padding: 13px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.items .it .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.items .it b { font-size: 15px; }
.items .it .meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.items .it .prog { margin-top: 8px; }

.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list a { text-decoration: none; color: var(--ink); font-weight: 600; }
.alert-list .due { color: var(--warn); font-weight: 700; white-space: nowrap; font-size: 13px; }
.alert-list .due.over { color: var(--bad); }

/* 단계 */
.stages { list-style: none; margin: 0; padding: 0; }
.stages li { display: flex; gap: 10px; align-items: flex-start; position: relative; padding-bottom: 12px; }
.stages li:not(:last-child)::before { content: ''; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.stages li.done:not(:last-child)::before { background: var(--sky); }
.stages .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; font-size: 11px; color: #fff; z-index: 1; }
.stages li.done .dot { background: var(--sky); border-color: var(--sky); }
.stages li.doing .dot { border-color: var(--navy); box-shadow: 0 0 0 4px var(--sky-soft); }
.stages li.doing .dot::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--navy); }
.stages li.skipped { opacity: .45; }
.stages li.skipped .nm { text-decoration: line-through; }
.stages .nm { flex: 1; padding-top: 1px; }
.stages li.doing .nm { font-weight: 700; color: var(--navy); }
.stages .when { font-size: 12px; color: var(--muted); }

/* 기록 */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl li:last-child { border-bottom: 0; }
.tl .hd { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.tl .chg { font-weight: 700; color: var(--navy); margin-top: 4px; font-size: 14px; }
.tl .memo { margin-top: 6px; white-space: pre-wrap; line-height: 1.55; }
.tl .tr { margin-top: 6px; padding: 8px 10px; background: var(--bg); border-radius: 8px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.tl .files { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.fpill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .5px; background: var(--sky-soft); color: var(--navy); padding: 2px 8px; border-radius: 6px; font-weight: 700; }

.upload { border: 2px solid var(--sky); }
.upload h2 { color: var(--navy); }
.drop { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px dashed var(--sky); border-radius: 12px; padding: 14px; color: var(--navy); font-weight: 600; cursor: pointer; background: var(--sky-soft); }
.drop input { display: none; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.picked span { font-size: 12px; background: var(--bg); padding: 4px 8px; border-radius: 8px; }

.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }
.check span { flex: 1; }
.check.ok span { color: var(--muted); text-decoration: line-through; }

/* 로그인 */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 60%, #0f2447 100%); }
.auth .box { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 28px 24px; }
.auth img { height: 54px; display: block; margin: 0 auto 18px; }
.auth h1 { text-align: center; font-size: 20px; }
.auth .err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 8px 0 0; }
.auth .tag { text-align: center; color: rgba(255,255,255,.6); font-style: italic; font-size: 13px; margin-top: 16px; }

/* 단계 편집 */
.svc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.svc-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; cursor: pointer; font-weight: 600; font-size: 13px; }
.svc-tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.svc-tabs button.off { opacity: .5; }
table.edit { width: 100%; border-collapse: collapse; }
table.edit th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px; font-weight: 600; }
table.edit td { padding: 4px; vertical-align: middle; }
table.edit td input { padding: 7px 9px; font-size: 13px; }
table.edit tr.off td { opacity: .45; }
table.edit .ord { white-space: nowrap; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }
