:root {
  --bg: #fbf7ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #243432;
  --muted: #65716e;
  --teal: #4d837b;
  --teal-dark: #2f625d;
  --coral: #d96b62;
  --coral-soft: #ffe7e1;
  --yellow: #f2c65d;
  --yellow-soft: #fff4cf;
  --line: #e8dfd2;
  --shadow: 0 14px 38px rgba(66, 73, 68, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(77, 131, 123, 0.1), transparent 34%),
    linear-gradient(315deg, rgba(242, 198, 93, 0.16), transparent 30%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 16px;
}

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

.event-name {
  margin: 0 0 2px;
  color: var(--teal-dark);
  font-size: 0.95rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.94rem;
}

.status-block {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  min-width: min(100%, 430px);
}

.register-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.register-select {
  min-height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-strong);
  font-weight: 800;
}

.connection,
.pending-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.connection {
  color: #ffffff;
  background: var(--teal);
}

.connection.offline {
  background: var(--coral);
}

.pending-badge {
  color: #62460a;
  background: var(--yellow-soft);
}

.checkout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.products-panel,
.order-panel {
  min-width: 0;
  border: 1px solid rgba(232, 223, 210, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.products-panel {
  padding: 16px;
}

.order-panel {
  position: sticky;
  top: 12px;
  padding: 16px;
}

.section-heading,
.order-heading,
.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding: 16px 0 14px;
  scrollbar-width: thin;
}

.category-tabs button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: var(--surface-strong);
  font-weight: 850;
}

.category-tabs button.active {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  min-width: 0;
}

.product-button {
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(232, 223, 210, 0.95);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
  box-shadow: 0 8px 20px rgba(36, 52, 50, 0.07);
}

.product-button:active,
.quick-cash button:active,
.quantity-btn:active,
.finish-btn:active {
  transform: translateY(1px);
}

.product-name {
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.22;
}

.product-price {
  color: var(--teal-dark);
  font-size: 1.12rem;
  font-weight: 900;
}

.order-list {
  display: grid;
  gap: 10px;
  min-height: 116px;
  margin: 16px 0;
}

.empty-state {
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  font-weight: 800;
}

.order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.order-item-title {
  margin-bottom: 4px;
  font-weight: 900;
  line-height: 1.22;
}

.order-item-meta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.order-controls {
  display: grid;
  grid-template-columns: 46px 44px 46px;
  grid-template-rows: 44px 36px;
  gap: 6px;
  align-items: center;
}

.quantity-btn,
.remove-btn {
  border-radius: var(--radius);
  font-weight: 950;
}

.quantity-btn {
  width: 46px;
  height: 44px;
  color: var(--teal-dark);
  background: #eaf4f0;
  font-size: 1.35rem;
}

.quantity-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 1rem;
  font-weight: 950;
}

.remove-btn {
  grid-column: 1 / -1;
  height: 36px;
  color: #8e342d;
  background: var(--coral-soft);
  font-size: 0.86rem;
}

.ghost {
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: #eaf4f0;
  font-size: 0.92rem;
  font-weight: 850;
}

.ghost.danger {
  color: #8e342d;
  background: var(--coral-soft);
}

.total-box,
.change-box {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius);
}

.total-box {
  color: #ffffff;
  background: var(--teal-dark);
}

.total-box span,
.change-box span,
.cash-box label {
  font-weight: 850;
}

.total-box strong {
  font-size: clamp(2.25rem, 8vw, 4rem);
  line-height: 1;
}

.cash-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.cash-box input {
  width: 100%;
  min-height: 58px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
}

.cash-box input:focus {
  outline: 3px solid rgba(77, 131, 123, 0.22);
  border-color: var(--teal);
}

.quick-cash {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.quick-cash button {
  min-height: 50px;
  border-radius: var(--radius);
  color: #62460a;
  background: var(--yellow-soft);
  font-weight: 950;
}

.change-box {
  border: 2px solid rgba(242, 198, 93, 0.65);
  background: linear-gradient(135deg, #fff8dd, #fffdf8);
}

.change-box strong {
  color: #9a3e36;
  font-size: clamp(2.75rem, 10vw, 5rem);
  line-height: 0.95;
}

.payment-message,
.save-message {
  min-height: 20px;
  margin-bottom: 0;
  color: #8e342d;
  font-weight: 900;
}

.save-message {
  margin-top: 10px;
  color: var(--teal-dark);
  text-align: center;
}

.finish-btn {
  width: 100%;
  min-height: 64px;
  margin-top: 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--coral);
  font-size: 1.15rem;
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(217, 107, 98, 0.28);
}

.summary-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.summary-head {
  align-items: end;
}

.summary-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-align: right;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.summary-metrics div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: var(--radius);
  background: #f4eee5;
}

.summary-metrics span,
.summary-lists li {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.summary-metrics strong {
  font-size: 1rem;
}

.summary-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.summary-lists ul {
  display: grid;
  gap: 6px;
  max-height: 172px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.summary-lists li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

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

  .order-panel {
    position: static;
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    display: grid;
    gap: 12px;
  }

  .status-block {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .register-label {
    display: none;
  }

  .register-select,
  .connection,
  .pending-badge {
    width: 100%;
    white-space: normal;
    text-align: center;
  }

  .register-select {
    grid-column: auto;
  }

  .products-panel,
  .order-panel {
    padding: 12px;
  }

  .order-panel {
    margin-bottom: 8px;
  }

  .order-heading {
    align-items: stretch;
  }

  .order-heading h2 {
    align-self: center;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .product-button {
    min-height: 112px;
    padding: 11px;
  }

  .product-name {
    font-size: 0.93rem;
  }

  .product-price {
    font-size: 1.04rem;
  }

  .order-item {
    grid-template-columns: 1fr;
  }

  .order-controls {
    grid-template-columns: 56px 1fr 56px;
  }

  .quantity-btn {
    width: 56px;
  }

  .quick-cash {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-lists,
  .summary-metrics {
    grid-template-columns: 1fr;
  }
}
