:root {
  --ink: #161917;
  --muted: #707672;
  --line: #e7e8e5;
  --paper: #f7f8f5;
  --white: #ffffff;
  --green: #1d6a4a;
  --green-soft: #e8f2ec;
  --red: #d94a37;
  --red-soft: #fce9e5;
  --amber: #f0a62b;
  --shadow: 0 14px 36px rgba(25, 31, 27, 0.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body { min-width: 320px; letter-spacing: 0; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(29, 106, 74, .22); outline-offset: 2px; }
.hidden { display: none !important; }
.app-shell { width: 100%; min-height: 100vh; max-width: 720px; margin: 0 auto; background: var(--paper); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  min-height: calc(72px + var(--safe-top)); padding: calc(12px + var(--safe-top)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--white); background: #151716;
}
.topbar h1 { margin: 2px 0 0; font-size: 22px; line-height: 1.15; }
.eyebrow { margin: 0; color: #aeb5b0; font-size: 11px; }
.summary-pill {
  border: 1px solid #353a36; border-radius: 8px; padding: 7px 10px; min-width: 84px;
  color: var(--white); background: #222623; text-align: right;
}
.summary-pill span { display: block; color: #aeb5b0; font-size: 10px; }
.summary-pill strong { display: block; margin-top: 1px; font-size: 15px; }

main { padding-bottom: calc(78px + var(--safe-bottom)); }
.view { display: none; padding: 18px 14px 96px; }
.view.active { display: block; }
.section-heading, .page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-kicker { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 650; }
h2 { margin: 0; font-size: 23px; line-height: 1.2; }
h3 { margin: 0; font-size: 16px; }
.status-badge, .live-dot, .offline-label { border-radius: 999px; padding: 5px 9px; color: var(--green); background: var(--green-soft); font-size: 11px; font-weight: 700; }
.status-badge.busy { color: #a23a2e; background: var(--red-soft); }

.table-strip, .category-strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
.table-strip::-webkit-scrollbar, .category-strip::-webkit-scrollbar { display: none; }
.table-strip { padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.table-button {
  position: relative; flex: 0 0 56px; height: 58px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); font-size: 17px; font-weight: 750;
}
.table-button small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.table-button.busy::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.table-button.active { color: var(--white); border-color: var(--green); background: var(--green); }
.table-button.active small { color: #d9ece1; }
.category-strip { padding-top: 15px; padding-bottom: 13px; }
.category-strip button {
  flex: 0 0 auto; height: 34px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px;
  color: #565c58; background: var(--white); font-size: 13px;
}
.category-strip button.active { color: var(--white); border-color: var(--ink); background: var(--ink); }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.product-card {
  position: relative; min-height: 88px; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  background: var(--white); text-align: left; overflow: hidden;
}
.product-card:active { transform: scale(.985); background: #f1f5f2; }
.product-card-name { width: calc(100% - 28px); overflow-wrap: anywhere; font-size: 15px; font-weight: 700; }
.product-card-price { color: var(--red); font-size: 17px; font-weight: 800; }
.product-card-price small { font-size: 10px; font-weight: 600; }
.product-qty {
  position: absolute; top: 9px; right: 9px; min-width: 23px; height: 23px; border-radius: 50%; padding: 0 5px;
  display: grid; place-items: center; color: var(--white); background: var(--green); font-size: 12px; font-weight: 800;
}
.cart-bar {
  position: fixed; z-index: 25; left: max(12px, calc((100vw - 696px) / 2)); right: max(12px, calc((100vw - 696px) / 2)); bottom: calc(70px + var(--safe-bottom));
  min-height: 62px; border: 0; border-radius: 8px; padding: 8px 12px;
  display: flex; align-items: center; gap: 10px; color: var(--white); background: #151716; box-shadow: var(--shadow); text-align: left;
}
.cart-bar.empty { opacity: .72; }
.cart-count { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: var(--amber); font-weight: 800; }
.cart-copy { display: flex; flex-direction: column; flex: 1; }
.cart-copy small { color: #afb5b0; font-size: 10px; }
.cart-copy strong { margin-top: 2px; font-size: 20px; }
.cart-action { font-size: 13px; font-weight: 700; }

.bottom-nav {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(62px + var(--safe-bottom)); padding: 5px max(8px, calc((100vw - 704px) / 2)) var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid #dedfdd; background: rgba(255,255,255,.97); backdrop-filter: blur(18px);
}
.bottom-nav button { min-width: 0; border: 0; background: transparent; color: #7a807c; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.bottom-nav button span { height: 25px; font-size: 20px; line-height: 24px; }
.bottom-nav button small { font-size: 10px; }
.bottom-nav button.active { color: var(--green); font-weight: 750; }

.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; background: var(--white); font-size: 23px; line-height: 1; }
.primary-button, .secondary-button, .danger-button, .checkout-button { min-height: 44px; border-radius: 8px; padding: 0 15px; font-weight: 750; }
.primary-button { border: 0; color: var(--white); background: var(--green); }
.primary-button.compact { min-height: 38px; }
.primary-button.full, .checkout-button { width: 100%; }
.secondary-button { border: 1px solid var(--line); background: var(--white); }
.danger-button { width: 100%; border: 1px solid #efc7c1; color: #b63b2d; background: #fff7f5; }
.checkout-button { min-height: 52px; border: 0; color: var(--white); background: var(--red); font-size: 16px; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; margin-bottom: 14px; border-radius: 8px; background: #e9ebe7; }
.segmented button { height: 34px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 13px; }
.segmented button.active { color: var(--ink); background: var(--white); box-shadow: 0 2px 8px rgba(25,31,27,.08); font-weight: 700; }
.order-list, .product-list { display: flex; flex-direction: column; gap: 8px; }
.order-card, .manage-card { border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.order-card { width: 100%; padding: 13px; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 11px; align-items: center; text-align: left; }
.order-table { width: 48px; height: 48px; border-radius: 8px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); font-weight: 800; }
.order-card.voided { opacity: .58; }
.order-card.voided .order-table { color: var(--muted); background: #eef0ed; }
.order-main strong, .order-main small { display: block; }
.order-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.order-main small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.order-amount { text-align: right; }
.order-amount strong, .order-amount small { display: block; }
.order-amount strong { font-size: 16px; }
.order-amount small { margin-top: 4px; color: var(--muted); font-size: 10px; }

.search-box { height: 42px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; display: flex; align-items: center; gap: 8px; background: var(--white); }
.search-box span { color: var(--muted); font-size: 20px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; }
.management-summary { margin-bottom: 11px; color: var(--muted); font-size: 12px; }
.manage-card { padding: 12px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; }
.manage-info { min-width: 0; }
.manage-info strong { display: block; overflow-wrap: anywhere; font-size: 15px; }
.manage-info span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.manage-price { color: var(--red); font-size: 15px; font-weight: 800; }
.switch { position: relative; width: 45px; height: 27px; border: 0; border-radius: 999px; padding: 0; background: #cfd3cf; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: left .15s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 21px; }
.edit-product { border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 700; padding: 8px 0; }

.stat-hero { border-radius: 8px; padding: 20px; color: var(--white); background: #151716; }
.stat-hero span, .stat-hero small { display: block; color: #b7bcb8; }
.stat-hero span { font-size: 12px; }
.stat-hero strong { display: block; margin: 8px 0 6px; font-size: 36px; line-height: 1; }
.stat-hero small { font-size: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.stat-grid article { min-height: 91px; border: 1px solid var(--line); border-radius: 8px; padding: 13px; background: var(--white); }
.stat-grid span { display: block; color: var(--muted); font-size: 11px; }
.stat-grid strong { display: inline-block; margin-top: 12px; font-size: 23px; }
.stat-grid small { margin-left: 3px; color: var(--muted); font-size: 10px; }
.report-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.report-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.report-heading span { color: var(--muted); font-size: 11px; }
.ranking-list { display: flex; flex-direction: column; gap: 10px; }
.ranking-row { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; align-items: center; gap: 9px; }
.rank-number { color: var(--muted); font-size: 12px; font-weight: 800; }
.ranking-copy { min-width: 0; }
.ranking-title { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.ranking-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-title span { color: var(--muted); }
.rank-bar { height: 6px; margin-top: 5px; border-radius: 999px; background: #e7ebe7; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.ranking-revenue { color: var(--red); font-size: 12px; font-weight: 700; }
.payment-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.payment-card { border: 1px solid var(--line); border-radius: 8px; padding: 11px; background: var(--white); }
.payment-card span, .payment-card small { display: block; }
.payment-card span { color: var(--muted); font-size: 11px; }
.payment-card strong { display: block; margin: 6px 0 2px; font-size: 16px; }
.payment-card small { color: var(--muted); font-size: 9px; }
.week-chart { height: 150px; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 6px; padding-top: 15px; }
.day-column { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.day-column strong { margin-bottom: 4px; font-size: 8px; color: var(--muted); }
.day-bar { width: min(25px, 75%); min-height: 3px; border-radius: 3px 3px 0 0; background: #a9c7b7; }
.day-column.today .day-bar { background: var(--green); }
.day-column span { margin-top: 6px; color: var(--muted); font-size: 9px; }

.settings-group { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 15px; background: var(--white); }
.settings-group h3 { margin-bottom: 10px; }
.field-row { min-height: 50px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.field-row input { min-width: 0; width: 150px; border: 0; text-align: right; outline: 0; }
.stepper { display: grid; grid-template-columns: 36px 50px 36px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.stepper button, .stepper input { width: auto; height: 34px; border: 0; background: var(--paper); text-align: center; }
.stepper input { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--white); }
.settings-note, .install-tip p { margin: 0 0 13px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.danger-zone h3 { color: #a23a2e; }
.version-label { color: #9ba09c; text-align: center; font-size: 10px; }

.modal-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(10,12,11,.48); backdrop-filter: blur(2px); }
.bottom-sheet, .dialog { position: fixed; z-index: 70; left: 50%; width: min(100%, 540px); background: var(--white); box-shadow: var(--shadow); }
.bottom-sheet { bottom: 0; max-height: 88vh; transform: translateX(-50%); border-radius: 8px 8px 0 0; padding: 8px 16px calc(16px + var(--safe-bottom)); overflow-y: auto; }
.dialog { top: 50%; max-height: 88vh; transform: translate(-50%, -50%); border-radius: 8px; padding: 16px; overflow-y: auto; }
.sheet-handle { width: 36px; height: 4px; margin: 0 auto 12px; border-radius: 999px; background: #d8dbd8; }
.sheet-header, .dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-header { margin-bottom: 18px; }
.cart-items { max-height: 42vh; margin: 14px 0; overflow-y: auto; }
.cart-item { min-height: 58px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 10px; }
.cart-item-copy { min-width: 0; }
.cart-item-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cart-item-copy small { color: var(--muted); font-size: 10px; }
.cart-item-total { font-size: 13px; font-weight: 750; }
.qty-stepper { display: grid; grid-template-columns: 30px 27px 30px; align-items: center; }
.qty-stepper button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font-size: 18px; }
.qty-stepper span { text-align: center; font-size: 13px; font-weight: 750; }
.note-field { min-height: 48px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.note-field span { font-size: 12px; font-weight: 700; }
.note-field input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 12px; }
.sheet-footer { padding-top: 12px; border-top: 1px solid var(--line); }
.total-line { margin-bottom: 11px; display: flex; align-items: center; justify-content: space-between; }
.total-line span { color: var(--muted); font-size: 12px; }
.total-line strong { font-size: 25px; }
.checkout-amount { padding: 18px; margin-bottom: 18px; border-radius: 8px; background: var(--paper); text-align: center; }
.checkout-amount span { display: block; color: var(--muted); font-size: 12px; }
.checkout-amount strong { display: block; margin-top: 7px; font-size: 34px; }
.form-label { margin: 0 0 9px; color: var(--muted); font-size: 11px; }
.payment-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.payment-options button { height: 48px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; gap: 7px; background: var(--white); }
.payment-options button.active { border: 2px solid var(--green); background: var(--green-soft); font-weight: 750; }
.pay-icon { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--white); font-size: 11px; font-weight: 800; }
.wechat { background: #35a853; }.alipay { background: #168cff; }.cash { background: #e19a27; }.other { background: #707672; }
.form-field { display: block; margin-bottom: 14px; }
.form-field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.form-field input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--white); }
.order-detail-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.order-detail-meta div { border-radius: 7px; padding: 10px; background: var(--paper); }
.order-detail-meta span, .order-detail-meta strong { display: block; }
.order-detail-meta span { color: var(--muted); font-size: 9px; }
.order-detail-meta strong { margin-top: 4px; font-size: 13px; }
.detail-items { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 13px; }
.detail-row { min-height: 38px; display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; font-size: 12px; }
.detail-row span:nth-child(2) { color: var(--muted); }
.detail-total { display: flex; justify-content: space-between; margin-bottom: 14px; font-size: 14px; }
.detail-total strong { font-size: 20px; }
.void-label { margin: 0 0 13px; border-radius: 7px; padding: 10px; color: #a23a2e; background: var(--red-soft); font-size: 11px; text-align: center; }

.empty-state { padding: 55px 18px; text-align: center; }
.empty-state.compact-empty { padding: 34px 18px; }
.empty-icon { width: 44px; height: 44px; margin: 0 auto 11px; border-radius: 50%; display: grid; place-items: center; color: var(--green); background: var(--green-soft); font-size: 25px; }
.empty-state h3 { margin-bottom: 7px; }
.empty-state p { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(82px + var(--safe-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); border-radius: 7px; padding: 10px 14px; color: var(--white); background: rgba(21,23,22,.94); box-shadow: var(--shadow); font-size: 12px; white-space: nowrap; }

@media (min-width: 560px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .view { padding-left: 20px; padding-right: 20px; }
  .table-strip, .category-strip { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
}

@media (max-height: 700px) {
  .product-card { min-height: 78px; }
  .view { padding-top: 12px; }
}
