/* 모두의 장부 관리자 사이트 — PC 우선 관리 콘솔
   왼쪽 메뉴 · 상단 지점/기간 필터 · 데이터 표(검색·필터·정렬·페이지·선택 일괄 작업) · 오른쪽 상세 패널
   표 설계는 IBM Carbon Data Table / Shopify Admin Index Table 을 참고했다 */
:root {
  --bg: #f4f4f4; --surface: #ffffff; --surface-2: #f8f9fa; --line: #e0e0e0; --line-strong: #c6c6c6;
  --text: #161616; --muted: #6f6f6f; --brand: #0f62fe; --brand-weak: #edf5ff; --danger: #da1e28; --danger-weak: #fff1f1;
  --ok: #198038; --ok-weak: #defbe6; --warn: #8e6a00; --warn-weak: #fcf4d6; --in: #0f766e; --out: #b91c1c;
  --side-w: 232px; --top-h: 56px; --drawer-w: min(560px, 46vw); --radius: 6px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .12);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616; --surface: #1f1f1f; --surface-2: #262626; --line: #393939; --line-strong: #525252;
    --text: #f4f4f4; --muted: #a8a8a8; --brand: #4589ff; --brand-weak: #0f2a5c; --danger: #ff8389; --danger-weak: #3d1a1c;
    --ok: #42be65; --ok-weak: #0e3b1f; --warn: #f1c21b; --warn-weak: #3b3007; --in: #2dd4bf; --out: #f87171;
    --shadow: 0 2px 12px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.amt.out { color: var(--out); } .amt.in { color: var(--in); }
[hidden] { display: none !important; }

/* ---------- 레이아웃 ---------- */
#shell { display: grid; grid-template-columns: var(--side-w) 1fr; grid-template-rows: var(--top-h) 1fr; height: 100vh; }
#side { grid-row: 1 / 3; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--line); }
.brand img { width: 28px; height: 28px; border-radius: 6px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
#nav { padding: 8px; display: grid; gap: 1px; }
#nav .grp { font-size: 11px; color: var(--muted); padding: 12px 10px 4px; letter-spacing: .02em; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--text); }
#nav a:hover { background: var(--surface-2); text-decoration: none; }
#nav a.on { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
#nav a .cnt { margin-left: auto; font-size: 11px; background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; min-width: 18px; text-align: center; }
.side-foot { margin-top: auto; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.side-foot button { margin-top: 6px; }

#top { display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
#top .title { font-weight: 600; font-size: 15px; white-space: nowrap; }
#gfilter { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: nowrap; }
#gfilter label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
#main { overflow: auto; padding: 20px 24px 40px; min-width: 0; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-h p { margin: 4px 0 0; }

/* ---------- 입력 ---------- */
.inp, select.inp, textarea.inp { height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); min-width: 0; }
textarea.inp { height: auto; padding: 8px 10px; width: 100%; }
.inp:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.btn { height: 32px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field > .inp, .field > select, .field > textarea { color: var(--text); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }

/* 지점 다중 선택 */
.ms { position: relative; }
.ms > button { min-width: 180px; justify-content: space-between; }
.ms-pop { position: absolute; right: 0; top: 36px; z-index: 30; width: 280px; max-height: 360px; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.ms-pop .check { display: flex; padding: 4px 6px; border-radius: 4px; }
.ms-pop .check:hover { background: var(--surface-2); }
.ms-pop .row { display: flex; gap: 6px; padding: 4px 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- 카드·지표 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; text-align: left; cursor: pointer; }
.kpi:hover { border-color: var(--brand); }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12px; color: var(--muted); }
.kpi.warn { border-left: 3px solid var(--warn); }
.kpi.err { border-left: 3px solid var(--danger); }
.delta.up { color: var(--out); } .delta.down { color: var(--in); }
.note { font-size: 12px; color: var(--muted); margin: 8px 0; }
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ok-weak); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.chip.err { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.chip.info { background: var(--brand-weak); color: var(--brand); border-color: transparent; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--out); }
svg.chart { width: 100%; height: 200px; }
svg.chart text { font-size: 10px; fill: var(--muted); }

/* ---------- 데이터 표 ---------- */
.dt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dt-tools { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dt-tools .search { flex: 1 1 220px; max-width: 360px; }
.dt-bulk { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--brand); color: #fff; flex-wrap: wrap; }
.dt-bulk .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.dt-bulk .btn:hover { background: rgba(255,255,255,.12); }
.dt-bulk small { opacity: .85; }
.dt-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .arr { opacity: .35; margin-left: 4px; }
.tbl th.sorted .arr { opacity: 1; color: var(--brand); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.sel { background: var(--brand-weak); }
.tbl td.chk, .tbl th.chk { width: 36px; padding-right: 0; }
.tbl td small { color: var(--muted); }
.tbl .ellipsis { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.dt-foot .pg { display: flex; gap: 4px; align-items: center; }
.dt-empty { padding: 40px; text-align: center; color: var(--muted); }
.dt-sum { display: flex; gap: 18px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.dt-sum b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- 상세 패널·대화상자 ---------- */
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 40;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .18s ease; }
#drawer.open { transform: none; }
#drawer header { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
#drawer header h2 { flex: 1; }
#drawer .body { overflow: auto; padding: 16px 18px; display: grid; gap: 14px; align-content: start; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
pre.msg { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0; font-size: 13px; font-family: inherit; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 60; }
.modal .box { background: var(--surface); border-radius: 8px; width: min(480px, 92vw); padding: 20px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; }
.pair-qr { width: 240px; margin: 0 auto; background: #fff; }
.pair-qr svg { display: block; width: 100%; height: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #262626; color: #fff; padding: 10px 16px; border-radius: 6px; opacity: 0; transition: .2s; z-index: 70; pointer-events: none; max-width: 80vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); }

/* ---------- 검수 (원본 이미지 ↔ 추출값) ---------- */
.review { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr); gap: 16px; align-items: start; }
.review .img { position: sticky; top: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.review .img .stage { overflow: auto; max-height: calc(100vh - 180px); background: var(--surface-2); border-radius: 4px; }
.review .img img { display: block; width: 100%; transform-origin: top left; }
.review .img .zoom { display: flex; gap: 6px; padding: 6px 2px 0; }
.items td input { width: 100%; height: 28px; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; background: var(--surface); }
.items td.num input { text-align: right; }
.conf-low { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- 로그인 ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px; display: grid; gap: 14px; }
#login .brand { border: 0; padding: 0 0 6px; }
#login .err { color: var(--danger); font-size: 13px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

@media (max-width: 1100px) { .review { grid-template-columns: 1fr; } .review .img { position: static; } :root { --drawer-w: 92vw; } }
@media (max-width: 760px) {
  #shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; min-height: 100vh; }
  #side { grid-row: auto; flex-direction: row; overflow-x: auto; }
  #nav { display: flex; padding: 4px; } #nav .grp, .side-foot, .brand small { display: none; }
  #top { flex-wrap: wrap; height: auto; padding: 8px 16px; } #gfilter { flex-wrap: wrap; margin-left: 0; }
  #main { padding: 16px; }
  .grid.two { grid-template-columns: 1fr; }
}
