:root {
  color-scheme: light;
  --paper: #f7f7f4;
  --surface: #ffffff;
  --ink: #24231f;
  --muted: #706d63;
  --line: #e2dfd5;
  --green: #927323;
  --green-soft: #fff5d2;
  --yellow: #edcf72;
  --yellow-soft: #fff9e6;
  --red: #b5423b;
  --blue: #34659a;
  --shadow: 0 8px 30px rgba(52, 43, 19, .08);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(247,247,244,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.topbar-main { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 760px; margin: auto; padding: 0 16px; }
.brand { font-size: 18px; font-weight: 800; }
.date-chip { border: 0; background: var(--surface); border-radius: 6px; padding: 8px 10px; font-size: 13px; box-shadow: 0 1px 0 var(--line); }
.content { max-width: 760px; margin: 0 auto; padding: 16px; }

.bottom-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(66px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.nav-btn { border: 0; background: transparent; display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; color: var(--muted); font-size: 11px; }
.nav-btn strong { font-size: 21px; line-height: 1; font-weight: 500; }
.nav-btn.active { color: var(--green); font-weight: 800; }

h1 { margin: 4px 0 6px; font-size: 25px; letter-spacing: 0; }
h2 { margin: 0; font-size: 18px; letter-spacing: 0; }
p { margin: 0; }
.subtle { color: var(--muted); font-size: 13px; line-height: 1.5; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stack { display: grid; gap: 12px; }
.summary-band { display: grid; grid-template-columns: repeat(3, 1fr); background: #f3d98e; color: #2d291e; border-radius: 8px; overflow: hidden; margin: 14px 0; }
.summary-item { padding: 12px; border-right: 1px solid rgba(62,52,20,.14); }
.summary-item:last-child { border: 0; }
.summary-item span { display: block; font-size: 11px; opacity: .75; }
.summary-item strong { display: block; margin-top: 4px; font-size: 18px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; background: #e7ebe7; border-radius: 7px; }
.segmented button { min-height: 38px; border: 0; background: transparent; border-radius: 5px; color: var(--muted); font-weight: 700; font-size: 13px; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.toolbar { display: grid; gap: 10px; margin: 12px 0; }
.inventory-search { display: grid; grid-template-columns: 28px minmax(0,1fr); align-items: center; gap: 8px; }
.inventory-search > span { display: grid; place-items: center; color: var(--green); font-size: 24px; line-height: 1; }
.inventory-search input { min-width: 0; width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 0 11px; background: var(--surface); outline: none; font-size: 13px; }
.inventory-search input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(154,104,0,.13); }
.closing-search { margin-top: 10px; }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; height: 46px; appearance: none; border: 1px solid var(--line); border-radius: 7px; padding: 0 42px 0 13px; background: var(--surface); font-weight: 750; }
.select-wrap::after { content: "⌄"; position: absolute; right: 15px; top: 10px; pointer-events: none; color: var(--muted); }
.select-wrap.category-emphasized select { border-left: 4px solid #d4a32d; padding-left: 10px; }
.production-category-select select { height: 48px; border-color: #bfc6c1; font-size: 15px; }
.category-strip { position: sticky; top: 58px; z-index: 15; display: flex; gap: 7px; overflow-x: auto; padding: 9px 0; background: var(--paper); scrollbar-width: none; }
.category-strip::-webkit-scrollbar { display: none; }
.category-chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 12px; font-size: 13px; }
.category-chip.active { border-color: #d5b756; background: var(--yellow); color: #29261d; }
.selected-category-summary { display: flex; align-items: baseline; gap: 7px; min-height: 28px; margin: 0 0 8px; padding: 2px 1px 6px; }
.selected-category-summary span { color: #667069; font-size: 10px; font-weight: 700; }
.selected-category-summary strong { min-width: 0; color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.selected-category-summary em { margin-left: auto; color: #667069; font-size: 11px; font-style: normal; white-space: nowrap; }

.product-list { display: grid; gap: 8px; }
.product-section-divider { grid-column: 1 / -1; display: flex; align-items: center; gap: 9px; margin: 5px 0 0; color: #59615c; font-size: 12px; font-weight: 800; }
.product-section-divider::after { content: ""; flex: 1; height: 1px; background: #cdd2ce; }
.product-section-divider span { white-space: nowrap; }
.product-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 10px 7px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.product-row.inactive { opacity: .44; background: #eef0ee; }
.product-row.unconfigured { border-left: 4px solid var(--yellow); background: var(--yellow-soft); }
.product-info { min-width: 0; display: flex; align-items: center; gap: 8px; }
.product-info > div { min-width: 0; }
.product-thumb { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 4px; object-fit: cover; background: #eef0ee; }
.product-name { min-width: 0; font-weight: 750; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.inventory-entry .product-name { font-size: 13px; }
.product-meta { margin-top: 4px; color: var(--muted); font-size: 11px; }
.qty-control { width: 128px; height: 46px; display: grid; grid-template-columns: 38px 1fr 38px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fafbfa; }
.qty-control button { border: 0; background: transparent; font-size: 22px; color: var(--green); }
.qty-value { border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; width: 100%; text-align: center; background: white; font-weight: 850; font-size: 18px; outline: none; }
.qty-value.missing { color: #a4aaa6; font-weight: 600; }
.qty-value:focus { box-shadow: inset 0 0 0 2px var(--green); }
.plan-value { display: inline-flex; align-items: center; gap: 5px; }
.plan-value em { font-style: normal; color: var(--green); font-weight: 800; }
.not-produced { width: 94px; min-height: 42px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; font-size: 12px; font-weight: 700; }
.not-produced.active { background: #ecefed; color: var(--muted); }

.pos-page-head, .pos-page-divider { min-height: 34px; margin: 2px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; scroll-margin-top: 112px; }
.pos-page-head strong, .pos-page-divider strong { display: inline-grid; place-items: center; min-width: 42px; height: 26px; padding: 0 9px; border-radius: 999px; background: #fff0bd; color: #674900; font-size: 13px; }
.pos-page-head button, .pos-page-divider button { border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 800; padding: 7px 2px; }
.pos-page-divider { margin-top: 18px; padding-top: 9px; border-top: 2px solid #d4a32d; }
.pos-page-divider strong { background: var(--yellow); color: #29261d; }
.pos-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-inline: -6px; }
.pos-card { min-width: 0; min-height: 104px; border: 1px solid #cbd4cd; border-radius: 5px; background: var(--surface); padding: 8px 3px 7px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; box-shadow: 0 1px 2px rgba(24,35,29,.05); }
.pos-card span { width: 100%; font-size: 11px; line-height: 1.3; font-weight: 750; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.inventory-entry .pos-card span { font-size: 10px; }
.pos-card strong { width: 100%; padding-top: 7px; border-top: 1px solid var(--line); color: var(--green); font-size: 22px; line-height: 1; }
.pos-card strong.missing { color: #a8afaa; font-weight: 600; }
.pos-card em { width: 100%; padding-top: 6px; border-top: 1px solid #d6dbd7; color: #7c847f; font-size: 10px; font-style: normal; font-weight: 750; }
.pos-card.inactive { color: #8e9691; background: #ecefed; opacity: .68; }
.pos-card:disabled { cursor: default; }
.pos-card.pos-empty { background: #fafaf8; border-color: #e5e3dc; box-shadow: none; }

.action-row { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 12; display: flex; gap: 8px; padding: 10px 0; background: linear-gradient(transparent, var(--paper) 22%); }
.primary, .secondary, .danger { min-height: 46px; border-radius: 7px; padding: 0 15px; font-weight: 800; }
.primary { flex: 1; border: 0; background: var(--yellow); color: #29261d; }
.secondary { border: 1px solid var(--line); background: var(--surface); }
.danger { border: 1px solid #edc7c3; background: #fff4f3; color: var(--red); }

.home-grid { display: grid; gap: 10px; margin-top: 16px; }
.task-card { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px; text-align: left; box-shadow: 0 2px 10px rgba(28,44,34,.03); }
.task-card strong { font-size: 17px; }
.task-card span { color: var(--muted); font-size: 13px; margin-top: 5px; display: block; }
.task-card b { font-size: 22px; color: var(--green); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; background: #b7bdb9; }
.status-dot.done { background: #d99a18; }

.settings-list { display: grid; gap: 8px; }
.settings-row { width: 100%; min-height: 58px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; text-align: left; }
.settings-row strong { display: block; font-size: 15px; }
.settings-row span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.settings-row b { color: var(--muted); font-size: 20px; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 13px; }
.admin-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.admin-card input, .admin-card select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; background: white; }
.admin-actions { display: flex; gap: 7px; margin-top: 10px; }
.admin-filter { position: sticky; top: 58px; z-index: 14; display: grid; gap: 8px; margin: 0 -2px 12px; padding: 8px 2px 10px; background: var(--paper); border-bottom: 1px solid var(--line); }
.admin-actions .secondary { flex: 1; min-height: 40px; font-size: 13px; }
.admin-actions .secondary.is-off { color: var(--red); background: #fff4f3; border-color: #edc7c3; }
.admin-category-nav { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; gap: 7px; }
.category-rename-row { display: grid; grid-template-columns: minmax(0, 1fr) 58px 58px; gap: 7px; }
.category-rename-row input { width: 100%; min-width: 0; height: 42px; border: 1px solid var(--green); border-radius: 7px; padding: 0 11px; background: var(--surface); font-size: 14px; font-weight: 700; }
.category-rename-row button { min-height: 42px; padding: 0 8px; font-size: 13px; }
.icon-command { min-width: 44px; height: 46px; padding: 0; font-size: 20px; }
.icon-command:disabled { opacity: .35; }
.category-command { min-width: 66px; height: 46px; padding: 0 9px; font-size: 12px; }
.new-product-command { width: 100%; min-height: 40px; font-size: 13px; }
.admin-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.admin-card-head strong { overflow-wrap: anywhere; }
.sale-control { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; color: #68716b; font-size: 10px; font-weight: 800; }
.sale-switch { position: relative; width: 36px; height: 22px; border: 0; border-radius: 999px; padding: 0; background: #cbd0cd; transition: background .16s ease; }
.sale-switch > span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform .16s ease; }
.sale-switch.on { background: var(--yellow); }
.sale-switch.on > span { transform: translateX(14px); }
.sale-switch:focus-visible { outline: 3px solid rgba(154,104,0,.2); outline-offset: 2px; }
.admin-category-field { display: grid; grid-template-columns: 54px minmax(0,1fr); align-items: center; gap: 7px; }
.admin-category-field label { margin: 0; }
.admin-category-field select { height: 40px; }
.admin-actions .order-button { flex: 0 0 44px; font-size: 20px; padding: 0; }
.admin-actions .sale-button { flex: 1; }
.compact-admin-card { padding: 9px 10px; }
.admin-product-stack { gap: 6px; }
.compact-admin-card .admin-card-head { align-items: center; gap: 6px; margin-bottom: 6px; }
.compact-admin-card .admin-card-head strong { flex: 1; font-size: 14px; line-height: 1.25; }
.compact-admin-card .sale-control { margin-left: 2px; }
.compact-admin-card .admin-category-field { grid-template-columns: 42px minmax(0,1fr); gap: 5px; }
.compact-admin-card .admin-category-field label { font-size: 10px; }
.compact-admin-card .admin-category-field select { height: 34px; padding: 0 8px; font-size: 13px; }
.compact-admin-card .admin-actions { margin-top: 6px; }
.compact-admin-card .admin-actions .secondary { min-height: 34px; font-size: 12px; }
.drag-handle { flex: 0 0 24px; width: 24px; height: 30px; border: 0; background: transparent; color: #78817b; padding: 0; font-size: 22px; line-height: 1; touch-action: none; cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.compact-admin-card.dragging { opacity: .58; border-color: var(--green); }
.compact-admin-card.drop-before { box-shadow: 0 -4px 0 var(--green); }
.compact-admin-card.drop-after { box-shadow: 0 4px 0 var(--green); }
.compact-admin-card.just-moved { border-color: var(--green); animation: moved-product-highlight 1.8s ease-out; }
@keyframes moved-product-highlight {
  0%, 35% { background: #fff0bd; box-shadow: 0 0 0 3px rgba(154,104,0,.18); }
  100% { background: var(--surface); box-shadow: none; }
}
.selected-product { position: sticky; top: 164px; z-index: 13; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 7px; margin-bottom: 10px; padding: 10px; border: 2px solid var(--green); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.selected-product > span { color: var(--green); font-size: 10px; font-weight: 800; }
.selected-product > strong { overflow-wrap: anywhere; }
.selected-product .sale-control { justify-self: end; }
.selected-product .admin-category-field { grid-column: 1 / -1; }
.admin-pos-page { margin-bottom: 18px; }
.admin-pos-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 5px; margin-inline: -6px; }
.admin-pos-slot { position: relative; min-width: 0; min-height: 88px; padding: 17px 3px 5px; border: 1px solid #cfd6d1; border-radius: 5px; background: var(--surface); overflow: hidden; }
.admin-pos-slot small { position: absolute; top: 3px; left: 5px; color: #98a09b; font-size: 9px; }
.admin-pos-slot span { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow-wrap: anywhere; font-size: 10px; line-height: 1.25; font-weight: 700; }
.admin-pos-slot.selected { border: 3px solid var(--green); padding: 15px 1px 3px; background: var(--green-soft); }
.admin-pos-slot.inactive { background: #ecefed; color: #8b938e; }
.empty { padding: 38px 16px; text-align: center; color: var(--muted); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 88px; transform: translate(-50%, 20px); background: #17251e; color: white; padding: 10px 14px; border-radius: 6px; opacity: 0; pointer-events: none; transition: .2s; font-size: 13px; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.undo-toast { position: fixed; z-index: 82; left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 430px; margin: 0 auto; padding: 9px 10px 9px 14px; border-radius: 6px; background: #17251e; color: #fff; box-shadow: 0 8px 24px rgba(17,28,22,.24); font-size: 12px; font-weight: 700; }
.undo-toast button { flex: 0 0 auto; min-height: 36px; border: 0; border-radius: 4px; padding: 0 10px; background: #fff; color: var(--green); font-size: 12px; font-weight: 850; }
.sheet-backdrop { position: fixed; z-index: 70; inset: 0; background: rgba(17, 28, 22, .42); }
.qty-sheet { position: fixed; z-index: 71; left: 0; right: 0; bottom: 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 8px 8px 0 0; box-shadow: 0 -12px 40px rgba(17,28,22,.2); }
.admin-add-sheet { position: fixed; z-index: 71; left: 0; right: 0; bottom: 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 8px 8px 0 0; box-shadow: 0 -12px 40px rgba(17,28,22,.2); }
.admin-add-sheet > label { display: block; margin: 8px 0 6px; color: var(--muted); font-size: 12px; }
.admin-add-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.sheet-handle { width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 3px; background: #cbd1cd; }
.sheet-head { max-width: 430px; margin: 0 auto 12px; min-height: 54px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; }
.sheet-head strong { display: block; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.sheet-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.sheet-head output { min-width: 84px; text-align: right; color: var(--green); font-size: 32px; font-weight: 850; }
.number-pad { max-width: 430px; margin: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.number-pad button { height: 54px; border: 1px solid var(--line); border-radius: 6px; background: #f8faf8; font-size: 24px; font-weight: 750; }
.number-pad button:active { background: var(--green-soft); }
.number-pad .key-sub { color: var(--muted); font-size: 15px; }
.sheet-actions { max-width: 430px; margin: 10px auto 0; display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.sheet-actions .secondary, .sheet-actions .primary { width: 100%; }
.product-picker { position: fixed; z-index: 71; left: 0; right: 0; bottom: 0; max-height: min(78dvh, 680px); padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); display: grid; grid-template-rows: auto auto auto minmax(0,1fr); background: var(--surface); border-radius: 8px 8px 0 0; box-shadow: 0 -12px 40px rgba(17,28,22,.2); }
.picker-head { display: grid; grid-template-columns: minmax(0,1fr) 40px; align-items: center; gap: 8px; margin-bottom: 9px; }
.picker-head strong { display: block; font-size: 17px; }
.picker-head span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.picker-head button { width: 40px; height: 40px; border: 0; background: transparent; font-size: 26px; color: var(--muted); }
.picker-search { width: 100%; height: 46px; border: 2px solid var(--green); border-radius: 7px; padding: 0 12px; background: white; font-size: 16px; outline: none; }
.picker-results { margin-top: 9px; display: grid; align-content: start; gap: 5px; overflow-y: auto; }
.picker-results button { min-height: 52px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: white; text-align: left; }
.picker-results button strong { display: block; font-size: 14px; }
.picker-results button span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

@media (min-width: 680px) {
  .content { padding: 22px; }
  .home-grid { grid-template-columns: 1fr 1fr; }
  .product-list { grid-template-columns: 1fr 1fr; }
  .product-row { min-height: 62px; }
  .pos-card { min-height: 112px; }
  .pos-card span { font-size: 12px; }
  .inventory-entry .pos-card span { font-size: 10px; }
}
