:root {
  --navy: #1f3a5f;
  --navy-2: #2b4c78;
  --accent: #c8913a;
  --bg: #f4f2ee;
  --card: #ffffff;
  --line: #e4e0d8;
  --text: #22252b;
  --muted: #6d7380;
  --ok: #2e7d4f;
  --warn: #b7791f;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- 레이아웃 ---------- */
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.nav {
  background: var(--navy); color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { font-weight: 800; font-size: 17px; padding: 4px 10px 18px; letter-spacing: -.3px; }
.brand small { display: block; font-weight: 500; font-size: 12px; opacity: .65; margin-top: 2px; }
.nav a {
  color: rgba(255,255,255,.82); text-decoration: none; padding: 9px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 10px; font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.15); color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255,255,255,.12); margin: 10px 6px; }
.nav .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.nav .me b { display: block; font-size: 14px; }
.nav .me button { background: none; border: 0; color: rgba(255,255,255,.7); padding: 4px 0; cursor: pointer; margin-right: 10px; }
.nav .me button:hover { color: #fff; text-decoration: underline; }
main { padding: 22px 26px 60px; min-width: 0; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -.4px; }
.page-head .spacer { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

/* ---------- 폼 요소 ---------- */
input[type=text], input[type=number], input[type=password], input[type=date], input[type=search], input[type=tel],
input[type=email], select, textarea {
  border: 1px solid #cfcac0; background: #fff; border-radius: 8px; padding: 8px 10px; min-height: 38px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(43,76,120,.15); }
textarea { resize: vertical; min-height: 64px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 15px; width: 100%; min-width: 0; }
.grid2 > *, .grid3 > * { min-width: 0; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.inline { display: flex; gap: 6px; align-items: stretch; }
.inline > input { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #cfcac0;
  background: #fff; border-radius: 8px; padding: 8px 14px; min-height: 38px; cursor: pointer; font-weight: 600;
  white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { background: #f7f5f1; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e6b8b2; }
.btn.danger:hover { background: #fdf1ef; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #efece6; }

.seg { display: inline-flex; border: 1px solid #cfcac0; border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid #e4e0d8; }
.seg button.on { background: var(--navy); color: #fff; }

/* ---------- 테이블 ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 9px 10px;
  border-bottom: 1px solid var(--line); background: #faf9f6; white-space: nowrap; position: sticky; top: 0;
}
table.t td { padding: 9px 10px; border-bottom: 1px solid #f0ede7; vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #faf8f3; }
table.t tr.dim td { color: #a3a7af; text-decoration: line-through; }
table.t tfoot td { font-weight: 700; background: #faf9f6; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: 12.5px; }
.ellipsis { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef0f4; color: #4a5160; }
.badge.cash { background: #e8f4ec; color: #22663f; }
.badge.card { background: #e8eefa; color: #2a4c8a; }
.badge.transfer { background: #f1ebfa; color: #5b3d8f; }
.badge.credit { background: #fbefe0; color: #8f5814; }
.badge.red { background: #fbe9e7; color: var(--danger); }
.badge.admin { background: #1f3a5f; color: #fff; }

/* ---------- 카드형 지표 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat .foot { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > * { min-width: 0; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 110px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-row .track { background: #f0ede7; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-row .fill { background: var(--navy-2); height: 100%; border-radius: 4px; }
.vbars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.vbars .vb { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 4px; height: 100%; }
.vbars .vb i { display: block; width: 100%; background: var(--navy-2); border-radius: 3px 3px 0 0; min-height: 1px; }
.vbars .vb:hover i { background: var(--accent); }
.vlabels { display: flex; gap: 3px; font-size: 11px; color: var(--muted); }
.vlabels span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; min-width: 4px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.pos-left { padding: 14px; min-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.search-wrap { position: relative; }
.search-wrap input { width: 100%; font-size: 17px; min-height: 48px; padding-left: 14px; }
.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(20,30,50,.14); max-height: 380px; overflow-y: auto;
}
.results .r { padding: 9px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #f3f0ea; }
.results .r:last-child { border-bottom: 0; }
.results .r:hover, .results .r.sel { background: #f3f6fb; }
.results .r .nm { flex: 1; min-width: 0; }
.results .r .nm b { display: block; font-weight: 600; }
.cart { margin-top: 12px; flex: 1; }
.cart td input { width: 100%; min-height: 34px; padding: 4px 8px; text-align: right; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty input { width: 54px !important; text-align: center !important; }
.qty button { width: 30px; height: 32px; border: 1px solid #cfcac0; background: #fff; border-radius: 6px; cursor: pointer; font-weight: 700; }
.x { border: 0; background: none; color: #a0a4ab; font-size: 18px; cursor: pointer; padding: 2px 6px; }
.x:hover { color: var(--danger); }
.pos-right { padding: 16px; position: sticky; top: 16px; }
.pos-right .row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.pos-total { font-size: 30px; font-weight: 800; color: var(--navy); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.paybtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.paybtns button { min-height: 52px; font-size: 16px; font-weight: 700; border: 2px solid #d6d1c6; background: #fff; border-radius: 10px; cursor: pointer; }
.paybtns button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.paybtn-go { width: 100%; min-height: 60px; font-size: 19px; margin-top: 12px; border-radius: 12px; }
.pct { display: flex; gap: 4px; margin-top: 6px; }
.pct button { flex: 1; }
.change { font-size: 20px; font-weight: 800; color: var(--ok); }
.hr { height: 1px; background: var(--line); margin: 10px 0; }

/* ---------- 모달 ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 22, 35, .45); display: flex; align-items: flex-start;
  justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; animation: fade .12s;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal.xwide { max-width: 1100px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: #faf9f6; border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- 토스트 ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #222831; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
  font-weight: 500; max-width: 380px; animation: fade .15s;
}
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* ---------- 로그인 ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #1f3a5f, #2b4c78 60%, #3a5f8f); }
.auth .box { background: #fff; border-radius: 16px; padding: 30px 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth h1 { margin: 0 0 4px; font-size: 22px; }
.auth p { margin: 0 0 20px; color: var(--muted); }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth .btn { min-height: 46px; font-size: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--navy); }

.drop { border: 2px dashed #cfcac0; border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); background: #faf9f6; }
pre.code { background: #f5f3ef; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; overflow-x: auto; margin: 6px 0; }

/* ---------- 반응형 ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .pos-right { position: static; }
  .pos-left { min-height: 0; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; z-index: 50; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; gap: 2px; }
  .brand, .nav .sep { display: none; }
  .nav a { white-space: nowrap; margin: 0; padding: 8px 10px; font-size: 14px; }
  .nav a .ico { display: none; }
  .nav .me { margin: 0 0 0 auto; border: 0; padding: 0 6px; display: flex; align-items: center; white-space: nowrap; }
  .nav .me b, .nav .me span { display: none; }
  main { padding: 14px 12px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .bar-row { grid-template-columns: 70px 1fr 90px; }
  .hide-m { display: none; }
}
@media print { .nav, #toasts { display: none; } }
