:root {
  /* Upstage-inspired light theme */
  --bg: #f5f6f9;
  --surface: #eef0f5;       /* 옅은 회색 면 (입력/헤더) */
  --card: #ffffff;
  --line: #e6e7ee;
  --line-strong: #d7d9e3;

  --ink: #16161d;           /* 본문 텍스트 */
  --ink-soft: #3d3d4e;
  --muted: #8488a0;

  --accent: #5b52ff;        /* 메인 바이올렛 */
  --accent-hover: #4a41e6;
  --accent-soft: #eeedff;   /* 옅은 바이올렛 배경 */
  --accent-ink: #4036d6;

  --green: #16a34a;  --green-bg: #e7f6ec;
  --red:   #e5484d;  --red-bg:   #fce9ea;
  --amber: #b7791f;  --amber-bg: #fbf0d8;
  --blue:  #2563eb;  --blue-bg:  #e7eefe;

  --shadow: 0 1px 2px rgba(20,20,40,.04), 0 6px 20px rgba(20,20,50,.05);
  --shadow-hover: 0 6px 26px rgba(91,82,255,.14);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Geist", "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- 로그인 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(91,82,255,.12), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--card);
  padding: 46px 40px;
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  width: 372px;
  text-align: center;
}
.login-logo { font-size: 40px; font-weight: 800; letter-spacing: 1px; color: var(--ink); }
.login-logo::after { content: "."; color: var(--accent); }
.login-sub { color: var(--muted); margin: 8px 0 30px; font-size: 14px; }
#login-form { display: flex; flex-direction: column; gap: 11px; }
#login-form input {
  padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 15px; background: #fff; transition: .15s;
}
#login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#login-form button {
  margin-top: 6px; padding: 14px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15.5px; font-weight: 600; transition: .15s;
}
#login-form button:hover { background: var(--accent-hover); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------------- 레이아웃 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 238px; background: var(--card); color: var(--ink-soft);
  display: flex; flex-direction: column; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line);
}
.brand { color: var(--ink); font-size: 23px; font-weight: 800; letter-spacing: .3px; padding: 6px 12px 22px; cursor: pointer; }
.brand:hover { opacity: .8; }
.brand-accent { color: var(--accent); }
#nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-group-label { font-size: 11px; color: var(--muted); padding: 16px 12px 6px; letter-spacing: .5px; font-weight: 600; text-transform: uppercase; }
.nav-group-label.divider { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 16px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 10px; color: var(--ink-soft);
  font-size: 14.5px; font-weight: 500; border: none; background: none; text-align: left; width: 100%; transition: .12s;
}
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 14px; }
.user-info { font-size: 12.5px; color: var(--muted); padding: 0 12px 10px; line-height: 1.5; }
.user-info strong { color: var(--ink); }
.logout {
  width: 100%; padding: 10px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-soft); border-radius: 10px; font-size: 13px; font-weight: 500; transition: .12s;
}
.logout:hover { background: var(--surface); border-color: var(--muted); }

.content { flex: 1; padding: 34px 40px; overflow-x: hidden; min-width: 0; }

/* ---------------- 모바일 (사이드바 → 햄버거 드로어) ---------------- */
#mtopbar { display: none; }
#m-overlay { display: none; }
@media (max-width: 860px) {
  #mtopbar {
    display: flex; align-items: center; gap: 14px;
    position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 50;
    background: var(--card); border-bottom: 1px solid var(--line); padding: 0 16px;
  }
  .mbrand { font-size: 19px; font-weight: 800; letter-spacing: .3px; cursor: pointer; }
  .mmenu { width: 32px; height: 32px; border: none; background: none; padding: 5px; display: flex; flex-direction: column; justify-content: center; gap: 5px; cursor: pointer; }
  .mmenu span { display: block; height: 2.5px; background: var(--ink); border-radius: 2px; }

  .sidebar {
    position: fixed; top: 0; left: -284px; height: 100vh; width: 268px; z-index: 70;
    transition: left .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.28);
  }
  .sidebar.open { left: 0; }
  #m-overlay { position: fixed; inset: 0; background: rgba(20,20,40,.45); z-index: 65; }
  #m-overlay.show { display: block; }

  .content { padding: 72px 16px 28px; }
  .page-head { margin-bottom: 18px; }
  .page-title { font-size: 22px; }
  .stat-grid { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .section { padding: 16px; }
  .modal, .modal.wide { width: 100%; padding: 22px 18px; }
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; }
.page-desc { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

/* ---------------- 카드 / 통계 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -0.02em; }
.stat-value.warn { color: var(--red); }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat-card.clickable { cursor: pointer; transition: .15s; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--accent); }

.section { background: var(--card); border-radius: var(--radius); padding: 22px 24px; border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 22px; }
.section-title { font-size: 15.5px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 900px){ .grid-2 { grid-template-columns: 1fr; } }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; margin-bottom: 22px; }
.panel-link { cursor: pointer; transition: .15s; }
.panel-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
.go-link { font-size: 12px; font-weight: 600; color: var(--accent); }
.mini-stats { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.mini-stats b { font-size: 15px; }
.mini-stats .ms-warn b { color: var(--red); }
.mini-stats .ms-prog b { color: var(--blue); }

/* 매장 카드 그리드 */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.store-card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; transition: .15s; }
.store-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.store-card .pill { display: inline-block; background: var(--accent-soft); color: var(--accent-ink); padding: 4px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 700; }
.store-card .sc-total { font-size: 26px; font-weight: 800; margin-top: 14px; letter-spacing: -0.02em; }
.store-card .sc-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------------- 테이블 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface); position: sticky; top: 0; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafaff; }
td.num, th.num { text-align: right; }
.qty-zero { color: #b8bcca; font-weight: 400; }
.qty-low { color: #000000; font-weight: 800; }

.badge { display: inline-block; padding: 6px 15px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.badge.in { background: var(--green); }
.badge.out { background: var(--red); }
.badge.pending { background: var(--amber); }
.badge.prog { background: var(--blue); }
.cat-tag { display: inline-block; padding: 4px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); letter-spacing: .2px; }
/* 카테고리별 단색 필박스 (꽉 채움) */
.cat-tag.cat-welcomekit { background: #e8590c; color: #fff; }   /* 사은품 - 오렌지 */
.cat-tag.cat-pillow     { background: #d6336c; color: #fff; }   /* 침구 - 핑크 */
.cat-tag.cat-motionbed  { background: #5b52ff; color: #fff; }   /* 프레임 - 바이올렛 */
.cat-tag.cat-mattress   { background: #0ca678; color: #fff; }   /* 매트리스 - 그린 */
.content a { color: var(--accent); }

/* ---------------- 버튼 ---------------- */
.btn { padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-size: 14px; font-weight: 600; transition: .12s; }
.btn-dark { background: var(--accent); color: #fff; }
.btn-dark:hover { background: var(--accent-hover); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(.94); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { filter: brightness(.94); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-ghost:hover { background: var(--surface); border-color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.link-danger { color: var(--red); background: none; border: none; font-size: 12.5px; text-decoration: underline; }

/* 필터/검색 */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 14px; background: #fff;
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar input[type=text] { min-width: 200px; }

/* ---------------- 모달 ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22,22,40,.42); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: 18px; padding: 28px; width: 444px; max-width: 100%; box-shadow: 0 20px 60px rgba(20,20,50,.25); max-height: 90vh; overflow-y: auto; }
.modal.wide { width: 660px; }
.modal h3 { font-size: 19px; font-weight: 700; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 14.5px; background: #fff; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[readonly] { background: var(--surface); color: var(--ink-soft); }
.modal-error { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; padding: 11px; border: none; background: #fff; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.active-in { background: var(--green); color: #fff; }
.seg button.active-out { background: var(--red); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 100; box-shadow: 0 8px 26px rgba(0,0,0,.22); }

/* ---------------- 재고 피벗 테이블 ---------------- */
.cat-block { margin-bottom: 22px; }
.cat-head { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.cat-cnt { font-size: 12px; color: var(--muted); }
.cat-sub { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 14px 0 6px; }
table.pivot th, table.pivot td { padding: 9px 12px; }
table.pivot th.num, table.pivot td.num { text-align: center; }
table.pivot td:first-child { font-weight: 600; }
table.dash-stock th, table.dash-stock td { padding-top: 16px; padding-bottom: 16px; font-size: 14.5px; }
.cell-empty { color: var(--line-strong); }
.qty-sum { font-weight: 700; background: var(--surface); }
table.pivot tfoot .total-row td { border-top: 2px solid var(--accent); border-bottom: none; font-weight: 800; background: var(--accent-soft); }
table.pivot tfoot .total-row td:first-child { color: var(--accent-ink); }
.inv-cell { cursor: pointer; font-weight: 600; transition: .1s; }
.inv-cell:hover { background: var(--accent); color: #fff !important; }
.memo-cell { white-space: normal; vertical-align: middle; }
.memo-col { width: 38%; }
/* 사이즈 없는 표(사은품·침구): 폭을 줄여 재고를 제품 옆에 배치 */
.pivot-simple { max-width: 860px; }
.pivot-simple th:first-child, .pivot-simple td:first-child { width: 200px; }
.pivot-simple th.num, .pivot-simple td.num { width: 90px; text-align: left; padding-left: 18px; }
.memo-line { font-size: 12.5px; line-height: 1.6; margin: 2px 0; color: var(--ink-soft); }
.memo-tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-right: 6px; white-space: nowrap; }
.memo-tag.in { background: var(--green-bg); color: var(--green); }
.memo-tag.out { background: var(--red-bg); color: var(--red); }

/* 제품 관리 - 사이즈 칩 */
.size-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.size-chip { display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 11px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12.5px; font-weight: 700; background: #fff; }
.size-chip .chip-x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 5px; border-radius: 50%; }
.size-chip .chip-x:hover { background: var(--red); color: #fff; }
.size-chip.add { padding: 5px 13px; border-style: dashed; color: var(--accent); border-color: var(--accent); background: none; cursor: pointer; font-weight: 600; }
.size-chip.add:hover { background: var(--accent-soft); }

/* 제품 추가/편집 - 사이즈 체크박스 */
.size-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.size-check { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer; user-select: none; transition: .12s; }
.size-check input { width: auto; margin: 0; cursor: pointer; accent-color: var(--accent); }
.size-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.size-hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* 대시보드 공지 미리보기 (2열) */
.dash-notice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px){ .dash-notice-grid { grid-template-columns: 1fr; } }
.dash-notice { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--bg); }
.dn-title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dn-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.dn-body { color: var(--ink-soft); font-size: 13px; margin-top: 8px; line-height: 1.5; }

/* 공지사항 */
.notice-list { display: flex; flex-direction: column; gap: 14px; }
.notice-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.notice-card.pinned { border-color: var(--accent); background: linear-gradient(0deg, var(--card), var(--accent-soft) 220%); }
.notice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.notice-title { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notice-pin { font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
.notice-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.notice-meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.notice-body { margin-top: 14px; font-size: 14.5px; line-height: 1.7; color: var(--ink-soft); }
.notice-files { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-soft); text-decoration: none; max-width: 260px; }
.file-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.file-chip .fc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-size { color: var(--muted); font-size: 11.5px; flex-shrink: 0; }
.attach-item-wrap { position: relative; }
.attach-item-wrap .chip-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border: none; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; padding: 0; }
.attach-item-wrap .chip-x:hover { background: var(--red); }
.attach-item-wrap .attach-item, .attach-item-wrap > a.file-chip { display: inline-block; }

/* AS 첨부 (사진/영상) */
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attach-item { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); background: var(--surface); }
.attach-item a { display: block; width: 100%; height: 100%; }
.attach-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-vid { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.attach-item .chip-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: none; border-radius: 50%; background: rgba(22,22,40,.7); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; padding: 0; }
.attach-item .chip-x:hover { background: var(--red); }
.attach-badge { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
#as-files { width: 100%; font-size: 13px; }

/* 일괄 입출고 모달 */
.bulk-list { max-height: 48vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.bulk-group-head { font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 4px 4px; position: sticky; top: 0; background: var(--card); }
.bulk-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.bulk-item:last-child { border-bottom: none; }
.bi-label { flex: 1; font-size: 14px; }
.bi-size { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); font-size: 11.5px; color: var(--accent-ink); font-weight: 600; }
.bi-cur { font-size: 12px; color: var(--muted); min-width: 50px; text-align: right; }
.bulk-item input { width: 76px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; text-align: right; background: #fff; font-size: 14px; }
.bulk-item input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bulk-summary { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; margin: 12px 2px; }
