:root {
  color-scheme: dark;
  --bg: #07130f;
  --panel: #121715;
  --panel-2: #090d0b;
  --line: #29312e;
  --text: #f8fafc;
  --muted: #a1a1aa;
  --green: #10b981;
  --lime: #86efac;
  --red: #ef4444;
  --amber: #fbbf24;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  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: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

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

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

.caption {
  margin-top: 3px;
  color: var(--muted);
  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: #03120d;
}

.secondary,
.icon-button {
  border: 1px solid #3f3f46;
  background: #27272a;
  color: #fff;
}

.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);
}

.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;
}

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

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

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

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

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

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid #3f3f46;
  border-radius: 12px;
  padding: 0 12px;
  background: #09090b;
  color: #fff;
  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,
#customerProductList {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card {
  padding: 14px;
}

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

.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(--lime);
  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: #134e4a;
  color: #a7f3d0;
  font-size: 12px;
  font-weight: 900;
}

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

.pill.warn {
  background: #451a03;
  color: #fde68a;
}

.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;
}

.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(5, 8, 7, 0.96);
  backdrop-filter: blur(10px);
}

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

.sticky-total strong {
  display: block;
  color: var(--lime);
  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(5, 8, 7, 0.98);
}

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

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

.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: #000;
}

.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 #3f3f46;
  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: #fff;
  color: #111827;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

@media (max-width: 820px) {
  #productList,
  #weightList,
  #customerProductList {
    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;
  }

  .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,
  #customerProductList {
    grid-template-columns: 1fr;
  }
}
