:root {
  --bg: #f5f6f7;
  --card: #ffffff;
  --ink: #1d1f22;
  --muted: #6b7280;
  --line: #e3e5e8;
  --soft: #f0f2f4;
  --green: #03c75a;
  --green-ink: #028a3f;
  --green-soft: #e8f8ef;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #b26b00;
  --amber-soft: #fff4e0;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 버튼 */
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); padding: 7px 14px; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.primary:not(:disabled):hover { background: var(--green-ink); }
button.ghost:not(:disabled):hover { background: var(--soft); }
button.danger { color: var(--red); }
button.mini { padding: 3px 9px; font-size: 12.5px; border-radius: 6px; }
.filebtn { display: inline-block; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; background: var(--card); }
.filebtn:hover { background: var(--soft); }
.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; }

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 64px; }

/* 머리글 */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--green); display: inline-block; }
.top nav { display: flex; gap: 6px; }
.top nav button { white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 80px; }

/* 가져오기 */
.importer { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
#importForm { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.lnk { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.lnk em { font-style: normal; font-weight: 400; color: var(--muted); }
.importer .hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.imp-tabs { margin-bottom: 12px; }
#periodForm { display: grid; grid-template-columns: 2fr 1fr auto; gap: 10px; align-items: end; }
.mini-select { width: auto; padding: 5px 8px; font-size: 13px; }
.codebox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.codebox input { width: 110px; padding: 5px 8px; font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.codebox span { font-weight: 400; font-size: 12.5px; }

/* 기간 가져오기 결과 */
.scan { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.scan-h { margin: 14px 0 8px; font-size: 14px; }
.scan-h small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.kind { margin-top: 12px; }
.kind-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.kind-h .chk { margin-left: auto; font-size: 13px; }
.scan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.sg { display: grid; grid-template-columns: auto 56px 1fr; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; background: #fff; }
.sg.on { border-color: var(--green); background: var(--green-soft); }
.sg.dim { opacity: .55; cursor: default; }
.sg-name { min-width: 0; padding: 3px 7px; font-size: 13.5px; font-weight: 600; border-radius: 6px; background: rgba(255,255,255,.85); }
.sg-links { display: flex; gap: 8px; flex-wrap: wrap; }
.sg-links a { color: var(--muted); font-size: 12px; }
.sg-links a:hover { color: var(--green-ink); }
.sg-ph { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--soft); }
.sg-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sg-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12px; color: var(--muted); }
.sg-tx b { color: var(--ink); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-tx .badge { align-self: flex-start; }
.lp-list { display: flex; flex-direction: column; gap: 8px; }
.lp { display: grid; grid-template-columns: auto 1fr 230px; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.lp.dim { opacity: .55; }
.lp-ph { display: flex; gap: 3px; }
.lp-ph img { width: 48px; height: 64px; object-fit: cover; border-radius: 4px; background: var(--soft); display: block; }
.lp-tx { display: flex; flex-direction: column; min-width: 0; font-size: 12px; color: var(--muted); }
.lp-tx b { color: var(--ink); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp select { font-size: 13px; padding: 5px 8px; }
.sg-no { color: var(--ink); font-weight: 700; margin-right: 2px; }
.okline { font-size: 12.5px; color: var(--green-ink); }
.warnline { font-size: 12.5px; color: var(--amber); background: var(--amber-soft); padding: 4px 8px; border-radius: 6px; }

/* 맨 아래 공통 사진 */
.ft-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; min-height: 60px; }
.ft { width: 150px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.ft img { width: 100%; aspect-ratio: 4 / 5; object-fit: contain; background: var(--soft); display: block; }
.ft-btns { display: flex; justify-content: center; gap: 4px; padding: 5px; }

/* 코디컷 고르기 */
.dlg.xwide { width: min(1180px, calc(100vw - 32px)); }
.codi { display: grid; grid-template-columns: minmax(280px, 440px) 1fr; gap: 16px; margin-top: 10px; }
.codi-imgbox { position: relative; }
.codi-ph img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--soft); border-radius: 8px; display: block; cursor: zoom-in; }
.codi-imgbox .zm { position: absolute; left: 8px; bottom: 8px; width: 32px; height: 32px; padding: 0; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.92); border: 1px solid var(--line); color: #333; cursor: zoom-in; }
.codi-imgbox .zm:hover { background: #fff; transform: scale(1.08); }
.codi-nav { justify-content: center; margin-top: 8px; }
.codi-ph .muted { margin: 8px 0 0; font-size: 13px; }
.codi-list { max-height: calc(100vh - 260px); overflow: auto; padding-right: 4px; }
.codi-kind { margin-bottom: 10px; }
.codi-kind > b { display: block; font-size: 13px; margin-bottom: 5px; }
.codi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.ct { display: flex; flex-direction: column; padding: 4px; border: 2px solid var(--line); border-radius: 8px; background: #fff; text-align: left; gap: 3px; }
.ct.on { border-color: var(--green); background: var(--green-soft); }
.ct-ph { position: relative; aspect-ratio: 1; border-radius: 5px; overflow: hidden; background: var(--soft); }
.ct-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ct-tx { font-size: 11.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.bar i.busy { width: 35% !important; animation: busy 1.1s ease-in-out infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* 피드(글 목록) */
.feed { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.feed-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.post {
  position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff;
  cursor: pointer; display: flex; flex-direction: column;
}
.post.on { outline: 2px solid var(--green); border-color: transparent; }
.post.noimg { opacity: .5; cursor: default; }
.post .ph { aspect-ratio: 1; background: var(--soft); }
.post .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post .meta { padding: 7px 8px 8px; font-size: 12px; }
.post .meta b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post .meta span { color: var(--muted); }
.post .num { position: absolute; top: 6px; left: 6px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--green); color: #fff; font-size: 12px; font-weight: 700; display: none; align-items: center; justify-content: center; padding: 0 6px; }
.post.on .num { display: inline-flex; }
.post .tag { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 9px; }
.feed-more { text-align: center; margin-top: 12px; }

/* 작업 목록 */
.work { margin-top: 18px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 3px; border-radius: 9px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; }
.tabs button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs button span { color: var(--muted); font-weight: 400; margin-left: 2px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* 상품 카드 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.card.sel { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head .code { font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
.card-head .src { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.card-head .src a { color: var(--muted); }
.card-head .sp { flex: 1; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 9px; background: var(--soft); color: var(--muted); }
.badge.ok { background: var(--green-soft); color: var(--green-ink); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }

.card-body { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 14px; }
.main-ph { width: 220px; }
.sq { width: 220px; height: 220px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.sq img { width: 100%; height: 100%; display: block; }
.sq .lab { position: absolute; left: 6px; top: 6px; background: var(--green); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 9px; }
.sq .none { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 13px; }
.main-ph select { margin-top: 8px; font-size: 13px; padding: 5px 8px; }

.fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 12px; align-content: start; }
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f > span { font-size: 12.5px; color: var(--muted); }
.f > span b { color: var(--red); font-weight: 400; }
.f.c6 { grid-column: span 6; } .f.c4 { grid-column: span 4; } .f.c3 { grid-column: span 3; } .f.c2 { grid-column: span 2; } .f.c1 { grid-column: span 1; }
.f small { color: var(--muted); font-size: 12px; }
.f.bad input, .f.bad select { border-color: var(--red); background: var(--red-soft); }
.optrow { display: grid; grid-template-columns: 90px 1fr; gap: 6px; }

.photos { padding: 0 14px 12px; }
.photos-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.seg { display: inline-flex; background: var(--soft); padding: 3px; border-radius: 8px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 13px; }
.seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button b { font-weight: 600; color: var(--green-ink); margin-left: 2px; }
.seg button b.over { color: var(--red); }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; }
.th { position: relative; aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden; border: 2px solid transparent; background: var(--soft); cursor: pointer; }
.th img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.th.off img { opacity: .3; filter: grayscale(1); }
.th.on { border-color: var(--green); }
.th.dt { border-color: #3b82f6; }
.th .n.dn { background: #3b82f6; }
.th .n { position: absolute; left: 3px; top: 3px; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 8px; }
.th .n.main { background: #111; }
.th .s { position: absolute; right: 3px; bottom: 3px; background: rgba(0,0,0,.55); color: #fff; font-size: 10.5px; padding: 0 5px; border-radius: 8px; }
.th .mk { position: absolute; right: 3px; top: 3px; display: none; background: rgba(255,255,255,.95); border: 1px solid var(--line); font-size: 11px; padding: 0 5px; border-radius: 6px; }
.th:hover .mk { display: block; }
.th .zm, .ct .zm { position: absolute; left: 3px; bottom: 3px; width: 24px; height: 24px; padding: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.92); border: 1px solid var(--line); color: #333; cursor: zoom-in; }
.th .zm:hover, .ct .zm:hover { background: #fff; transform: scale(1.12); }
.sq img { cursor: zoom-in; }

/* 사진 크게 보기 */
.view { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0e0f11; color: #fff; outline: none; }
.view[open] { display: grid; grid-template-rows: auto 1fr auto; }
.view::backdrop { background: rgba(0,0,0,.6); }
.view-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; font-size: 14px; }
.view-name { flex: 1; color: #cfd2d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view-x { background: transparent; border: 0; color: #fff; font-size: 28px; line-height: 1; padding: 2px 10px; }
.view-stage { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; min-height: 0; }
.view-stage img { max-width: 100%; max-height: calc(100vh - 150px); margin: 0 auto; object-fit: contain; display: block; }
.view-arrow { height: 100%; max-height: 240px; background: transparent; border: 0; color: #fff; font-size: 48px; opacity: .75; }
.view-arrow:hover:not(:disabled) { opacity: 1; background: rgba(255,255,255,.06); }
.view-arrow:disabled { opacity: .15; }
.view-bar { padding: 10px 16px 14px; text-align: center; }
.view-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.view-btns button { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); color: #fff; padding: 8px 14px; }
.view-btns button.on { background: var(--green); border-color: var(--green); }
.view-btns button:disabled { opacity: .35; cursor: default; }
.view-msg { min-height: 1.4em; margin-top: 6px; font-size: 13px; color: #ffd27a; }
.view-hint { font-size: 12px; color: #9aa0a6; }
.th.drag { opacity: .4; }
.th.over { outline: 2px dashed var(--green); outline-offset: 1px; }

.card-foot { padding: 10px 14px 14px; border-top: 1px dashed var(--line); display: grid; grid-template-columns: 1fr; gap: 6px; }
.card-foot textarea { min-height: 90px; font-size: 13px; }
.issues { color: var(--red); font-size: 12.5px; }
.addpost { display: flex; gap: 6px; }
.addpost input { font-size: 13px; padding: 5px 9px; }

/* 대화창 */
.dlg { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg.wide { width: min(820px, calc(100vw - 32px)); }
.dlg.small { width: min(400px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(20,22,25,.45); }
.dlg-body { padding: 18px 20px; }
.dlg-body > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.dlg-body h2 { margin: 0 0 6px; font-size: 18px; }
.dlg-body footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.x { border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 2px 8px; }
.steps { padding-left: 20px; line-height: 1.7; }
.steps li { margin-bottom: 8px; }
.err { color: var(--red); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.settings h3 { grid-column: 1 / -1; margin: 14px 0 0; font-size: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.settings h3:first-child { border-top: 0; padding-top: 0; margin-top: 4px; }
.settings h3 small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.settings .wide { grid-column: 1 / -1; }
.settings-backup { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.settings-backup p { margin: 4px 0 8px; }

.bar { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; margin: 12px 0 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1d1f22; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 50; white-space: pre-line;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--red); }

@media (max-width: 820px) {
  #importForm, #periodForm { grid-template-columns: 1fr; }
  .lp { grid-template-columns: 1fr; }
  .codi { grid-template-columns: 1fr; }
  .codi-list { max-height: none; }
  .card-body { grid-template-columns: 1fr; }
  .main-ph, .sq { width: 100%; }
  .sq { height: auto; aspect-ratio: 1; }
  .fields { grid-template-columns: repeat(2, 1fr); }
  .f.c6, .f.c4, .f.c3 { grid-column: span 2; } .f.c2, .f.c1 { grid-column: span 1; }
  .settings { grid-template-columns: 1fr; }
  main { padding: 12px 12px 80px; }
  .top { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
}
