:root {
  --navy: #16294a;
  --accent: #d81b23;
  --ink: #16202e;
  --ink-2: #4a5668;
  --ink-3: #8b95a4;
  --line: #e2e6ec;
  --wash: #f6f7f9;
  --ok: #17803d;
  --warn: #b45309;
  --radius: 6px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 14px; color: var(--ink); background: var(--wash); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy); }

/* ---------------------------------------------------------- 로그인 */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate form { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 34px; width: min(400px, 100%); box-shadow: 0 10px 40px rgba(22,41,74,.08); }
.gate h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.03em; }
.gate p { margin: 0 0 22px; color: var(--ink-3); font-size: 13px; line-height: 1.6; }
.gate .mark { width: 40px; height: 40px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; margin-bottom: 16px; }

/* ---------------------------------------------------------- 셸 */
.shell { display: grid; grid-template-columns: 246px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 18px 18px; border-bottom: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; gap: 10px; }
.side .brand .mark { width: 30px; height: 30px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.side .brand b { font-size: 14px; letter-spacing: -.03em; }
.side .brand small { display: block; font-size: 10px; opacity: .6; letter-spacing: .1em; }

.side .searchbox { padding: 12px 14px 6px; }
.side .navsearch { width: 100%; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); color: #fff; border-radius: var(--radius); padding: 7px 10px; font-size: 12.5px; }
.side .navsearch::placeholder { color: rgba(255,255,255,.45); }
.side .navsearch:focus { outline: none; border-color: rgba(255,255,255,.45); background: rgba(255,255,255,.14); }

.side nav { flex: 1; overflow-y: auto; padding: 6px 0 14px; }
.side .navgroup { padding: 14px 18px 6px; font-size: 10.5px; letter-spacing: .12em; font-weight: 700; color: rgba(255,255,255,.38); }
.side nav button.navitem { width: 100%; text-align: left; background: none; border: 0; color: rgba(255,255,255,.74); padding: 9px 18px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.side nav button.navitem:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav button.navitem.on { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.side nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.side nav .subnav { padding: 2px 0 6px; background: rgba(0,0,0,.16); }
.side nav button.subitem { width: 100%; text-align: left; background: none; border: 0; color: rgba(255,255,255,.6); padding: 6px 18px 6px 30px; cursor: pointer; font-size: 12.5px; display: block; }
.side nav button.subitem:hover { color: #fff; background: rgba(255,255,255,.05); }
.side nav button.subitem.on { color: #fff; font-weight: 600; background: rgba(255,255,255,.08); }
.side .foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.12); display: grid; gap: 8px; }
.side .foot a, .side .foot button { color: rgba(255,255,255,.75); font-size: 12.5px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: none; }
.side .foot a:hover, .side .foot button:hover { color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------- 상단 바 */
.bar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 22px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar h2 { margin: 0; font-size: 16px; letter-spacing: -.03em; flex: 1; min-width: 140px; }
.bar .crumb { flex: 1; min-width: 140px; font-size: 15px; letter-spacing: -.02em; }
.bar .crumb b { font-weight: 700; }
.bar .crumb span { color: var(--ink-3); font-weight: 500; }
.bar a.btn { text-decoration: none; display: inline-block; }
.bar .meta { color: var(--ink-3); font-size: 12px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #fdeced; color: var(--accent); }
.badge.gray { background: var(--wash); color: var(--ink-3); }

.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--navy); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.pri { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.pri:hover:not(:disabled) { background: #101f39; }
.btn.dan { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; font-weight: 500; }

/* ---------------------------------------------------------- 본문 */
.body { padding: 22px; flex: 1; min-width: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
.card > h3 { margin: 0; padding: 13px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.card > h3 .grow { flex: 1; }
.card .pad { padding: 16px 18px; }
.hint { color: var(--ink-3); font-size: 12.5px; line-height: 1.65; margin: 0 0 14px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(22,41,74,.25); outline-offset: -1px; border-color: var(--navy); }
textarea { resize: vertical; min-height: 68px; line-height: 1.6; }

/* 한/영 쌍 */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair > div { min-width: 0; }
.pair .tag { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 4px; display: block; }
.row { border-bottom: 1px solid var(--line); padding: 12px 18px; }
.row:last-child { border-bottom: 0; }
.row > .k { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; word-break: break-all; }
.group { background: var(--wash); padding: 9px 18px; font-size: 11.5px; font-weight: 700; color: var(--ink-2); letter-spacing: -.01em; border-bottom: 1px solid var(--line); position: sticky; top: 0; }

/* 목록 항목 */
.item { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: #fff; }
.item > .head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--wash); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; }
.item > .head b { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item > .head .no { font-family: ui-monospace, monospace; font-size: 11px; color: var(--ink-3); }
.item > .bd { padding: 14px; }
.item.closed > .bd { display: none; }

.tools { display: flex; gap: 5px; }
.tools button { border: 1px solid var(--line); background: #fff; width: 26px; height: 26px; border-radius: 4px; cursor: pointer; font-size: 12px; line-height: 1; display: grid; place-items: center; color: var(--ink-2); }
.tools button:hover { border-color: var(--navy); color: var(--navy); }
.tools button.del:hover { border-color: var(--accent); color: var(--accent); }

/* 표 편집 */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tbl table { border-collapse: collapse; width: 100%; }
.tbl td { border: 1px solid var(--line); padding: 0; min-width: 90px; }
.tbl td input { border: 0; border-radius: 0; padding: 6px 8px; background: transparent; }
.tbl td.h input { font-weight: 700; background: var(--wash); }

/* 이미지 */
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.imgs .th { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--wash); position: relative; aspect-ratio: 1; }
.imgs .th img { width: 100%; height: 100%; object-fit: contain; display: block; }
.imgs .th .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 4px; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }
.imgs .th .nm { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 9.5px; padding: 2px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imgs .th.pick { cursor: pointer; }
.imgs .th.pick:hover { border-color: var(--navy); }

/* 알림 */
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; max-width: min(440px, 90vw); }
.toast div { background: var(--navy); color: #fff; padding: 11px 15px; border-radius: var(--radius); font-size: 13px; box-shadow: 0 8px 26px rgba(0,0,0,.2); animation: tin .2s ease; }
.toast div.err { background: var(--accent); }
.toast div.ok { background: var(--ok); }
@keyframes tin { from { opacity: 0; transform: translateY(6px) } }

.errbox { background: #fdeced; border: 1px solid #f5c2c5; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.errbox b { color: var(--accent); font-size: 13px; display: block; margin-bottom: 6px; }
.errbox ul { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.75; color: #7d1d22; }

pre.log { background: #10151d; color: #cfd8e3; padding: 14px; border-radius: var(--radius); font-size: 11.5px; line-height: 1.55; max-height: 340px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-all; }

.modal { position: fixed; inset: 0; background: rgba(12,17,25,.55); display: grid; place-items: center; z-index: 90; padding: 20px; }
.modal .box { background: #fff; border-radius: 10px; width: min(880px, 100%); max-height: 88vh; overflow: auto; }
.modal .box > h3 { margin: 0; padding: 15px 20px; border-bottom: 1px solid var(--line); font-size: 15px; display: flex; align-items: center; }
.modal .box > h3 .grow { flex: 1; }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th, table.list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.list th { background: var(--wash); font-size: 11.5px; color: var(--ink-2); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { display: flex; overflow-x: auto; padding: 6px; }
  .side nav button { width: auto; white-space: nowrap; }
  .pair { grid-template-columns: 1fr; }
  .body { padding: 14px; }
}

/* ---------------------------------------------------------- 새 편집 요소 */
.flabel { display: block; font-size: 12px; color: var(--ink-2); margin: 0 0 5px; font-weight: 600; }

/* 여러 칸을 한 줄에 놓는 행 */
.gridrow { display: grid; grid-template-columns: var(--cols, 1fr); gap: 8px; margin-bottom: 7px; align-items: center; }
.gridrow.head { font-size: 11px; color: var(--ink-3); font-weight: 700; margin-bottom: 4px; }
.gridrow label.f { margin-bottom: 0; }

/* 첨부파일 줄 */
.filerow { display: grid; grid-template-columns: 92px 1fr 72px auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.filerow .meta { font-size: 11.5px; color: var(--ink-3); text-align: right; }

/* 제품 · 카테고리 목록 줄 */
.prow { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 7px; background: #fff; }
.prow .thumb { width: 46px; height: 46px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 4px; background: var(--wash); display: grid; place-items: center; overflow: hidden; }
.prow .thumb img { width: 100%; height: 100%; object-fit: contain; }
.prow .thumb .noimg { font-size: 9px; color: var(--ink-3); }
.prow .grow { flex: 1; min-width: 0; }
.prow b { font-size: 13.5px; display: block; }
.prow .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* 제품 상세 상단 되돌아가기 줄 */
.backbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.backbar b { font-size: 15px; flex: 1; }
.backbar a.btn { text-decoration: none; }
