/* ============================================================
   유니폼스토리 — 플랫폼 관리자(A) UI 공통 스타일
   밀도: dashboard(8/10) · 스티치/케어라벨 모티프 유지
   ============================================================ */
:root {
  --ink: #111726;
  --ink-2: #4a5166;
  --ink-3: #7b8296;
  --primary: #2740b0;
  --primary-deep: #1d2f86;
  --primary-soft: #eef1fc;
  --stitch: #e8930c;
  --stitch-bright: #ffb020;
  --navy: #0c1a30;
  --navy-2: #14294a;
  --paper: #f4f5f8;
  --card: #ffffff;
  --line: #e4e7ee;
  --line-soft: #eef0f5;

  /* 상태 색 — 태그 상태머신 */
  --st-registered: #64748b;
  --st-assigned: #7c3aed;
  --st-inuse: #2740b0;
  --st-pickup: #b45309;
  --st-factoryin: #0369a1;
  --st-washing: #0e7490;
  --st-washed: #0f766e;
  --st-shipped: #4f46e5;
  --st-delivered: #15803d;
  --st-lost: #dc2626;
  --st-damaged: #be123c;
  --st-retired: #6b7280;

  /* 차트 카테고리 팔레트 (검증 통과) */
  --ch-1: #4a5fd5;
  --ch-2: #0d9488;
  --ch-3: #d97706;
  --ch-4: #8b5cf6;

  --violet: #7c5cff;
  --grad-cta: linear-gradient(120deg, #4053e8, #7c5cff);
  --grad-brand: linear-gradient(120deg, #4a5fd5 0%, #7c5cff 55%, #22d3ee 130%);

  --font-display: "IBM Plex Sans KR", "Pretendard Variable", sans-serif;
  --font-body: "Pretendard Variable", "IBM Plex Sans KR", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 23, 38, 0.04), 0 4px 16px rgba(17, 23, 38, 0.05);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
svg { display: block; }

:focus-visible { outline: 3px solid rgba(39, 64, 176, 0.4); outline-offset: 2px; }

/* ---------- 앱 셸 ---------- */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--navy);
  color: #b9c6dd;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid var(--navy-2);
}
.sidebar-brand .mark { width: 26px; height: 26px; flex-shrink: 0; }
.sidebar-brand .sub { display: block; font-size: 10.5px; font-weight: 500; color: #7a8db1; letter-spacing: 0.05em; }

.side-group { padding: 14px 12px 4px; }
.side-group-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; color: #5f7099; padding: 0 10px 6px; text-transform: uppercase; }
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 1px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.side-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.side-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-item.active {
  background: linear-gradient(100deg, rgba(74, 95, 213, 0.4), rgba(124, 92, 255, 0.22));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--stitch), 0 4px 16px rgba(64, 83, 232, 0.28);
}
.side-item.soon { color: #5f7099; cursor: default; }
.side-item.soon:hover { background: transparent; color: #5f7099; }
.side-item.soon .tag-soon { margin-left: auto; font-size: 10px; background: var(--navy-2); color: #7a8db1; border-radius: 4px; padding: 1px 6px; }

.sidebar-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--navy-2); font-size: 12px; color: #7a8db1; }
.sidebar-foot a { color: #b9c6dd; }
.sidebar-foot a:hover { color: #fff; }

/* ---------- 메인 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.topbar .crumb { font-size: 12px; color: var(--ink-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  width: 240px;
  color: var(--ink-3);
}
.search svg { width: 15px; height: 15px; flex-shrink: 0; }
.search input { border: 0; background: transparent; outline: none; font: inherit; width: 100%; color: var(--ink); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--grad-cta);
  box-shadow: 0 3px 10px rgba(64, 83, 232, 0.35);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
}

.content { padding: 24px 28px 48px; display: grid; gap: 18px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-family: var(--font-display); font-size: 14.5px; font-weight: 700; }
.card-head .hint { font-size: 12px; color: var(--ink-3); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.link-more { font-size: 12.5px; font-weight: 600; color: var(--primary); }
.link-more:hover { color: var(--primary-deep); }

/* ---------- KPI 타일 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { position: relative; padding: 16px 18px; overflow: hidden; transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease; }
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--grad-brand);
}
.kpi.warn::before { background: linear-gradient(120deg, #dc2626, #f59e0b); }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(30, 41, 90, 0.12); }
.kpi .kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.kpi .kpi-label svg { width: 15px; height: 15px; color: var(--primary); }
.kpi .kpi-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 6px; }
.kpi .kpi-delta { font-size: 12px; margin-top: 2px; color: var(--ink-3); }
.kpi .kpi-delta .up { color: var(--st-delivered); font-weight: 600; }
.kpi .kpi-delta .down { color: var(--st-lost); font-weight: 600; }
.kpi.warn .kpi-label svg { color: var(--st-lost); }

/* ---------- 순환 파이프라인 위젯 ---------- */
.pipeline { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.pipe-step {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 12px 10px;
  background: var(--card);
}
.pipe-step::after {
  /* 스티치 연결선 */
  content: "";
  position: absolute;
  top: 50%;
  right: -11px;
  width: 12px;
  height: 2px;
  background-image: linear-gradient(90deg, #c2c9da 0 4px, transparent 4px 7px);
  background-size: 7px 2px;
}
.pipe-step:last-child::after { display: none; }
.pipe-step .name { font-size: 12px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.pipe-step .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pipe-step .count { font-family: var(--font-display); font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 5px; }
.pipe-step .pct { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 99px;
  padding: 3px 9px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.registered { color: var(--st-registered); background: rgba(100, 116, 139, 0.1); }
.badge.assigned { color: var(--st-assigned); background: rgba(124, 58, 237, 0.09); }
.badge.inuse { color: var(--st-inuse); background: rgba(39, 64, 176, 0.08); }
.badge.pickup { color: var(--st-pickup); background: rgba(180, 83, 9, 0.1); }
.badge.factoryin { color: var(--st-factoryin); background: rgba(3, 105, 161, 0.09); }
.badge.washing { color: var(--st-washing); background: rgba(14, 116, 144, 0.09); }
.badge.washed { color: var(--st-washed); background: rgba(15, 118, 110, 0.09); }
.badge.shipped { color: var(--st-shipped); background: rgba(79, 70, 229, 0.09); }
.badge.delivered { color: var(--st-delivered); background: rgba(21, 128, 61, 0.09); }
.badge.lost { color: var(--st-lost); background: rgba(220, 38, 38, 0.08); }
.badge.damaged { color: var(--st-damaged); background: rgba(190, 18, 60, 0.08); }
.badge.retired { color: var(--st-retired); background: rgba(107, 114, 128, 0.1); }
.badge.plain::before { display: none; }

/* ---------- 테이블 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8f9fc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.01em; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

/* 사이클 미니 바 */
.cycle-mini { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.cycle-mini .bar { flex: 1; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.cycle-mini .bar span { display: block; height: 100%; background: var(--ch-2); border-radius: 3px; }
.cycle-mini .bar span.high { background: var(--ch-3); }
.cycle-mini .bar span.max { background: var(--st-lost); }
.cycle-mini .val { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }

/* ---------- 필터 바 ---------- */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.filterbar .spacer { flex: 1; }
select.control, input.control {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  min-height: 36px;
}
select.control:hover, input.control:hover { border-color: #c6cde0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--grad-cta);
  color: #fff;
  box-shadow: 0 4px 14px rgba(64, 83, 232, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(64, 83, 232, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.2); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: #c6cde0; }
.btn-sm { min-height: 30px; padding: 0 11px; font-size: 12px; border-radius: 7px; }

/* ---------- 탭 ---------- */
.tabs { display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid var(--line-soft); }
.tab {
  padding: 9px 14px 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
  border: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .cnt { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-left: 5px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 대시보드 그리드 ---------- */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ---------- 차트 ---------- */
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.bar-svg text { font-family: var(--font-body); }
.bar-svg .axis { font-size: 10.5px; fill: var(--ink-3); }
.bar-svg .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.bar-svg .bar-rect { transition: opacity 0.15s ease; cursor: default; }
.bar-svg .bar-rect:hover { opacity: 0.8; }
.bar-svg .val-label { font-size: 10.5px; fill: var(--ink-2); font-weight: 600; }

/* 스택바 (상태 분포) */
.stack-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; }
.stack-bar span { display: block; height: 100%; min-width: 3px; }
.stack-rows { display: grid; gap: 9px; margin-top: 16px; }
.stack-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.stack-row .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.stack-row .lbl { color: var(--ink-2); }
.stack-row .v { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.stack-row .p { width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 11.5px; }

/* ---------- 알림 리스트 ---------- */
.alert-list { display: grid; }
.alert-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line-soft); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .who { min-width: 0; }
.alert-row .qty { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); flex-shrink: 0; }
.shortage {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--st-lost);
  background: rgba(220, 38, 38, 0.08);
  padding: 3px 9px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* ---------- 부서 트리 ---------- */
.tree { padding: 10px; font-size: 13.5px; }
.tree-org { padding: 8px 10px; font-weight: 700; font-family: var(--font-display); font-size: 13px; color: var(--ink-2); }
.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px 7px 22px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  color: var(--ink-2);
  font-weight: 500;
}
.tree-item:hover { background: var(--paper); color: var(--ink); }
.tree-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-item .cnt { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }

/* ---------- 페이지네이션 ---------- */
.pagination { display: flex; align-items: center; gap: 4px; padding: 12px 18px; justify-content: flex-end; }
.pagination .info { margin-right: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.page-btn {
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink-2);
}
.page-btn:hover { border-color: var(--line); }
.page-btn.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 요약 스트립 ---------- */
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.summary-strip .kpi .kpi-value { font-size: 24px; }

/* ---------- 반응형 ---------- */
@media (max-width: 1200px) {
  .kpi-grid, .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: repeat(4, 1fr); }
  .pipe-step:nth-child(4)::after { display: none; }
  .grid-2-1, .grid-1-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .search { display: none; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .pipe-step:nth-child(even)::after { display: none; }
  .kpi-grid, .summary-strip { grid-template-columns: 1fr 1fr; }
}
