/* ===== 나울 재고 관제 웹 — 모바일 우선 ===== */
:root {
  --soldout: #A32D2D;   /* 품절 빨강 */
  --low:     #854F0B;   /* 임박 주황 */
  --ok:      #3B6D11;   /* 양호 초록 */
  --plenty:  #185FA5;   /* 충분 파랑 */

  --bg:      #0f1115;
  --card:    #1a1e26;
  --card-2:  #232834;
  --line:    #2e3440;
  --text:    #e8ebf0;
  --muted:   #9aa3b2;
  --accent:  #185FA5;
  --danger:  #A32D2D;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
               "Apple SD Gothic Neo", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- 헤더 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 17px; letter-spacing: -0.3px; }
.topbar .brand small { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.topbar .who { color: var(--muted); font-size: 13px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 11px 16px; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: filter .12s ease; text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translatey(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger  { background: transparent; border-color: var(--danger); color: #e88; }
.btn-ghost   { background: transparent; }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 카드 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }

/* ---------- 로그인 ---------- */
.login-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .mark { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.login-logo .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); }
.field-select {
  width: 100%; padding: 12px 14px; font-size: 16px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); appearance: none;
}
.field-select:focus { outline: none; border-color: var(--accent); }
.login-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }
.msg { font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; display: none; }
.msg.show { display: block; }
.msg.error { background: rgba(163,45,45,.15); color: #f0a0a0; border: 1px solid rgba(163,45,45,.4); }
.msg.success { background: rgba(59,109,17,.15); color: #a8d98a; border: 1px solid rgba(59,109,17,.4); }

/* ---------- 요약 카드 ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.stat .num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat .lab { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat.s-soldout .num { color: #e07a7a; }
.stat.s-low .num { color: #d6a55a; }
.stat .num.total { color: var(--text); }

/* ---------- 경보 ---------- */
.warnings { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.warn { padding: 11px 13px; border-radius: 10px; font-size: 13.5px; font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.warn.line_wiped { background: rgba(163,45,45,.18); border: 1px solid rgba(163,45,45,.5); color: #f0b0b0; }
.warn.extension  { background: rgba(133,79,11,.18); border: 1px solid rgba(133,79,11,.5); color: #e6c082; }
.warn.invalid    { background: rgba(110,110,120,.18); border: 1px solid rgba(110,110,120,.5); color: #c8ccd6; }
.warn.soldout    { background: rgba(163,45,45,.18); border: 1px solid rgba(163,45,45,.5); color: #f0b0b0; }

/* 안전재고 라벨 (네이버 재고) */
.sku .safe { font-size: 10px; color: var(--muted); flex: 0 0 auto; white-space: nowrap; }

/* ---------- 라인 섹션 ---------- */
.line-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.line-head .name { font-size: 16px; font-weight: 700; }
.line-head .badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--card-2); color: var(--muted); margin-left: 8px; }
.line-head .badge.wiped { background: var(--soldout); color: #fff; }
.line-head .badge.ext  { background: var(--low); color: #fff; }

/* SKU 행: 2줄 구조 — 윗줄(점+이름+수량), 아랫줄(안전+막대). 이름은 잘리지 않고 줄바꿈됨 */
.sku { padding: 10px 0; border-top: 1px solid var(--line); }
.sku:first-child { border-top: none; }
.sku-top { display: flex; align-items: flex-start; gap: 8px; }
.sku-top .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; margin-top: 5px; }
.sku-top .nm { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; word-break: break-word; }
.sku-top .nm .tag-ext { font-size: 10px; color: var(--low); border: 1px solid var(--low); border-radius: 4px; padding: 0 4px; margin-right: 5px; }
.sku-top .qty { font-size: 15px; font-weight: 700; flex: 0 0 auto; min-width: 40px; text-align: right; }
.sku-bot { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-left: 17px; }
.sku-bot .safe { font-size: 11px; color: var(--muted); flex: 0 0 auto; white-space: nowrap; }
.bar-wrap { flex: 1; height: 7px; background: var(--card-2); border-radius: 5px; overflow: hidden; }
.bar { height: 100%; border-radius: 5px; }

.st-soldout .dot, .st-soldout .bar { background: var(--soldout); }
.st-low .dot, .st-low .bar { background: var(--low); }
.st-ok .dot, .st-ok .bar { background: var(--ok); }
.st-plenty .dot, .st-plenty .bar { background: var(--plenty); }
.st-soldout .qty { color: #e07a7a; }
.st-low .qty { color: #d6a55a; }

/* ---------- 입력부 ---------- */
textarea {
  width: 100%; min-height: 120px; padding: 12px; font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.help { font-size: 12px; color: var(--muted); margin: 8px 0; }
.updated { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 4px; }
.hidden { display: none !important; }

/* ---------- 관리자 테이블 ---------- */
.user-card { padding: 12px 0; border-top: 1px solid var(--line); }
.user-card:first-child { border-top: none; }
.user-row { display: flex; align-items: center; gap: 10px; }
.user-row .uinfo { flex: 1; min-width: 0; }
.user-row .uinfo .un { font-weight: 600; font-size: 14px; }
.user-row .uinfo .um { font-size: 12px; color: var(--muted); }
.role-pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.role-pill.admin { background: var(--accent); color: #fff; }
.role-pill.staff { background: var(--card-2); color: var(--muted); }
.temp-pass {
  background: rgba(59,109,17,.15); border: 1px solid rgba(59,109,17,.4);
  border-radius: 8px; padding: 10px 12px; margin-top: 10px; font-size: 13px;
}
.temp-pass code { font-family: ui-monospace, monospace; font-size: 15px; color: #a8d98a; user-select: all; }

/* ---------- 권한 영역 ---------- */
.perms { margin-top: 10px; padding: 10px 12px; background: var(--card-2); border-radius: 10px; }
.perms-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.perm-name { font-size: 13.5px; }
.perm-fixed { font-size: 12px; color: var(--plenty); font-weight: 600; }
.perm-select {
  padding: 6px 10px; font-size: 13px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; min-width: 84px;
  transition: border-color .2s ease;
}
.perm-select:focus { outline: none; border-color: var(--accent); }

@media (min-width: 480px) {
  .topbar .who { font-size: 14px; }
}

/* ===== 앱 레이아웃 (디스코드식 사이드바 + 메인) ===== */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: 244px; flex: 0 0 244px; background: #14171e;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar-head { padding: 16px 16px 12px; font-weight: 800; font-size: 16px; border-bottom: 1px solid var(--line); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.cat { margin-bottom: 14px; }
.cat-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 4px 8px; }
.chan { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: #c7ccd6; font-size: 14px; }
.chan:hover { background: var(--card-2); }
.chan.active { background: var(--accent); color: #fff; }
.chan-ico { width: 18px; text-align: center; flex: 0 0 auto; }
.chan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan.soon, .chan.locked { color: #6b7280; cursor: default; }
.chan.soon:hover, .chan.locked:hover { background: transparent; }
.chan-tag.soon { font-size: 10px; background: var(--card-2); color: var(--muted); padding: 1px 6px; border-radius: 10px; flex: 0 0 auto; }
.chan-lock { font-size: 11px; opacity: .7; flex: 0 0 auto; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px 12px; }
.sidebar-foot .me { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sidebar-foot-btns { display: flex; gap: 6px; }

.main { flex: 1; min-width: 0; }
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; padding: 0 10px 0 0; line-height: 1; }
.drawer-overlay { display: none; }
.view.hidden { display: none; }

.placeholder { text-align: center; padding: 56px 20px; color: var(--muted); }
.ph-icon { font-size: 46px; margin-bottom: 14px; }
.ph-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.ph-desc { font-size: 14px; max-width: 360px; margin: 0 auto; }

/* ===== 리포트 (숫자카드 + 표 섹션) ===== */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.metric .mlab { font-size: 12px; color: var(--muted); }
.metric .mval { font-size: 21px; font-weight: 800; margin-top: 4px; line-height: 1.15; }
.metric .msub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.metric.good .mval { color: #a8d98a; }
.metric.warn .mval { color: #d6a55a; }
.metric.bad .mval  { color: #e07a7a; }
.rnote { font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.rrow { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.rrow:first-of-type { border-top: none; }
.rrow .rl { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.35; word-break: break-word; }
.rrow .rl .rsub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.rrow .rv { flex: 0 0 auto; font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100dvh; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
  .hamburger { display: inline-block; }
  .topbar .who { display: none; }
}
