:root {
  --ink: #171827;
  --muted: #737786;
  --bg: #f6f4f1;
  --card: #ffffff;
  --line: #dedbd6;
  --blue: #2b6cb0;
  --blue-bg: #e9f2ff;
  --gold: #9a6a12;
  --gold-bg: #fff2d9;
  --brand: #18182b;
  --accent: #0f766e;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background: #efefef;
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.phone {
  width: min(100vw, 390px);
  height: min(100vh, 844px);
  min-height: 680px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid #cfcfcf;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, .18);
}

.app-header {
  color: #fff;
  background: var(--brand);
}

.statusbar {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-size: 12px;
  font-weight: 700;
}

.titlebar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

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

.brand h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.truck {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: #d9efff;
  font-size: 15px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  font-size: 20px;
}

.app-main {
  position: relative;
  height: calc(100% - 84px - 64px);
  overflow: auto;
  padding: 14px 12px 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 46px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.tab {
  position: relative;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--ink);
}

.order-list,
.simple-list {
  display: grid;
  gap: 0;
}

.order-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  min-height: 84px;
  padding: 12px;
  margin: 0 0 -1px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.order-no {
  font-weight: 700;
  font-size: 14px;
}

.badge {
  align-self: start;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
}

.badge.printed {
  color: var(--blue);
  background: var(--blue-bg);
}

.badge.reprint {
  color: var(--gold);
  background: var(--gold-bg);
}

.customer {
  grid-column: 1;
  font-weight: 700;
  font-size: 15px;
}

.time {
  grid-column: 1;
  color: var(--muted);
  font-size: 13px;
}

.amount {
  grid-column: 2;
  grid-row: 3;
  align-self: end;
  font-weight: 800;
  font-size: 15px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
}

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

.form-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card h3,
.card-head h3 {
  margin: 0;
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

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

.check input {
  width: 16px;
  height: 16px;
}

.pill,
.wide {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--accent);
  background: #e7f4f0;
}

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

.wide {
  width: 100%;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 68px 82px 34px;
  gap: 8px;
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.item-row label {
  min-width: 0;
}

.item-row .product-name-field {
  grid-column: 1 / -1;
}

.item-row input {
  height: 36px;
  padding: 0 8px;
}

.item-row select {
  height: 38px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-btn {
  width: 34px;
  height: 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--danger);
}

.line-amount {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.summary strong {
  font-size: 16px;
}

.total-edit {
  width: 148px;
  color: var(--ink);
  font-weight: 700;
}

.total-edit input {
  height: 36px;
  margin-top: 4px;
  text-align: right;
  font-weight: 800;
}

.discount-info {
  min-height: 18px;
  color: var(--gold);
  font-size: 13px;
  text-align: right;
}

.hint,
.empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.count-pill {
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--blue);
  background: var(--blue-bg);
  font-size: 12px;
}

.product-tools {
  margin-bottom: 10px;
}

.product-form-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 10px;
}

.product-list,
.customer-list {
  display: grid;
  gap: 10px;
}

.product-card,
.customer-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.product-main strong,
.customer-main strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}

.product-meta,
.customer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.product-price {
  align-self: start;
  font-size: 17px;
  font-weight: 800;
}

.product-remark {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.customer-address,
.customer-remark {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.product-actions,
.customer-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.product-actions button,
.customer-actions button {
  height: 34px;
  border-radius: 8px;
  color: var(--ink);
  background: #f1f3f5;
}

.product-actions .use,
.customer-actions .use {
  color: #fff;
  background: var(--accent);
}

.product-actions .remove,
.customer-actions .remove {
  color: #fff;
  background: var(--danger);
}

.printer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-text {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #f1f3f5;
  font-size: 13px;
}

.status-text.ok {
  color: var(--accent);
  background: #e7f4f0;
}

.status-text.error {
  color: var(--danger);
  background: #fff0ee;
}

.simple-item {
  padding: 14px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}

.simple-item strong {
  display: block;
  margin-bottom: 4px;
}

.bottom-nav {
  height: 64px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
}

.nav {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: #34394a;
  background: transparent;
  font-size: 11px;
}

.nav span {
  font-size: 20px;
  line-height: 1;
}

.nav.active {
  color: #0e4b76;
}

.receipt {
  display: none;
  width: 80mm;
  color: #000;
  background: #fff;
  font-family: "SimSun", "Microsoft YaHei", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.receipt h3 {
  margin: 0 0 10px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
}

.receipt .divider {
  border-top: 1px dashed #000;
  margin: 6px 0;
}

.receipt table {
  width: 100%;
  border-collapse: collapse;
}

.receipt th,
.receipt td {
  padding: 2px 1px;
  text-align: left;
}

.receipt .right {
  text-align: right;
}

.receipt .sign {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

@media (max-width: 420px) {
  body {
    display: block;
    background: var(--bg);
  }

  .phone {
    width: 100vw;
    height: 100vh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media print {
  body {
    display: block;
    background: #fff;
  }

  body * {
    visibility: hidden;
  }

  #printArea,
  #printArea * {
    display: block;
    visibility: visible;
  }

  #printArea table,
  #printArea thead,
  #printArea tbody,
  #printArea tr {
    display: table;
    width: 100%;
  }

  #printArea th,
  #printArea td {
    display: table-cell;
  }

  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    margin: 0;
    padding: 3mm;
  }

  @page {
    size: 80mm auto;
    margin: 0;
  }
}
