:root {
  --bg: #0e0e11;
  --panel: #15151a;
  --panel-2: #1d1d23;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f0e7;
  --muted: rgba(244, 240, 231, 0.66);
  --accent: #cf3a2f;
  --accent-soft: rgba(207, 58, 47, 0.18);
  --gold: #c8a96a;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(900px 380px at 20% 10%, rgba(200, 169, 106, 0.1), transparent 55%),
    radial-gradient(800px 420px at 85% 15%, rgba(255, 255, 255, 0.04), transparent 60%),
    linear-gradient(180deg, #0e0e11 0%, #121216 60%, #0e0e11 100%);
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
  min-height: 100svh;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(14, 14, 17, 0.92);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.brand-mark::after {
  content: "L";
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0.08em;
}

.brand-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.screen {
  padding: 24px 18px 80px;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  padding: 28px 24px;
  margin-top: 8vh;
}

.card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

#pin-input {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#pin-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s ease;
}

.primary-btn:hover {
  background: #b53026;
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hint {
  margin: 24px 0 4px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.link-btn {
  display: block;
  margin: 0 auto;
  background: transparent;
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
}

.link-btn:hover {
  text-decoration: underline;
}

/* === Scanner === */
.scan-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reader {
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  aspect-ratio: 1;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: 20px;
}

#reader__dashboard_section_csr,
#reader__dashboard_section_swaplink,
#reader__header_message {
  display: none !important;
}

#reader__camera_selection,
#reader__dashboard_section_fsr {
  background: transparent !important;
  color: var(--muted) !important;
}

#reader select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
}

.scan-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pin-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.pin-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}

.pin-value {
  font-family: ui-monospace, "SF Mono", monospace;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.manual-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.manual-row {
  display: flex;
  gap: 8px;
}

#manual-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}

#manual-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === Result card === */
.result {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 18px 16px;
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result.is-ok {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
}

.result.is-already {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}

.result.is-error {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
}

.result.is-info {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.1);
}

.result-title {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-icon {
  font-size: 28px;
}

.result-rows {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.result-row dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0;
  align-self: center;
}

.result-row dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  font-size: 15px;
}

.result-error {
  margin-top: 8px;
  font-size: 14px;
  color: var(--bad);
}

.result-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* === Log === */
.log {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.log-title {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

#log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

#log-list li {
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#log-list li.is-ok { border-color: rgba(34, 197, 94, 0.35); }
#log-list li.is-already { border-color: rgba(245, 158, 11, 0.35); }
#log-list li.is-error { border-color: rgba(239, 68, 68, 0.35); }

.log-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .topbar { padding: 12px 14px; }
  .screen { padding: 18px 12px 60px; }
  .card { margin-top: 4vh; padding: 22px 18px; }
}
