:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f4f7fb;
  color: #17212b;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-strong: #f8fbff;
  --line: #d5e0ea;
  --line-soft: #e6edf3;
  --text: #17212b;
  --muted: #667789;
  --muted-strong: #415468;
  --cyan: #087ea4;
  --blue: #2f6fc1;
  --green: #198754;
  --danger: #c34255;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
}
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(49, 111, 150, .22);
  box-shadow: 5vw 12vh 0 rgba(49, 111, 150, .17), 12vw 39vh 0 rgba(47, 111, 193, .14), 19vw 23vh 0 rgba(49, 111, 150, .12), 25vw 67vh 0 rgba(47, 111, 193, .13), 31vw 14vh 0 rgba(49, 111, 150, .18), 38vw 45vh 0 rgba(49, 111, 150, .15), 44vw 82vh 0 rgba(47, 111, 193, .14), 51vw 27vh 0 rgba(49, 111, 150, .13), 58vw 58vh 0 rgba(49, 111, 150, .14), 65vw 9vh 0 rgba(47, 111, 193, .12), 71vw 74vh 0 rgba(49, 111, 150, .14), 78vw 31vh 0 rgba(49, 111, 150, .16), 84vw 88vh 0 rgba(47, 111, 193, .11), 91vw 18vh 0 rgba(49, 111, 150, .16), 96vw 61vh 0 rgba(47, 111, 193, .13);
  opacity: .6;
  pointer-events: none;
}
body::before { top: 4vh; left: 2vw; animation: twinkle 5s ease-in-out infinite alternate; }
body::after { top: 17vh; left: 7vw; width: 2px; height: 2px; opacity: .28; animation: twinkle 7s 1s ease-in-out infinite alternate; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

@keyframes twinkle { from { opacity: .12; } to { opacity: .32; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, .2); } 50% { box-shadow: 0 0 0 4px rgba(25, 135, 84, 0); } }

.scan-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 64px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.scan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.eyebrow { margin: 0; color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: 1.7px; }
.eyebrow .prompt { color: var(--green); margin-right: 6px; }
.eyebrow .slash { color: #7f91a5; margin: 0 7px; }
.scan-header h1 { margin: 10px 0 0; color: #17212b; font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: 0; }
.scan-header h1 span { color: var(--cyan); }
.scan-subtitle { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.system-meta { display: flex; align-items: flex-end; flex-direction: column; gap: 10px; padding-top: 4px; }
.system-status { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border: 1px solid #c8d7e6; border-radius: 999px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 1px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2.4s ease-out infinite; }
.system-version { color: #7a8a9b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }

.scan-totals { display: flex; justify-content: flex-end; gap: 0; margin-top: 22px; }
.stat-block { min-width: 172px; padding: 5px 24px 5px 20px; border-left: 1px solid var(--line); }
.stat-block:first-child { padding-left: 0; border-left: 0; }
.stat-label { display: block; color: var(--muted-strong); font-size: 11px; font-weight: 800; letter-spacing: .8px; }
.stat-block strong { display: block; margin-top: 4px; color: var(--text); font-size: 30px; line-height: 1; }
.stat-block-accent strong { color: var(--green); }
.stat-block small { display: block; margin-top: 7px; color: #728396; font-size: 10px; white-space: nowrap; }

.scan-overview {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.queue-heading { display: flex; align-items: baseline; gap: 14px; }
.queue-kicker { color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; }
.queue-label { color: var(--muted-strong); font-size: 15px; }
.queue-heading strong { color: var(--text); font-size: 32px; line-height: 1; }
.queue-meta { display: flex; align-items: center; gap: 18px; }
.queue-refresh { color: #76879a; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; letter-spacing: .8px; }
.queue-refresh b { color: var(--blue); font-weight: 800; }
.connection { display: inline-flex; align-items: center; gap: 8px; color: #728092; font-size: 11px; font-weight: 700; }
.connection .dot { width: 7px; height: 7px; border-radius: 50%; background: #9baaba; }
.connection.online { color: var(--green); }
.connection.online .dot { background: var(--green); box-shadow: 0 0 7px rgba(25, 135, 84, .28); }

.scan-notice,
.scan-error { margin-top: 16px; padding: 12px 15px; border: 1px solid #b9dcc9; border-left: 3px solid var(--green); background: #edf8f2; color: #18794e; font-size: 13px; }
.scan-notice.failed,
.scan-error { border-color: #e5bcc5; border-left-color: var(--danger); background: #fff1f3; color: #a32b42; }

.scan-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding-top: 22px; }
.scan-task { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: 0 10px 26px rgba(23, 33, 43, .06); }
.scan-task:hover { border-color: #9eb8cc; background: var(--panel-strong); }
.scan-task-header, .scan-task-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.scan-task-header h2 { margin: 0; overflow-wrap: anywhere; color: var(--text); font-size: 15px; letter-spacing: 0; }
.scan-task-header p { display: flex; flex-wrap: wrap; gap: 9px; margin: 6px 0 0; color: #728396; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.scan-sequence { color: var(--cyan); font-weight: 800; }
.scan-status { flex: 0 0 auto; padding: 5px 9px; border: 1px solid #e3cb83; border-radius: 4px; background: #fff4d7; color: #8b5b0b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; font-weight: 800; letter-spacing: .4px; }

.scan-qr-row { display: grid; grid-template-columns: 164px minmax(0, 1fr); gap: 18px; align-items: center; margin-top: 17px; padding: 12px; border: 1px solid var(--line-soft); border-radius: 5px; background: #f3f7fa; }
.scan-qr { width: 164px; aspect-ratio: 1; display: grid; place-items: center; padding: 9px; border: 1px solid #d5e0e7; border-radius: 4px; background: #ffffff; }
.scan-qr img { display: block; width: 100%; height: 100%; object-fit: contain; }
.scan-qr-expired { color: #b43a56; font-size: 12px; font-weight: 800; text-align: center; }
.scan-copy strong, .scan-copy span, .scan-copy small { display: block; }
.scan-copy strong { color: var(--text); font-size: 15px; }
.scan-copy span { margin-top: 9px; color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; font-weight: 800; }
.scan-copy small { margin-top: 10px; color: #728396; font-size: 11px; line-height: 1.6; }
.scan-task-footer { align-items: center; margin-top: 14px; color: #728396; font-size: 11px; }
.scan-task-footer > span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.scan-task-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.primary, .secondary { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 13px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; text-decoration: none; font-size: 12px; font-weight: 800; }
.primary { color: #ffffff; background: var(--green); }
.secondary { color: #355b76; border-color: #bdd0dd; background: transparent; }
.primary:hover { background: #11643f; box-shadow: 0 0 14px rgba(25, 135, 84, .18); }
.secondary:hover { border-color: #8aaabd; color: var(--text); background: #f9fbfd; }
.scan-task-actions button:disabled { cursor: wait; opacity: .58; }
.scan-empty { grid-column: 1 / -1; padding: 90px 16px; border: 1px dashed #c9d8e4; color: #728396; text-align: center; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.scan-empty::before { content: "//"; display: block; margin-bottom: 10px; color: #527d9a; font-size: 22px; font-weight: 800; }

@media (max-width: 820px) {
  .scan-shell { width: min(100% - 32px, 620px); padding-top: 28px; }
  .scan-header { align-items: stretch; flex-direction: column; }
  .system-meta { align-items: flex-start; }
  .scan-totals { justify-content: flex-start; }
  .scan-list { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .scan-shell { width: min(100% - 22px, 620px); padding-top: 20px; }
  .scan-header h1 { font-size: 38px; }
  .scan-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-block { min-width: 0; padding-right: 12px; }
  .stat-block small { white-space: normal; line-height: 1.4; }
  .scan-overview { align-items: flex-start; flex-direction: column; gap: 12px; }
  .queue-meta { width: 100%; justify-content: space-between; }
  .scan-qr-row { grid-template-columns: minmax(0, 1fr); }
  .scan-qr { width: min(100%, 184px); justify-self: center; }
  .scan-task-footer { align-items: stretch; flex-direction: column; gap: 13px; }
  .scan-task-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-task-actions button { min-width: 0; }
}
