:root{
  --bg:#f5f7fa;
  --panel:#ffffff;
  --border:#d6dbe6;
  --text:#1e2433;
  --muted:#6b6f7b;
  --ok:#3ddc97;
  --info-br:#2b73ff;
}

*{
  box-sizing:border-box;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Inter","Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  line-height:1.45;
  font-size:16px;
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
}

.wrap{
  max-width:860px;
  margin:0 auto;
  padding:16px 16px 20px;
}

/* ========= header ========= */

.site-header{
  background:var(--panel);
  padding-top:8px;
  padding-bottom:8px;
}

.header-inner{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
  row-gap:8px;
}

.branding{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}

.brand-title{
  font-weight:600;
  font-size:24px;
  line-height:1.2;
  color:var(--text);
  text-decoration:none;
  word-break:break-word;
}

.brand-sub{
  font-size:12px;
  line-height:1.3;
  color:var(--muted);
}

.header-actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:flex-start;
  gap:8px;
  font-size:13px;
  line-height:1.2;
  margin-left:auto;
  padding-left:12px;
}

.ghost-btn{
  appearance:none;
  -webkit-appearance:none;
  background:#fff;
  border:1px solid var(--border);
  border-radius:8px;
  color:var(--text);
  text-decoration:none;
  cursor:pointer;
  padding:8px 10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:500;
  min-height:32px;
  white-space:nowrap;
  line-height:1.2;
  box-shadow:0 1px 2px rgba(0,0,0,.04);
}

.ghost-btn:hover{
  background-color:#eef4ff;
  color:#000000;
  border-color:#2b73ff;
}

/* ========= intro ========= */

.intro{
  margin:16px 0 24px;
}

.intro h1{
  margin:0 0 15px;
  font-size:26px;
  line-height:1.2;
  font-weight:600;
  color:var(--text);
  letter-spacing:-.02em;
}

.intro p{
  margin:0;
  font-size:16px;
  line-height:1.4;
  color:var(--muted);
}

/* ========= cards ========= */

.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:16px 16px 20px;
  box-shadow:0 8px 24px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);
  color:var(--text);
}

/* Подсветка карточки по статусу (ошибки = красный и т.д.) */
.status-ok{
  border-color:#3ddc97;
  box-shadow:0px 0px 10px 5px  rgba(141,222,187,.4);
}

.status-warn{
  border-color:#4bace0;
  box-shadow:0px 0px 10px 5px  rgba(75, 174, 224, 0.4);
}

.status-bad{
  border-color:#ff6b6b;
  box-shadow:0px 0px 10px 5px  rgba(255,107,107,.4);
}

.card-title{
  margin:0 0 4px;
  font-size:20px;
  line-height:1.25;
  font-weight:600;
  color:var(--text);
}

.card-desc{
  margin:.375rem 0 1rem 0;
  color:var(--muted);
  font-size: 15px;
  line-height:1.45;
}

/* ========= формы ========= */

.form-row{display:flex; gap:8px; align-items:center; flex-wrap:nowrap; white-space:nowrap}

.input{
  flex:1 1 auto;
  min-width:0;
  appearance:none;
  -webkit-appearance:none;
  font-family:inherit;
  font-size:16px;
  line-height:1.4;
  padding:12px 14px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  box-shadow:0 0 0 3px rgba(43,115,255,0);
  transition:border-color .12s,box-shadow .12s,background .12s;
}

.input:focus{
  outline:none;
  border-color:#2b73ff;
  box-shadow:0 0 0 3px rgba(43,115,255,.2);
  background:#fff;
}

.icon-btn{
  flex:0 0 auto;
  appearance:none;
  -webkit-appearance:none;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:28px 0;
  width:56px;
  min-width:46px;
  height:46px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  line-height:0;
  box-shadow:0 1px 2px rgba(0,0,0,.04);
}

.icon-btn:hover{
  background:#eef4ff;
  color:#2b73ff;
  border-color:#2b73ff;
}

.icon-btn[hidden]{
  display:none;
}

.btn{
  flex:0 0 auto;
  cursor:pointer;
  appearance:none;
  -webkit-appearance:none;
  border:0;
  border-radius:10px;
  min-width:88px;
  min-height:45px;
  line-height:1.2;
  font-size:14px;
  font-weight:600;
  background:#2b73ff;
  color:#fff;
  padding:14px 14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  position:relative;
  box-shadow:0 12px 30px rgba(43,115,255,.3),0 1px 2px rgba(0,0,0,.08);
  overflow:hidden;
}

.btn[disabled],
.btn[aria-busy="true"]{
  opacity:.6;
  cursor:default;
}

.btn:not([disabled]):not([aria-busy="true"]):hover{
  background:#1f5ce0;
}

/* бегущая полоска пока кнопка занята */
.timerbar{
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:100%;
  border-radius:10px;
  pointer-events:none;
  background-image:linear-gradient(90deg,rgba(255,255,255,.4) 0%,rgba(255,255,255,0) 70%);
  animation:timer-shimmer 2s infinite;
  opacity:0;
}

.btn[aria-busy="true"] .timerbar{
  opacity:1;
}

@keyframes timer-shimmer{
  0%{transform:translateX(-60%);}
  100%{transform:translateX(100%);}
}

/* «три точки» анимация ожидания после окончания отсчёта */
.dots{
  display:inline-flex;
  gap:4px;
}

.dots i{
  width:4px;
  height:4px;
  border-radius:50%;
  background:#fff;
  animation:dotsPulse 1s infinite ease-in-out;
}

.dots i:nth-child(2){animation-delay:.15s;}
.dots i:nth-child(3){animation-delay:.3s;}

@keyframes dotsPulse{
  0%,100%{opacity:.2;transform:translateY(0);}
  50%{opacity:1;transform:translateY(-2px);}
}

/* ========= вывод результата поиска ========= */

.result{
  margin-top:16px;
  font-size:14px;
  line-height:1.45;
  color:var(--text);
}
.result a,
.result a:visited{
  color:#2b73ff;
}

.result-err{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  column-gap:13px;
  row-gap:18px;
}

.result-err .badge{
  margin:0;
}

.result-msg{
  flex:0 1 auto;
}

.result-msg--block{
  flex-basis:100%;
}

.badge{
  display:inline-block;
  border-radius:999px;
  font-size:12px;
  line-height:1.2;
  font-weight:500;
  padding:10px 10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  margin-right:13px;
  margin-bottom:18px;
}

.badge.warn{
  background:#77cfff;
  border-color:#59b1e1;
  color:#235773;
}

.badge.ok{
  background:#d8f5e6;
  border-color:#3ddc97;
  color:#146c43;
}

.badge.bad{
  background:#ffecec;
  border-color:#ff6b6b;
  color:#7f1d1d;
}

/* key/value таблица ответа */
.kv{
  display:grid;
  grid-template-columns:max-content 1fr;
  column-gap:12px;
  row-gap:8px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  padding:12px 14px;
  font-size:15px;
  line-height:1.4;
  position:relative;
  container-type:inline-size;
  align-items: center;
}

.kv .k{
  font-size:14px;
  line-height:1.3;
  font-weight:500;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:4px;
  position:relative;
}

.fn-excise-note{
  margin-top:4px;
  font-size:13px;
  color:var(--muted);
}

/* всплывающая подсказка (light) */
.tip{
  position:absolute;
  z-index:50;
  top:calc(100% + 8px);
  left:0;
  background:#fff !important;
  color:var(--text) !important;
  border:1px solid var(--border) !important;
  box-shadow:0 20px 64px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06);
  border-radius:12px;
  padding:12px 32px 12px 14px;
  font-size:13px;
  line-height:1.4;
  max-width:min(480px,100cqw) !important;
  min-width:min(260px,100cqw) !important;
  box-sizing:border-box;
}

.tip-close{
  position:absolute;
  top:8px;
  right:8px;
  background:none;
  border:0;
  color:var(--muted);
  font-size:16px;
  line-height:1;
  width:24px;
  height:24px;
  cursor:pointer;
}

.tip-close:hover{
  color:#000;
}

.tip strong{
  color:var(--text);
}

.tip p{
  margin:6px 0 0;
  font-size:13px;
  line-height:1.4;
  color:var(--muted);
}

.tip[hidden]{
  display:none!important;
}

/* чтобы тултип не улетал влево на мобильных — ограничиваем ширину по контейнеру карты */
@container (max-width:480px){
  .tip{
    left:0;
    right:auto;
    max-width:100cqw !important;
    min-width:min(260px,100cqw) !important;
  }
}

/* ========= Сканер (оверлей камеры остаётся тёмным для читабельности превью) ========= */

.scan-overlay[hidden]{
  display:none!important;
}

.scan-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.9);
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:9999;
}

.scan-box{
  background:#0f1424;
  border:1px solid rgba(255,255,255,.12);
  border-radius:16px;
  box-shadow:0 40px 120px rgba(0,0,0,.9),0 2px 3px rgba(0,0,0,.8);
  width:100%;
  max-width:420px;
  font-size:14px;
  line-height:1.4;
  color:#fff;
  display:flex;
  flex-direction:column;
  max-height:90vh;
}

.scan-toolbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  padding:12px;
  border-bottom:1px solid rgba(255,255,255,.12);
  gap:8px;
}

.scan-toolbar .left{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

/* в оверлее кнопки и селект должны быть светлыми на тёмном фоне */
.scan-overlay .ghost-btn{
  background:rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.3);
  color:#fff;
  box-shadow:none;
}

.scan-overlay .ghost-btn:hover{
  background:rgba(255,255,255,.16);
  color:#fff;
  border-color:rgba(255,255,255,.6);
}

#cameraSelect{
  font-size:13px;
  line-height:1.2;
  padding:8px 10px;
  min-height:32px;
  background:rgba(255,255,255,.07);
  border-radius:8px;
  border:1px solid rgba(255,255,255,.3);
  color:#fff;
  cursor:pointer;
  min-width:140px;
}

.modes-label{
  color:#fff;
  font-weight:700;
  font-size:13px;
  letter-spacing:.4px;
  border:1px solid rgba(255,255,255,.3);
  padding:6px 10px;
  border-radius:10px;
  min-width:fit-content;
}

.video-wrap{position:relative;flex:1 1 auto;min-height:220px;overflow:hidden}
#scanVideo{width:100%;height:auto;background:#000;border-radius:10px}

.roi{
  position:absolute;
  left:6%;
  right:6%;
  top:40%;
  bottom:38%;
  border:2px solid rgba(255,255,255,.7);
  border-radius:6px;
  box-shadow:0 0 0 9999px rgba(0,0,0,.35) inset;
  pointer-events:none;
  animation:roiPulse 2s infinite linear;
}

@keyframes roiPulse{
  0%,100%{border-color:rgba(255,255,255,.35)}
  50%{border-color:rgba(255,255,255,.6)}
}

.focus-ring{
  position:absolute;
  width:88px;
  height:88px;
  border:2px solid rgba(153,185,255,.95);
  border-radius:50%;
  pointer-events:none;
  transform:translate(-50%,-50%) scale(.9);
  opacity:0;
  transition:opacity .15s ease,transform .15s ease;
  box-shadow:0 0 0 3px rgba(153,185,255,.25),inset 0 0 18px rgba(153,185,255,.18);
}

.focus-ring.show{
  opacity:1;
  transform:translate(-50%,-50%) scale(1);
}

.scan-hint{
  color:#c5ccda;
  font-size:13px;
  padding:12px;
  text-align:center;
}

.scan-actions{
  position:sticky;
  bottom:0;
  background:linear-gradient(to top,rgba(15,18,36,.97),rgba(15,18,36,0));
  padding:10px 12px calc(8px + env(safe-area-inset-bottom));
  display:flex;
  gap:8px;
  justify-content:flex-end;
  align-items:center;
  border-top:1px solid rgba(255,255,255,.06);
}

/* ========= footer ========= */

.site-footer{
  border-top:1px solid var(--border);
  margin-top:18px;
  padding-top:16px;
  padding-bottom:64px;
  font-size:12px;
  line-height:1.4;
  color:var(--muted);
  background:var(--bg);
}

/* ========= helpers ========= */

.sr-only{
  position:absolute!important;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.mobile-only{
  display:inline-flex;
}

@media(min-width:720px){
  .mobile-only{
    display:none;
  }
}

/* ========= FAQ ========= */

.faq{
  margin-top:32px;
}

.faq-head{
  appearance:none;
  -webkit-appearance:none;
  background:none;
  border:0;
  padding:0;
  font-size:20px;
  line-height:1.25;
  font-weight:600;
  color:var(--text);
  display:flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
}

.faq-head::after{
  content:"";
  width:10px;
  height:10px;
  border-right:2px solid var(--muted);
  border-bottom:2px solid var(--muted);
  border-radius:2px;
  transform:rotate(-45deg) translateY(-1px);
  transition:transform .15s;
}

.faq-head[aria-expanded="true"]::after{
  transform:rotate(45deg) translateY(1px);
}

.faq-body{
  margin-top:16px;
}

.faq-list{
  display:grid;
  gap:8px;
}

.faq-q{
  --faq-q-minh:3rem;
  width:100%;
  display:flex;
  align-items:center;
  text-align:left;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  border-radius:8px;
  padding:12px 14px;
  min-height:var(--faq-q-minh);
  line-height:1.3;
  font-size:15px;
  font-weight:500;
  cursor:pointer;
  justify-content:space-between;
  box-shadow:0 1px 2px rgba(0,0,0,.03);
}

.faq-q[aria-expanded="true"]{
  background:#fff;
  border-color:#2b73ff;
  color:var(--text);
  box-shadow:0 0 0 2px rgba(43,115,255,.2);
}

.faq-a{
  font-size:15px;
  line-height:1.45;
  color:var(--text);
  background:#f9fafb;
  border-left:3px solid #2b73ff;
  border-radius:0 8px 8px 0;
  padding:12px 14px;
}
.faq-a ul,
.msg-list{
  margin:6px 0;
  padding-left:20px;
}
.info-tip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:1.25em;
  height:1.25em;
  margin-left:.45rem;
  border:1px solid currentColor;
  border-radius:50%;
  background:transparent;
  color:inherit;
  font-weight:700;
  line-height:1;
  cursor:pointer;
  transition: transform .15s ease;
}
.info-tip:hover{ transform: scale(1.05); }
.info-tip:focus{ outline:2px solid currentColor; outline-offset:2px; }

/* === PATCH: мобильный хедер и кнопки (<640px) === */
@media (max-width: 639px) {

  /* Вся шапка: сначала бренд, потом ряд кнопок */
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    row-gap: 0.75rem;
  }

  /* Контейнер с кнопками: теперь это единая полоса под брендом */
  .header-actions {
    order: 2; /* идёт после .branding */
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: stretch;         /* тянем все кнопки по высоте самой высокой */
    justify-content: space-between;
    flex-wrap: nowrap;            /* сами кнопки НЕ переносятся на новую строку */
    column-gap: 0.5rem;
    margin-left: 0;               /* убираем auto, чтобы не уезжало вправо */
  }

  .branding {
    order: 1;
    width: 100%;
  }

  /* Каждая кнопка: занимает треть строки, может стать выше из-за переноса текста */
  .header-actions .ghost-btn {
    flex: 1 1 0;
    min-width: 0;                 /* разрешаем сжиматься, чтобы влезли все три */
    white-space: normal !important;   /* можно переносить текст внутри */
    word-break: break-word;
    text-align: center;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  /* Форма: на мобильных кнопку "Проверить" показываем под полем, на всю ширину */
  .form-row{
    flex-wrap: wrap;
    align-items: stretch;
    white-space: normal;
  }

  .form-row .btn{
    flex: 1 0 100%;
    width: 100%;
    margin-top: 10px;
    padding: 20px;
  }

  .input{
  padding: 17px;
  }

  .form-row .input{
    flex-basis: 0;
  }

  

}

/* ================== Кнопки копирования значений ================== */
.copy-btn {
  border: none;
  background: transparent;
  padding: 0;
  margin-left: 4px;
  cursor: pointer;
  color: #91b1b8;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.copy-btn:focus {
  outline: none;
}

.copy-icon {
  width: 16px;
  height: 16px;
  opacity: 0.75;
}

.copy-icon path {
  fill: #91b1b8;           
}

.copy-btn:hover .copy-icon {
  opacity: 1;
}

.copy-btn--done .copy-icon {
  opacity: 1;
}

.copy-btn--done .copy-icon path {
  fill: #19ce80;
}
