/* Receptor QR — mobile first. Palette inspired by a crimson/magenta brand on light gray. */

:root {
  --brand-1: #a3125e;
  --brand-2: #d8133c;
  --brand: #c8102e;
  --brand-soft: #fcebee;
  --brand-ink: #c8102e;
  --grad: linear-gradient(160deg, var(--brand-1) 0%, var(--brand-2) 100%);
  --btn: linear-gradient(180deg, #da1a43 0%, #c20f30 100%);

  --bg: #eef0f5;
  --card: #ffffff;
  --panel: #f2f3f8;
  --line: #dfe2ea;
  --text: #1d1f2b;
  --muted: #6b7083;
  --shadow: 0 1px 2px rgb(20 22 40 / 6%), 0 4px 16px rgb(20 22 40 / 5%);

  --ok: #2e7d32;   --ok-bg: #e6f4e7;   --ok-line: #9fd3a5;
  --warn: #855600; --warn-bg: #fff4dc; --warn-line: #f1cf87;
  --bad: #b3122f;  --bad-bg: #fdebee;  --bad-line: #f2b3bf;
  --info: #2c4a9a; --info-bg: #eaeefb; --info-line: #b9c6ee;

  --map-ok: #2e9e48;
  --map-rec: #2f7fd1;
  --map-part: #9ccfa6;
  --map-miss: #d9dce5;

  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand-soft: #3b1621;
  --brand-ink: #ff7088;
  --bg: #121319;
  --card: #1c1d26;
  --panel: #252733;
  --line: #323546;
  --text: #ecedf3;
  --muted: #9ca1b4;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);

  --ok: #86d793;   --ok-bg: #15301b;   --ok-line: #2d5c35;
  --warn: #f3c56e; --warn-bg: #33280f; --warn-line: #5e4818;
  --bad: #ff8ea2;  --bad-bg: #3a141c;  --bad-line: #6c2434;
  --info: #a9bcf5; --info-bg: #1a2240; --info-line: #34437a;

  --map-ok: #3fb75a;
  --map-rec: #5aa2ee;
  --map-part: #2f6a3b;
  --map-miss: #343746;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2 { line-height: 1.2; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 16px; height: 16px; }

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

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: env(safe-area-inset-top);
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 12px rgb(120 10 40 / 25%);
}

.topbar__inner {
  max-width: 560px;
  height: 56px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.brand__logo { width: 28px; height: 28px; color: #fff; }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: -8px;
  padding: 8px;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
}
.theme-toggle__track { position: relative; width: 34px; height: 18px; border-radius: 9px; background: rgb(255 255 255 / 35%); }
.theme-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
:root[data-theme="dark"] .theme-toggle__thumb { transform: translateX(16px); }

/* ---------- Layout ---------- */

.main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

.view { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card--selected { border: 2px solid var(--brand); }
.card__title { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card__head .card__title { margin: 0; }

.footer {
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.footer a { color: inherit; }

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s, filter .15s, background-color .15s;
}
.btn:active { transform: scale(.98); }
.btn .icon { width: 20px; height: 20px; }
.btn--lg { width: 100%; min-height: 54px; font-size: 16px; }
.btn--small { min-height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.btn--primary { background: var(--btn); color: #fff; box-shadow: 0 4px 14px rgb(200 16 46 / 28%); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.btn--danger { color: var(--bad); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--text); }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- Start ---------- */

.hero { display: flex; flex-direction: column; gap: 14px; padding: 24px 18px 18px; text-align: center; }
.hero__title { margin: 0; font-size: 22px; font-weight: 800; }
.hero__text { margin: -6px auto 4px; max-width: 34ch; color: var(--muted); }

.pair { display: flex; align-items: center; justify-content: center; gap: 12px; }
.pair__arrow { color: var(--muted); }
.tile { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 14px; color: #fff; }
.tile .icon { width: 28px; height: 28px; }
.tile--brand { background: var(--grad); box-shadow: 0 4px 12px rgb(200 16 46 / 25%); }
.tile--alt { background: linear-gradient(160deg, #353a55, #545a7e); }

.resume { padding: 12px 14px; border-radius: 12px; text-align: left; background: var(--card); }

.steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: flex-start; gap: 12px; }
.steps__n {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 14px;
  font-weight: 800;
}

/* ---------- File rows ---------- */

.file-row { display: flex; align-items: center; gap: 12px; text-align: left; }
.file-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.file-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-row__text strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.install .file-row__text strong { white-space: normal; }

/* ---------- Camera ---------- */

.camera {
  position: relative;
  width: min(100%, 54vh);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 18px;
  background: #0b0b10;
  box-shadow: var(--shadow);
}
.camera video { display: block; width: 100%; height: 100%; object-fit: cover; }

.camera__finder { position: absolute; inset: 8%; pointer-events: none; }
.camera__finder i {
  position: absolute;
  width: 20%;
  height: 20%;
  border: 4px solid rgb(255 255 255 / 85%);
  transition: border-color .25s;
}
.camera__finder i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.camera__finder i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.camera__finder i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.camera__finder i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.camera__finder.is-hit i { border-color: #4ade80; transition: none; }

.camera__pill {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.camera__pill.is-live .dot { background: #ef4444; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.camera__hint {
  position: absolute;
  left: 50%;
  bottom: 13%;
  max-width: 76%;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.camera__engine { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: rgb(255 255 255 / 70%); }

/* ---------- Progress ---------- */

.pct { font-size: 26px; font-weight: 800; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.progress { height: 10px; margin: 14px 0; overflow: hidden; border-radius: 99px; background: var(--panel); }
.progress__fill { width: 0; height: 100%; border-radius: inherit; background: var(--grad); transition: width .3s; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--panel); }
.stat__label { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.stat__value { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Alerts ---------- */

.alerts { display: flex; flex-direction: column; gap: 10px; }
.alerts:empty { display: none; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 14px;
  text-align: left;
}
.alert > .icon { width: 20px; height: 20px; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__body strong { display: block; }
.alert__text { overflow-wrap: anywhere; }
.alert__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.alert__actions .btn { background: var(--card); color: inherit; border: 1px solid currentColor; }
.alert--ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-line); }
.alert--warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.alert--bad  { color: var(--bad);  background: var(--bad-bg);  border-color: var(--bad-line); }
.alert--info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }

/* ---------- Parts map ---------- */

.map { display: block; width: 100%; height: 0; }
.map-note { margin: 10px 0 0; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legend__ok { background: var(--map-ok); }
.legend__rec { margin-left: 6px; margin-right: 4px; background: var(--map-rec); }
.legend__miss { margin-left: 6px; background: var(--map-miss); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Done / error ---------- */

.done { display: flex; flex-direction: column; gap: 14px; text-align: center; }
.done__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 4px auto 0;
  border: 2px solid var(--ok-line);
  border-radius: 50%;
  background: var(--ok-bg);
  color: var(--ok);
}
.done__icon .icon { width: 32px; height: 32px; stroke-width: 2.5; }
.done__icon--bad { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad); }
.done__title { margin: 0; font-size: 22px; font-weight: 800; }
.done p { margin: 0; }

.file-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; background: var(--card); text-align: left; }

.badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.badge--ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-line); }
.badge--warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }

.preview { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.preview img { display: block; max-width: 100%; max-height: 300px; margin: 0 auto; }
.preview pre {
  max-height: 220px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  text-align: left;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn-col { display: flex; flex-direction: column; gap: 10px; }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.summary div { padding: 8px 10px; border-radius: 10px; background: var(--panel); text-align: left; }
.summary dt { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.summary dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 360px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  .stat { padding: 8px; }
  .stat__value { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
