@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:       #0f0d0b;
  --bg2:      #1a1612;
  --bg3:      #221e19;
  --bg4:      #2a2520;

  --brand:       #d4893a;
  --brand-light: #e8a455;
  --brand-dim:   rgba(212,137,58,0.15);
  --brand-glow:  0 0 20px rgba(212,137,58,0.2);

  --cream:  #f5ead8;
  --cream2: #c8b89a;
  --muted:  #7a6a58;

  --danger:    #e05252;
  --danger-bg: rgba(224,82,82,0.12);
  --success:   #52b86e;
  --success-bg:rgba(82,184,110,0.12);
  --info:      #5290e0;
  --info-bg:   rgba(82,144,224,0.12);

  --border:  rgba(212,137,58,0.12);
  --border2: rgba(212,137,58,0.28);

  --r-sm: 6px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --ease: cubic-bezier(0.4,0,0.2,1);

  --sidebar-w: 240px;
  --topbar-h:  60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans KR', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--cream);
  min-height: 100vh;
  display: flex;
}

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: width 0.25s var(--ease);
  overflow: hidden;
}
.sidebar-logo {
  padding: 24px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo h1 {
  font-size: 1.25rem; font-weight: 800;
  color: var(--brand-light);
  letter-spacing: -0.3px;
}
.sidebar-logo p { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  display: flex; flex-direction: column; gap: 3px;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem; font-weight: 500;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.nav-link:hover { background: var(--bg4); color: var(--cream); }
.nav-link.active {
  background: var(--brand-dim);
  color: var(--brand-light);
  border: 1px solid var(--border2);
}
.nav-link .ni { font-size: 1.05rem; width: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.74rem; color: var(--muted);
  display: flex; flex-direction: column; gap: 8px;
}
.switch-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--cream2);
  font-size: 0.8rem; font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  width: 100%;
}
.switch-btn:hover { border-color: var(--border2); color: var(--cream); }

/* ── 메인 레이아웃 ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ── 상단바 ── */
.topbar {
  height: var(--topbar-h);
  background: rgba(15,13,11,0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 90;
}
.topbar-title { font-size: 1rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-time { font-size: 0.8rem; color: var(--muted); }

/* ── 페이지 바디 ── */
.page { padding: 28px 28px; max-width: 1200px; }

/* ── 통계 그리드 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: all 0.2s var(--ease);
}
.stat-card:hover { border-color: var(--border2); box-shadow: var(--brand-glow); transform: translateY(-2px); }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.si-brand  { background: var(--brand-dim); }
.si-danger { background: var(--danger-bg); }
.si-success{ background: var(--success-bg); }
.si-info   { background: var(--info-bg); }
.stat-label { font-size: 0.76rem; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 1.75rem; font-weight: 900; line-height: 1; }
.sv-brand   { color: var(--brand-light); }
.sv-danger  { color: var(--danger); }
.sv-success { color: var(--success); }

/* ── 카드 ── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── 섹션 헤더 ── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 0.95rem; font-weight: 700; }
.section-badge {
  background: var(--brand-dim); color: var(--brand-light);
  font-size: 0.7rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
}
.section-badge.danger { background: var(--danger-bg); color: var(--danger); }

/* ── 최근 이력 행 ── */
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-badge {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; flex-shrink: 0;
}
.tx-badge.IN  { background: var(--success-bg); color: var(--success); }
.tx-badge.OUT { background: var(--danger-bg);  color: var(--danger); }
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 0.88rem; font-weight: 600; }
.tx-meta { font-size: 0.73rem; color: var(--muted); margin-top: 1px; }
.tx-qty { font-size: 0.9rem; font-weight: 700; }
.tx-qty.IN  { color: var(--success); }
.tx-qty.OUT { color: var(--danger); }

/* ── 테이블 ── */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.74rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg4); }
tbody td { padding: 13px 14px; vertical-align: middle; }

/* ── 재고 바 ── */
.stock-bar {
  height: 5px; background: var(--bg2);
  border-radius: 999px; margin-top: 5px;
  width: 100px; overflow: hidden;
}
.stock-fill { height: 100%; border-radius: 999px; transition: width 0.5s var(--ease); }
.stock-fill.ok  { background: var(--success); }
.stock-fill.low { background: var(--danger); }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--r-md);
  font-size: 0.86rem; font-weight: 600;
  border: none; cursor: pointer;
  transition: all 0.18s var(--ease);
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-light)); color: #fff; }
.btn-primary:hover { opacity: 0.88; box-shadow: var(--brand-glow); }
.btn-secondary { background: var(--bg4); color: var(--cream2); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border2); color: var(--cream); }
.btn-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(224,82,82,0.2); }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(82,184,110,0.2); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }

/* ── 뱃지 ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700;
}
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-success { background: var(--success-bg); color: var(--success); }

/* ── 필터 바 ── */
.filter-bar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filter-chip {
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.filter-chip:hover { border-color: var(--border2); color: var(--cream); }
.filter-chip.active { background: var(--brand-dim); border-color: var(--brand); color: var(--brand-light); }

.search-box { flex: 1; min-width: 180px; position: relative; }
.search-box input {
  width: 100%; padding: 8px 14px 8px 34px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 999px; color: var(--cream);
  font-size: 0.85rem; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--brand); }
.search-box input::placeholder { color: var(--muted); }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; }

/* ── 페이지 헤더 ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.3rem; font-weight: 800; }
.page-subtitle { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

/* ── 부족 재고 아이템 행 ── */
.low-item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.low-item-row:last-child { border-bottom: none; }
.low-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.low-info { flex: 1; min-width: 0; }
.low-name { font-size: 0.88rem; font-weight: 600; }
.low-qty { text-align: right; flex-shrink: 0; }
.low-qty-val { font-size: 1rem; font-weight: 700; color: var(--danger); }
.low-qty-sub { font-size: 0.7rem; color: var(--muted); }

/* ── 모달 (PC — 중앙 팝업) ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(5px);
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity 0.22s var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.28s var(--ease);
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-size: 1.05rem; font-weight: 800; }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: none; background: var(--bg2); color: var(--muted);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--cream); background: var(--bg4); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.form-control {
  width: 100%; padding: 11px 14px;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--r-md); color: var(--cream);
  font-size: 0.9rem; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(212,137,58,0.12); }
.form-control::placeholder { color: var(--muted); }
.form-control option { background: var(--bg3); }
.form-hint { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── 입출고 타입 선택 ── */
.type-tabs { display: flex; gap: 10px; margin-bottom: 18px; }
.type-tab {
  flex: 1; padding: 12px;
  border-radius: var(--r-md); border: 2px solid var(--border);
  background: transparent; color: var(--muted);
  font-size: 0.9rem; font-weight: 700;
  cursor: pointer; transition: all 0.18s; font-family: inherit; text-align: center;
}
.type-tab.in.active  { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.type-tab.out.active { border-color: var(--danger);  background: var(--danger-bg);  color: var(--danger); }

/* ── 수량 피커 ── */
.qty-picker { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.qty-btn {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--cream); font-size: 1.3rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.qty-btn:hover { background: var(--bg4); border-color: var(--border2); }
.qty-input { flex: 1; text-align: center; font-size: 1.1rem; font-weight: 700; }

/* ── 토스트 ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r-md); padding: 13px 16px;
  font-size: 0.87rem; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); min-width: 220px;
  animation: slideIn 0.28s var(--ease);
}
.toast.success { border-color: rgba(82,184,110,0.4); }
.toast.error   { border-color: rgba(224,82,82,0.4); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── 스피너 ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
