:root {
  color-scheme: light;
  --red: #b71922;
  --red-dark: #83121a;
  --red-soft: #fff0f1;
  --ink: #202124;
  --muted: #60646c;
  --line: #d9dce1;
  --paper: #ffffff;
  --panel: #f6f7f9;
  --success: #176b38;
  --danger: #a4141c;
  --shadow: 0 12px 32px rgba(32, 33, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--panel);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(183, 25, 34, 0.08), rgba(246, 247, 249, 0) 280px),
    var(--panel);
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) clamp(12px, 2vw, 24px) max(18px, env(safe-area-inset-bottom));
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--red);
  color: white;
  font-weight: 900;
  font-size: 1.3rem;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--red-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
}

h2 {
  margin-bottom: 4px;
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
}

h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.sale-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 16px;
  align-items: start;
}

.product-panel,
.cart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2vw, 18px);
}

.compact-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading p,
.cart-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 650;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}

.category-button.active {
  border-color: var(--red);
  background: var(--red);
  color: white;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.product-card {
  position: relative;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.product-card.in-cart {
  border-color: var(--red);
  background: #fff8f8;
}

.product-add {
  display: grid;
  grid-template-rows: 1fr auto;
  width: 100%;
  min-height: 118px;
  border: 0;
  padding: 14px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.product-add:active {
  transform: translateY(1px);
}

.product-name {
  display: block;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.14;
  text-wrap: balance;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.product-price {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 0.95rem;
  font-weight: 900;
}

.product-qty {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-weight: 950;
}

.product-minus {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(164, 20, 28, 0.28);
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  font-size: 1.35rem;
  font-weight: 950;
  box-shadow: 0 6px 18px rgba(32, 33, 36, 0.12);
}

.cart-panel {
  position: sticky;
  top: 12px;
}

.cart-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.6rem;
  font-weight: 900;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.cart-list {
  display: grid;
  gap: 8px;
  min-height: 74px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.cart-item-title {
  font-weight: 850;
}

.cart-item-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.cart-item-subtotal {
  align-self: center;
  font-size: 1.08rem;
  font-weight: 900;
}

.quantity-controls {
  display: grid;
  grid-template-columns: 44px 44px 44px;
  gap: 6px;
  grid-column: 1 / -1;
}

.quantity-controls button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 900;
}

.quantity-controls .remove {
  color: var(--danger);
}

.total-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  border-top: 2px solid var(--ink);
  padding-top: 12px;
}

.total-box span {
  font-size: 1.05rem;
  font-weight: 850;
}

.total-box strong {
  color: var(--red);
  font-size: clamp(2.2rem, 6vw, 3.15rem);
  line-height: 1;
}

.cash-box {
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.cash-box label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
}

.money-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
}

.money-input:focus-within {
  border-color: var(--red);
}

.money-input input {
  width: 100%;
  border: 0;
  outline: 0;
  font-size: 1.45rem;
  font-weight: 850;
  background: transparent;
}

.money-input span {
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 850;
}

.change-line {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 850;
}

.change-line.ok {
  color: var(--success);
}

.change-line.missing {
  color: var(--danger);
}

.cart-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.secondary-action {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  background: white;
  color: var(--ink);
  font-weight: 900;
}

.secondary-action.strong {
  border-color: var(--red);
  color: var(--red-dark);
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(420px, calc(100vw - 28px));
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.mobile-total-bar {
  display: none;
}

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

  .cart-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: max(8px, env(safe-area-inset-top)) 8px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .eyebrow {
    margin-bottom: 0;
    font-size: 0.68rem;
  }

  h1 {
    font-size: 1.32rem;
  }

  h2 {
    font-size: 1.12rem;
  }

  .product-panel,
  .cart-panel {
    border-radius: 10px;
    padding: 8px;
  }

  .compact-heading {
    gap: 4px;
    margin-bottom: 8px;
  }

  .compact-heading p {
    display: none;
  }

  .category-tabs {
    margin-inline: -8px;
    padding-inline: 8px;
  }

  .category-button {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 0.9rem;
  }

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

  .compact-heading {
    flex-direction: column;
  }

  .product-add {
    min-height: 92px;
    border-radius: 10px;
    padding: 9px;
  }

  .product-card {
    border-radius: 10px;
  }

  .product-card.in-cart .product-add {
    padding-right: 42px;
  }

  .product-name {
    font-size: 0.92rem;
    line-height: 1.1;
  }

  .product-footer {
    margin-top: 7px;
  }

  .product-price {
    min-height: 27px;
    padding: 0 8px;
    font-size: 0.82rem;
  }

  .product-qty {
    min-width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .product-minus {
    top: 5px;
    right: 5px;
    width: 34px;
    height: 34px;
    font-size: 1.18rem;
  }

  .cart-panel {
    scroll-margin-top: 10px;
  }

  .cart-header {
    align-items: center;
  }

  .icon-button {
    width: 56px;
    height: 56px;
  }

  .cart-list {
    gap: 10px;
  }

  .cart-item {
    border-radius: 10px;
    padding: 12px;
  }

  .quantity-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quantity-controls button {
    min-height: 52px;
    border-radius: 10px;
    font-size: 1.25rem;
  }

  .total-box strong {
    font-size: 2.5rem;
  }

  .cash-box {
    border-radius: 10px;
    padding: 12px;
  }

  .money-input {
    min-height: 64px;
    border-radius: 10px;
  }

  .money-input input {
    font-size: 1.65rem;
  }

  .change-line {
    font-size: 1.18rem;
  }

  .secondary-action {
    min-height: 60px;
    border-radius: 10px;
  }

  .mobile-total-bar {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 74px;
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(32, 33, 36, 0.18);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 36px rgba(32, 33, 36, 0.22);
    backdrop-filter: blur(12px);
  }

  .mobile-total-main,
  .mobile-total-reset {
    min-height: 58px;
    border: 0;
    border-radius: 12px;
    font-weight: 900;
  }

  .mobile-total-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px;
    background: var(--red);
    color: white;
    text-align: left;
  }

  .mobile-total-main span {
    min-width: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-total-main strong {
    flex: 0 0 auto;
    font-size: 1.35rem;
  }

  .mobile-total-reset {
    background: var(--panel);
    color: var(--red-dark);
  }

  .toast {
    right: 10px;
    bottom: calc(94px + env(safe-area-inset-bottom));
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-button {
    min-height: 46px;
    padding: 0 12px;
  }

  .product-add {
    min-height: 88px;
  }

  .total-box {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 360px) {
  .product-grid {
    gap: 6px;
  }

  .product-add {
    min-height: 84px;
    padding: 8px;
  }

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

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

  .product-card.in-cart .product-add {
    padding-right: 38px;
  }

  .mobile-total-bar {
    grid-template-columns: minmax(0, 1fr) 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
