:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f3f4f6;
  color: #111827;
  --bg: #f7f8fa;
  --card: #ffffff;
  --line: #e5e7eb;
  --muted: #6b7280;
  --soft: #f1f5f9;
  --ink: #111827;
  --accent: #111827;
  --good: #0f766e;
  --warn: #c2410c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef1f4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.phone-shell {
  position: relative;
  width: min(100vw, 430px);
  min-height: 100vh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--bg);
}

.view {
  display: none;
  min-height: 100vh;
  padding-bottom: 88px;
}

.view-active {
  display: block;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 18px 18px;
  background: var(--bg);
  color: var(--ink);
}

.hero-header.admin {
  background: var(--bg);
}

.hero-header p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  font-size: 26px;
  line-height: 1.12;
  letter-spacing: 0;
}

.ghost-pill {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-weight: 800;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.buyer-panel,
.panel,
.login-panel,
.total-panel,
.detail-panel,
.stats-panel,
.product-card,
.order-card,
.product-admin-card,
.user-admin-card,
.audit-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: none;
}

.buyer-panel,
.panel,
.login-panel,
.total-panel {
  margin: 10px 14px;
  padding: 14px;
}

.buyer-panel,
.login-panel,
.panel {
  display: grid;
  gap: 12px;
}

.field,
.user-admin-card label {
  display: grid;
  gap: 7px;
  color: #374151;
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field textarea,
.user-admin-card input,
.user-admin-card select,
.product-form select,
.product-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: 0;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field textarea:focus,
.search-box:focus-within,
.product-form input:focus,
.product-form select:focus,
.user-admin-card input:focus,
.user-admin-card select:focus {
  border-color: #9ca3af;
}

.field input:disabled {
  background: var(--soft);
  color: #4b5563;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #9ca3af;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 14px;
}

.metric-row div {
  min-width: 0;
  padding: 13px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  text-align: center;
}

.metric-row strong,
.metric-row span {
  display: block;
}

.metric-row strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.category-tabs,
.segmented {
  display: flex;
  gap: 8px;
  margin: 12px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-tabs button,
.segmented button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--soft);
  color: #4b5563;
  font-size: 13px;
  font-weight: 800;
}

.category-tabs button.active,
.segmented button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.product-list,
.order-list,
.line-list,
.product-admin-list {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.product-card {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.product-thumb {
  display: grid;
  width: 60px;
  height: 60px;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 14%, #fff);
  color: var(--tone);
  font-size: 18px;
  font-weight: 900;
}

.product-main {
  min-width: 0;
}

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

.product-title h3 {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-title span,
.product-main p,
.order-head span,
.order-foot span,
.order-lines p,
.detail-head span,
.detail-meta p,
.product-admin-card span,
.user-card-head span,
.hint,
.stats-total span,
.stats-list span {
  color: var(--muted);
  font-size: 12px;
}

.product-main p {
  margin-top: 7px;
}

.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.product-bottom strong,
.line-item strong,
.total-panel strong,
.order-foot strong,
.product-admin-card b,
.stats-total b,
.stats-list b {
  color: var(--warn);
}

.product-bottom strong {
  font-size: 16px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 7px;
}

.stepper button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.stepper .add {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.stepper input {
  width: 42px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: center;
  font-weight: 900;
}

.cart-bar {
  position: fixed;
  right: max(0px, calc((100vw - 430px) / 2));
  bottom: 56px;
  left: max(0px, calc((100vw - 430px) / 2));
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100vw, 430px);
  margin: 0 auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(14px);
}

.cart-summary {
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  flex: 1;
  column-gap: 10px;
  align-items: center;
  min-width: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.cart-summary span {
  display: grid;
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.cart-summary strong {
  color: var(--warn);
}

.cart-summary small {
  color: var(--muted);
}

.primary-action,
.submit-order,
.product-form button,
.pay-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.primary-action:disabled {
  background: #d1d5db;
}

.sub-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 58px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(14px);
}

.sub-header h2 {
  text-align: center;
  font-size: 17px;
}

.back-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.section-head,
.line-item,
.order-head,
.order-foot,
.product-admin-card,
.detail-head,
.stats-total,
.stats-list article,
.user-card-head,
.user-actions,
.audit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-list {
  padding: 0;
}

.line-item {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.line-item:first-child {
  border-top: 0;
}

.line-item h4,
.order-head strong {
  font-size: 14px;
}

.line-item p,
.total-panel p,
.detail-meta p {
  margin-top: 4px;
}

.total-panel div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-panel strong {
  font-size: 22px;
}

.submit-order {
  width: calc(100% - 28px);
  margin: 0 14px 14px;
}

.order-card {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.order-head strong,
.order-head span,
.detail-head strong,
.detail-head span,
.product-admin-card strong,
.product-admin-card span,
.product-admin-card b,
.user-card-head strong,
.user-card-head span,
.audit-card strong,
.audit-card span {
  display: block;
}

.product-admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.order-head em,
.detail-head em,
.user-card-head em,
.audit-card em {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.order-head em.unpaid,
.detail-head em.unpaid {
  background: #fff7ed;
  color: var(--warn);
}

.order-head em.paid,
.detail-head em.paid,
.user-card-head em.active {
  background: #ecfdf5;
  color: var(--good);
}

.order-head em.cancelled,
.detail-head em.cancelled,
.user-card-head em.disabled {
  background: var(--soft);
  color: #667586;
}

.order-lines {
  display: grid;
  gap: 4px;
}

.order-foot strong {
  font-size: 18px;
}

.order-actions,
.user-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

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

.order-actions button,
.user-actions button,
.product-admin-card button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.audit-card {
  padding: 13px;
}

.audit-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.audit-card em {
  background: var(--soft);
  color: #4b5563;
  text-align: right;
}

.order-actions button:disabled,
.user-actions button:disabled,
.product-admin-card button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.order-actions button.danger,
.user-actions button.danger,
.product-admin-card button.danger {
  background: #fef2f2;
  color: #b42318;
}

.order-detail,
.stats-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.stats-filter {
  display: grid;
  gap: 8px;
  margin: 0 14px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.stats-filter input,
.stats-filter select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: 0;
  background: #fff;
  color: var(--ink);
}

.quick-range,
.filter-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.filter-actions {
  grid-template-columns: 1fr 1fr 1fr;
}

.quick-range button,
.filter-actions button {
  min-height: 38px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.quick-range button.active,
.filter-actions button:first-child {
  background: var(--ink);
  color: #fff;
}

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

.stats-summary article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

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

.stats-summary strong {
  color: var(--ink);
  font-size: 18px;
}

.detail-panel,
.stats-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.stats-panel h3 {
  font-size: 15px;
}

.stats-total strong {
  color: var(--ink);
  font-size: 30px;
}

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

.stats-list article {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.stats-list article:first-child {
  padding-top: 0;
  border-top: 0;
}

.bar-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  align-items: center;
  justify-content: stretch;
  gap: 12px;
  overflow: hidden;
}

.bar-row > div,
.bar-row > b {
  position: relative;
  z-index: 1;
}

.bar-row > div {
  min-width: 0;
}

.bar-row > b {
  width: 132px;
  justify-self: end;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.stats-orders {
  display: grid;
  gap: 8px;
}

.stat-order {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.stat-order strong,
.stat-order span,
.stat-order b {
  display: block;
}

.stat-order em {
  justify-self: end;
  min-width: 64px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.stat-order > span {
  justify-self: end;
  text-align: right;
}

.stat-order em.unpaid {
  background: #fff7ed;
  color: var(--warn);
}

.stat-order em.paid {
  background: #ecfdf5;
  color: var(--good);
}

.login-panel {
  display: grid;
  gap: 12px;
}

.hint {
  line-height: 1.5;
}

.hidden,
.unit-admin[hidden],
.admin-workbench.is-locked {
  display: none;
}

.admin-tab {
  display: none;
}

.admin-tab.active {
  display: block;
}

.admin-metrics strong {
  font-size: 14px;
}

.product-form {
  display: grid;
  gap: 8px;
  margin: 0 14px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.store-picker {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.store-picker p {
  color: #374151;
  font-size: 12px;
  font-weight: 800;
}

.store-picker div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.store-picker label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.store-picker label span {
  color: #667586;
  font-weight: 800;
}

.store-picker input {
  width: auto;
}

.product-form button {
  width: 100%;
}

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

.product-form .secondary-action {
  background: var(--soft);
  color: var(--ink);
}

.admin-category-tabs {
  padding: 0 14px 10px;
}

.unit-admin {
  display: grid;
  gap: 10px;
  margin: 0 14px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

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

.unit-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: 0;
  background: #fff;
  color: var(--ink);
}

.unit-form button,
.unit-chip button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

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

.unit-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.unit-chip button {
  min-height: 26px;
  padding: 0 8px;
  background: #fef2f2;
  color: #b42318;
}

.product-admin-card,
.user-admin-card {
  padding: 12px;
}

.user-admin-card {
  display: grid;
  gap: 10px;
}

.bottom-nav {
  position: fixed;
  right: max(0px, calc((100vw - 430px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 430px) / 2));
  display: grid;
  grid-template-columns: repeat(var(--nav-count, 3), 1fr);
  width: min(100vw, 430px);
  height: 56px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.bottom-nav.nav-hidden {
  display: none;
}

.bottom-nav button[hidden] {
  display: none;
}

.bottom-nav button {
  background: transparent;
  color: #6b7280;
  font-weight: 900;
}

.bottom-nav button.active {
  color: var(--ink);
}

.site-footer {
  display: grid;
  gap: 4px;
  padding: 18px 18px 76px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.empty-state {
  padding: 28px 14px;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 112px;
  z-index: 5;
  max-width: min(330px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transform: translate(50%, 12px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(50%, 0);
}

@media (max-width: 360px) {
  .product-card {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .product-thumb {
    width: 54px;
    height: 54px;
  }

  .primary-action {
    padding: 0 12px;
  }
}
