:root {
  font-family: Inter, "Yu Gothic UI", "Hiragino Sans", Meiryo, sans-serif;
  color: #1c2925;
  background: #f4f2ed;
  color-scheme: light;
  font-variant-numeric: tabular-nums;
  --paper: #fffdf8;
  --line: #dfd9ca;
  --muted: #586560;
  --green: #1d493d;
  --soft: #e8efe6;
  --gold: #ae8951;
  --bar-height: 54px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 0 0, #e5ebe0 0, transparent 56%), #f6f1e8;
}
h1, h2, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }

button {
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid #d7dbd0;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { opacity: .52; cursor: default; }
button:not(:disabled):hover { border-color: #7d9587; }
:focus-visible { outline: 3px solid #946331; outline-offset: 2px; }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar-height);
  padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right));
  border-bottom: 1px solid #d9ceba;
  background: var(--paper);
  box-shadow: 0 2px 8px #3028170a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: inherit;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(145deg, #367363, var(--green));
  box-shadow: 0 0 0 1px #fff3 inset, 0 2px 4px #1d493d38;
  color: #fff;
  font-size: 18px;
}

.status { margin-inline-end: auto; color: var(--muted); font-size: 12px; }
.menu { position: relative; }
.menu summary {
  list-style: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--soft); }
.menu nav {
  position: absolute;
  z-index: 4;
  inset: calc(100% + 3px) 0 auto auto;
  width: 174px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 5px 17px #1c29251a;
}
.menu nav button { width: 100%; background: transparent; border-color: transparent; text-align: left; }
.menu nav button:not(:disabled):hover { background: var(--soft); border-color: transparent; }
.install-help { display: flex; align-items: center; min-height: 44px; padding-inline: 10px; color: var(--green); }
.rotate { display: none; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 39%);
  gap: 18px;
  height: calc(100dvh - var(--bar-height));
  padding: 17px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.products { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.products h1 {
  padding-inline-start: 10px;
  border-inline-start: 3px solid var(--gold);
  font-size: 25px;
  line-height: 1.3;
  letter-spacing: -.04em;
}
.groups { display: flex; flex: none; gap: 6px; overflow: auto; padding-bottom: 5px; border-bottom: 1px solid #d7d5c7; }
.groups button {
  min-width: 106px;
  padding-inline: 16px;
  border-color: #d9d8cd;
  border-radius: 999px;
  background: #fffdf8aa;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.groups button[aria-pressed=true] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.groups button:focus-visible { outline-offset: -3px; }
.groups button[aria-pressed=true]:focus-visible { outline-color: #fff; }
.product-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 4px; margin: -1px -4px 0; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 11px; }
.tile { min-width: 0; }
.add {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 7px 7px 9px;
  border-color: #ddd8c9;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 2px 5px #3f33150e;
  text-align: left;
  transition: transform 150ms ease, box-shadow 170ms ease, background-color 170ms ease, border-color 170ms ease;
}
.product-media {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  aspect-ratio: 8 / 5;
  max-height: 168px;
  overflow: hidden;
  border-radius: 9px;
  background: radial-gradient(ellipse at 50% 32%, #faf6eb 0, #ece5d4 76%);
  box-shadow: 0 0 0 1px #7d684617 inset;
}
.product-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, #88744c0c 0 1px, transparent 1px 7px);
  mask-image: radial-gradient(ellipse, transparent 20%, black 95%);
}
.product-media::after {
  content: "";
  width: 30px;
  height: 23px;
  border: 1px solid #ae956b;
  border-radius: 5px;
  background:
    radial-gradient(circle at 70% 30%, #ae956b 0 2px, transparent 2.6px),
    linear-gradient(135deg, transparent 49%, #c1ae8c 51%) 2px bottom / 13px 11px no-repeat,
    linear-gradient(45deg, #c1ae8c 48%, transparent 51%) 15px bottom / 13px 7px no-repeat;
  opacity: .82;
}
.product-media:has(img[data-loaded])::after { visibility: hidden; }
.product-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 170ms ease, transform 220ms ease;
}
.product-media img[data-loaded] { opacity: 1; }
.product-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  padding-inline: 5px;
}
.product-name { font-size: 15px; line-height: 1.32; overflow-wrap: anywhere; }
.price { color: var(--green); font-size: 16px; font-weight: 750; text-align: right; white-space: nowrap; }
.tile[data-active=true] .add { border-color: #588271; background: #eaf1e7; box-shadow: 0 0 0 1px #588271 inset; }
.qty {
  position: absolute;
  inset: 12px 12px auto auto;
  padding: 2px 7px;
  border: 1px solid #fff;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}
.qty:not([hidden]) { animation: quantity-in 185ms ease-out both; }
.tile:not([hidden]) { animation: tile-in 190ms ease-out both; }
.add:active { transform: scale(.98); }
@media (hover: hover) {
  .add:hover:not(:active) { transform: translateY(-2px); box-shadow: 0 5px 10px #3f331526; }
  .add:hover .product-media img { transform: scale(1.025); }
}
@keyframes tile-in { from { opacity: .5; transform: translateY(4px); } }
@keyframes quantity-in { from { opacity: .3; transform: scale(.8); } }

.checkout {
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 5px 18px #3f331511;
  container-type: inline-size;
}
.checkout-head, .total, .change dl div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.checkout-head h2 { font-size: 17px; }
#units { padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--green); font-size: 13px; font-weight: 700; }
.total {
  padding: 10px 14px;
  border: 1px solid #295849;
  border-radius: 12px;
  background: repeating-radial-gradient(circle at 102% 125%, transparent 0 13px, #fff1 14px 15px), linear-gradient(115deg, #173e34, #2b6252);
  box-shadow: 0 3px 8px #1d493d26;
  color: #fff;
}
.total p { font-size: 14px; font-weight: 650; white-space: nowrap; }
.total output, .calculator-display output, .change-main output {
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.045em;
  text-align: right;
  white-space: nowrap;
}
.total output { font-size: clamp(29px, 13.8cqi, 60px); }

.cart {
  flex: 0 1 auto;
  min-height: min(45px, 12dvh);
  max-height: clamp(90px, 16dvh, 145px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(63px, auto);
  align-items: center;
  gap: 5px;
  min-height: 45px;
  border-bottom: 1px solid #ecebe5;
}
.cart-label { font-size: 14px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.cart-label small { padding-inline-start: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.cart-row strong { text-align: right; font-size: 14px; white-space: nowrap; }
.cart-remove {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 44px;
  border: 0;
  background: transparent;
  font-size: 18px;
}
.cart-remove span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.cart-remove:not(:disabled):hover span { background: var(--soft); }
.cart-remove:focus-visible { outline-offset: -3px; }

.action-area { display: grid; flex: 1 0 auto; min-height: 0; min-width: 0; }
.action-area > section { grid-area: 1 / 1; }
.selection, .sheet { display: flex; flex-direction: column; gap: 7px; justify-content: flex-end; }
.selection h2, .sheet h2 { font-size: 15px; }
.candidates, .keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.candidates button { min-height: 47px; padding-inline: 2px; font-size: clamp(13px, 4.7cqi, 20px); white-space: nowrap; }
.candidates button { transition: border-color 150ms ease, background-color 150ms ease; }
.candidates button:first-child { border-color: #a5baad; background: var(--soft); }
.candidates button:hover:not(:disabled) { background: var(--soft); }
#empty { font-size: 14px; margin-block: 8px; color: var(--muted); }
#manual { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; text-align: left; }
#manual span { font-size: 19px; }
.plain { align-self: flex-end; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.primary { border-color: var(--green); background: var(--green); color: #fff; }

.keypad { display: grid; place-items: center; grid-template-columns: minmax(0, 1fr); }
.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  width: min(100%, 410px);
  padding: 9px;
  border-radius: 11px;
  background: #edf1ea;
}
.calculator-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding-inline: 8px;
  border-radius: 7px;
  background: #fff;
}
.calculator-display h2 { font-size: 13px; }
.calculator-display output { margin-left: auto; font-size: clamp(23px, 10.3cqi, 40px); }
.keys button { padding-inline: 3px; font-size: 28px; line-height: 1; }
.keys .key-command { font-size: 14px; }
.note { color: #813e28; font-size: 14px; }
.note:empty { display: none; }
.keypad .note { display: flex; align-items: center; height: 1.45em; }
.keypad .note:empty { display: flex; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 7px; }
.sheet-actions button { padding-inline: 4px; font-size: 15px; }
.change { gap: 12px; }
.change-main {
  display: grid;
  gap: 7px;
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--soft);
  order: 1;
}
.change-main output { font-size: clamp(29px, 13.5cqi, 54px); }
.change dl { padding-inline: 4px; }
.change dt { color: var(--muted); font-size: 14px; }
.change dd { font-size: 17px; font-weight: 750; }
.change .sheet-actions { order: 3; }
.change .note { order: 2; }
.sheet.is-entering { animation: slide-in 170ms ease-out both; }
.sheet.is-leaving { animation: slide-out 170ms ease-in both; }
@keyframes slide-in { from { transform: translateY(105%); } to { transform: translateY(0); } }
@keyframes slide-out { from { transform: translateY(0); } to { transform: translateY(105%); } }
@media (prefers-reduced-motion: reduce) {
  .sheet.is-entering, .sheet.is-leaving, .tile:not([hidden]), .qty:not([hidden]) { animation: none; }
  .groups button, .add, .product-media img, .candidates button { transition: none; }
  .add:active, .add:hover:not(:active), .add:hover .product-media img { transform: none; }
}

.toast {
  position: fixed;
  z-index: 5;
  inset: auto auto max(12px, env(safe-area-inset-bottom)) 50%;
  transform: translateX(-50%);
  padding: 10px 17px;
  max-width: calc(100% - 24px);
  border-radius: 9px;
  background: var(--green);
  color: #fff;
}

dialog {
  width: min(560px, 94vw);
  max-height: 92dvh;
  overflow: auto;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: inherit;
}
dialog::backdrop { background: #142b2399; }
dialog h2 { font-size: 22px; }
dialog form { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
#sales-content > * + * { margin-top: 10px; }
#sales-content ul { padding-left: 23px; }
.day-select { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.day-select select, .void-form input, #master select, #master input:not([type="checkbox"]) {
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  font: inherit;
}
.sale-row { padding: 8px 0; border-top: 1px solid var(--line); }
.sale-row p { margin: 4px 0; }
#sales-content summary { min-height: 44px; padding-block: 10px; font-weight: 700; cursor: pointer; }
.void-form { flex-wrap: wrap; justify-content: flex-start; }
.void-form label { display: flex; align-items: center; gap: 6px; }
.void-form input { width: min(185px, 42vw); }
.void-form p:empty, #master-status:empty { display: none; }
.master-note, #master-status { margin-bottom: 10px; font-size: 15px; }
#master-status { color: var(--green); font-weight: 700; }
#master-sheet { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#master-sheet a { display: inline-flex; align-items: center; min-height: 44px; color: var(--green); }
.master-picker { display: flex; align-items: end; gap: 8px; margin-bottom: 14px; }
.master-picker label { flex: 1; min-width: 0; }
.master-picker button { flex: none; }
#master-form, #master label { display: grid; align-items: stretch; gap: 8px; }
#master-form { margin-bottom: 0; gap: 12px; }
#master select, #master input:not([type="checkbox"]) { width: 100%; }
.master-photo, #master .master-photo label { display: flex; align-items: center; gap: 10px; }
.master-photo img { width: 92px; height: 70px; object-fit: contain; background: var(--soft); border-radius: 6px; }

@media (orientation: landscape) {
  .checkout { overflow: hidden; }
  .action-area { flex: 1 1 0; overflow: auto; }
}
@media (max-height: 680px) and (orientation: landscape) {
  .checkout[data-candidates="9"] .cart { max-height: 67px; }
  .checkout[data-phase=keypad] .cart,
  .checkout[data-phase=transition]:has(.keypad:not([hidden])) .cart { display: none; }
}
@media (max-width: 940px) and (orientation: landscape) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(310px, 43%); gap: 10px; padding-inline: 10px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checkout { padding: 10px; gap: 7px; }
}
@media (max-height: 540px) and (orientation: landscape) {
  :root { --bar-height: 46px; }
  .workspace { padding-block: 7px; }
  .products { gap: 6px; }
  .checkout { padding: 8px; gap: 6px; }
  .total { padding-block: 5px; }
  .total output { font-size: clamp(27px, 10cqi, 44px); }
  .candidates button { min-height: 44px; }
  .cart { max-height: 90px; }
  .checkout[data-phase=keypad] .checkout-head { display: none; }
  .calculator { padding: 6px; gap: 4px; }
  .calculator-display { min-height: 41px; }
  .keys { gap: 4px; }
}
@media (orientation: portrait) {
  .rotate { display: block; padding: 6px 12px; background: #f3e9d7; font-size: 13px; }
  .workspace { display: flex; flex-direction: column; height: auto; gap: 12px; padding: 12px; }
  .products { max-height: 54dvh; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checkout { min-height: 345px; }
  .keypad { margin-block: 4px; }
}

#tenant-name { font-size: 15px; overflow-wrap: anywhere; }
.setup-form, .device-actions { display: grid; gap: 12px; margin: 16px 0; }
.setup-form label, .device-actions label { display: grid; gap: 6px; }
.setup-form input, .device-actions input { font: inherit; min-height: 44px; padding: 8px; width: 100%; }
#device p { overflow-wrap: anywhere; margin-block: 10px; }
#status { white-space: normal; }
