/* 재고·주문 관리 예시 — 비탈길 커피 로스터스 */
@font-face { font-family: 'Pretendard Variable'; src: url('/fonts/PretendardVariable.woff2') format('woff2-variations'); font-weight: 45 920; font-display: swap; }

:root {
  --bg: #F4F2ED; --surface: #FFFFFF; --sunk: #EFECE5; --line: #E0DCD2; --line-2: #CFCABE;
  --ink: #1E2421; --ink-2: #4B524E; --ink-3: #7A807B;
  --accent: #24493D; --accent-ink: #FFFFFF; --accent-soft: #E3EBE6;
  --low: #B2412D; --low-soft: #F8E7E2; --warn: #9A6410; --warn-soft: #F6EDDA;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif; letter-spacing: -0.15px; overflow-x: hidden; word-break: keep-all; overflow-wrap: break-word; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2 { margin: 0; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.muted { color: var(--ink-3); font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }
small { font-size: 12px; color: var(--ink-3); font-weight: 400; }

/* 뼈대 */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 40px); }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: calc(100vh - 40px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand__mark { width: 32px; height: 32px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.brand strong { display: block; font-size: 14px; line-height: 1.3; }
.brand small { display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__btn { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border: 0; background: none; border-radius: var(--radius); text-align: left; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.nav__btn:hover { background: var(--sunk); }
.nav__btn.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav__badge { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--low); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 19px; text-align: center; font-variant-numeric: tabular-nums; }
.nav__badge--muted { background: var(--line-2); color: var(--ink); }
.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.side__user { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.side__note { margin: 0; font-size: 12px; line-height: 1.55; color: var(--ink-3); padding-top: 10px; border-top: 1px solid var(--line); }

.main { padding: 26px 32px 60px; min-width: 0; }
.panel__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.panel__head p { margin: 4px 0 0; }
.panel__actions { display: flex; gap: 8px; }

/* 버튼·입력 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #1A3A30; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { background: var(--sunk); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.iconbtn { width: 36px; height: 36px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-size: 18px; line-height: 1; color: var(--ink-3); flex: none; }
.input { height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); min-width: 0; width: 100%; }
.input:focus, .btn:focus-visible, .seg__btn:focus-visible, .nav__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=number].num { text-align: right; }

.filters { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filters .input { width: 240px; }
.seg { display: inline-flex; background: var(--sunk); border-radius: var(--radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg__btn { border: 0; background: none; padding: 5px 11px; border-radius: 4px; cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.seg__btn.is-on { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: 0 0 0 1px var(--line); }
.seg--full { display: flex; margin: 14px 0 4px; }
.seg--full .seg__btn { flex: 1; padding: 7px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* 요약 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 16px; }
.stat { padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat__label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.stat__value { font-size: 28px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.2; }
.stat__sub { font-size: 12px; color: var(--ink-3); }
.stat--low .stat__value { color: var(--low); }
.stat--warn .stat__sub { color: var(--warn); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; margin-bottom: 16px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.box--flat { margin-top: 28px; }
.box__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.box__row .box__title { margin: 0; }
.box__title { font-size: 14px; font-weight: 650; margin-bottom: 12px; }
.box__title .muted { font-size: 12.5px; }

.lowlist { list-style: none; margin: 0; padding: 0; }
.lowlist li + li { border-top: 1px solid var(--line); }
.lowlist__btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border: 0; background: none; cursor: pointer; text-align: left; }
.lowlist__btn:hover span:first-child { text-decoration: underline; text-underline-offset: 3px; }
.lowlist__btn small { margin-left: 8px; }
.lowlist__btn .num { color: var(--ink-3); white-space: nowrap; }
.lowlist__btn .num b { color: var(--low); font-weight: 700; }
.lowlist__more { padding-top: 10px; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 64px; align-items: center; gap: 10px; font-size: 13px; }
.bar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar__track { height: 14px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.bar__track i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.bar__val { text-align: right; font-weight: 650; }
.bar__val small { margin-left: 2px; }

/* 표 */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.box .tablewrap { border: 0; margin: 0 -18px -16px; border-radius: 0 0 var(--radius) var(--radius); border-top: 1px solid var(--line); }
.box--flat .tablewrap { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 12px; background: #FAF9F6; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: 0; padding: 10px 12px; }
.tbl .r { text-align: right; }
.tbl tbody tr:hover td { background: #FBFAF7; }
.tbl tr.is-low td:first-child { box-shadow: inset 3px 0 0 var(--low); }
.tbl .cell-title strong { font-weight: 600; }
.tbl .cell-title .num { margin-right: 4px; font-size: 12.5px; }
.tbl .cell-act { width: 1%; white-space: nowrap; }
.tbl tr.empty td { text-align: center; color: var(--ink-3); padding: 28px 12px; }
.tbl .memo { display: block; margin-top: 2px; }
.cell-lines { font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.cell-lines b { color: var(--ink); font-weight: 650; margin-left: 2px; }
.cell-lines .sep { margin: 0 6px; color: var(--line-2); }
.m-only { display: none; }
.warn { display: block; color: var(--low); font-weight: 600; }

.meter { position: relative; display: block; width: 110px; height: 6px; background: var(--sunk); border-radius: 3px; }
.meter i { display: block; height: 100%; background: #7E9A8E; border-radius: 3px; }
.meter b { position: absolute; top: -3px; width: 1px; height: 12px; background: var(--ink-3); }
.meter--low i { background: var(--low); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag--low { background: var(--low-soft); color: var(--low); }
.kind { font-size: 12.5px; font-weight: 600; }
.kind--in { color: var(--accent); }
.kind--out { color: var(--ink-2); }
.kind--adjust { color: var(--warn); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.st::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st--received { color: var(--warn); }
.st--ready { color: #2F5E9E; }
.st--shipped { color: var(--ink-3); }

/* 대화상자 */
.dlg { border: 0; border-radius: 10px; padding: 0; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 18px 50px rgba(20, 28, 24, .22); }
.dlg--wide { width: min(560px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(24, 30, 27, .4); }
.dlg form { padding: 22px 22px 18px; }
.dlg__title { font-size: 17px; font-weight: 700; }
.dlg form > .muted { margin: 4px 0 0; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-top: 14px; min-width: 0; flex: 1; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-row { display: flex; gap: 10px; }
.lines__label { margin: 14px 0 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.lines { display: flex; flex-direction: column; gap: 8px; margin: 5px 0 8px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 90px 36px; gap: 8px; }
.err { color: var(--low); font-size: 13px; font-weight: 600; margin: 10px 0 0; }
.dlg__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* 태블릿 */
@media (max-width: 1080px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 22px 22px 60px; }
}

/* 모바일 — 사이드 메뉴는 위 띠로, 표는 카드로 */
@media (max-width: 760px) {
  .app { display: flex; flex-direction: column; min-height: 0; }
  .side { display: contents; }
  .brand { order: 0; padding: 14px 16px 10px; background: var(--surface); }
  .nav { order: 1; flex-direction: row; gap: 0; padding: 0 6px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  .nav__btn { flex: 1; justify-content: center; gap: 6px; border-radius: 0; padding: 11px 6px; border-bottom: 2px solid transparent; }
  .nav__btn.is-on { background: none; border-bottom-color: var(--accent); }
  .main { order: 2; }
  .side__foot { order: 3; margin: 0 16px 32px; padding: 14px 0 0; border-top: 1px solid var(--line); }
  .side__note { border-top: 0; padding-top: 0; }
  .side__foot .btn { align-self: flex-start; }
  .main { padding: 18px 16px 28px; }
  h1 { font-size: 20px; }
  .panel__head { align-items: flex-start; }
  .panel__actions { width: 100%; }
  .panel__actions .btn { flex: 1; }
  .filters .input { width: 100%; }
  .seg { max-width: 100%; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 14px; }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat__value { font-size: 24px; }
  .box { padding: 14px; }
  .box .tablewrap { margin: 0 -14px -14px; }
  .bar { grid-template-columns: minmax(0, 1fr) 56px; gap: 3px 8px; }
  .bar__name { grid-column: 1 / -1; }

  .tablewrap { overflow: visible; background: none; border: 0; }
  .box .tablewrap { background: var(--surface); }
  .tbl--cards thead { display: none; }
  .tbl--cards, .tbl--cards tbody, .tbl--cards tfoot { display: block; }
  .tbl--cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; position: relative; }
  .box .tbl--cards tr { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; }
  .tbl--cards td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  .tbl--cards tbody tr:hover td { background: none; }
  .tbl--cards td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
  .tbl--cards td.r { text-align: left; }
  .tbl--cards .cell-title { grid-column: 1 / -1; padding-right: 90px; }
  .tbl--cards .cell-lines { grid-column: 1 / -1; }
  .tbl--cards .cell-act { position: absolute; top: 10px; right: 12px; width: auto; }
  .tbl--cards .col-meter { display: none; }
  .tbl--cards tr.is-low { box-shadow: inset 3px 0 0 var(--low); }
  .tbl--cards tr.is-low td:first-child { box-shadow: none; }
  .tbl--cards tr.empty { display: block; }
  .tbl--cards tfoot tr { display: block; border: 0; background: none; padding: 6px 0; }
  #logTable .cell-title { padding-right: 0; }

  .m-only { display: inline; }
  #stockTable tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #stockTable .col-cat { display: none; }
  #orderTable tr, #pendingTable tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #logTable tr { grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 12px; padding: 10px 0; }
  #logTable td[data-label]::before { display: none; }
  #logTable .cell-title { grid-column: 1; grid-row: 1; font-weight: 600; }
  #logTable .col-time { grid-column: 1; grid-row: 2; font-size: 12.5px; }
  #logTable td[data-label="구분"] { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  #logTable td[data-label="수량"] { grid-column: 3; grid-row: 1 / span 2; align-self: center; text-align: right; min-width: 64px; }
  #logTable .col-memo { grid-column: 1 / -1; font-size: 12.5px; }
  #logTable .col-memo:empty { display: none; }
  .box--flat { padding: 14px 14px 4px; }
  .box--flat .tablewrap { border: 0; background: none; }
  .field-row { flex-direction: column; gap: 0; }
  .line { grid-template-columns: minmax(0, 1fr) 76px 36px; }
}
