:root {
  color-scheme: light;
  --bg: #f4f8f2;
  --panel: #ffffff;
  --panel-2: #eef6ea;
  --line: #d8e5d6;
  --text: #183327;
  --muted: #66756c;
  --green: #258553;
  --green-dark: #16633c;
  --lime: #dff3d6;
  --blue: #173b78;
  --red: #c2410c;
  --amber: #f1b74a;
  --shadow: 0 14px 34px rgba(24, 51, 39, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(241, 183, 74, 0.16), transparent 30%),
    linear-gradient(180deg, #f8fbf6 0%, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

small {
  display: block;
  color: inherit;
  font-size: 11px;
  line-height: 1.15;
}

.app-shell {
  max-width: 920px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  background: rgba(248, 251, 246, 0.9);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border: 1px solid #e5eadf;
  border-radius: 14px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 8px 18px rgba(24, 51, 39, 0.1);
}

.brand {
  font-size: 24px;
  font-weight: 900;
}

.brand small {
  display: inline;
  color: var(--muted);
}

.caption {
  margin-top: 3px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.icon-button,
.primary,
.secondary,
.danger {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 900;
}

.link-button {
  display: inline-grid;
  place-items: center;
  text-align: center;
}

.icon-button small,
.primary small,
.secondary small,
.danger small,
.tab small {
  margin-top: 2px;
  font-weight: 800;
  opacity: 0.85;
}

.primary {
  background: var(--green);
  color: #fff;
}

.secondary,
.icon-button {
  border: 1px solid #b9d4c2;
  background: #ffffff;
  color: var(--green-dark);
}

.danger {
  background: var(--red);
  color: #fff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card strong {
  display: block;
  font-size: 24px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-title {
  margin: 8px 0 14px;
}

.section-title h1 {
  margin: 0;
  font-size: 28px;
}

.section-title h1 small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.customer-hero {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin: 8px 0 16px;
  border: 1px solid #c6d9cf;
  border-radius: 22px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(37, 133, 83, 0.95), rgba(23, 59, 120, 0.9)),
    #173b78;
  color: #fff;
  box-shadow: var(--shadow);
}

.customer-hero img {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  object-fit: contain;
  background: #fff;
}

.customer-hero h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.16;
}

.customer-hero p {
  margin: 8px 0 0;
  color: #fff3c4;
  font-weight: 900;
}

.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
  margin-bottom: 14px;
}

.sale-banner {
  margin-bottom: 14px;
  border: 1px solid #e6c26b;
  border-radius: 16px;
  padding: 14px;
  background: #fff8df;
}

.sale-banner strong,
.sale-banner span {
  display: block;
}

.sale-banner strong {
  font-size: 18px;
}

.sale-banner span {
  margin-top: 5px;
  color: #6b5b2d;
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 7px;
  color: #315143;
  font-size: 13px;
  font-weight: 900;
}

label small {
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid #cbdccc;
  border-radius: 12px;
  padding: 0 12px;
  background: #fbfdf9;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
}

.toggle-line input {
  width: 22px;
  min-height: 22px;
}

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

#productList,
#weightList {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

#customerProductList {
  grid-template-columns: 1fr;
  gap: 12px;
}

.card {
  padding: 14px;
}

#productList .card,
#weightList .card,
#customerProductList .card {
  padding: 10px;
}

#customerProductList .card {
  display: grid;
  gap: 9px;
}

.category-group {
  overflow: hidden;
  border: 1px solid #dbe8d7;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 24px rgba(39, 89, 57, 0.08);
}

.category-toggle {
  display: grid;
  width: 100%;
  min-height: 56px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 0;
  padding: 12px 14px;
  background: linear-gradient(135deg, #ffffff, #f1f8ee);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.category-title {
  font-size: 19px;
  font-weight: 900;
}

.category-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.category-arrow {
  border-radius: 999px;
  padding: 7px 10px;
  background: #e6f6ed;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.category-group.is-open .category-toggle {
  border-bottom: 1px solid #dbe8d7;
}

.category-products {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
}

.compact-product-card {
  min-height: 112px;
  align-content: space-between;
}

.product-thumb {
  width: 100%;
  aspect-ratio: 1.32;
  border: 1px solid #e1eadf;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.product-thumb-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e6f6ed, #fff8df);
  color: var(--green-dark);
  font-size: 22px;
  font-weight: 900;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

.card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.name {
  font-size: 20px;
  font-weight: 900;
}

#productList .name,
#weightList .name,
#customerProductList .name {
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bilingual-name small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.money {
  color: var(--green-dark);
  font-size: 20px;
  font-weight: 900;
  white-space: nowrap;
}

#productList .money,
#weightList .money,
#customerProductList .money {
  font-size: 17px;
}

.price-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #e6f6ed;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.pill-text,
.button-text {
  display: grid;
  gap: 1px;
  line-height: 1.05;
}

.pill.warn {
  background: #fff1d6;
  color: #9a5b00;
}

.qty-line {
  margin-top: 14px;
}

.qty-line button {
  min-width: 56px;
}

.qty-line input {
  max-width: 130px;
  text-align: center;
  font-size: 22px;
}

.compact-qty {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}

.compact-qty button {
  min-width: 0;
  min-height: 40px;
  border-radius: 10px;
  padding: 0 8px;
  font-size: 18px;
}

.compact-qty input {
  min-height: 40px;
  max-width: none;
  padding: 0 6px;
  font-size: 18px;
}

.weight-actions .confirm-weight {
  grid-column: 1 / -1;
}

.customer-shell {
  padding-bottom: 116px;
}

.customer-total {
  bottom: 12px;
}

.customer-total-actions {
  display: flex;
  gap: 8px;
}

.customer-total-actions button {
  min-width: 96px;
}

.customer-order-card {
  margin-top: 16px;
}

.copy-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.customer-order-result .invoice-table th:nth-child(5),
.customer-order-result .invoice-table td:nth-child(5) {
  text-align: left;
  white-space: normal;
}

.sticky-total {
  position: sticky;
  bottom: 78px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 -10px 28px rgba(24, 51, 39, 0.12);
}

.sticky-total span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.sticky-total strong {
  display: block;
  color: var(--green-dark);
  font-size: 26px;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(920px, 100%);
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.98);
}

.tab {
  min-height: 56px;
  border: 0;
  border-radius: 12px;
  background: #eef6ea;
  color: #315143;
  font-weight: 900;
}

.tab.active {
  background: var(--green);
  color: #fff;
}

.bill {
  border-radius: 18px;
  padding: 18px;
  background: #fff;
  color: #111827;
}

.bill h2 {
  margin: 0 0 4px;
  color: #000;
}

.bill .line {
  height: 2px;
  margin: 14px 0;
  background: var(--blue);
}

.bill .muted {
  color: #52525b;
}

.invoice-table-wrap {
  width: 100%;
  margin-top: 16px;
  overflow-x: auto;
}

.invoice-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  color: #111827;
  font-size: 14px;
}

.invoice-table th,
.invoice-table td {
  border: 1px solid #d1d5db;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.invoice-table th {
  background: #f3f4f6;
  color: #000;
  font-weight: 900;
}

.invoice-table th:nth-child(1),
.invoice-table td:nth-child(1),
.invoice-table th:nth-child(3),
.invoice-table td:nth-child(3),
.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4) {
  text-align: center;
}

.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5),
.invoice-table th:nth-child(6),
.invoice-table td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
}

.invoice-english {
  display: block;
  margin-top: 3px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

.invoice-total {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: #000;
  font-weight: 900;
}

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

.invoice-total span {
  color: #374151;
}

.invoice-total strong {
  text-align: right;
  font-size: 24px;
}

.warning {
  margin: 12px 0;
  border-radius: 12px;
  padding: 12px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 900;
}

.empty {
  border: 1px dashed #b9d4c2;
  border-radius: 16px;
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 40;
  max-width: min(88vw, 460px);
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

@media (max-width: 820px) {
  #productList,
  #weightList,
  .category-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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

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

  .between {
    flex-direction: column;
  }

  .money {
    white-space: normal;
  }

  .caption {
    max-width: 230px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }

  .customer-hero {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    border-radius: 18px;
    padding: 12px;
  }

  .customer-hero img {
    width: 72px;
    height: 72px;
    border-radius: 14px;
  }

  .customer-hero h1 {
    font-size: 20px;
  }

  .customer-hero p {
    font-size: 13px;
  }

  .tab {
    min-height: 58px;
    padding-inline: 6px;
  }

  .customer-total {
    align-items: stretch;
  }

  .customer-total-actions {
    flex: 1;
  }

  .customer-total-actions button {
    flex: 1;
    padding-inline: 8px;
  }
}

@media (max-width: 360px) {
  #productList,
  #weightList,
  .category-products {
    grid-template-columns: 1fr;
  }
}
