/* ============================================
   超市管理系统 —— 设计系统
   ------------------------------------------------------------
   配色：零售绿（#059669）主色，橙色（#EA580C）提示，红色仅用于危险操作
   字体：系统字体栈（中文站不依赖外网字体），金额/编号用等宽数字
   形态：扁平化，1px 描边替代重阴影，信息密度偏高
   ============================================ */

:root {
  /* ---- 品牌绿：钱、成交、安全 ---- */
  --brand-50:  #ECFDF5;
  --brand-100: #D1FAE5;
  --brand-200: #A7F3D0;
  --brand-400: #34D399;
  --brand-500: #10B981;
  --brand-600: #059669;
  --brand-700: #047857;
  --brand-800: #065F46;

  /* ---- 橙：需要留意（库存预警、待支付） ---- */
  --accent-50:  #FFF7ED;
  --accent-200: #FED7AA;
  --accent-500: #F97316;
  --accent-600: #EA580C;

  /* ---- 红：仅危险操作 ---- */
  --danger-50:  #FEF2F2;
  --danger-200: #FECACA;
  --danger-500: #EF4444;
  --danger-600: #DC2626;

  /* ---- 蓝：信息、微信支付 ---- */
  --info-50:  #EFF6FF;
  --info-200: #BFDBFE;
  --info-600: #2563EB;

  /* ---- 中性 ---- */
  --n-0:   #FFFFFF;
  --n-25:  #FCFDFC;
  --n-50:  #F8FAF9;
  --n-100: #F1F5F4;
  --n-200: #E6EAE9;
  --n-300: #D3DAD8;
  --n-400: #7E8A87;
  --n-500: #667270;
  --n-600: #4A5451;
  --n-700: #333C3A;
  --n-800: #212927;
  --n-900: #121817;

  /* ---- 语义 ---- */
  --bg:          #F4F7F6;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAF9;
  --border:      #E6EAE9;
  --border-2:    #D3DAD8;
  --text:        #121817;
  --text-2:      #4A5451;
  --text-3:      #5C6764;
  --text-faint:  #667270;

  /* ---- 尺度 ---- */
  --r-sm: 6px;
  --r:    9px;
  --r-lg: 13px;
  --r-xl: 18px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(18, 24, 23, 0.05);
  --sh-2: 0 1px 3px rgba(18, 24, 23, 0.06), 0 6px 16px rgba(18, 24, 23, 0.05);
  --sh-3: 0 10px 34px rgba(18, 24, 23, 0.13);

  --ring: 0 0 0 3px var(--brand-200);
  --tr: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 金额、编号、库存等数字统一等宽对齐 */
.num, .table .num, .stat .value, .cart-item .sub,
.cart-total, .order-no, .barcode, .feed-amt, .rank-qty {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.mono, .order-no, .barcode {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

a { color: inherit; text-decoration: none; }

/* 单行截断 */
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 最多两行 */
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
img { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   图标：统一 1.7px 描边
   尺寸走令牌，避免各处随意写死
   ============================================================ */
.icon-sm { font-size: 14px; }
.icon-md { font-size: 18px; }
.icon-lg { font-size: 24px; }
.icon-xl { font-size: 32px; }

.icon {
  display: inline-block;
  width: 1em; height: 1em;
  vertical-align: -0.14em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon-fill { fill: currentColor; stroke: none; }

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 20px;
  background: var(--n-900);
  color: var(--n-100);
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: 18px; }
.brand .mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r);
  background: var(--brand-600);
  color: #fff;
  font-size: 18px;
}
.brand .name { font-size: 15px; font-weight: 650; letter-spacing: 0.01em; white-space: nowrap; }
.brand .sub { font-size: 11.5px; color: var(--n-400); margin-top: -2px; }

.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }

.nav a {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border-radius: var(--r);
  color: var(--n-300);
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  transition: background var(--tr), color var(--tr);
}
.nav a .icon { font-size: 16px; opacity: 0.85; }
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav a.active { background: var(--brand-700); color: #fff; }
.nav a.active .icon { opacity: 1; }

.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--n-300); }
.topbar .user .who { text-align: right; line-height: 1.25; }
.topbar .user .who b { color: #fff; font-weight: 600; font-size: 13px; }
.topbar .user .who span { font-size: 11px; color: var(--n-400); }

/* 深色顶栏上的按钮反转 */
.topbar .btn {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--n-100);
}
.topbar .btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.24); }

/* ============================================================
   页面骨架
   ============================================================ */
.page { max-width: 1400px; margin: 0 auto; padding: 24px 20px 40px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 680; letter-spacing: -0.01em; }
.page-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; font-weight: 620; display: flex; align-items: center; gap: 8px; }
.card-head h3 .icon { font-size: 16px; color: var(--text-3); }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  min-height: 38px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px; font-weight: 550;
  white-space: nowrap;
  transition: background var(--tr), border-color var(--tr), color var(--tr), box-shadow var(--tr);
}
.btn .icon { font-size: 16px; }
.btn:hover:not(:disabled) { background: var(--n-50); border-color: var(--n-400); }
.btn:active:not(:disabled) { background: var(--n-100); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: var(--sh-1);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-700); border-color: var(--brand-700); }
.btn-primary:active:not(:disabled) { background: var(--brand-800); }

.btn-danger { background: var(--danger-600); border-color: var(--danger-600); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; border-color: #B91C1C; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--n-100); color: var(--text); }

.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 15px; border-radius: var(--r); }
.btn-sm { min-height: 30px; padding: 4px 9px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* ============================================================
   表单
   ============================================================ */
.field { margin-bottom: 16px; }
.field > label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.field > label .req { color: var(--danger-600); margin-left: 2px; }
.field-hint { margin-top: 6px; font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.field-hint a { color: var(--brand-700); text-decoration: underline; text-underline-offset: 2px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; min-width: 0; }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  min-height: 40px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  background: var(--surface);
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-600);
  box-shadow: var(--ring);
}
.input:disabled, .select:disabled { background: var(--n-50); color: var(--text-faint); cursor: not-allowed; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7774' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 15px;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 12px;
  background: var(--n-50);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px; font-weight: 620;
  text-align: left; white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--tr); }
.table tbody tr:hover { background: var(--n-25); }
.table .num { text-align: right; }
.table .act { text-align: right; white-space: nowrap; }
.table .act .btn + .btn { margin-left: 8px; }
.table .strong { font-weight: 600; }
.table .dim { color: var(--text-3); font-size: 12.5px; }

.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-3);
}

/* ============================================================
   徽标
   ============================================================ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.tag .icon { font-size: 12px; }
.tag-ok     { background: var(--brand-50);  color: var(--brand-800); }
.tag-warn   { background: var(--accent-50); color: #9A4E08; }
.tag-danger { background: var(--danger-50); color: #991B1B; }
.tag-info   { background: var(--info-50);   color: #1D4ED8; }
.tag-gray   { background: var(--n-100);     color: var(--text-3); }

/* ============================================================
   提示条
   ============================================================ */
.alert {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 12px 14px; margin-bottom: 16px;
  border: 1px solid; border-radius: var(--r);
  font-size: 13.5px; line-height: 1.6;
}
.alert .icon { font-size: 17px; margin-top: 1px; flex: none; }
.alert-ok   { background: var(--brand-50);  border-color: var(--brand-200); color: var(--brand-800); }
.alert-err  { background: var(--danger-50); border-color: var(--danger-200); color: #991B1B; }
.alert-warn { background: var(--accent-50); border-color: var(--accent-200); color: #9A4E08; }
.alert-info { background: var(--info-50);   border-color: var(--info-200); color: #1D4ED8; }

/* ============================================================
   弹窗
   ============================================================ */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(18, 24, 23, 0.5);
  backdrop-filter: blur(2px);
  animation: fade var(--tr);
}
.modal {
  display: flex; flex-direction: column;
  width: 100%; max-width: 520px;
  max-height: 88vh;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: pop var(--tr);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 640; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 15px 22px; border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-3); font-size: 18px;
  transition: background var(--tr), color var(--tr);
}
.icon-btn:hover { background: var(--n-100); color: var(--text); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ============================================================
   KPI 卡
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat {
  position: relative; overflow: hidden;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.stat .label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-3); font-weight: 550;
  margin-bottom: 8px;
}
.stat .label .icon { font-size: 14px; opacity: 0.7; }
.stat .value {
  font-size: 27px; font-weight: 700; line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat .value .unit { font-size: 14px; font-weight: 550; color: var(--text-3); margin-left: 3px; }
.stat .sub { margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.stat.accent  { border-left: 3px solid var(--brand-600); }
.stat.accent  .value { color: var(--brand-700); }
.stat.warn    { border-left: 3px solid var(--accent-500); }
.stat.warn    .value { color: var(--accent-600); }
.stat.info    { border-left: 3px solid var(--info-600); }
.stat.neutral { border-left: 3px solid var(--border-2); }

/* ============================================================
   工具条 / 网格
   ============================================================ */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar .grow { flex: 1 1 200px; min-width: 160px; }
.toolbar .select { width: auto; min-width: 130px; }
.check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13.5px; color: var(--text-2); cursor: pointer; user-select: none;
}
.check input { width: 16px; height: 16px; accent-color: var(--brand-600); cursor: pointer; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 > .card, .grid-3 > .card { min-width: 0; }

/* ============================================================
   空状态
   ============================================================ */
.empty { padding: 48px 20px; text-align: center; color: var(--text-faint); }
.empty .icon-wrap {
  width: 52px; height: 52px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--n-100); color: var(--n-400);
  font-size: 24px;
}
.empty .title { font-size: 14.5px; color: var(--text-2); font-weight: 550; margin-bottom: 4px; }
.empty .desc { font-size: 13px; }

/* ============================================================
   图表
   ============================================================ */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-faint); font-size: 11px; }
.chart .area { fill: url(#chartGrad); }
.chart .line { fill: none; stroke: var(--brand-600); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: #fff; stroke: var(--brand-600); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .dot, .chart .dot:hover { r: 5.5; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--text-3); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* 排行榜 */
.rank-list { display: flex; flex-direction: column; }
.rank-item {
  display: grid; grid-template-columns: 24px 1fr auto;
  gap: 11px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.rank-item:last-child { border-bottom: none; }
.rank-no {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--n-100); color: var(--text-3);
  font-size: 11.5px; font-weight: 700;
}
.rank-item:nth-child(1) .rank-no { background: #FEF3C7; color: #92400E; }
.rank-item:nth-child(2) .rank-no { background: var(--n-100); color: var(--text-2); }
.rank-item:nth-child(3) .rank-no { background: #FFEDD5; color: #9A4E08; }
.rank-name { font-size: 13.5px; font-weight: 550; }
.rank-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.rank-qty { font-size: 14px; font-weight: 700; }

/* 实时流水 */
.feed-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.feed-item:last-child { border-bottom: none; }
.feed-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.feed-amt { font-size: 15px; font-weight: 700; color: var(--brand-700); }

/* 实时指示 */
.live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-3);
}
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand-500);
  box-shadow: 0 0 0 0 var(--brand-500);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* 标签页 */
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabbar button {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 16px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-3); font-size: 14px; font-weight: 550;
  white-space: nowrap;
  transition: color var(--tr), border-color var(--tr);
}
.tabbar button .icon { font-size: 16px; }
.tabbar button:hover { color: var(--text); }
.tabbar button.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }

/* 步骤指引 */
.guide { counter-reset: step; list-style: none; }
.guide li {
  position: relative;
  counter-increment: step;
  padding-left: 30px; margin-bottom: 11px;
  font-size: 13.5px; color: var(--text-2); line-height: 1.7;
}
.guide li::before {
  content: counter(step);
  position: absolute; left: 0; top: 3px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-600); color: #fff;
  font-size: 11.5px; font-weight: 700;
}
.guide li b { color: var(--text); font-weight: 620; }
.guide code {
  padding: 1.5px 6px; border-radius: 4px;
  background: var(--n-100); color: var(--n-800);
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .brand { margin-right: 0; }
  .brand .sub { display: none; }
  .brand .mark { width: 28px; height: 28px; font-size: 16px; }
  .nav { order: 3; width: 100%; padding-bottom: 2px; }
  .topbar .user { margin-left: auto; }
  .page { padding: 16px 14px 32px; }
  .page-title { font-size: 19px; }
  .stat .value { font-size: 23px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .modal-mask { padding: 12px; align-items: flex-end; }
  .modal { max-height: 92vh; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .card-body { padding: 14px; }
  .field-row { flex-direction: column; gap: 0; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* 尊重系统的减弱动效设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 打印（对账单/小票） */
@media print {
  .topbar, .toolbar, .pager, .btn { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}
