:root {
  --bg: #0f0f10;
  --panel: #1a1a1c;
  --text: #f2f2f0;
  --muted: #9a9a92;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --accent: #c96f4a; /* takeover terracotta */
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- setup ---------- */
#screen-setup { align-items: center; justify-content: center; padding: 24px; }
.setup-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.setup-box h1 { font-size: 42px; letter-spacing: 8px; text-align: center; color: var(--accent); }
.setup-box .sub { text-align: center; color: var(--muted); margin-top: -12px; }
.setup-box label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.setup-box input {
  padding: 14px; border-radius: 10px; border: 1px solid #333;
  background: var(--panel); color: var(--text); font-size: 16px;
}
.setup-status { min-height: 20px; font-size: 14px; color: var(--muted); text-align: center; }
.setup-status.err { color: var(--red); }

/* ---------- buttons ---------- */
.btn-primary {
  padding: 16px; border: none; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 17px; font-weight: 700; cursor: pointer;
}
.btn-primary:disabled { opacity: .5; }
.btn-ghost {
  padding: 8px 14px; border: 1px solid #444; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 14px; cursor: pointer;
}
.btn-danger {
  padding: 8px 14px; border: 1px solid var(--red); border-radius: 8px;
  background: transparent; color: var(--red); font-size: 14px; cursor: pointer;
}

/* ---------- status bar ---------- */
#statusbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background: var(--panel); font-size: 14px; color: var(--muted);
}
#stat-counts { color: var(--text); font-weight: 700; font-size: 16px; }
#stat-sync { margin-left: auto; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.online { background: var(--green); }
.dot.offline { background: var(--red); }
.queue-badge {
  background: var(--yellow); color: #000; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; font-size: 12px;
}

/* ---------- scanner ---------- */
#scanner-wrap { flex: 1; position: relative; overflow: hidden; background: #000; }
#qr-reader { width: 100%; height: 100%; }
#qr-reader video { object-fit: cover; }

/* ---------- verdict overlay ---------- */
.verdict {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px;
}
.verdict.green { background: var(--green); }
.verdict.yellow { background: var(--yellow); }
.verdict.red { background: var(--red); }
#verdict-icon { font-size: 88px; font-weight: 900; color: #fff; line-height: 1; }
#verdict-name { font-size: 32px; font-weight: 800; color: #fff; }
#verdict-detail { font-size: 18px; color: rgba(255,255,255,.9); }
#verdict-undo { margin-top: 18px; border-color: rgba(255,255,255,.7); color: #fff; font-weight: 700; }

/* ---------- tab bar ---------- */
#tabbar, .tabbar-clone {
  display: flex; background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabbar button, .tabbar-clone button {
  flex: 1; padding: 14px; border: none; background: transparent;
  color: var(--muted); font-size: 15px; font-weight: 600; cursor: pointer;
}
#tabbar button.active, .tabbar-clone button.active { color: var(--accent); }

/* ---------- search ---------- */
.subheader {
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background: var(--panel);
}
#search-input {
  width: 100%; padding: 12px; font-size: 17px; border-radius: 10px;
  border: 1px solid #333; background: var(--bg); color: var(--text);
}
#search-results, #log-list { flex: 1; overflow-y: auto; list-style: none; }
#search-results li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; border-bottom: 1px solid #222; font-size: 17px;
}
#search-results li .meta { font-size: 13px; color: var(--muted); }
#search-results li.checked .state { color: var(--green); font-weight: 700; }
#search-results li.cancelled .state { color: var(--red); font-weight: 700; }
#search-results li button { flex: none; }

/* ---------- log ---------- */
.log-header { display: flex; align-items: center; gap: 10px; }
#log-title { font-weight: 700; margin-right: auto; }
#log-list li {
  padding: 10px 14px; border-bottom: 1px solid #222; font-size: 14px;
  display: flex; gap: 10px; align-items: baseline;
}
#log-list li .t { color: var(--muted); font-size: 12px; flex: none; }
#log-list li .v { font-weight: 700; flex: none; width: 64px; }
#log-list li .v.GREEN { color: var(--green); }
#log-list li .v.YELLOW { color: var(--yellow); }
#log-list li .v.RED { color: var(--red); }
.log-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--panel); font-size: 13px; color: var(--muted);
}
