:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #fffdfa;
  --surface-2: #f0eee7;
  --ink: #23211d;
  --muted: #69645a;
  --line: #ded8ca;
  --accent: #136f63;
  --accent-2: #a94722;
  --accent-soft: #e1f0eb;
  --danger: #a83232;
  --shadow: 0 18px 45px rgba(45, 35, 22, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(247, 245, 239, 0.9)),
    url("https://images.unsplash.com/photo-1601599561213-832382fd07ba?auto=format&fit=crop&w=1800&q=80");
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar,
.product-panel,
.cart-panel,
.summary-panel,
.orders-panel {
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid rgba(222, 216, 202, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.topbar h1,
.section-heading h2,
.split-lists h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.5rem, 3vw, 2.15rem);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.pos-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.75fr);
  gap: 16px;
}

.product-panel,
.cart-panel,
.summary-panel,
.orders-panel {
  padding: 18px;
}

.product-panel {
  min-height: 620px;
}

.cart-panel {
  position: sticky;
  top: 16px;
  align-self: start;
}

.summary-panel,
.orders-panel {
  grid-column: 1 / -1;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading h2 {
  font-size: 1.25rem;
}

.product-grid,
.bundle-grid {
  display: grid;
  gap: 10px;
}

.product-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.bundle-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.product-button,
.bundle-button {
  display: grid;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.product-button:hover,
.bundle-button:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(19, 111, 99, 0.12);
  transform: translateY(-1px);
}

.bundle-button {
  background: var(--accent-soft);
  border-color: rgba(19, 111, 99, 0.25);
}

.item-name {
  align-self: start;
  font-size: 1.02rem;
  font-weight: 750;
  line-height: 1.35;
}

.item-meta {
  align-self: end;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.price {
  color: var(--accent);
  font-weight: 850;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.cart-items {
  display: grid;
  gap: 10px;
  min-height: 80px;
  margin-bottom: 16px;
}

.cart-empty,
.empty-state {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(240, 238, 231, 0.55);
}

.cart-row,
.order-row,
.list-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}

.cart-title {
  font-weight: 760;
}

.cart-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 3px;
}

.qty-controls {
  display: grid;
  grid-template-columns: 34px 38px 34px;
  align-items: center;
  gap: 4px;
}

.qty-controls button,
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 800;
}

.qty-controls span {
  text-align: center;
  font-weight: 800;
}

.checkout-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.totals {
  display: grid;
  gap: 9px;
  margin: 16px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.totals span {
  color: var(--muted);
}

.grand-total {
  font-size: 1.35rem;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 13px;
  font-weight: 850;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #172f2c;
  color: #fff;
}

.kpi span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.86rem;
  font-weight: 700;
}

.kpi strong {
  font-size: 1.55rem;
}

.split-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.split-lists h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.compact-list,
.orders-list {
  display: grid;
  gap: 8px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.list-row span:last-child {
  color: var(--accent);
  font-weight: 850;
}

.order-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
}

.order-id {
  font-weight: 800;
}

.order-detail {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

.order-total {
  text-align: right;
  font-size: 1.1rem;
  font-weight: 900;
}

.delete-order {
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 750;
}

@media (max-width: 960px) {
  .pos-grid {
    grid-template-columns: 1fr;
  }

  .cart-panel {
    position: static;
  }

  .kpi-grid,
  .split-lists {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding: 10px 0;
  }

  .topbar,
  .section-heading,
  .order-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .checkout-controls,
  .kpi-grid,
  .split-lists {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .product-grid,
  .bundle-grid {
    grid-template-columns: 1fr;
  }
}
