:root {
  /* 华为风格：深蓝主色 + 白底卡片 + 丝滑动效 */
  --bg: #f1f3f5;
  --bg-accent: #e5eaf2;
  --surface: #ffffff;
  --ink: #182431;
  --muted: #6b7785;
  --line: #e4e8ee;
  --primary: #0a59f7;
  --primary-dark: #0047d4;
  --primary-soft: #e8f0fe;
  --warn: #c27a0e;
  --warn-soft: #fff6e8;
  --danger: #e84026;
  --danger-soft: #fef1ef;
  --ok: #00a870;
  --ok-soft: #e8f8f1;
  --amount-sales: #0a59f7;
  --amount-profit: #00a870;
  --shadow: 0 10px 32px rgba(10, 40, 100, 0.08);
  --shadow-sm: 0 2px 10px rgba(10, 40, 100, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.12, 0.64, 1);
  --font: "Noto Sans SC", "PingFang SC", "HarmonyOS Sans", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.55;
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 480px at 12% -10%, rgba(10, 89, 247, 0.10), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(0, 71, 212, 0.06), transparent 50%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 42%, #e9eef6 100%);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  touch-action: manipulation;
}

.app {
  width: min(1240px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(228, 232, 238, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: box-shadow 0.28s var(--ease), transform 0.28s var(--ease);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2f7bff 0%, var(--primary) 55%, var(--primary-dark) 100%);
  color: white;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px rgba(10, 89, 247, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

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

.store-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #f0f3f8;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.store-switcher[hidden] {
  display: none !important;
}

.store-switcher-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

.store-switcher select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: #fff;
  min-width: 120px;
  max-width: 180px;
  color: var(--ink);
}

.store-switcher select:disabled {
  color: var(--ink);
  opacity: 1;
  background: #eef2f8;
  cursor: default;
}

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.dashboard-total {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-total-card {
  min-width: 148px;
  padding: 12px 14px 12px 16px;
  border-radius: var(--radius-sm);
  background: #f5f7fb;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
}

.dashboard-total-card--sales {
  border-left-color: var(--primary);
  background: var(--primary-soft);
}

.dashboard-total-card--profit {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.dashboard-total-card--count {
  border-left-color: #5b6b7c;
  background: #f3f5f7;
}

.dashboard-total-card .k {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.dashboard-total-card .v {
  margin-top: 4px;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dashboard-total-card .v.sales {
  color: var(--amount-sales);
}

.dashboard-total-card .v.profit-pos {
  color: var(--amount-profit);
}

.dashboard-total-card .v.profit-neg {
  color: var(--danger);
}

.dashboard-total-card .v.profit-zero {
  color: var(--muted);
}

.dashboard-total-card .v.count {
  color: var(--muted);
}

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

.dash-store-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.28s var(--ease), box-shadow 0.28s var(--ease), transform 0.28s var(--ease-spring);
}

.dash-store-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.dash-store-card.is-disabled {
  opacity: 0.72;
}

.dash-store-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.dash-store-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.dash-store-metrics {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.dash-metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.dash-metric .k {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.dash-metric .v {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dash-metric .v.sales {
  color: var(--amount-sales);
}

.dash-metric .v.profit-pos {
  color: var(--amount-profit);
}

.dash-metric .v.profit-neg {
  color: var(--danger);
}

.dash-metric .v.profit-zero {
  color: var(--muted);
}

.dash-metric .v.count {
  color: var(--muted);
  font-size: 16px;
}

.panel-block {
  margin-bottom: 22px;
}

.auth-store-list {
  display: grid;
  gap: 4px;
  max-width: 220px;
}

.auth-store-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.person-name-block {
  display: grid;
  gap: 4px;
  line-height: 1.35;
}

.tel-link {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(10, 89, 247, 0.35);
}

.tel-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tel-link.muted {
  color: var(--muted);
  font-weight: 500;
  border-bottom-color: rgba(102, 120, 114, 0.35);
}

.tel-link.muted:hover {
  color: var(--primary-dark);
  border-bottom-color: var(--primary-dark);
}

.person-name-block .field-note {
  display: inline-block;
  min-width: 3em;
  margin-right: 4px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition:
    background 0.28s var(--ease),
    color 0.28s var(--ease),
    transform 0.28s var(--ease-spring),
    box-shadow 0.28s var(--ease);
}

.tab:hover {
  color: var(--ink);
  background: rgba(10, 89, 247, 0.06);
}

.tab.active {
  background: linear-gradient(135deg, #2f7bff, var(--primary));
  color: white;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(10, 89, 247, 0.28);
}

.tab:active {
  transform: scale(0.97);
}

.panel[hidden] {
  display: none !important;
}

.pay-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.pay-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.28s var(--ease), box-shadow 0.28s var(--ease), transform 0.28s var(--ease-spring);
}

.pay-card:hover {
  border-color: #c5ced9;
  box-shadow: var(--shadow);
}

.pay-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10, 89, 247, 0.14);
  background: var(--primary-soft);
}

.pay-card .label {
  font-size: 12px;
  color: var(--muted);
}

.pay-card .value {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 700;
}

.pay-io {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.pay-io-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.pay-io-row span {
  flex: none;
  opacity: 0.85;
}

.pay-io-row strong {
  font-weight: 700;
  text-align: right;
  word-break: break-all;
}

.pay-io-in {
  color: var(--amount-profit);
}

.pay-io-out {
  color: var(--danger);
}

.pay-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pay-option {
  position: relative;
  cursor: pointer;
}

.pay-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pay-option span {
  display: block;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  background: #f7f9fc;
  color: var(--ink);
}

.pay-option input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}

.form-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  min-height: 46px;
  outline: none;
  background: #f7f9fc;
  font: inherit;
  color: var(--ink);
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.form-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 89, 247, 0.12);
  background-color: white;
}

.badge-income {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-expense {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 900px) {
  .pay-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pay-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  cursor: pointer;
  transition:
    background 0.28s var(--ease),
    border-color 0.28s var(--ease),
    color 0.28s var(--ease),
    box-shadow 0.28s var(--ease),
    transform 0.22s var(--ease-spring);
  white-space: nowrap;
  font-weight: 500;
  font-size: 14px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #2f7bff, var(--primary));
  color: white;
  box-shadow: 0 6px 16px rgba(10, 89, 247, 0.24);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 8px 20px rgba(10, 89, 247, 0.3);
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: #f0f3f8;
  border-color: #c5ced9;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
  font-weight: 600;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

/* label.btn 的 display 会盖掉原生 hidden，备份按钮必须强制隐藏 */
.file-btn[hidden],
#importBackupLabel[hidden],
#btnExport[hidden],
#btnOpenInbound[hidden] {
  display: none !important;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.28s var(--ease), box-shadow 0.28s var(--ease), transform 0.28s var(--ease-spring);
}

.stat-card:hover {
  border-color: #c5ced9;
  box-shadow: var(--shadow);
}

.stat-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10, 89, 247, 0.18);
  background: #fff;
}

.stat-card--pending.is-active {
  border-color: #b86a1e;
  box-shadow: 0 0 0 2px rgba(184, 106, 30, 0.14);
}

.stat-card--profit.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10, 89, 247, 0.12);
}

.stat-card .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-card .value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.stat-card .value .sub {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
}

.stat-card--pending {
  background: #fffaf4;
  border-color: #e0c49a;
  border-left: 3px solid var(--warn);
  box-shadow: var(--shadow-sm);
}

.stat-card--pending .label {
  color: #7a4e12;
  font-weight: 600;
}

.stat-card--pending .value {
  color: #8a4b0a;
  font-size: 24px;
}

.stat-card--cost {
  background: var(--primary-soft);
  border-color: var(--line);
  border-left: 3px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.stat-card--cost .value.sales {
  color: var(--amount-sales);
}

.stat-card--profit {
  background: var(--ok-soft);
  border-color: var(--line);
  border-left: 3px solid var(--ok);
  box-shadow: var(--shadow-sm);
}

.stat-card--profit .label {
  color: var(--muted);
  font-weight: 600;
}

.stat-card--profit .value,
.stat-card--profit .value.sales {
  color: var(--amount-sales);
  font-size: 20px;
}

.stat-card--profit .value .sub {
  color: var(--muted);
}

.stat-card--profit .value .sub.profit-pos {
  color: var(--amount-profit);
}

.stat-card--profit .value .sub.profit-neg {
  color: var(--danger);
}

.stat-card--profit .value .sub.profit-zero {
  color: var(--muted);
}

.stat-card .value.sales {
  color: var(--amount-sales);
}

.stat-card .value.count {
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 260px;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 89, 247, 0.1);
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-time {
  margin-top: -4px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-label {
  color: var(--muted);
  font-size: 12px;
  margin-right: 4px;
  font-weight: 500;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.28s var(--ease), border-color 0.28s var(--ease), color 0.28s var(--ease), transform 0.22s var(--ease-spring);
}

.chip:hover {
  border-color: #c5ced9;
  color: var(--ink);
}

.chip.active {
  background: linear-gradient(135deg, #2f7bff, var(--primary));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(10, 89, 247, 0.24);
}

.chip:active {
  transform: scale(0.97);
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  min-height: 360px;
}

/* 有几条显示几条，不预留空白高度（调店审核等短列表） */
.table-wrap--auto {
  min-height: 0;
  margin-bottom: 14px;
}

.table-wrap--auto .empty {
  padding: 28px 16px;
}

.table {
  --row-font: 16px;
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.table th,
.table td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid #e8eeea;
  vertical-align: middle;
  font-size: var(--row-font);
  line-height: 1.45;
  white-space: nowrap;
}

.table th {
  position: sticky;
  top: 0;
  background: #eef2f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}

.table tr:hover td {
  background: #f3f7f5;
}

.qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.qty-cell .muted {
  margin-top: 4px;
  font-size: 12px;
}

.qty-inline {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary, var(--primary));
}

.imei-cell {
  font-size: var(--row-font);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: #243a31;
}

.product-cell,
.spec-cell {
  min-width: 0;
}

.product-brand,
.spec-main,
.product-model,
.spec-sub {
  font-size: var(--row-font);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.product-model,
.spec-sub {
  margin-top: 6px;
  color: var(--ink);
  background: #eef2f8;
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line);
}

.price-cell {
  font-size: var(--row-font);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1.35;
  white-space: nowrap;
}

.price-cost {
  color: var(--muted);
}

.price-sale {
  color: var(--ink);
}

.person-cell {
  font-size: var(--row-font);
  font-weight: 600;
  color: var(--ink);
}

.time-cell {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.55;
  white-space: nowrap;
}

.time-label {
  display: inline-block;
  min-width: 1.2em;
  margin-right: 6px;
  color: var(--primary);
  font-weight: 700;
}

.pay-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px 5px 6px;
  border-radius: 6px;
  line-height: 1.35;
  white-space: nowrap;
}

.pay-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.pay-alipay {
  color: #0a6cff;
  background: #e8f2ff;
}
.pay-alipay .pay-icon { background: linear-gradient(145deg, #3d9eff, #0a6cff); }

.pay-wechat {
  color: #1a9f4b;
  background: #e9f8ef;
}
.pay-wechat .pay-icon { background: linear-gradient(145deg, #2fce68, #09bb07); }

.pay-cash {
  color: #9a5b16;
  background: #fff4e5;
}
.pay-cash .pay-icon { background: linear-gradient(145deg, #f0b14a, #d9891a); }

.pay-union {
  color: #c0392b;
  background: #fdeceb;
}
.pay-union .pay-icon { background: linear-gradient(145deg, #e74c3c, #c0392b); }

.pay-bank {
  color: #2c4f8a;
  background: #eaf0f8;
}
.pay-bank .pay-icon { background: linear-gradient(145deg, #4f79bd, #2c4f8a); }

.pay-credit {
  color: #6c3483;
  background: #f5eaf8;
}
.pay-credit .pay-icon { background: linear-gradient(145deg, #a569bd, #6c3483); }

.pay-other {
  color: var(--primary);
  background: #e8f3ec;
}
.pay-other .pay-icon { background: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  letter-spacing: 0.02em;
}

.table .btn-small {
  font-size: 13px;
  font-weight: 700;
  padding: 7px 10px;
}

.table .actions {
  gap: 6px;
  max-width: 168px;
}

.badge-in {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-out {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-pending {
  background: #e8eef8;
  color: #2f4f8a;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 20% -10%, rgba(10, 89, 247, 0.14), transparent 55%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
}

/* 防止 display:grid 盖掉 hidden，导致登录后仍停在登录页 */
.auth-screen[hidden],
#appMain[hidden],
#adminApp[hidden],
#gateScreen[hidden],
.auth-card[hidden],
.panel[hidden] {
  display: none !important;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(228, 232, 238, 0.95);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: hwModalIn 0.4s var(--ease-spring);
}

.auth-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, #2f7bff, var(--primary), var(--primary-dark));
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand .brand-mark {
  margin: 0 auto 14px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.auth-brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-actions {
  display: grid;
  gap: 10px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

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

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.auth-form span {
  font-size: 13px;
  color: var(--muted);
}

.auth-form input,
.auth-form select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  min-height: 44px;
  outline: none;
  background: #f7f9fc;
  font: inherit;
}

.auth-form input:focus,
.auth-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 89, 247, 0.1);
  background: white;
}

.code-row {
  display: flex;
  gap: 8px;
}

.code-row input {
  flex: 1;
  min-width: 0;
}

.auth-tip {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.link-btn {
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  width: 100%;
}

.user-pill {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid rgba(10, 89, 247, 0.16);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
}

.admin-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
  min-width: 220px;
}

.date-range {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.date-range label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.date-range input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: white;
  font: inherit;
}

.perf-cell {
  min-width: 110px;
}

.perf-cell .perf-amount {
  font-weight: 700;
  color: var(--primary-dark);
}

.perf-cell .perf-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.date-range[hidden] {
  display: none !important;
}

#adminTableBody select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fafbfd;
  font: inherit;
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.profit-pos { color: var(--amount-profit); }
.profit-neg { color: var(--danger); }
.profit-zero { color: var(--muted); }

.money.profit-pos,
.money.sales {
  color: var(--amount-profit);
}

.money.sales {
  color: var(--amount-sales);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  padding: 72px 20px;
  color: var(--muted);
}

.empty h3 {
  margin: 0 0 8px;
  color: var(--ink);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 24px);
}

.modal::backdrop {
  background: rgba(12, 28, 56, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  width: min(860px, 100%);
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid rgba(228, 232, 238, 0.95);
  box-shadow: 0 24px 64px rgba(10, 40, 100, 0.18);
  overflow: visible;
  animation: hwModalIn 0.32s var(--ease-spring);
}

@keyframes hwModalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head,
.modal-foot {
  border-radius: 0;
  background: var(--surface);
}

.modal-head,
.modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
}

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

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal-foot {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.modal-body {
  padding: 26px 28px 22px;
  max-height: min(72vh, 760px);
  overflow: auto;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: #eef2f8;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
}

.icon-btn:hover {
  background: #e4ebe7;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 22px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 防止 display:flex 盖掉 hidden，导致「数量」等字段该藏却还显示 */
.form-grid label[hidden],
.form-grid [hidden],
.inbound-form-body [hidden],
#inboundQtyWrap[hidden],
#inboundImeiWrap[hidden],
#inboundSpecFields[hidden] {
  display: none !important;
}

.form-grid label.full,
.form-grid .full {
  grid-column: 1 / -1;
}

.imei-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}


.imei-row input {
  flex: 1;
  min-width: 0;
}

.imei-row .btn {
  flex-shrink: 0;
  min-height: 48px;
  padding-left: 18px;
  padding-right: 18px;
}

.field-tip {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inbound-batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #f5f7fb;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.inbound-batch-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.inbound-batch-bar .field-tip {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.inbound-batch-bar .btn {
  flex: none;
}

.autocomplete-field {
  position: relative;
}

.suggest-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 4px);
  z-index: 20;
  max-height: 240px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(16, 36, 72, 0.14);
}

.brand-suggest {
  max-height: min(320px, 50vh);
  z-index: 25;
}

.suggest-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
}

.suggest-item:hover,
.suggest-item.active {
  background: var(--primary-soft);
}

.suggest-item .brand-tag {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}

.suggest-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.scan-card {
  width: min(520px, 100%);
}

.scan-tip {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14px;
}

.qr-reader {
  overflow: hidden;
  border-radius: 16px;
  background: #10231c;
  min-height: 260px;
}

.qr-reader video {
  border-radius: 16px;
}

#qrReader__scan_region {
  min-height: 260px;
}

#qrReader__dashboard_section_csr button,
#qrReader__dashboard_section_swaplink {
  margin-top: 8px;
}

.form-grid span {
  font-size: 14px;
  color: var(--muted);
}

.form-grid input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  min-height: 46px;
  outline: none;
  background: #f7f9fc;
  font: inherit;
  color: var(--ink);
  line-height: 1.4;
}

.form-grid input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 89, 247, 0.1);
  background: white;
}

.phone-summary {
  background: #f4f8f6;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  line-height: 1.7;
}

.modal-card--wide {
  width: min(980px, 100%);
}

/* 入库弹窗：与详情同宽，内容摊开少滚动 */
.modal-card--inbound {
  width: min(980px, calc(100vw - 24px));
}

.modal-card--inbound .inbound-form-body,
.modal-card--inbound .modal-body {
  max-height: min(78vh, 820px);
  padding-bottom: 28px;
}

.modal-card--inbound .form-grid {
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  align-items: start;
}

.modal-card--inbound .form-grid > .full,
.modal-card--inbound .form-grid > label.full {
  grid-column: 1 / -1;
}

/* 分类 + 搜索并排，更像详情摊开 */
.inbound-top-row {
  display: grid;
  grid-template-columns: minmax(200px, 0.9fr) minmax(280px, 1.4fr);
  gap: 18px 20px;
  grid-column: 1 / -1;
}

@media (max-width: 720px) {
  .inbound-top-row {
    grid-template-columns: 1fr;
  }
}

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

.detail-item {
  background: #f5f7fb;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 74px;
}

.detail-item.span-2 {
  grid-column: span 2;
}

.detail-item .k {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.detail-item .v {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-all;
}

.multiple-strong {
  color: #a85d12;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.multiple-text {
  margin-top: 4px;
  color: #8a5a1a;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .detail-item.span-2 {
    grid-column: span 1;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(24, 36, 49, 0.92);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(16, 36, 72, 0.22);
  z-index: 50;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: hwToastIn 0.28s var(--ease-spring);
}

@keyframes hwToastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.review-notify {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: 168px;
  border: 0;
  border-radius: 16px;
  padding: 14px 14px 12px;
  text-align: left;
  cursor: pointer;
  color: white;
  background: linear-gradient(145deg, #f25545, #c62828);
  box-shadow: 0 12px 28px rgba(200, 48, 48, 0.28);
  animation: notifyPulse 2.2s ease-in-out infinite;
  transition: transform 0.28s var(--ease-spring);
}

.review-notify:active {
  transform: scale(0.97);
}

.review-notify[hidden] {
  display: none !important;
}

.review-notify-dot {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ff3b30;
  border: 2px solid white;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(255, 59, 48, 0.45);
}

.review-notify-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
}

.review-notify-desc {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.92;
  line-height: 1.4;
}

/* 工作通知：左下角（与右下角收款审核对称） */
.work-notify {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 60;
  width: 168px;
  border: 0;
  border-radius: 16px;
  padding: 14px 14px 12px;
  text-align: left;
  cursor: pointer;
  color: white;
  background: linear-gradient(145deg, #2f7bff, var(--primary-dark));
  box-shadow: 0 12px 28px rgba(10, 89, 247, 0.32);
  animation: notifyPulse 2.2s ease-in-out infinite;
  transition: transform 0.28s var(--ease-spring);
}

.work-notify:active {
  transform: scale(0.97);
}

.work-notify[hidden] {
  display: none !important;
}

.work-notify-dot {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ff9500;
  border: 2px solid white;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(255, 149, 0, 0.45);
}

.work-notify-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
}

.work-notify-desc {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.92;
  line-height: 1.4;
}

@keyframes notifyPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* —— 平板 / 窄屏 —— */
@media (max-width: 900px) {
  .app {
    width: min(100%, calc(100% - 20px));
    padding: 18px 0 calc(36px + env(safe-area-inset-bottom, 0px));
  }

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

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .brand h1 {
    font-size: 18px;
  }

  .header {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-card--inbound .form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: none;
    white-space: nowrap;
  }

  .table-wrap {
    min-height: 280px;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }

  .table-wrap--auto {
    min-height: 0;
  }

  .modal-card {
    width: min(860px, calc(100vw - 16px));
    border-radius: 18px;
  }

  .modal-head,
  .modal-foot,
  .modal-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .modal-body {
    max-height: min(70dvh, 640px);
  }
}

/* —— 手机 H5 / APP —— */
@media (max-width: 640px) {
  .app {
    width: 100%;
    padding: 12px 12px calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 20px;
  }

  .brand h1 {
    font-size: 18px;
    line-height: 1.3;
  }

  .brand p {
    font-size: 12px;
  }

  .header-actions {
    gap: 8px;
  }

  .header-actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .tabs {
    margin-bottom: 14px;
    padding: 4px;
    border-radius: 12px;
  }

  .tab {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 42px;
  }

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

  .stat-card {
    padding: 12px 12px;
    border-radius: 14px;
  }

  .stat-card .label {
    font-size: 12px;
  }

  .stat-card .value {
    font-size: 20px;
    margin-top: 6px;
  }

  .stat-card--pending .value {
    font-size: 24px;
  }

  .stat-card--profit .value {
    font-size: 16px;
  }

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

  .pay-card {
    padding: 12px;
    border-radius: 12px;
  }

  .pay-card .value {
    font-size: 15px;
  }

  .pay-io-row {
    font-size: 12px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 10px;
  }

  .search-box {
    min-width: 0;
    width: 100%;
  }

  .search-box input {
    min-height: 44px;
    font-size: 16px; /* 避免 iOS 自动放大 */
    border-radius: 12px;
  }

  .filters {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: none;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .toolbar-time {
    margin-top: 0;
  }

  .table {
    --row-font: 14px;
  }

  .table th,
  .table td {
    padding: 10px 8px;
  }

  .table th {
    font-size: 12px;
  }

  .actions {
    gap: 6px;
  }

  .actions .btn {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .empty {
    padding: 48px 16px;
  }

  .auth-screen {
    min-height: 100dvh;
    align-items: flex-start;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 14px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .auth-card {
    width: 100%;
    padding: 22px 16px;
    border-radius: 18px;
  }

  .auth-brand h1 {
    font-size: 20px;
  }

  .auth-form input,
  .code-row .btn,
  .btn-block {
    min-height: 46px;
    font-size: 16px;
  }

  .code-row {
    flex-wrap: wrap;
  }

  .code-row .btn {
    flex: 1 1 auto;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .modal-card,
  .scan-card {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  }

  .modal-head h2 {
    font-size: 18px;
  }

  .modal-body {
    flex: 1;
    padding: 16px;
    max-height: none;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-foot {
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .modal-foot .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
  }

  .imei-row {
    flex-direction: column;
  }

  .imei-row .btn {
    width: 100%;
  }

  .pay-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: auto;
    text-align: center;
    border-radius: 14px;
    font-size: 14px;
  }

  .review-notify {
    right: 12px;
    left: auto;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: min(168px, calc(100vw - 24px));
    padding: 14px 12px;
  }

  .review-notify-title {
    font-size: 16px;
  }

  .work-notify {
    left: 12px;
    right: auto;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: min(168px, calc(100vw - 24px));
    padding: 14px 12px;
  }

  .work-notify-title {
    font-size: 16px;
  }
}

/* 超小屏 */
@media (max-width: 380px) {
  .stats,
  .pay-summary {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card--profit .value {
    font-size: 15px;
  }

  .header-actions .btn {
    flex: 1 1 100%;
  }
}

/* 开启系统弹窗提醒条 */
.push-permission-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 75;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(16, 36, 72, 0.14);
}

.push-permission-bar[hidden] {
  display: none !important;
}

.push-permission-tip {
  margin: 0;
  flex: 1 1 200px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 500;
}

.push-permission-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.push-permission-actions .btn {
  min-height: 40px;
}

/* 以 APP 全屏打开时，顶栏避开刘海 */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .app {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
}

/* —— 手机 H5 加强：看板、门店、入库、表格 —— */
@media (max-width: 640px) {
  .store-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .store-switcher select {
    flex: 1;
    min-width: 0;
    max-width: none;
    min-height: 40px;
    font-size: 16px;
  }

  .user-pill {
    width: 100%;
    justify-content: center;
  }

  .dashboard-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }

  .dashboard-total {
    width: 100%;
  }

  .dashboard-total-card {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .date-range {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }

  .date-range label {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .date-range input[type="date"] {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .modal-card--inbound,
  .modal-card--wide {
    width: 100%;
  }

  .modal-card--inbound .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .modal-card--inbound .inbound-form-body,
  .modal-card--inbound .modal-body {
    max-height: none;
  }

  .inbound-top-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .inbound-batch-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .inbound-batch-bar .btn {
    width: 100%;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea {
    font-size: 16px;
  }

  .table-wrap {
    margin-left: -4px;
    margin-right: -4px;
    border-radius: 10px;
  }

  .table {
    min-width: 720px;
  }

  .work-notify,
  .review-notify {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* —— 华为风丝滑补强 —— */
.panel {
  animation: hwPanelIn 0.34s var(--ease);
}

@keyframes hwPanelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card:active,
.pay-card:active,
.dash-store-card:active {
  transform: scale(0.985);
}

.dash-store-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(10, 89, 247, 0.12);
}

.form-grid input:focus,
.form-grid textarea:focus,
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 89, 247, 0.14);
  outline: none;
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* —— PWA 提示条 / 本地数据说明（不改业务逻辑） —— */
.auth-local-tip {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-soft, #fff6e8);
  border: 1px solid #f0d7a8;
  color: #7a4e12;
  font-size: 13px;
  line-height: 1.45;
}

.auth-local-tip a {
  color: var(--primary, #0a59f7);
  font-weight: 600;
}

.pwa-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  z-index: 80;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 32px rgba(10, 40, 100, 0.14);
  backdrop-filter: blur(10px);
}

.pwa-banner[hidden] {
  display: none !important;
}

.pwa-banner p {
  margin: 0;
  flex: 1 1 180px;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
}

.pwa-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pwa-banner--tip {
  top: calc(12px + env(safe-area-inset-top, 0px));
  border-left: 4px solid var(--warn, #c27a0e);
}

.pwa-banner--install {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-left: 4px solid var(--primary, #0a59f7);
}

.pwa-banner--update {
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  border-left: 4px solid var(--ok, #00a870);
}

@media (max-width: 640px) {
  .pwa-banner {
    padding: 12px;
  }

  .pwa-banner-actions .btn {
    min-height: 40px;
  }

  /* 有安装条时，避免挡住通知球 */
  body:has(#pwaInstallBar:not([hidden])) .work-notify,
  body:has(#pwaInstallBar:not([hidden])) .review-notify {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
}

/* 弹窗安全区：强化刘海/底部 Home 条 */
@media (max-width: 640px) {
  .modal-head {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }

  .modal-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .auth-form input,
  .search-box input {
    font-size: 16px;
  }
}
