/* 지얼 관리자 — 휴대폰 우선. 휴대폰: 아래 탭 + 화면 전체 편집 창 / PC(900px 이상): 위 탭 + 오른쪽 편집 창 */
:root {
  --bg: #f4f2ee; --card: #ffffff; --text: #1d1b18; --muted: #6b665e; --line: #ddd8cf; --soft: #f8f6f2;
  --accent: #8a5a2b; --accent-text: #ffffff; --accent-soft: #f3e9dd;
  --ok: #2e7d4f; --ok-soft: #e4f3ea; --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #8a6100; --warn-soft: #fff4d6;
  --sale: #d61f26; --field: #ffffff; --shadow: 0 8px 28px rgba(0, 0, 0, .14);
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --card: #211f1c; --text: #f1ede6; --muted: #a8a197; --line: #3a3631; --soft: #1b1a17;
    --accent: #d29a5f; --accent-text: #1b1208; --accent-soft: #3a2c1e;
    --ok: #6fcf97; --ok-soft: #1d3326; --bad: #ff8a80; --bad-soft: #3a1f1c; --warn: #f2c14e; --warn-soft: #3a3019;
    --sale: #ff6b6b; --field: #2a2723; --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --card: #211f1c; --text: #f1ede6; --muted: #a8a197; --line: #3a3631; --soft: #1b1a17;
  --accent: #d29a5f; --accent-text: #1b1208; --accent-soft: #3a2c1e;
  --ok: #6fcf97; --ok-soft: #1d3326; --bad: #ff8a80; --bad-soft: #3a1f1c; --warn: #f2c14e; --warn-soft: #3a3019;
  --sale: #ff6b6b; --field: #2a2723; --shadow: 0 8px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.55 -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
img { max-width: 100%; }

/* ---------- 머리 ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.top .brand small { display: block; font-size: 12px; font-weight: 500; letter-spacing: .08em; color: var(--muted); }
.top .who { margin-left: auto; font-size: 14px; color: var(--muted); }

/* ---------- 탭 (휴대폰: 아래 / PC: 머리 아래) ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); }
.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button .ic { font-size: 20px; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--accent); }
main { padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); max-width: 1280px; margin: 0 auto; }
@media (min-width: 900px) {
  .tabs { position: sticky; top: 61px; bottom: auto; height: auto; padding: 0 16px; display: flex; gap: 4px; border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg); }
  .tabs button { flex-direction: row; gap: 6px; padding: 12px 16px; font-size: 16px; border-bottom: 3px solid transparent; }
  .tabs button[aria-current="page"] { border-bottom-color: var(--accent); }
  main { padding-bottom: 48px; }
}

/* ---------- 공통 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px; margin-bottom: 14px; }
.card h2 { font-size: 20px; margin: 0 0 6px; }
.card > p, .desc { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
h1.page { font-size: 24px; margin: 4px 0 14px; }
label.f { display: block; font-weight: 600; font-size: 15px; margin: 14px 0 6px; }
.in, select.in, textarea.in { width: 100%; font-size: 18px; padding: 12px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--text); }
textarea.in { resize: vertical; min-height: 84px; }
.in:focus { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.in.changed { border-color: var(--accent); background: var(--accent-soft); }
.hint { font-size: 14px; color: var(--muted); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.block { width: 100%; font-size: 18px; padding: 15px; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.msg { margin-top: 12px; font-size: 15px; min-height: 1.4em; }
.msg.bad { color: var(--bad); } .msg.ok { color: var(--ok); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.sale { background: var(--sale); color: #fff; border-color: transparent; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; padding: 10px 6px; border-radius: 9px; font-size: 16px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
.switch:last-child { border-bottom: 0; }
.switch input { width: 52px; height: 30px; appearance: none; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 25px; }

/* ---------- 알림 (맨 위, 크게) ---------- */
#toast { position: fixed; top: 10px; left: 50%; transform: translate(-50%, -140%); z-index: 100; width: min(560px, calc(100% - 24px));
  padding: 15px 18px; border-radius: 14px; font-size: 17px; font-weight: 700; box-shadow: var(--shadow); transition: transform .25s; }
#toast.show { transform: translate(-50%, 0); }
#toast.ok { background: var(--ok); color: #fff; }
#toast.bad { background: var(--bad); color: #fff; }

/* ---------- 제품 목록 ---------- */
.tools { display: grid; gap: 10px; margin-bottom: 12px; }
.search { position: relative; }
.search .in { padding-left: 42px; }
.search::before { content: "⌕"; position: absolute; left: 14px; top: 50%; transform: translateY(-52%); font-size: 22px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 8px 14px; border-radius: 99px; font-size: 15px; font-weight: 600; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chips button.warn[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: #fff; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.filters select { font-size: 15px; padding: 10px 8px; }
.count { color: var(--muted); font-size: 15px; margin: 4px 2px 10px; display: flex; justify-content: space-between; gap: 10px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; } }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column; }
.item:focus-visible, .item.sel { outline: 3px solid var(--accent); }
.item .ph { aspect-ratio: 1; background: var(--soft); display: flex; align-items: center; justify-content: center; position: relative; }
.item .ph img { max-width: 92%; max-height: 92%; object-fit: contain; }
.item .ph .noimg { color: var(--muted); font-size: 13px; }
.item .tags { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.item .meta { padding: 9px 10px 11px; display: grid; gap: 2px; }
.item .nm { font-weight: 700; font-size: 16px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item .sz { font-size: 13px; color: var(--muted); }
.item .pr { font-size: 16px; font-weight: 800; }
.item .pr.none { color: var(--bad); font-weight: 600; font-size: 14px; }
.item.off { opacity: .55; }

/* ---------- 편집 창 (휴대폰: 전체 / PC: 오른쪽) ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; }
.sheet .dim { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet .panel { position: relative; width: 100%; height: 100%; background: var(--bg); display: flex; flex-direction: column; animation: up .2s ease-out; }
@media (min-width: 900px) { .sheet .panel { width: 560px; box-shadow: var(--shadow); animation: left .2s ease-out; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes left { from { transform: translateX(40px); opacity: 0; } }
.sheet .head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet .head .t { flex: 1; min-width: 0; }
.sheet .head .t b { display: block; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .head .t small { color: var(--muted); font-size: 13px; }
.sheet .x { border: 0; background: var(--soft); width: 42px; height: 42px; border-radius: 50%; font-size: 22px; cursor: pointer; color: var(--text); flex: none; }
.sheet .body { flex: 1; overflow: auto; padding: 14px 14px 24px; -webkit-overflow-scrolling: touch; }
.sheet .foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.sheet .foot .state { flex: 1; font-size: 14px; color: var(--muted); }
.sheet .foot .state.dirty { color: var(--accent); font-weight: 700; }
.sheet .foot .btn.primary { min-width: 140px; }
.hero { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.hero img { width: 104px; height: 104px; object-fit: contain; background: var(--soft); border-radius: 10px; flex: none; }
.hero .info { font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.spec { border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px 14px; margin-bottom: 12px; background: var(--soft); }
.spec .sh { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-weight: 700; }
.retail { margin-top: 8px; font-size: 15px; color: var(--muted); }
.retail b { color: var(--text); font-size: 17px; }
.loglist { list-style: none; padding: 0; margin: 0; }
.loglist li { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.loglist li:last-child { border-bottom: 0; }
.loglist .when { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.loglist .what { font-size: 15px; }
.loglist .what del { color: var(--muted); }
.loglist .what ins { text-decoration: none; font-weight: 700; }

/* ---------- 특가 ---------- */
.sale-grid { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .sale-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .sale-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sitem { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; grid-template-columns: 96px 1fr; gap: 12px; }
.sitem img { width: 96px; height: 96px; object-fit: contain; background: var(--soft); border-radius: 8px; }
.sitem .pct { color: var(--sale); font-weight: 800; }
.sitem .acts { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.sitem .acts .btn { flex: 1; }
.sitem.hidden { opacity: .55; }
.bulk { display: grid; gap: 10px; }
.bulk .b { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
.bulk .b .lbl { grid-column: 1 / -1; font-weight: 700; }

/* ---------- 상세페이지 편집기 ---------- */
#detail { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: flex; flex-direction: column; }
#detail .bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#detail .bar b { flex: 1; min-width: 140px; font-size: 17px; }
#detail .area { flex: 1; min-height: 0; }
#detail .tip { font-size: 13px; color: var(--muted); padding: 6px 12px; background: var(--card); border-bottom: 1px solid var(--line); }

/* 작은 버튼 글자가 두 줄로 꺾이지 않게 */
.btn.small { white-space: nowrap; }
.sitem .acts .btn { padding: 10px 6px; font-size: 14px; white-space: nowrap; }

/* 새 타일 사진 올리기 */
.drop { display: grid; gap: 4px; place-items: center; text-align: center; padding: 26px 12px; border: 2px dashed var(--line); border-radius: 12px; background: var(--soft); cursor: pointer; }
.drop b { font-size: 18px; color: var(--accent); }
.drop span { font-size: 14px; color: var(--muted); }
.drop.on { border-color: var(--accent); background: var(--accent-soft); }
.uplist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.uplist li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.uplist .nm { font-weight: 600; word-break: break-all; }
.uplist .st { grid-column: 1; color: var(--muted); }
.uplist .act { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.uplist .act img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.uplist li.ok { border-color: var(--ok); background: var(--ok-soft); } .uplist li.ok .st { color: var(--ok); }
.uplist li.bad { border-color: var(--bad); background: var(--bad-soft); } .uplist li.bad .st { color: var(--bad); }
.uplist li.warn { border-color: var(--warn); background: var(--warn-soft); } .uplist li.warn .st { color: var(--warn); }
.uplist li.busy .st { color: var(--accent); }
@media (max-width: 520px) { .uplist li { grid-template-columns: 1fr; } .uplist .act { grid-column: 1; grid-row: auto; justify-content: flex-start; } }

/* 카탈로그 앞부분 (디자인 PDF) 쪽 그림 */
.dpgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dpgrid a { position: relative; display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--soft); }
.dpgrid img { display: block; width: 100%; aspect-ratio: 1200 / 1697; object-fit: cover; }
.dpgrid span { position: absolute; left: 6px; bottom: 6px; padding: 1px 7px; border-radius: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; }
