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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-2: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.operator-chip {
  border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.15);
  color: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; max-width: 40vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== 布局 ===== */
.main { max-width: 640px; margin: 0 auto; padding: 12px 12px 32px; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title-row .card-title { margin-bottom: 0; }

/* ===== 托盘横幅 ===== */
.tray-banner {
  position: sticky; top: 52px; z-index: 19;
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #0f172a; color: #fff; padding: 10px 14px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.tray-banner-label { font-size: 12px; color: #94a3b8; }
.tray-banner-code { font-size: 20px; font-weight: 700; letter-spacing: .5px; word-break: break-all; }
.tray-banner-count { font-size: 12px; color: #4ade80; }

/* ===== 扫码区 ===== */
.scan-target {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  background: #eff6ff; border: 1px dashed #93c5fd; border-radius: 10px; padding: 10px 12px;
}
.scan-target-step {
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 600;
  border-radius: 6px; padding: 2px 8px; flex-shrink: 0;
}
.scan-target-text { font-size: 15px; font-weight: 600; color: var(--primary-dark); }

.reader-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #000; margin-bottom: 12px; }
.reader-wrap video { width: 100% !important; display: block; }
.cam-status {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55); color: #4ade80; font-size: 13px; text-align: center; padding: 4px;
}

.cam-error {
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px;
}

/* ===== 按钮 ===== */
.btn {
  border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
  padding: 10px 16px; cursor: pointer; transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn-big { width: 100%; min-height: 54px; font-size: 17px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #dbeafe; color: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost.btn-small { font-size: 13px; padding: 4px 10px; }
.btn-danger { background: #fee2e2; color: var(--danger); }

/* ===== 输入 ===== */
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1; min-width: 0; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; background: #fff; color: var(--text);
}
.input-row input:focus { outline: none; border-color: var(--primary); }

.operator-setup .input-row { margin-top: 10px; }

.manual { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.manual-label { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }

/* ===== 本次已扫列表 ===== */
.badge {
  display: inline-block; min-width: 22px; text-align: center;
  background: var(--primary); color: #fff; border-radius: 999px;
  font-size: 12px; padding: 1px 7px; vertical-align: 2px;
}
.session-list { list-style: none; max-height: 42vh; overflow-y: auto; }
.session-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }
.session-code { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; word-break: break-all; }
.session-meta { font-size: 12px; color: var(--text-2); }
.session-tag {
  font-size: 11px; font-weight: 600; border-radius: 5px; padding: 1px 6px; flex-shrink: 0;
}
.tag-new { background: #dcfce7; color: var(--success); }
.tag-transfer { background: #fef3c7; color: var(--warn); }
.empty-tip { color: var(--text-2); font-size: 14px; text-align: center; padding: 18px 0; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-msg { font-size: 14px; color: var(--text-2); word-break: break-all; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns .btn { flex: 1; min-height: 46px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: 50%; transform: translateX(-50%);
  z-index: 60; max-width: 88vw;
  border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.2); text-align: center; word-break: break-all;
}
.toast-success { background: var(--success); }
.toast-warn { background: var(--warn); }
.toast-error { background: var(--danger); }

.hidden { display: none !important; }
