:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #1c2430;
  --muted: #6b7380;
  --line: #e6eaee;
  --accent: #1f7a45;
  --accent-soft: #e8f6ee;
  --accent-ink: #ffffff;
  --shadow: 0 8px 24px rgb(16 24 40 / 6%);
  --rail: 4.75rem;
  --ticket: 22.5rem;
  accent-color: var(--accent);
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--ticket);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button, input, select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 2.5rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  color: var(--ink);
}

input:focus,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

button.ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem 0.55rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.rail-item {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.15rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 0;
}

.rail-item svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.rail-item.is-active,
.rail-item:hover,
.rail-item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 100dvh;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.shift-label, .muted, .notice {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.search {
  position: relative;
}

.search input {
  width: 100%;
  border-radius: 999px;
  padding-left: 1rem;
  background: var(--bg);
}

.clock {
  display: flex;
  gap: 0.45rem;
  align-items: end;
}

.clock label, form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

body.has-shift .clock {
  display: none;
}

.notice {
  min-height: 0;
  margin: 0.6rem 1.1rem 0;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #cfe8d6;
}

.notice:empty {
  display: none;
}

.stage {
  min-height: 0;
  overflow: auto;
  padding: 0.9rem 1.1rem 1.4rem;
}

.categories {
  display: flex;
  gap: 0.55rem;
  margin: 0 0 0.85rem;
  padding: 0;
  border: 0;
  overflow-x: auto;
}

.cat-chip {
  flex: 0 0 auto;
}

.cat-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cat-chip span {
  display: grid;
  place-content: center;
  min-width: 5.5rem;
  min-height: 4.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
}

.cat-chip:has(:checked) span,
.cat-chip:hover span {
  background: var(--accent-soft);
  border-color: #cfe8d6;
  color: var(--accent);
}

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.75rem, 1fr));
  gap: 0.85rem;
}

.sku-card {
  content-visibility: auto;
  contain-intrinsic-size: 11rem 12rem;
  min-height: 11.5rem;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.55rem;
  padding: 1rem 0.75rem 0.85rem;
  text-align: center;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.sku-card.is-unavailable {
  opacity: 0.55;
  cursor: not-allowed;
}

.sku-card.is-unavailable:hover,
.sku-card.is-unavailable:focus-visible {
  border-color: var(--line);
}

.sku-avatar {
  width: 4.6rem;
  height: 4.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sku-card strong {
  font-size: 0.9rem;
}

.sku-price {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
}

.sku-stock {
  color: var(--muted);
  font-size: 0.75rem;
}

.ticket {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.ticket-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
  padding: 1rem 1rem 0.6rem;
}

.ticket h2 {
  margin: 0;
  font-size: 1rem;
}

.badge[hidden] {
  display: none !important;
}

#sale-form {
  display: grid;
  align-content: start;
  gap: 0.7rem;
  min-height: 0;
  padding: 0 1rem 1rem;
  overflow: auto;
}

.cart-list {
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 5.5rem;
}

.cart-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.cart-list small {
  display: block;
  color: var(--muted);
}

.apply {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.apply p {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.totals {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.totals .grand {
  font-weight: 700;
  color: var(--accent);
}

.pay {
  min-height: 2.9rem;
  font-weight: 700;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.numpad button {
  min-height: 2.55rem;
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 700;
  font-size: 1.05rem;
}

.numpad button:hover,
.numpad button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #cfe8d6;
}

.numpad [data-key="clear"] {
  grid-column: span 2;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

dialog {
  border: 0;
  border-radius: 16px;
  padding: 1.2rem 1.3rem;
  width: min(28rem, calc(100% - 2rem));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(15 23 42 / 40%);
}

#order-overview {
  width: min(24rem, calc(100% - 2rem));
  padding: 1.35rem 1.35rem 1.15rem;
}

.overview-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.overview h2 {
  margin: 0;
  font-size: 1.25rem;
}

.overview-table {
  width: 100%;
  margin: 0.9rem 0 0.75rem;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.overview-table th {
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0 0 0.4rem;
  border-bottom: 1px solid var(--line);
}

.overview-table th:first-child,
.overview-table td:first-child {
  width: 2.4rem;
}

.overview-table th:last-child,
.overview-table td:last-child {
  text-align: right;
}

.overview-table td {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.overview-table small {
  display: block;
  color: var(--muted);
}

.overview-totals {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.overview-totals div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
}

.overview-totals .grand {
  font-weight: 700;
  color: var(--accent);
  padding-top: 0.3rem;
  border-top: 1px solid var(--line);
}

.overview-pay {
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

#order-overview .dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

#overview-done {
  margin-top: 0.8rem;
}

#overview-done[hidden],
#overview-confirm[hidden] {
  display: none !important;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.choice-grid button {
  min-height: 2.3rem;
  padding: 0.3rem 0.7rem;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.choice-grid button.is-selected,
.choice-grid button:hover,
.choice-grid button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #cfe8d6;
}

.size-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.variant-fieldset {
  margin: 0.7rem 0 0;
  padding: 0;
  border: 0;
}

.variant-fieldset legend {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

#variant-picker {
  width: min(36rem, calc(100% - 2rem));
}

@media (max-width: 960px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .rail {
    flex-direction: row;
    justify-content: space-around;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .ticket {
    min-height: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
