/* ============ base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e6e8eb;
  --line-strong: #d5d8dc;
  --text: #1b1d1f;
  --text-sub: #6b7280;
  --text-mut: #9aa0a6;
  --primary: #2f6df6;
  --primary-weak: #eef3ff;
  --primary-press: #1f57d6;
  --topbar-bg: #1b1d1f;
  --danger: #e5484d;
  --warn: #e79a2b;
  --ok: #1f9d55;
  --radius: 8px;
  --sidebar-w: 232px;
  --topbar-h: 56px;
  font-synthesis-weight: none;
}
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
ul { list-style: none; }
input { font: inherit; }

/* ============ layout ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--panel); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ============ sidebar ============ */
.brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: 8px;
  padding: 0 16px; flex-shrink: 0;
  background: var(--topbar-bg); color: #fff;
}
.brand .logo {
  width: 26px; height: 26px; border-radius: 6px; background: #fff;
  color: #111; font-weight: 700; font-size: 11px;
  display: flex; align-items: center; justify-content: center; letter-spacing: -.5px;
}
.brand .co { font-weight: 600; font-size: 13px; }
.brand .collapse { margin-left: auto; color: rgba(255,255,255,.55); }

.nav { padding: 8px 0 24px; flex: 1; }
.nav-group { margin-top: 10px; }
.nav-group > .cap {
  padding: 8px 18px 4px; font-size: 11px; color: var(--text-mut); font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 18px; color: var(--text-sub); font-size: 13px; border-radius: 0;
}
.nav-item .ic { width: 16px; text-align: center; opacity: .7; font-size: 13px; }
.nav-item:hover { background: #f7f8f9; }
.nav-item.active { color: var(--primary); font-weight: 600; background: var(--primary-weak); box-shadow: inset 2px 0 0 var(--primary); }
.nav-item.disabled { opacity: .55; pointer-events: none; }

/* ============ topbar ============ */
.topbar {
  height: var(--topbar-h); flex-shrink: 0; background: var(--topbar-bg); color: #fff;
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 15px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .t-ic { color: rgba(255,255,255,.7); font-size: 14px; padding: 6px; }
.topbar .lang { color: rgba(255,255,255,.8); font-size: 12px; }
.topbar .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg,#5b8def,#8f6ef0); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}

/* ============ content ============ */
.content { padding: 20px 28px 60px; flex: 1; }
.tabs {
  display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.tabs a {
  padding: 11px 2px; font-size: 13px; font-weight: 600; color: var(--text-mut);
}
.tabs a.active { color: var(--text); font-weight: 700; }

.subtabs {
  display: flex; align-items: center; gap: 18px;
  background: #f6f7f8; border-bottom: 1px solid var(--line);
  margin: -16px -28px 16px; padding: 8px 28px;
}
.subtabs > button {
  font-size: 15px; font-weight: 600; color: var(--text-mut); padding: 2px 0;
}
.subtabs > button.active { color: var(--text); font-weight: 700; }
.subtabs .sub-actions { margin-left: auto; display: flex; gap: 8px; }

/* ============ toolbar ============ */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
}
.toolbar .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  height: 32px; padding: 0 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--panel); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap;
}
.btn:hover { background: #f7f8f9; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-press); }
.btn.primary:disabled { background: #c7d3ea; border-color: #c7d3ea; color: #fff; cursor: not-allowed; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.icon-only { width: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn.icon-only svg { width: 15px; height: 15px; }
.btn.icon-only.corner { position: absolute; top: 16px; right: 16px; border-color: transparent; }
.btn.icon-only.corner:hover { background: #f0f1f3; border-color: var(--line-strong); }
.btn .chev { font-size: 10px; color: var(--text-mut); }
.btn.primary .chev { color: #dbe6ff; }

.filter-btn {
  height: 32px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--text-sub);
}
.filter-btn.set { color: var(--text); border-color: var(--primary); background: var(--primary-weak); }
.filter-btn:hover { background: #f7f8f9; }

.filter-btn b { color: var(--primary); margin-left: 2px; }
.filter-btn.set { color: var(--text); border-color: var(--primary); background: var(--primary-weak); }

/* ============ applied filter chips ============ */
.filterbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; align-items: center; }
.filterbar .fchip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px;
  background: var(--primary-weak); color: var(--primary); border-radius: 6px; font-size: 11.5px;
}
.filterbar .fchip button { color: var(--primary); font-size: 11px; opacity: .65; padding: 2px 4px; }
.filterbar .fchip button:hover { opacity: 1; }
.filterbar .fclear { height: 26px; padding: 0 8px; font-size: 11.5px; color: var(--text-sub); }
.filterbar .fclear:hover { color: var(--text); }

/* ============ filter modal ============ */
.fmodal { display: flex; height: 420px; }
.fmodal .groups { width: 186px; flex-shrink: 0; border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 0; }
.fmodal .groups button { display: block; width: 100%; text-align: left; padding: 9px 14px; border-left: 2px solid transparent; }
.fmodal .groups button:hover { background: #f7f8f9; }
.fmodal .groups button.active { background: var(--primary-weak); border-left-color: var(--primary); }
.fmodal .groups .g-name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.fmodal .groups .g-name .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.fmodal .groups .g-sum { font-size: 11px; color: var(--text-mut); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmodal .opts { flex: 1; overflow-y: auto; padding: 12px 16px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 7px 2px; font-size: 12.5px; cursor: pointer; border-radius: 4px; }
.opt:hover { background: #f7f8f9; }
.opt.child { padding-left: 22px; }
.opt input { width: 15px; height: 15px; accent-color: var(--primary); flex-shrink: 0; }
.foot .sum { margin-right: auto; font-size: 12px; color: var(--text-sub); align-self: center; }

/* ============ dropdown ============ */
.dropdown-menu {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; z-index: 150;
}
.dropdown-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; font-size: 12.5px;
  border-radius: 6px; white-space: nowrap;
}
.dropdown-menu button:hover { background: var(--primary-weak); color: var(--primary); }
.dropdown-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* ============ stats ============ */
.statwrap { margin-bottom: 18px; }
.statwrap h5 { font-size: 11px; color: var(--text-mut); font-weight: 700; letter-spacing: .02em; margin: 12px 0 6px; }
.statwrap h5:first-child { margin-top: 0; }
.statgrid { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 116px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); padding: 10px 12px;
}
.stat.click { cursor: pointer; }
.stat.click:hover { border-color: var(--line-strong); }
.stat.active { border-color: var(--primary); background: var(--primary-weak); box-shadow: inset 0 0 0 1px var(--primary); }
.stat .k { font-size: 11.5px; color: var(--text-sub); }
.stat .v { font-size: 19px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 11px; font-weight: 500; color: var(--text-mut); margin-left: 3px; }
.stat.alert .v { color: var(--danger); }
.stat.warn .v { color: var(--warn); }

/* ============ count / search rows ============ */
.countrow { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.countrow .total { font-size: 13px; font-weight: 600; }
.countrow .total b { color: var(--primary); }
.searchrow { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.searchrow .right { margin-left: auto; display: flex; gap: 8px; }
.searchbox { position: relative; display: inline-flex; }
.searchbox .search { width: 260px; transition: width .15s ease; }
.searchbox .search.expanded { width: 380px; }
.searchbox.has-term .search { padding-right: 30px; }
.search-clear {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%; display: none;
  align-items: center; justify-content: center; font-size: 9px; line-height: 1;
  color: var(--text-sub); background: #e6e8eb;
}
.search-clear:hover { color: var(--text); background: #d8dbdf; }
/* 공통 패턴: 검색어가 있고 + 필드를 호버(또는 포커스)할 때만 노출 */
.searchbox.has-term:hover .search-clear,
.searchbox.has-term:focus-within .search-clear { display: flex; }
.search {
  height: 32px; width: 220px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0 10px 0 30px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 9px center;
}

/* ============ table ============ */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 880px; }
tbody td:nth-child(3), thead th:nth-child(3) { white-space: nowrap; }
thead th {
  text-align: left; padding: 10px 12px; background: #fafbfc; color: var(--text-sub);
  font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable:hover { background: var(--primary-weak); cursor: pointer; }
td .muted { color: var(--text-mut); }
td .sub { color: var(--text-mut); font-size: 11px; margin-top: 2px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hi { width: 12px; height: 12px; display: inline-block; vertical-align: -1px; fill: none;
  stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  opacity: .5; margin-right: 3px; }
.hcnt { color: var(--text-sub); margin-left: 2px; font-variant-numeric: tabular-nums; }

/* product cell: thumbnail + name + memo flag */
.prodcell { display: flex; align-items: center; gap: 7px; }
.thumb {
  width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.thumb svg { width: 11px; height: 11px; }
.thumb.empty { background: #eef0f2; color: var(--text-mut); }
.prodcell .pname { min-width: 0; }
th.c, td.c { text-align: center; width: 52px; }
.memo-flag { display: inline-flex; color: var(--text-mut); cursor: default; }
.memo-flag svg { width: 15px; height: 15px; }
.memo-flag:hover { color: var(--text-sub); }

/* ============ chips / badges ============ */
.chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px;
  background: #f0f1f3; color: var(--text-sub); font-size: 11px; margin: 1px 3px 1px 0;
}
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px;
  background: #eef3ff; color: var(--primary); font-size: 11px; margin: 1px 3px 1px 0;
}
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.badge.stock { background: #eef0f2; color: #5b6067; }
.badge.assigned { background: #e7f0ff; color: #2f6df6; }
.badge.repair { background: #fff1e0; color: #c9791b; }
.badge.lost { background: #fdecec; color: #d23b40; }
.badge.disposed { background: #eceef0; color: #9aa0a6; text-decoration: line-through; }
.badge.clickable { cursor: pointer; gap: 3px; }
.badge.clickable:hover { filter: brightness(0.96); }
.badge.clickable .bchev { font-size: 9px; opacity: .7; }
.badge.exp-valid { background: #eaf7ef; color: #1f9d55; }
.badge.exp-soon { background: #fff4e0; color: #c9791b; }
.badge.exp-over { background: #fdecec; color: #d23b40; }
.type-pill { font-size: 11px; color: var(--text-sub); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; }

/* ============ 분류 관리 ============ */
.cat-layout { display: flex; gap: 24px; align-items: flex-start; }
.cat-tree {
  width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 16px;
}
.cat-tree-head { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.cat-tree-head-label { font-size: 12.5px; font-weight: 700; }
.cat-tree-head [data-manage] { margin-left: auto; }
.cat-tree-group { display: flex; flex-direction: column; gap: 1px; }
.cat-tree-label {
  display: flex; align-items: center; gap: 5px; width: 100%; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-mut); letter-spacing: .02em; padding: 4px 8px; margin-bottom: 1px;
}
.cat-tree-label:hover { color: var(--text-sub); }
.cat-tree-chevron { font-size: 9px; width: 10px; flex-shrink: 0; }
.cat-tree-item {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 7px 8px; border-radius: 6px; font-size: 12.5px; color: var(--text-sub); text-align: left;
}
.cat-tree-item:hover { background: #f7f8f9; }
.cat-tree-item.active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.cat-tree-count { color: var(--text-mut); font-size: 11px; font-variant-numeric: tabular-nums; }
.cat-tree-item.active .cat-tree-count { color: var(--primary); }
.cat-tree-empty { padding: 4px 8px; font-size: 12px; color: var(--text-mut); }

.cat-detail { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 20px; }
.cat-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cat-detail-head h3 { font-size: 17px; font-weight: 700; }
.cat-detail-acts { display: flex; gap: 6px; flex-shrink: 0; }
/* .kv2와 특이성을 똑같이(단일 클래스) 두면 소스 순서상 .kv2에 밀리므로 두 클래스를 묶어 특이성을 더 높여둠 */
.kv2.cat-detail-kv { grid-template-columns: 110px 1fr 110px 1fr; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.cat-usage { display: flex; align-items: center; gap: 32px; margin-top: 14px; }
.cat-usage .k { width: 110px; flex-shrink: 0; color: var(--text-mut); font-size: 12px; }
.cat-usage-bullets { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; }
.usebullet {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; flex-shrink: 0;
  border: 1px solid var(--line-strong); border-radius: 6px; font-size: 11px; color: var(--text-mut); white-space: nowrap;
}
.usebullet.on { border-color: var(--primary); color: var(--primary); }
.cat-asset-head { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); margin-bottom: 10px; }
.cat-asset-head h4 { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cat-prod-row td:first-child { display: flex; align-items: center; gap: 6px; }
.cat-prod-chevron { display: inline-block; width: 10px; color: var(--text-mut); font-size: 10px; }
.cat-prod-sub td { padding: 10px 12px 14px 36px; background: #fafbfc; }
.cat-unit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 8px; border-radius: 6px; font-size: 12px; cursor: pointer; max-width: 320px;
}
.cat-unit-row:hover { background: #eef0f2; }
.cat-unit-no { color: var(--text-sub); font-variant-numeric: tabular-nums; }

/* 분류 관리 모달 — 구조 편집 전용(추가·이름변경·순서·삭제·대분류이동만. 유형/권한/필드노출은 별도 폼) */
.cat-manage-modal { display: flex; flex-direction: column; max-height: 88vh; }
/* 위 body/add-group는 display:flex를 직접 지정해서 [hidden]의 기본 display:none을 덮어써버림 — 모드 전환 시 확실히 숨겨지도록 재지정 */
.cat-manage-modal [hidden] { display: none !important; }
.cat-manage-modal .cat-manage-head { display: flex; align-items: center; gap: 4px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.cat-manage-modal .cat-manage-head h3 { padding: 0; border: 0; }
.cat-manage-modal .body { flex: 1; overflow-y: auto; min-height: 0; }
.cat-manage-modal .cat-manage-create { flex: 1; overflow-y: auto; min-height: 0; padding: 18px 20px; }
.cat-manage-create-group {
  height: 34px; display: flex; align-items: center; padding: 0 10px;
  background: #f6f7f8; border-radius: var(--radius); font-size: 12.5px; color: var(--text-mut);
}
.cat-manage-create select {
  width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 10px; background: var(--panel); font-size: 12.5px;
}
button.usebullet { background: var(--panel); font: inherit; cursor: pointer; }
.cat-manage-add-group { display: flex; gap: 8px; padding: 14px 20px 0; flex-shrink: 0; }
.cat-manage-add-group input { flex: 1; }
.cat-manage-input {
  height: 32px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0 10px; background: var(--panel); font-size: 12.5px;
}
.cat-manage-add-group .btn { flex-shrink: 0; }
.cat-manage-body { display: flex; flex-direction: column; }
.cat-manage-group { margin-bottom: 16px; }
.cat-manage-row { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; }
.cat-manage-row.dragging { opacity: .35; }
.cat-manage-row.drag-over-top { box-shadow: inset 0 2px 0 var(--primary); }
.cat-manage-row.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--primary); }
.cat-manage-group-row { background: #f6f7f8; margin-bottom: 3px; }
.cat-manage-sub-row { padding-left: 30px; }
.cat-manage-sub-row:hover { background: #f7f8f9; }
.cat-manage-handle {
  display: flex; align-items: center; justify-content: center; width: 20px; height: 26px;
  flex-shrink: 0; color: var(--text-mut); cursor: grab; position: relative;
}
.cat-manage-handle svg { width: 14px; height: 14px; }
.cat-manage-handle:active { cursor: grabbing; }
/* 드래그 중(.dragging)에는 뜨지 않게 — 클릭해서 잡고 있는 상태에선 안내가 필요 없고 드래그 시각과도 겹치므로 */
.cat-manage-row:not(.dragging) .cat-manage-handle[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; top: 100%; left: 0; margin-top: 6px;
  background: #1b1d1f; color: #fff; font-size: 11px; padding: 4px 8px;
  border-radius: 6px; white-space: nowrap; z-index: 20;
}
.cat-manage-name-input {
  flex: 1; min-width: 0; height: 28px; font-size: 12.5px; color: var(--text);
  border: 1px solid transparent; border-radius: 6px; padding: 0 6px; background: transparent;
}
.cat-manage-name-input:hover { border-color: var(--line-strong); }
.cat-manage-name-input:focus { border-color: var(--primary); background: var(--panel); }
.cat-manage-group-row .cat-manage-name-input { font-weight: 700; }
.cat-manage-row-acts { display: flex; gap: 1px; flex-shrink: 0; }
.cat-manage-icon {
  width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--text-mut);
}
.cat-manage-icon svg { width: 14px; height: 14px; }
.cat-manage-icon:hover:not(.is-disabled) { background: #eef0f2; color: var(--text); }
.cat-manage-icon.is-disabled { opacity: .3; cursor: not-allowed; }
/* 네이티브 title 툴팁이 안 뜨는 환경이 있어 자산 상세 이전/다음 버튼과 동일한 방식(data-tip + ::after)으로 직접 그림 */
.cat-manage-icon[data-tip] { position: relative; }
.cat-manage-icon[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  background: #1b1d1f; color: #fff; font-size: 11px; padding: 4px 8px;
  border-radius: 6px; white-space: nowrap; z-index: 20;
}
.cat-manage-subs { display: flex; flex-direction: column; gap: 1px; }
.cat-manage-add-sub { margin: 6px 0 0 30px; align-self: flex-start; }

/* ============ pagination ============ */
.pager { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px 0 4px; position: relative; }
.pager button { width: 28px; height: 28px; border-radius: 6px; color: var(--text-sub); }
.pager button:hover { background: #eef0f2; }
.pager button.active { background: var(--text); color: #fff; }
.pager .pagesize { position: absolute; right: 0; }
.pager .pagesize select { height: 28px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 6px; }

/* ============ modal ============ */
.modal-back {
  position: fixed; inset: 0; background: rgba(17,19,21,.42); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal {
  background: var(--panel); border-radius: 12px; width: 480px; max-width: 100%;
  max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal.lg { width: 620px; }
.modal h3 { padding: 18px 20px; font-size: 15px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 18px 20px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
/* QR 라벨 — 공용 QR 팝오버 컴포넌트와 동일하게 dim 없는 앵커형 팝오버(openQrPopover) */
.qr-popover {
  position: fixed; width: 320px; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 16px; z-index: 200;
}
.qr-popover-body { display: flex; gap: 16px; align-items: center; }
.qr-popover-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
/* QR 썸네일 — 호버 시 "라벨 미리보기" 오버레이, 클릭하면 실제 라벨 구성 확대(openLabelPreview) */
.qr-thumb {
  position: relative; width: 96px; height: 96px; flex-shrink: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer;
}
.qr-thumb-hover {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(17,19,21,.6); color: #fff; font-size: 11.5px; font-weight: 600;
  opacity: 0; transition: opacity .15s;
}
.qr-thumb:hover .qr-thumb-hover { opacity: 1; }
/* 실제 라벨(다운로드 이미지) 구성 미리보기 — 타이틀/푸터 없는 가벼운 라이트박스(openLabelPreview) */
.label-pop { position: relative; background: var(--panel); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.label-pop-close {
  position: absolute; top: -12px; right: -12px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.15);
  display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 12px;
}
.label-pop-close:hover { background: #f0f1f3; color: var(--text); }
.label-sheet {
  width: 200px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  border: 1px dashed var(--line-strong); border-radius: 10px; padding: 24px 16px;
}
.label-qr svg { width: 140px; height: 140px; }
.label-text { text-align: center; }
.label-product { font-size: 13px; font-weight: 700; }
.label-no { font-size: 11.5px; color: var(--text-sub); margin-top: 3px; }
.label-cat { font-size: 11px; color: var(--text-mut); margin-top: 5px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 5px; font-weight: 600; }
.field .req { color: var(--danger); margin-left: 2px; }
.field input[type=text], .field input[type=date], .field input[type=number], .field select, .field textarea {
  width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 10px; background: var(--panel);
}
.field textarea { height: 66px; padding: 8px 10px; resize: vertical; }
.hint { font-size: 11px; color: var(--text-mut); margin-top: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { padding: 7px 14px; font-size: 12.5px; color: var(--text-sub); }
.seg button.active { background: var(--primary); color: #fff; }

/* ============ detail page ============ */
.detail-topbar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 -28px 16px; padding: 4px 22px;
}
.backbtn {
  width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; font-size: 17px; color: var(--text); line-height: 1;
}
.backbtn:hover { background: #eceef0; }
.navbtns { display: flex; gap: 4px; margin-bottom: 14px; }
.navbtns a {
  position: relative; width: 26px; height: 26px; border: 1px solid var(--line-strong); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-sub);
}
.navbtns a:hover { background: #f0f1f3; color: var(--text); }
.navbtns a[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: 100%; left: 0; margin-top: 6px;
  background: #1b1d1f; color: #fff; font-size: 11px; padding: 4px 8px;
  border-radius: 6px; white-space: nowrap; z-index: 10;
}

.dcard {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  padding: 18px 20px; margin-bottom: 14px;
}
.dgrid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; align-items: stretch; }
.dgrid .dcard { margin-bottom: 0; }

/* 상세 페이지: 좌우 컬럼 높이를 맞추고, 넘치면 각자 독립 스크롤 */
.content.detail-split { flex: none; height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; padding-bottom: 0; overflow: hidden; }
.detail-split .detail-topbar { flex-shrink: 0; }
.detail-split .dgrid { flex: 1; min-height: 0; }
.detail-split .dgrid > .dcard { height: 100%; overflow-y: auto; }

@media (max-width: 860px) {
  .dgrid { grid-template-columns: 1fr; }
  .content.detail-split { height: auto; overflow: visible; display: block; }
  .detail-split .dgrid { flex: none; }
  .detail-split .dgrid > .dcard { height: auto; overflow: visible; }
}

/* 분류 관리: 좌우 컬럼 높이를 맞추고, 넘치면 각자 독립 스크롤 */
.content.cat-split { flex: none; height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; padding-bottom: 0; overflow: hidden; }
.cat-split .tabs { flex-shrink: 0; }
.cat-split .cat-layout { flex: 1; min-height: 0; }
.cat-split .cat-layout > .cat-tree, .cat-split .cat-layout > .cat-detail { height: 100%; overflow-y: auto; }

@media (max-width: 860px) {
  .cat-layout { flex-direction: column; }
  .content.cat-split { height: auto; overflow: visible; display: block; }
  .cat-split .cat-layout { flex: none; }
  .cat-split .cat-layout > .cat-tree, .cat-split .cat-layout > .cat-detail { height: auto; overflow: visible; }
}
/* min-height: 이력 탭에서 우측 액션 버튼(hactions)이 hidden 처리될 때 행 높이가 줄어 탭 전환마다 덜컹거리는 것 방지 — 버튼 높이(.btn.sm = 28px)로 고정 */
.dsection-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 28px; }
.dsection-head h4 { font-size: 13px; font-weight: 700; }
.dsection-head > div:not(.dtabs), .dsection-head .hactions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.dsection-head button[data-act] { margin-left: auto; }
.dsection-head .hactions button { margin-left: 0; }
/* [hidden]은 UA 기본 규칙(낮은 특이성)이라 위 display:flex 규칙에 밀려 무시되기 쉬움 — 명시적으로 이겨줌 */
.dsection-head .hactions[hidden], .stock-toolbar[hidden] { display: none; }

/* header card */
.dhead-top { display: flex; align-items: flex-start; gap: 14px; }
.dhead-id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.dthumb {
  width: 56px; height: 56px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; position: relative;
  padding: 0; border: none; cursor: default;
}
button.dthumb { cursor: pointer; }
button.dthumb:hover { filter: brightness(0.94); }
.dthumb svg { width: 22px; height: 22px; }
.dthumb.empty { background: #eef0f2; color: var(--text-mut); }
.dthumb .tcount {
  position: absolute; right: -5px; bottom: -5px; min-width: 20px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #1b1d1f; color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--panel);
}
.dhead-id h1 { font-size: 19px; font-weight: 700; }
.dhead-sub { display: block; margin-top: 5px; font-size: 12px; color: var(--text-sub); }
.dhead-sub b { color: var(--text); font-weight: 600; }
.ddot { color: var(--line-strong); }
.avatar-sm { width: 18px; height: 18px; border-radius: 50%; background: linear-gradient(135deg,#5b8def,#8f6ef0); color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.dhead-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 4px; }
.dsection { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 16px; }

/* kv grid */
.kv2 { display: grid; grid-template-columns: 110px 1fr; row-gap: 18px; column-gap: 32px; font-size: 12.5px; }
.kv2 > div { display: contents; }
.kv2 .k { color: var(--text-mut); font-size: 12px; padding-top: 1px; }
.kv2 .v { color: var(--text); }

/* list rows in cards */
.dlist { font-size: 12.5px; }
.drow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.drow:first-child { padding-top: 2px; }
.drow:last-child { border-bottom: none; padding-bottom: 2px; }
.drow .who { display: flex; align-items: center; }
.drow .since { margin-left: auto; }
.drow .qty { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; cursor: pointer; border-bottom: 1px dashed var(--line-strong); }
.drow .qty:hover { color: var(--primary); border-color: var(--primary); }
/* 값 수정 팝오버(공용) — 수량 변경·배정일 수정에서 재사용 */
.qty-popover {
  position: fixed; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 10px; z-index: 200;
}
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-step {
  width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--panel); font-size: 14px; line-height: 1; flex-shrink: 0;
}
.qty-step:hover:not(:disabled) { background: #f7f8f9; }
.qty-step:disabled { opacity: .4; }
.qty-stepper input {
  width: 68px; height: 28px; border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 0 8px; font-size: 12.5px; text-align: center; font-variant-numeric: tabular-nums;
}
/* 날짜 입력 공통 컴포넌트 — YYYY.MM.DD 텍스트 마스킹 + 달력 아이콘(네이티브 피커 오버레이) */
.dfield { position: relative; display: inline-block; }
.dfield input[type="text"] {
  width: 150px; height: 28px; border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 0 26px 0 8px; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.dfield-pick {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-mut); pointer-events: none;
}
.dfield-pick svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dfield-pick input[type="date"] { position: absolute; inset: -6px; opacity: 0; cursor: pointer; pointer-events: auto; }
.qty-pop-acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* 보유 현황 — 전체 카운트 + 검색(카테고리 선택) */
.stock-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stock-count { font-size: 12.5px; font-weight: 600; }
.stock-count b { color: var(--primary); }
.stock-search { margin-left: auto; display: flex; }
.stock-search select {
  height: 30px; border: 1px solid var(--line-strong); border-right: none;
  border-radius: var(--radius) 0 0 var(--radius); padding: 0 6px; font-size: 12px;
  background: #fafbfc; color: var(--text-sub);
}
.stock-search input {
  height: 30px; width: 200px; border: 1px solid var(--line-strong);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 0 10px; font-size: 12.5px;
}
.stock-search.solo input { border-radius: var(--radius); }

/* 배정 현황 — 카드형 행 */
.acard-list { display: flex; flex-direction: column; gap: 10px; }
.acard { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.acard-id { display: flex; align-items: center; gap: 10px; }
/* 구성원/근무지 구분 — 프로필 이미지+이름+그룹(공통 컴포넌트) 영역은 건드리지 않고 카드 모서리에 별도 표시 */
.acard-type { position: absolute; top: 12px; right: 14px; }
.acard-type .hi { margin-right: 0; width: 13px; height: 13px; }
.acard-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700;
}
.acard-avatar.ws { background: #eef0f2; color: var(--text-sub); }
.acard-avatar.ws svg { width: 18px; height: 18px; }
.acard-name { font-size: 13px; font-weight: 600; }
.acard-sub { font-size: 11.5px; color: var(--text-mut); margin-top: 2px; }
.acard-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.acard-date { font-size: 12px; color: var(--text-sub); }
.acard-date b { color: var(--text); font-weight: 600; }
/* 배정일 옆 수정 아이콘 — 재배정/반납과 성격이 다른 가벼운 데이터 정정이라 버튼 대신 인라인 아이콘으로 축소 */
.icon-edit {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: -3px;
  width: 18px; height: 18px; margin-left: 2px; border-radius: 4px; color: var(--text-mut); opacity: .7;
}
.icon-edit:hover { background: #f0f1f3; color: var(--text-sub); opacity: 1; }
.icon-edit svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.acard-actions { display: flex; gap: 6px; }

.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos .ph { width: 60px; height: 60px; border-radius: 8px; background: #eef0f2; display: flex; align-items: center; justify-content: center; color: var(--text-mut); font-size: 11px; }
.qrbox { display: flex; gap: 14px; align-items: center; }

/* card tabs + timeline */
.dtabs { display: flex; gap: 16px; }
.dtabs button { font-size: 13px; font-weight: 700; color: var(--text-mut); padding: 2px 0; display: flex; align-items: center; gap: 6px; }
.dtabs button.active { color: var(--text); }
.dtimeline { display: flex; flex-direction: column; gap: 10px; }
.hcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.hcard-head { display: flex; align-items: center; gap: 6px; }
.hcard-avatar {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700;
}
.hcard-who { font-size: 11.5px; font-weight: 600; color: var(--text-sub); }
.hcard-time { font-size: 11px; color: var(--text-mut); }
.hcard-time::after { content: " ·"; }
.hcard-script { margin-top: 8px; font-size: 13px; font-weight: 600; }
.hcard-diff {
  margin-top: 8px; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
.hcard-row { display: flex; align-items: center; gap: 8px; }
.hcard-tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 10px; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.hcard-tag.old { background: #eef0f2; color: var(--text-sub); }
.hcard-tag.new { background: #1b1d1f; color: #fff; }
.hcard-val { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.hcard-val .hi { margin-right: 0; }
.hval-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 16px; height: 16px; border-radius: 50%;
  color: #fff; font-size: 9px; font-weight: 700;
}

/* ============ 공통 사진 뷰어 ============ */
.viewer-back { background: rgba(12,13,14,.92); padding: 0; }
.viewer {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.v-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
  transition: opacity .25s, transform .25s;
}
.viewer.bar-hidden .v-bar { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.v-bar-l { display: flex; align-items: center; gap: 6px; }
.v-bar-c { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.v-bar-r { margin-left: auto; display: flex; gap: 4px; }
.v-count { color: #fff; font-size: 12.5px; font-variant-numeric: tabular-nums; margin-right: 6px; }
.v-ib {
  width: 32px; height: 32px; border-radius: 7px; color: rgba(255,255,255,.85); font-size: 15px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.v-ib:hover { background: rgba(255,255,255,.14); color: #fff; }
.v-ib.on { background: rgba(255,255,255,.2); color: #fff; }
.v-ib:disabled { opacity: .28; pointer-events: none; }
.v-ib[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 4px; background: rgba(0,0,0,.8); color: #fff; font-size: 11px; padding: 3px 7px;
  border-radius: 5px; white-space: nowrap;
}
.v-info {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 3;
  width: 340px; max-width: 80%; background: rgba(40,41,43,.96); color: #fff;
  border-radius: 12px; padding: 14px 16px;
}
.v-info-badge { display: inline-block; background: rgba(255,255,255,.16); font-size: 10.5px; padding: 2px 7px; border-radius: 5px; margin-bottom: 8px; }
.v-info-t { font-size: 14px; font-weight: 700; }
.v-info-sub { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 2px; }
.v-info-sub .muted { color: rgba(255,255,255,.4); }
.v-info-date { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 10px; }
.v-info-by { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 6px; }

.v-stage { display: flex; align-items: center; justify-content: center; width: 100%; flex: 1; min-height: 0; padding: 64px 16px 24px; }
.v-img-wrap { flex: 1; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.v-img { width: min(80vw, 940px); height: min(74vh, 700px); border-radius: 6px; background: #ccc; transition: transform .18s; }
.dropdown-menu button.danger { color: var(--danger); }

.notice { background: #fff8e6; border: 1px solid #f2e2b6; color: #8a6d1d; padding: 8px 12px; border-radius: var(--radius); font-size: 12px; margin-bottom: 14px; }
