:root {
  --primary: #2f54eb;
  --primary-light: #eef1fe;
  --danger: #f5222d;
  --danger-light: #fff1f0;
  --success: #52c41a;
  --success-light: #f0f9eb;
  --warning: #fa8c16;
  --text-main: #1f2329;
  --text-sub: #646a73;
  --text-weak: #8f959e;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e5e6eb;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(31, 35, 41, 0.06);
  --header-h: 48px;
  --tabbar-h: 56px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.page {
  min-height: 100vh;
  display: none;
  flex-direction: column;
}

.page.active {
  display: flex;
}

/* ========== 按钮 ========== */
.btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 15px;
  border-radius: 8px;
  padding: 10px 18px;
  transition: opacity .15s;
  font-family: inherit;
}

.btn:active { opacity: .8; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-plain {
  background: #f2f3f5;
  color: var(--text-sub);
}

.btn-block {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 10px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
}

.btn[disabled] {
  opacity: .5;
  pointer-events: none;
}

/* ========== 顶部导航 ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.header .title {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header .back {
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2px;
}

.header .logout {
  font-size: 13px;
  color: var(--text-sub);
  cursor: pointer;
  padding: 4px 8px;
}

/* ========== 底部导航 ========== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--tabbar-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-weak);
  font-size: 11px;
  cursor: pointer;
}

.tabbar .tab .icon { font-size: 20px; line-height: 1; }

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

.page-body {
  flex: 1;
  padding: 12px;
  padding-bottom: calc(var(--tabbar-h) + 20px);
}

/* ========== 登录页 ========== */
.login-page {
  background: linear-gradient(160deg, #2f54eb 0%, #597ef7 45%, #f5f6fa 45.2%, #f5f6fa 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 28px;
}

.login-brand {
  margin-top: 15vh;
  text-align: center;
  color: #fff;
}

.login-brand .logo {
  width: 72px;
  height: 72px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}

.login-brand h1 { font-size: 22px; font-weight: 600; letter-spacing: 1px; }

.login-brand p { font-size: 13px; opacity: .85; margin-top: 6px; }

.login-card {
  margin-top: 26px;
  width: 100%;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(31, 35, 41, 0.12);
  padding: 24px 22px;
}

.form-item {
  margin-bottom: 18px;
}

.form-item label {
  display: block;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  height: 46px;
}

.input-wrap:focus-within {
  border-color: var(--primary);
  background: #fff;
}

.input-wrap .prefix {
  font-size: 16px;
  margin-right: 8px;
}

.input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  height: 100%;
  color: var(--text-main);
}

.input-wrap input::placeholder { color: #b8bcc4; }

.login-tip {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-weak);
}

.login-btn {
  margin-top: 8px;
}

/* ========== 统计卡片 ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 12px;
  text-align: center;
}

.stat-card .num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .num.red { color: var(--danger); }
.stat-card .num.orange { color: var(--warning); }
.stat-card .num.blue { color: var(--primary); }
.stat-card .num.green { color: var(--success); }

.stat-card .label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-sub);
}

/* ========== 卡片 & 列表 ========== */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  margin: 4px 0 10px;
}

.section-title .more {
  font-size: 12px;
  color: var(--text-weak);
  font-weight: 400;
}

.tabs {
  display: flex;
  background: #eef0f4;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 12px;
}

.tabs .tab-item {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  font-size: 13px;
  color: var(--text-sub);
  border-radius: 6px;
  cursor: pointer;
}

.tabs .tab-item.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.alarm-list { list-style: none; }

.alarm-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}

.alarm-item .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.alarm-item .epc {
  font-family: Consolas, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

.alarm-item .goods {
  margin-top: 6px;
  font-size: 14px;
}

.alarm-item .goods .tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

.alarm-item .meta {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-weak);
}

.status-badge {
  flex-shrink: 0;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.status-badge.unhandled { background: var(--danger-light); color: var(--danger); }
.status-badge.whitelisted { background: var(--success-light); color: var(--success); }
.status-badge.reported { background: var(--primary-light); color: var(--primary); }

.whitelist-btn {
  flex-shrink: 0;
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #b7eb8f;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}

.whitelist-btn:active { opacity: .7; }

.whitelist-btn.done {
  background: #f5f5f5;
  border-color: #e0e0e0;
  color: var(--text-weak);
  cursor: default;
}

/* ========== 报备页 ========== */
.steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.steps .step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-weak);
  position: relative;
}

.steps .step .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f0f1f5;
  color: var(--text-weak);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.steps .step.active .dot { background: var(--primary); color: #fff; }
.steps .step.active { color: var(--primary); }
.steps .step.done .dot { background: var(--success); color: #fff; }
.steps .step.done { color: var(--success); }

.steps .line {
  flex: 1;
  height: 2px;
  background: #eef0f4;
  margin: 0 6px;
  position: relative;
  top: -12px;
}

.steps .line.done { background: var(--success); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.card .card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scan-area {
  border: 1.5px dashed #c0c4cc;
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
}

.scan-area .icon { font-size: 32px; }
.scan-area p { font-size: 13px; color: var(--text-sub); margin-top: 6px; }
.scan-area .sub { font-size: 11px; color: var(--text-weak); margin-top: 2px; }

.manual-input {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.manual-input input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: Consolas, Menlo, monospace;
  outline: none;
  background: #fff;
}

.manual-input input:focus { border-color: var(--primary); }

.epc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.epc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: Consolas, Menlo, monospace;
}

.epc-chip .del {
  cursor: pointer;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(47, 84, 235, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

.epc-chip .del:active { opacity: .6; }

.epc-chip.warn {
  background: var(--danger-light);
  color: var(--danger);
}

.epc-chip.warn .del { background: rgba(245, 34, 45, 0.15); }

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

.day-option {
  flex: 1;
  min-width: 60px;
  text-align: center;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  background: #fff;
  transition: all .15s;
}

.day-option .unit { font-size: 11px; }

.day-option.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.custom-days {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-sub);
}

.custom-days input {
  width: 80px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  text-align: center;
  outline: none;
  font-size: 14px;
}

.custom-days input:focus { border-color: var(--primary); }

.form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  resize: none;
  font-family: inherit;
  background: #fff;
}

.form-textarea:focus { border-color: var(--primary); }

.submit-bar {
  padding: 12px 0 24px;
}

/* ========== 白名单列表 ========== */
.wl-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}

.wl-item .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.wl-item .epc {
  font-family: Consolas, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.wl-item .info {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.wl-item .info b { color: var(--text-main); font-weight: 500; }

.wl-item .info .device-list {
    word-break: break-all;
    word-wrap: break-word;
}

.wl-item .progress {
  margin-top: 10px;
  height: 4px;
  border-radius: 2px;
  background: #eef0f4;
  overflow: hidden;
}

.wl-item .progress .bar {
  height: 100%;
  border-radius: 2px;
  background: var(--success);
}

.wl-item .progress .bar.expired { background: #d0d3d9; }

.wl-item .ops {
  margin-top: 10px;
  text-align: right;
}

.wl-item .ops .btn { margin-left: 8px; }

.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-weak);
}

.empty .icon { font-size: 48px; margin-bottom: 10px; }
.empty p { font-size: 13px; }

/* ========== 弹窗 & Toast ========== */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mask[hidden] { display: none; }

.confirm-box {
  width: 78%;
  max-width: 340px;
  background: #fff;
  border-radius: 14px;
  padding: 20px 18px;
  text-align: center;
}

.confirm-title { font-size: 16px; font-weight: 600; }

.confirm-content {
  font-size: 14px;
  color: var(--text-sub);
  margin-top: 10px;
  line-height: 1.6;
  word-break: break-all;
}

.confirm-content .hl { color: var(--danger); font-weight: 600; }

.confirm-btns {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.confirm-btns .btn { flex: 1; }

.toast {
  position: fixed;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 14px;
  padding: 12px 22px;
  border-radius: 8px;
  z-index: 300;
  max-width: 80%;
  text-align: center;
  display: none;
  pointer-events: none;
}

.toast.show { display: block; animation: fadeIn .2s; }

.toast.success { background: rgba(82, 196, 26, 0.9); }
.toast.error { background: rgba(245, 34, 45, 0.9); }

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ========== 加载骨架 ========== */
.skeleton {
  background: linear-gradient(90deg, #f0f1f5 25%, #e8eaf0 37%, #f0f1f5 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.checkbox-option {
    margin: 0 10px 0 0;
    display: inline-block;
}

.checkbox-option input {
    margin-right: 2px;
}
