:root {
  --bg: #0d1322;
  --bg-glow: rgba(255, 151, 89, 0.2);
  --panel: rgba(17, 24, 39, 0.92);
  --panel-soft: rgba(25, 33, 52, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f7f5ef;
  --muted: rgba(247, 245, 239, 0.64);
  --brand: #ff9a58;
  --brand-deep: #ee6c2f;
  --ok: #49d08d;
  --danger: #ff7f78;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow: 0 22px 50px rgba(5, 10, 20, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, var(--bg-glow), transparent 34%),
    linear-gradient(180deg, #151c30 0%, #0f1525 48%, #0b111e 100%);
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.login-shell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.login-hero,
.panel,
.tabbar {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)),
    var(--panel);
  box-shadow: var(--shadow);
}

.login-hero {
  padding: 28px 22px 22px;
  text-align: center;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff8f3;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(238, 108, 47, 0.3);
}

.login-title {
  margin: 18px 0 8px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

.login-copy {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.tip-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
}

.tip-badge {
  margin-top: 18px;
  color: #fff0c7;
  background: rgba(255, 201, 111, 0.12);
  border: 1px solid rgba(255, 201, 111, 0.2);
}

.login-panel,
.panel {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.input::placeholder {
  color: rgba(247, 245, 239, 0.34);
}

.input:focus {
  border-color: rgba(255, 154, 88, 0.48);
  box-shadow: 0 0 0 3px rgba(255, 154, 88, 0.14);
}

.code-input {
  font-size: 17px;
  letter-spacing: 0.3px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

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

.btn-primary {
  color: #fffaf4;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  box-shadow: 0 10px 22px rgba(238, 108, 47, 0.24);
}

.btn-ghost {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 4px 2px 0;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
}

.topbar-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  margin-bottom: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
    var(--panel-soft);
}

.tab-btn,
.mode-btn {
  min-height: 42px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.tab-btn.active,
.mode-btn.active {
  color: #fff9f2;
  background: linear-gradient(135deg, rgba(255, 154, 88, 0.22), rgba(238, 108, 47, 0.22));
}

.section-head,
.history-line,
.result-line,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head,
.history-line,
.result-line {
  justify-content: space-between;
}

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.scanner-card {
  margin-top: 16px;
}

.scanner-region {
  min-height: 280px;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)),
    #090f1b;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.scanner-region video {
  width: 100% !important;
  height: 280px !important;
  object-fit: cover;
  border-radius: 18px;
}

.scanner-hint {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.inline-actions {
  margin-top: 14px;
  flex-wrap: wrap;
}

.result-panel {
  display: grid;
  gap: 10px;
}

.result-panel.is-success {
  border-color: rgba(73, 208, 141, 0.24);
}

.result-panel.is-failed {
  border-color: rgba(255, 127, 120, 0.24);
}

.result-title,
.history-title,
.account-name {
  font-size: 17px;
  font-weight: 700;
}

.result-copy,
.account-sub,
.scope-text,
.history-sub,
.history-time,
.result-meta {
  color: var(--muted);
}

.result-copy,
.scope-text,
.history-sub {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.65;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
}

.status-pill.ok {
  color: #dffceb;
  background: rgba(73, 208, 141, 0.14);
  border: 1px solid rgba(73, 208, 141, 0.2);
}

.status-pill.danger {
  color: #ffe1df;
  background: rgba(255, 127, 120, 0.12);
  border: 1px solid rgba(255, 127, 120, 0.2);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.history-time {
  margin-top: 8px;
  font-size: 12px;
}

.empty {
  padding: 18px 0 4px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(13, 18, 28, 0.92);
  color: #fffdf9;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar-title {
    font-size: 20px;
  }

  .scanner-region,
  .scanner-region video {
    min-height: 250px;
    height: 250px !important;
  }
}
