/* ============================================================
   连锁门店库存管理系统 — Apple 流体界面设计系统
   弹簧：移动/页面切换 damping 1.0 / response 0.4（临界阻尼，无过冲）
        底部 Sheet     damping 0.8 / response 0.3（带轻弹跳）
   ============================================================ */

:root {
  color-scheme: dark;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  --bg: #000000;
  --bg-elevated: #0b0b0d;
  --surface: rgba(28, 28, 30, 0.72);
  --surface-solid: #1c1c1e;
  --surface-2: rgba(44, 44, 46, 0.6);
  --surface-hover: rgba(58, 58, 60, 0.5);
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.62);
  --text-3: rgba(235, 235, 245, 0.36);

  --blue: #0a84ff;
  --blue-soft: rgba(10, 132, 255, 0.16);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --purple: #bf5af2;
  --purple-soft: rgba(191, 90, 242, 0.16);

  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 10px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --shadow-float: 0 24px 64px -24px rgba(0, 0, 0, 0.92), 0 2px 8px rgba(0, 0, 0, 0.4);

  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --dur-1: 0.24s;
  --dur-2: 0.4s;

  --sidebar-w: 252px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-2: rgba(118, 118, 128, 0.08);
  --surface-hover: rgba(118, 118, 128, 0.14);
  --hairline: rgba(60, 60, 67, 0.12);
  --hairline-strong: rgba(60, 60, 67, 0.22);

  --text: #1c1c1e;
  --text-2: rgba(60, 60, 67, 0.6);
  --text-3: rgba(60, 60, 67, 0.36);

  --blue: #007aff;
  --blue-soft: rgba(0, 122, 255, 0.12);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.12);
  --purple: #af52de;
  --purple-soft: rgba(175, 82, 222, 0.12);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px -20px rgba(0, 0, 0, 0.28);
  --shadow-float: 0 24px 64px -24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(720px 420px at 12% -8%, rgba(10, 132, 255, 0.16), transparent 70%),
    radial-gradient(620px 380px at 96% 6%, rgba(191, 90, 242, 0.12), transparent 70%);
}

[data-theme="light"] body::before {
  background:
    radial-gradient(720px 420px at 10% -10%, rgba(0, 122, 255, 0.12), transparent 70%),
    radial-gradient(620px 380px at 96% 4%, rgba(175, 82, 222, 0.09), transparent 70%);
}

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

svg {
  width: 1em;
  height: 1em;
  flex: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--blue);
  text-decoration: none;
}

/* ---------------------------- 排版（光学字号） ---------------------------- */
.display {
  font-size: 34px;
  line-height: 1.14;
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0;
}

.title {
  font-size: 22px;
  line-height: 1.24;
  font-weight: 600;
  letter-spacing: -0.014em;
  margin: 0;
}

.headline {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.body {
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.006em;
}

.caption {
  font-size: 13px;
  line-height: 1.42;
  letter-spacing: -0.003em;
  color: var(--text-2);
}

.footnote {
  font-size: 12px;
  letter-spacing: 0.005em;
  color: var(--text-3);
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ------------------------------- 登录页 ------------------------------- */
.auth {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  animation: rise var(--dur-2) var(--ease-spring) both;
}

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0a84ff, #5e5ce6);
  box-shadow: 0 10px 26px -10px rgba(10, 132, 255, 0.8);
  margin-bottom: 20px;
}

.auth-logo svg {
  width: 26px;
  height: 26px;
}

.auth-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 0.5px solid var(--hairline);
}

.demo-accounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.demo-chip {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 0.5px solid var(--hairline);
  color: var(--text-2);
  transition: transform var(--dur-1) var(--ease-spring), background var(--dur-1);
}

.demo-chip:active {
  transform: scale(0.96);
  background: var(--surface-hover);
}

/* -------------------------------- 布局 -------------------------------- */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 0.5px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0a84ff, #5e5ce6);
  box-shadow: 0 8px 18px -8px rgba(10, 132, 255, 0.9);
  flex: none;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
}

.nav-group {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--dur-1) var(--ease-spring), color var(--dur-1), transform 0.12s var(--ease-spring);
  width: 100%;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.9;
  flex: none;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item:active {
  transform: scale(0.975);
}

.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  min-width: 19px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 0.5px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(160deg, #2c2c2e, #3a3a3c);
  color: var(--text);
  flex: none;
  border: 0.5px solid var(--hairline-strong);
}

[data-theme="light"] .avatar {
  background: linear-gradient(160deg, #e5e5ea, #d1d1d6);
}

.main {
  min-width: 0;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 34px 64px;
  max-width: 1280px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head .sub {
  margin-top: 5px;
  color: var(--text-2);
  font-size: 13.5px;
}

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

.page {
  animation: pageIn var(--dur-2) var(--ease-spring) both;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.994);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------- 卡片 -------------------------------- */
.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.card {
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  overflow: hidden;
}

.card-pad {
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.card-head h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.metric {
  padding: 18px 20px 17px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.metric-label {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: -0.002em;
}

.metric-value {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-value small {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-2);
  margin-left: 3px;
}

.metric-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.metric-ico {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.metric-ico svg {
  width: 17px;
  height: 17px;
}

.tint-blue { background: var(--blue-soft); color: var(--blue); }
.tint-green { background: var(--green-soft); color: var(--green); }
.tint-orange { background: var(--orange-soft); color: var(--orange); }
.tint-red { background: var(--red-soft); color: var(--red); }
.tint-purple { background: var(--purple-soft); color: var(--purple); }

/* -------------------------------- 列表 -------------------------------- */
.list {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 20px;
  border-top: 0.5px solid var(--hairline);
  transition: background var(--dur-1) linear;
  text-align: left;
  width: 100%;
}

.row:first-child {
  border-top: none;
}

.row.clickable:hover {
  background: var(--surface-2);
}

.row.clickable:active {
  background: var(--surface-hover);
}

.row-thumb {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  flex: none;
}

.row-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.008em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-side {
  text-align: right;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.row-qty {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* -------------------------------- 徽章 -------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 550;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: -0.002em;
  white-space: nowrap;
}

.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: var(--surface-2); color: var(--text-2); }

/* ------------------------------- 按钮 ------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.006em;
  background: var(--surface-2);
  color: var(--text);
  border: 0.5px solid var(--hairline);
  transition: transform 0.16s var(--ease-spring), background var(--dur-1), opacity var(--dur-1);
  will-change: transform;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:hover {
  background: var(--surface-hover);
}

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

.btn:disabled {
  opacity: 0.42;
  pointer-events: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 22px -12px rgba(10, 132, 255, 0.9);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--blue) 88%, #fff);
}

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

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
  padding: 13px;
  font-size: 15px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: var(--surface-2);
  border: 0.5px solid var(--hairline);
  transition: transform 0.16s var(--ease-spring), color var(--dur-1), background var(--dur-1);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ------------------------------- 分段控件 ------------------------------- */
.segmented {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 0.5px solid var(--hairline);
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.segment {
  position: relative;
  z-index: 1;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  border-radius: 9px;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease-spring);
}

.segment.active {
  color: var(--text);
}

.segment-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  border-radius: 9px;
  background: var(--surface-solid);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28), 0 0 0 0.5px var(--hairline);
  transition: transform var(--dur-2) var(--ease-spring), width var(--dur-2) var(--ease-spring);
}

/* -------------------------------- 表单 -------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 15px;
}

.field > label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  letter-spacing: -0.002em;
}

.input,
.select,
textarea.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 0.5px solid var(--hairline);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-1);
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus,
.select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px var(--blue-soft);
  background: var(--surface);
}

.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

.search {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.search .input {
  padding-left: 36px;
}

.form-error {
  font-size: 12.5px;
  color: var(--red);
  margin-top: -6px;
  margin-bottom: 10px;
}

/* 登录页：企微账号待绑定提示 */
.auth-bind {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 12px 13px;
  border-radius: 14px;
  background: var(--blue-soft, rgba(0, 122, 255, 0.1));
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.55;
  animation: rise 0.42s var(--spring, cubic-bezier(0.22, 1, 0.36, 1)) both;
}

.auth-bind svg {
  width: 17px;
  height: 17px;
  color: var(--blue, #007aff);
  margin-top: 1px;
}

.auth-bind b {
  font-weight: 600;
}

/* ------------------------------- 底部 Sheet ------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-1) linear;
}

.sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 91;
  display: none;
  width: min(560px, 100%);
  max-height: 88vh;
  transform: translate3d(-50%, 100%, 0);
  background: var(--bg-elevated);
  border-radius: 26px 26px 0 0;
  border: 0.5px solid var(--hairline);
  border-bottom: none;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  will-change: transform;
  touch-action: none;
}

.sheet.show {
  transform: translate3d(-50%, 0, 0);
}

.sheet-grip {
  padding: 9px 0 5px;
  display: grid;
  place-items: center;
  cursor: grab;
  flex: none;
}

.sheet-grip::before {
  content: "";
  width: 38px;
  height: 5px;
  border-radius: 999px;
  background: var(--hairline-strong);
}

.sheet-grip:active {
  cursor: grabbing;
}

.sheet-head {
  padding: 2px 20px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}

.sheet-body {
  padding: 0 20px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.sheet-foot {
  padding: 12px 20px calc(16px + var(--safe-bottom));
  border-top: 0.5px solid var(--hairline);
  display: flex;
  gap: 10px;
  flex: none;
  background: var(--bg-elevated);
}

/* -------------------------------- Toast -------------------------------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100% - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.92);
  color: #f5f5f7;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-float);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: toastIn 0.42s var(--ease-spring) both;
  max-width: 100%;
}

[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.96);
  color: #1c1c1e;
  border-color: rgba(0, 0, 0, 0.08);
}

.toast.out {
  animation: toastOut 0.26s var(--ease-out) both;
}

.toast svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.toast.err svg { color: var(--red); }
.toast.ok svg { color: var(--green); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

/* -------------------------------- 空态 -------------------------------- */
.empty {
  padding: 52px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  text-align: center;
}

.empty svg {
  width: 34px;
  height: 34px;
  opacity: 0.5;
}

.empty .t {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}

/* ------------------------------- 表格（桌面） ------------------------------- */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-3);
  padding: 11px 16px;
  border-bottom: 0.5px solid var(--hairline);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

table.data th.num,
table.data td.num {
  text-align: right;
}

table.data td {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--hairline);
  vertical-align: middle;
}

table.data tbody tr {
  transition: background var(--dur-1) linear;
}

table.data tbody tr:hover {
  background: var(--surface-2);
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

.cell-strong {
  font-weight: 550;
  letter-spacing: -0.008em;
}

.cell-sub {
  font-size: 11.5px;
  color: var(--text-3);
}

/* ------------------------------- 趋势柱 ------------------------------- */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 108px;
  padding: 6px 2px 0;
}

.spark-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.spark-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100%;
  width: 100%;
  justify-content: center;
}

.spark-bar {
  width: 9px;
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: height 0.5s var(--ease-spring);
}

.spark-bar.in { background: var(--blue); }
.spark-bar.out { background: var(--purple); }

.spark-label {
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-2);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
  vertical-align: middle;
}

.dot.in { background: var(--blue); }
.dot.out { background: var(--purple); }

/* ------------------------------- 开单页 ------------------------------- */
.create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.picked-list {
  display: flex;
  flex-direction: column;
}

.picked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 0.5px solid var(--hairline);
  animation: rowIn 0.34s var(--ease-spring) both;
}

.picked:first-child {
  border-top: none;
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}

.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 0.5px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
  flex: none;
}

.stepper button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 16px;
  font-weight: 500;
  transition: background var(--dur-1), transform 0.12s var(--ease-spring);
}

.stepper button:active {
  background: var(--surface-hover);
  transform: scale(0.9);
}

.stepper input {
  width: 46px;
  height: 30px;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.summary-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
}

.summary-line span:first-child {
  color: var(--text-2);
}

.sticky-side {
  position: sticky;
  top: 24px;
}

/* 移动端固定在 Tab 上方的提交条 */
.mobile-submit {
  display: none;
}

@media (max-width: 860px) {
  .mobile-submit {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(74px + var(--safe-bottom));
    z-index: 55;
    padding: 10px 14px;
    border-radius: 18px;
    background: var(--surface);
    border: 0.5px solid var(--hairline);
    box-shadow: var(--shadow-float);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: rise 0.42s var(--ease-spring) both;
  }

  body:has(.mobile-submit) .main {
    padding-bottom: calc(180px + var(--safe-bottom));
  }
}

/* ------------------------------- 移动端 Tab ------------------------------- */
.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 7px 8px calc(7px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 0.5px solid var(--hairline);
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 0 3px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 10px;
  transition: color var(--dur-1) var(--ease-spring), transform 0.16s var(--ease-spring);
}

.tab svg {
  width: 21px;
  height: 21px;
}

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

.tab.active {
  color: var(--blue);
}

.tab.center {
  position: relative;
}

.tab.center .tab-fab {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(10, 132, 255, 0.95);
  margin-top: -12px;
  margin-bottom: 2px;
  transition: transform 0.2s var(--ease-spring);
}

.tab.center:active .tab-fab {
  transform: scale(0.9);
}

.tab.center .tab-fab svg {
  width: 22px;
  height: 22px;
}

/* ------------------------------- 切换开关 ------------------------------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 20px;
  border-top: 0.5px solid var(--hairline);
}

.switch-row:first-child {
  border-top: none;
}

.switch {
  position: relative;
  width: 48px;
  height: 29px;
  border-radius: 999px;
  background: var(--surface-hover);
  transition: background var(--dur-1) var(--ease-spring);
  flex: none;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-2) var(--ease-spring);
}

.switch.on {
  background: var(--green);
}

.switch.on::after {
  transform: translateX(19px);
}

/* ------------------------------- 扫码 ------------------------------- */
.scanner {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
}

.scanner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  inset: 16% 12%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.42);
}

.scanner-tip {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
}

/* ------------------------------- 工具类 ------------------------------- */
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.mono-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mt-14 { margin-top: 14px; }
.mt-8 { margin-top: 8px; }
.hide-desktop { display: none; }

/* ------------------------------- 响应式 ------------------------------- */
@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .create-grid { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 0;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(104px + var(--safe-bottom));
  }

  .tabbar {
    display: grid;
  }

  .display { font-size: 28px; }
  .title { font-size: 19px; }

  .page-head {
    margin-bottom: 16px;
  }

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

  .grid.cols-2.keep-one {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric { padding: 15px 16px 14px; }
  .metric-value { font-size: 22px; }
  .metric-ico { width: 28px; height: 28px; right: 12px; top: 12px; }
  .metric-ico svg { width: 15px; height: 15px; }

  .card { border-radius: 20px; }
  .card-head { padding: 15px 16px 10px; }
  .card-pad { padding: 16px; }
  .row { padding: 12px 16px; }

  .create-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sticky-side {
    position: static;
  }

  .hide-mobile {
    display: none;
  }

  .hide-desktop {
    display: initial;
  }

  .sheet {
    width: 100%;
    border-radius: 24px 24px 0 0;
    max-height: 92vh;
  }

  .head-actions .btn span {
    display: none;
  }

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

@media (max-width: 420px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 20px; }
  .display { font-size: 25px; }
}

/* ------------------------------- 无障碍 ------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .card,
  .sidebar,
  .tabbar,
  .auth-card,
  .toast {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--surface-solid) !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --hairline: rgba(255, 255, 255, 0.34);
    --text-2: rgba(235, 235, 245, 0.86);
    --text-3: rgba(235, 235, 245, 0.66);
  }
}

:focus-visible {
  outline: 2.5px solid var(--blue);
  outline-offset: 2px;
  border-radius: 8px;
}

::selection {
  background: var(--blue-soft);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}
