:root {
  font-family: system-ui, -apple-system, "Yu Gothic UI", "Meiryo", sans-serif;
  color: #202b16;
  background: #f5f7ef;
  line-height: 1.6;
  font-weight: 450;
  --brand: #8EBA31;
  --dark: #263317;
  --muted: #536145;
  --line: #dbe3d0;
  --surface: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, h4, p { margin: 0 0 .65rem; }
h1 { font-size: clamp(1.3rem, 3vw, 1.8rem); margin-bottom: 0; }
h2 { font-size: 1.38rem; }
h3 { font-size: 1.14rem; }
h4 { font-size: 1rem; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { min-height: 44px; border: 1px solid #98a687; border-radius: .55rem; padding: .45rem .65rem; }
input, select, textarea { min-width: 0; width: 100%; background: white; color: inherit; }
input[type=checkbox] { width: 1.2rem; min-height: auto; accent-color: var(--brand); }
button { border-color: var(--brand); background: var(--brand); color: var(--dark); cursor: pointer; font-weight: 650; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .6; cursor: progress; }
button.secondary { background: #fff; color: var(--dark); }
button.subtle { border-color: #a0b385; color: inherit; background: transparent; }
:focus-visible { outline: 3px solid #8a5811; outline-offset: 2px; }
label { display: grid; gap: .18rem; font-weight: 600; }
label.inline { display: flex; align-items: center; gap: .35rem; }
.masthead { background: var(--brand); color: var(--dark); }
.masthead-inner { width: min(100% - 2rem, 72rem); margin: auto; padding: .8rem 0; display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.account { display: flex; align-items: center; justify-content: end; gap: .6rem; flex-wrap: wrap; font-size: .86rem; }
.masthead-controls { display: flex; align-items: end; justify-content: end; gap: .6rem; flex-wrap: wrap; }
.language { font-size: .76rem; }
.language select { width: auto; color: var(--dark); background: #fff; }
main { width: min(100% - 2rem, 72rem); margin: 1rem auto 3rem; }
.login { max-width: 28rem; margin: 2rem auto; }
nav { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
nav button[aria-current=true] { background: var(--brand); color: var(--dark); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: .85rem; padding: clamp(.85rem, 2vw, 1.35rem); margin-bottom: .85rem; }
.stack { display: grid; gap: .75rem; }
.row { display: flex; align-items: end; gap: .55rem; flex-wrap: wrap; }
.row > label { flex: 1 1 8rem; }
.split { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 25rem), 1fr)); align-items: start; }
.compact { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: .9rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.jan { white-space: nowrap; }
.jan-long { white-space: normal; }
.chip { display: inline-block; font-size: .84rem; padding: .13rem .55rem; border-radius: 1rem; background: #e8f0db; color: var(--dark); }
.warn { background: #fff2d8; color: #694308; }
.chip.bad { background: #fde7e6; color: #8c2924; }
#notice { border: 1px solid #bdcda8; background: #edf4e1; margin: 0 0 .8rem; border-radius: .55rem; padding: .65rem .85rem; white-space: pre-line; }
#notice.error { background: #fff0ef; border-color: #dbaeaa; color: #852921; }
#retry-request { margin: 0 0 .8rem; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: .55rem .5rem; vertical-align: top; }
th { white-space: nowrap; background: #f2f6f5; }
.catalog-select { white-space: nowrap; }
.catalog-actions { display: grid; gap: .35rem; }
.catalog-actions button { white-space: nowrap; }
.catalog-pagination { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin: .7rem 0; }
.catalog-product, .draft-product { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); gap: .55rem; align-items: start; }
.product-photo { display: grid; place-items: center; width: 3.5rem; aspect-ratio: 1; border: 1px solid var(--line); border-radius: .45rem; overflow: hidden; background: #f2f6f5; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.product-photo > * { grid-area: 1 / 1; }
.product-photo img { width: 100%; height: 100%; object-fit: contain; background: #fff; opacity: 0; }
.product-photo img[data-ready=true] { opacity: 1; }
.numeric { width: 7rem; }
.line-card { padding: .8rem 0; border-top: 1px solid var(--line); }
.line-card:first-child { border-top: none; }
.list-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.scan-form { padding: .85rem; background: #eef5f4; border-radius: .55rem; }
.scan-form input { font-size: 1.1rem; }
.edit-return { margin: .75rem 0 0; }
.request-jan { margin-bottom: .8rem; }
.request-jan label { white-space: nowrap; }
.request-jan .compact { flex-wrap: nowrap; }
.replenishment-tools { margin-bottom: .8rem; }
.replenishment-tools summary { cursor: pointer; font-weight: 650; }
#pos-import { padding-top: .55rem; }
.draft-product .jan, .store-order-line .jan { display: block; }
.draft-product h3, .store-order-line h3 { margin-bottom: 0; }
.draft-controls { display: grid; gap: .25rem; }
.draft-controls .numeric { max-width: 100%; }
.draft-inventory { grid-column: 1 / -1; display: flex; align-items: baseline; gap: .75rem; }
.draft-inventory > span { min-width: 0; overflow-wrap: anywhere; }
[data-note-button][data-has-note="true"]::after { content: " •"; }
.draft-note-dialog { width: min(94vw, 30rem); }
.draft-note-dialog textarea { resize: vertical; }
.store-order-line dl { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; margin: .35rem 0; }
.store-order-line dl > div { display: flex; gap: .5rem; }
.store-order-line dd { margin: 0; font-weight: 650; }
.store-order-line p { margin-bottom: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
dialog { border: 1px solid var(--line); border-radius: .85rem; max-width: min(94vw, 36rem); }
dialog::backdrop { background: #152625b0; }
video { display: block; width: 100%; max-height: 65vh; background: #102222; margin-bottom: .6rem; }
@media(max-width: 640px) {
  .order-lines { display: block; }
  .order-lines thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .order-lines tbody { display: grid; gap: .55rem; }
  .order-lines tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: .55rem; overflow: hidden; }
  .order-lines td { border: 0; padding: .4rem .55rem; }
  .order-lines td[data-label]::before { display: block; content: attr(data-label); color: var(--muted); font-size: .78rem; }
  .order-lines .line-product, .order-lines .line-purchase { grid-column: 1 / -1; overflow-wrap: anywhere; }
  .order-lines .line-product { background: #f2f6f5; }
  .order-lines .line-purchase { border-top: 1px solid var(--line); }
}
@media(max-width: 540px) {
  .masthead-inner, main { width: calc(100% - 1.2rem); }
  .masthead-inner { flex-wrap: wrap; }
  .masthead-inner h1 { white-space: nowrap; }
  .masthead-controls { margin-left: auto; }
  .account { margin-left: auto; }
  .row > label { flex-basis: 100%; }
  nav button { flex: 1 0 auto; }
  .account > span { text-align: right; }
  .catalog-table th { white-space: normal; }
  .catalog-table .jan { font-size: .87rem; }
  .catalog-product { grid-template-columns: minmax(0, 1fr); gap: .35rem; }
}
