:root {
  --ink: #17212b;
  --muted: #667085;
  --line: #dde5ea;
  --panel: #ffffff;
  --page: #f6f8fb;
  --mint: #168164;
  --mint-soft: #eaf8f3;
  --danger: #d94444;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--page);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(430px, 100%);
  display: grid;
  gap: 13px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.auth-card input,
.field-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

.auth-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  min-height: 100vh;
}

main,
.page {
  padding: 24px;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
}

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

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

.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: conic-gradient(from 180deg, #f9dcdc, #f9efb8, #d3f2df, #cce8f7, #f9dcdc);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(47, 184, 143, 0.18);
}

.mark::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 45% 45%;
  background: #fff;
  box-shadow: -7px 5px 0 #f5a9bc, 7px 5px 0 #8bdac1;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.subtle {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

.toolbar,
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search {
  width: min(38vw, 360px);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 48px;
  outline: none;
}

.ghost,
.button,
.range button,
.mini-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 46px;
}

.button.primary,
.primary {
  background: var(--mint);
  border-color: var(--mint);
  color: #fff;
}

.button.danger,
.mini-button.danger {
  border-color: rgba(217, 68, 68, 0.35);
  color: var(--danger);
}

.tabs,
.range {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab,
.range button {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;
}

.tab.active,
.range button.active {
  color: #fff;
  background: var(--mint);
  border-color: var(--mint);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.product {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 318px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(31, 45, 61, 0.05);
}

.product.low {
  border-color: rgba(217, 68, 68, 0.45);
}

.product-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fbf5e9;
  border-bottom: 1px solid var(--line);
  display: block;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.product h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.price {
  font-size: 24px;
  font-weight: 750;
  color: var(--mint);
}

.add,
.primary {
  width: 100%;
  min-height: 54px;
  border-radius: 8px;
  padding: 12px;
  font-weight: 760;
}

aside {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  padding: 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  box-shadow: var(--shadow);
}

.cart-head,
.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cart-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.cart-head h2,
.panel h2 {
  margin: 0;
  font-size: 20px;
}

.cart-list {
  overflow: auto;
  padding: 14px 2px;
}

.empty {
  color: var(--muted);
  padding: 24px 16px;
}

.cart-item {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.cart-title {
  font-weight: 720;
}

.qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafb;
}

.remove {
  color: var(--danger);
  background: transparent;
  padding: 8px;
}

.checkout {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.summary div {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.summary .total {
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  padding-top: 6px;
}

.pay-methods,
.cash-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

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

.pay,
.cash-preset {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 6px;
  min-height: 52px;
}

.pay.active {
  background: var(--mint-soft);
  border-color: var(--mint);
  color: var(--mint);
  font-weight: 720;
}

.cash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.change {
  text-align: right;
  color: var(--muted);
  font-size: 14px;
}

.reports,
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 18px;
}

.stat,
.card,
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(31, 45, 61, 0.05);
}

.stat,
.card {
  padding: 14px;
}

.stat span,
.card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat strong,
.card strong {
  font-size: 22px;
}

.panel {
  overflow: hidden;
  margin-bottom: 18px;
}

.panel h2 {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.list,
.close-form {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.close-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.close-form label {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 7px;
}

.close-value {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #f8fafb;
  color: var(--ink);
  font-weight: 750;
}

.close-history {
  border-top: 1px solid var(--line);
  padding: 12px 16px 14px;
  color: var(--muted);
  font-size: 14px;
}

.bar-row,
.stock-item {
  display: grid;
  gap: 7px;
}

.stock-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.stock-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.mini-button.active {
  background: #fff1f1;
  border-color: rgba(217, 68, 68, 0.35);
  color: var(--danger);
  font-weight: 750;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f5;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--mint);
  min-width: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 650;
  background: #f8fafb;
}

.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.2s ease;
}

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

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

  aside {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .reports,
  .stats,
  .dashboard,
  .close-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  main,
  .page,
  aside {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .actions {
    justify-content: flex-start;
  }

  .search {
    width: 100%;
  }

  .grid,
  .reports,
  .stats,
  .dashboard,
  .close-form {
    grid-template-columns: 1fr;
  }

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