:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d7dde8;
  --paper: #f6f7fb;
  --surface: #ffffff;
  --accent: #2f9f7b;
  --accent-2: #f45b5b;
  --sun: #ffc857;
  --leaf: #dced7a;
  --sky: #5a93f5;
  --mist: #9aa3bd;
  --danger: #b42318;
}

* { box-sizing: border-box; }
html, body { width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 200, 87, 0.24), rgba(246, 247, 251, 0) 220px),
    var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
a { color: inherit; text-decoration: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 800;
}
.brand > div:last-child {
  min-width: 0;
}
#brandName {
  display: block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  color: #fff;
  font-weight: 900;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.12);
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 20px rgba(17, 24, 39, 0.08);
}
.tab {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.screen {
  display: none;
  padding: 10px;
  max-width: 980px;
  margin: 0 auto 148px;
}
.screen.active { display: block; }
.grid, .list, .form-grid { display: grid; gap: 12px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.hero-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 159, 123, 0.94), rgba(90, 147, 245, 0.88)),
    #2f9f7b;
  color: #fff;
  box-shadow: 0 10px 28px rgba(47, 159, 123, 0.22);
}
.hero-strip h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.05;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.hero-total {
  min-width: 96px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  text-align: right;
}
.hero-total span {
  display: block;
  font-size: 12px;
}
.hero-total strong {
  display: block;
  margin-top: 4px;
}
.category-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.category-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.06);
}
.category-chip.active {
  background: #111827;
  color: #fff;
}
.category-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--sun);
  color: #111827;
  font-size: 0;
}
.category-icon svg { width: 22px; height: 22px; }
.category-label {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.1;
  text-align: left;
}
.category-chip:nth-child(2) .category-icon { background: var(--accent-2); color: #fff; }
.category-chip:nth-child(3) .category-icon { background: var(--leaf); }
.category-chip:nth-child(4) .category-icon { background: var(--sky); color: #fff; }
.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.product {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 10px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 1)),
    var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.07);
}
.product strong {
  display: block;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.product small {
  display: block;
  overflow-wrap: anywhere;
}
.product-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #edf7f1;
  color: var(--accent);
}
.product-icon svg { width: 24px; height: 24px; }
.muted { color: var(--muted); }
.price { font-weight: 900; color: var(--accent); }
.panel {
  padding: 14px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.05);
}
.cart {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin: 0 -10px 54px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}
.cart-row, .summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #edf0f5;
}
.cart-row > div:first-child {
  min-width: 0;
}
.cart-row strong,
.summary-row strong {
  overflow-wrap: anywhere;
}
.cart-row:last-child, .summary-row:last-child { border-bottom: 0; }
.qty { display: inline-flex; align-items: center; gap: 8px; }
button, input, select, textarea { font: inherit; }
button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #111827, #2c3445);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
button.secondary { background: #e5e7eb; color: var(--ink); }
button.accent { background: linear-gradient(135deg, var(--accent), #208664); }
button.warning { background: linear-gradient(135deg, var(--accent-2), #c2410c); }
button.danger { background: var(--danger); }
button.small { min-height: 34px; padding: 0 10px; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
label { display: block; margin-bottom: 6px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
textarea { min-height: 82px; }
.two { display: grid; grid-template-columns: 1fr; gap: 10px; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: flex-end;
  background: rgba(17, 24, 39, 0.5);
}
.modal.active { display: flex; }
.modal-body {
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  padding: 16px;
  border-radius: 8px 8px 0 0;
  background: #fff;
}
.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 18px;
  z-index: 20;
  display: none;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
}
.toast.active { display: block; }
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  background: #edf0f5;
  font-size: 12px;
  font-weight: 800;
}
.invoice {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; }
td, th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th:last-child, td:last-child { text-align: right; }
@media (min-width: 760px) {
  .tabs {
    position: static;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }
  .tab {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px;
  }
  .screen {
    padding: 14px;
    margin-bottom: 88px;
  }
  .cart {
    margin: 0 -14px -14px;
    padding: 12px 14px;
  }
  .two { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product {
    grid-template-columns: 42px minmax(0, 1fr);
  }
  .product .price {
    grid-column: 2;
  }
  .category-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal { align-items: center; justify-content: center; }
  .modal-body { max-width: 680px; border-radius: 8px; }
}

@media (min-width: 980px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
