:root {
  --bg: #f2f1ec;
  --bg-soft: #e9e7e0;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --ink: #171715;
  --ink-soft: #48463f;
  --muted: #6e6b62;
  --line: #e5e2d9;
  --line-strong: #d7d3c8;
  --accent: #d51f2b;
  --accent-dark: #ad1420;
  --accent-soft: #fbeaec;
  --ok: #16733f;
  --ok-soft: #e8f4ec;
  --warn: #8b5300;
  --warn-soft: #fdf3e2;
  --bad: #a5231d;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 1px 0 rgba(20, 20, 18, 0.04), 0 18px 50px -28px rgba(20, 20, 18, 0.28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(213, 31, 43, 0.055), transparent 65%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.scanning {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

p,
h1,
h2,
h3 {
  margin: 0;
}

.page {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

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

/* ---------- Верхняя панель ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  box-shadow: 0 7px 18px -8px rgba(213, 31, 43, 0.85);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-text b {
  font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-text small {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.local-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.local-pill:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.local-pill svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.local-pill .cloud-icon {
  display: none;
}

.local-pill.is-cloud {
  border-color: #cfe7d8;
  background: var(--ok-soft);
  color: var(--ok);
}

.local-pill.is-cloud .cloud-icon {
  display: block;
}

.local-pill.is-cloud .local-icon {
  display: none;
}

.local-pill.is-syncing {
  border-color: #f0d9ae;
  background: var(--warn-soft);
  color: var(--warn);
}

.local-pill.is-syncing .cloud-icon {
  animation: cloud-pulse 1.1s ease-in-out infinite;
}

.local-pill.is-error {
  border-color: #f0c9c6;
  background: var(--accent-soft);
  color: var(--bad);
}

.local-pill.is-offline {
  border-color: #f0d9ae;
  background: var(--warn-soft);
  color: var(--warn);
}

@keyframes cloud-pulse {
  50% { opacity: 0.4; }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 26px 22px 22px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(213, 31, 43, 0.3), transparent 42%),
    radial-gradient(90% 90% at 0% 100%, rgba(255, 255, 255, 0.07), transparent 55%),
    #191917;
  color: #fff;
  box-shadow: 0 24px 60px -36px rgba(10, 10, 9, 0.9);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 0.8px, transparent 0.8px);
  background-size: 13px 13px;
  opacity: 0.18;
  mask-image: linear-gradient(115deg, transparent 20%, #000 70%);
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  color: #e8bcbf;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(213, 31, 43, 0.16);
}

.hero h1 {
  max-width: 9ch;
  font-size: clamp(36px, 10.6vw, 52px);
  font-weight: 800;
  line-height: 0.96;
  letter-spacing: -0.048em;
}

.hero-copy > p {
  max-width: 31ch;
  margin-top: 13px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 14px;
  line-height: 1.45;
}

.hero .btn-light {
  margin-top: 22px;
}

.hero-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.hero-actions .btn {
  flex: 1;
}

.hero-art {
  display: none;
}

/* ---------- Шаги ---------- */

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 8px 18px;
  color: var(--muted);
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
}

.step span {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-soft);
}

.step p {
  font-size: 12px;
  font-weight: 600;
}

.step-line {
  width: 22px;
  height: 1px;
  background: var(--line-strong);
}

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 15px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease,
    opacity 0.15s ease;
}

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

.btn:focus-visible,
.icon-btn:focus-visible,
.round-btn:focus-visible,
.chip:focus-visible,
.history-item:focus-visible,
.text-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-lg {
  min-height: 54px;
  padding: 15px 20px;
  border-radius: 17px;
  font-size: 15.5px;
}

.btn-xl {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  font-size: 16px;
}

.btn-red {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 13px 28px -15px rgba(213, 31, 43, 0.95);
}

.btn-red:hover {
  background: var(--accent-dark);
}

.btn-light {
  background: #fff;
  color: var(--ink);
}

.btn-light:hover {
  background: #f6f3ee;
}

.btn-ghost-light {
  border-color: rgba(255, 255, 255, 0.17);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

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

.btn-ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: #fff;
  border-color: var(--line-strong);
}

.btn-outline {
  min-height: 46px;
  padding: 10px 8px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12.5px;
  border-radius: 13px;
}

.btn-outline:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.btn-outline svg {
  width: 17px;
  height: 17px;
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.55;
}

/* ---------- Карточки ---------- */

.card {
  position: relative;
  border: 1px solid rgba(20, 20, 18, 0.055);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.result-card {
  margin-top: 4px;
  padding: 18px;
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pill svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill-ok {
  border-color: #cfe7d8;
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-warn {
  border-color: #f0d9ae;
  background: var(--warn-soft);
  color: var(--warn);
}

.pill .spinner {
  width: 11px;
  height: 11px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-shell {
  padding: 17px 14px 13px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), transparent 40%),
    var(--surface-2);
}

.preview {
  width: min(222px, 62vw);
  margin: 0 auto;
  padding: 9px;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.preview svg {
  width: 100%;
  height: auto;
}

.preview-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.2;
}

.caption-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

/* ---------- Поля данных ---------- */

.data-list {
  display: grid;
  gap: 0;
  margin-top: 15px;
}

.data-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.data-row:last-child {
  border-bottom: 0;
}

.data-row dt {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.data-row dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
}

.data-row dd.truncate {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.data-row .warn-text {
  color: var(--warn);
  font-family: var(--font);
  font-size: 12px;
}

/* ---------- Размер ---------- */

.size-control {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.control-label {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 650;
}

.control-value {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-width: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
}

.chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.size-range {
  width: 100%;
  height: 32px;
  margin: 9px 0 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.size-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
}

.size-range::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  -webkit-appearance: none;
}

.size-range::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
}

.size-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
}

.hint {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.hint strong {
  color: var(--ink-soft);
  font-weight: 650;
}

.hint.is-warn {
  color: var(--warn);
}

.hint.is-bad {
  color: var(--bad);
}

/* ---------- Доп. настройки ---------- */

.advanced {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.advanced summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  list-style: none;
}

.advanced summary::-webkit-details-marker,
.raw-details summary::-webkit-details-marker,
.info-card summary::-webkit-details-marker {
  display: none;
}

.advanced summary svg,
.info-card .chev {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}

.advanced[open] summary svg {
  transform: rotate(180deg);
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 13px 13px;
}

.advanced-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.advanced-grid select {
  width: 100%;
  padding: 9px 28px 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #7a776e 50%),
    linear-gradient(135deg, #7a776e 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ---------- Экспорт ---------- */

.export-primary {
  margin-top: 18px;
}

.export-primary .btn {
  width: 100%;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
}

@media (max-width: 520px) {
  .export-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .export-grid #btn-share {
    grid-column: 1 / -1;
  }
}

.export-note {
  margin-top: 9px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.export-note span {
  color: var(--ink-soft);
  font-family: var(--mono);
}

.verify-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.verify-line .spinner {
  width: 13px;
  height: 13px;
}

.verify-line.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.verify-line.fail {
  background: var(--warn-soft);
  color: var(--warn);
}

.verify-line .v-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.verify-line .v-icon svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Данные кода ---------- */

.raw-details {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.raw-details summary {
  padding: 9px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.raw-box {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-height: 140px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  overflow: auto;
}

.raw-box code {
  flex: 1;
  min-width: 0;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.raw-box .icon-btn {
  position: sticky;
  top: 0;
  width: 30px;
  height: 30px;
  background: #fff;
}

.raw-box .icon-btn svg {
  width: 15px;
  height: 15px;
}

#btn-again {
  margin-top: 9px;
}

/* ---------- История ---------- */

.history {
  margin-top: 26px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  padding: 0 4px;
}

.section-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-btn {
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.text-btn:hover {
  color: var(--accent);
}

.history-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(20, 20, 18, 0.055);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.history-item:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.hist-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.hist-icon svg {
  width: 22px;
  height: 22px;
  shape-rendering: crispEdges;
}

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

.hist-main b {
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-main small {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-chev {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hist-chev svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Архив ---------- */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.archive-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.archive-btn:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.archive-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.archive-btn b {
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
}

.archive-teaser {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.6);
}

.archive-teaser-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--ink);
}

.archive-teaser-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.archive-teaser-main {
  flex: 1;
  min-width: 0;
}

.archive-teaser-main h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.archive-teaser-main p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.archive-teaser .btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 13px;
  font-size: 11.5px;
}

.sheet-head-copy {
  min-width: 0;
}

.sheet-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

dialog.sheet.sheet-wide {
  max-width: 860px;
  overflow: hidden;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 24px);
  padding: 20px 18px calc(16px + env(safe-area-inset-bottom));
}

.archive-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.9;
  stroke-linecap: round;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  outline: 0;
}

.archive-tools .text-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
  margin: 0 -2px;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid rgba(20, 20, 18, 0.07);
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.archive-item:hover {
  border-color: var(--line-strong);
}

.archive-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.archive-check {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

.archive-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}

.archive-icon svg {
  width: 19px;
  height: 19px;
  shape-rendering: crispEdges;
}

.archive-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.archive-main b {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-main small {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-main:hover b {
  color: var(--accent);
}

.archive-qty {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10.5px;
}

.archive-qty input {
  width: 42px;
  padding: 6px 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: center;
}

.archive-qty input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.archive-empty {
  padding: 26px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.archive-more .btn {
  margin-top: 6px;
  min-height: 38px;
}

.archive-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.archive-selection {
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

.archive-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.archive-actions .btn {
  min-height: 38px;
  padding: 0 12px;
  font-size: 11.5px;
}

.archive-manage {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.archive-manage .text-btn {
  color: var(--muted);
}

.archive-manage .text-btn:hover {
  color: var(--bad);
}

.archive-manage .text-btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- Печать листом ---------- */

#print-dialog .sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog.sheet-wide .print-layout {
  display: grid;
  grid-template-columns: minmax(0, 250px) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.print-settings {
  min-width: 0;
}

.setting {
  display: block;
  margin-bottom: 13px;
}

.setting-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.setting-head output {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
}

.segmented.segmented-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
}

.segmented.segmented-3 span {
  padding: 7px 3px;
  font-size: 10px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 9px 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}

.check-row input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.print-preview-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.print-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  flex: 1;
  min-height: 160px;
  max-height: min(54vh, 520px);
  padding: 12px;
  overflow: auto;
  border-radius: 15px;
  background: var(--bg-soft);
}

.sheet-page {
  position: relative;
  overflow: hidden;
  background: #fff;
  color: #000;
}

.sheet-page--preview {
  width: min(100%, 220px);
  flex: 0 0 auto;
  container-type: size;
  border-radius: 2px;
  box-shadow: 0 5px 16px -6px rgba(20, 20, 18, 0.4);
}

.sheet-code {
  position: absolute;
}

.sheet-code svg {
  width: 100%;
  height: 100%;
}

.sheet-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  font-family: var(--mono);
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.sheet-label span {
  display: block;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
}

.sheet-guide {
  position: absolute;
  border: 1px dashed rgba(0, 0, 0, 0.28);
}

.sheet-calib {
  position: absolute;
  border: 1px solid #000;
}

.sheet-calib span {
  position: absolute;
  right: 100%;
  top: 50%;
  padding-right: 1.2mm;
  color: #000;
  font-family: var(--mono);
  font-size: 0.62cqh;
  white-space: nowrap;
  transform: translateY(-50%);
}

.print-summary {
  margin-top: 9px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
}

.print-warning {
  margin-top: 7px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 10.5px;
  line-height: 1.45;
}

.sheet-actions.print-actions {
  grid-template-columns: 0.8fr 1fr 1fr;
}

/* ---------- Информация ---------- */

.info-card {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.45);
}

.info-card summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.info-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.info-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.info-card summary > span:nth-child(2) {
  flex: 1;
}

.info-card[open] .chev {
  transform: rotate(180deg);
}

.info-body {
  padding: 0 15px 15px;
}

.info-body ol {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.info-body li {
  margin-bottom: 7px;
  padding-left: 2px;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--warn-soft);
  color: #6d4b14;
  font-size: 11px;
  line-height: 1.45;
}

.notice strong {
  color: var(--warn);
}

/* ---------- Футер ---------- */

.footer {
  margin-top: 26px;
  padding: 0 6px;
  text-align: center;
}

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

.footer .privacy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 7px;
  font-size: 10px;
}

.footer .privacy svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Сканер ---------- */

.scanner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #080808;
  color: #fff;
  animation: fade-in 0.18s ease both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.scanner video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #080808;
}

.scanner-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.62) 0, transparent 22%, transparent 70%, rgba(0, 0, 0, 0.74) 100%);
  pointer-events: none;
}

.scanner-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  z-index: 2;
}

.scanner-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.82);
}

.round-btn {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.round-btn:active {
  background: rgba(255, 255, 255, 0.16);
}

.round-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.round-btn.on {
  border-color: rgba(255, 220, 120, 0.65);
  background: rgba(255, 208, 74, 0.24);
  color: #ffe08a;
}

.scanner-center {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  flex: 1;
  padding: 24px;
}

.scan-frame {
  position: relative;
  width: min(68vw, 300px);
  aspect-ratio: 1;
  border-radius: 4px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.48);
}

.scan-frame .corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 0 solid var(--accent);
  filter: drop-shadow(0 0 8px rgba(213, 31, 43, 0.55));
}

.scan-frame .tl {
  top: -2px;
  left: -2px;
  border-top-width: 3px;
  border-left-width: 3px;
  border-top-left-radius: 4px;
}

.scan-frame .tr {
  top: -2px;
  right: -2px;
  border-top-width: 3px;
  border-right-width: 3px;
  border-top-right-radius: 4px;
}

.scan-frame .bl {
  bottom: -2px;
  left: -2px;
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-bottom-left-radius: 4px;
}

.scan-frame .br {
  right: -2px;
  bottom: -2px;
  border-right-width: 3px;
  border-bottom-width: 3px;
  border-bottom-right-radius: 4px;
}

.scan-line {
  position: absolute;
  top: 4%;
  left: 3%;
  width: 94%;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 80, 90, 0.95), transparent);
  box-shadow: 0 0 12px rgba(255, 60, 70, 0.8);
  animation: scan-move 2.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scan-move {
  0%, 100% { top: 5%; opacity: 0.55; }
  50% { top: 94%; opacity: 1; }
}

.scanner-bottom {
  position: relative;
  z-index: 2;
  padding: 0 24px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
}

.scan-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  line-height: 1.3;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.scan-status.warn {
  border-color: rgba(255, 196, 92, 0.55);
  background: rgba(64, 44, 0, 0.62);
  color: #ffd889;
}

.scanner-bottom p {
  margin-top: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

.scan-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 8, 8, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.scan-error-card {
  width: 100%;
  max-width: 360px;
  padding: 24px 20px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background: #1e1e1c;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.error-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(213, 31, 43, 0.18);
  color: #ff8b93;
  font-size: 22px;
  font-weight: 700;
}

.scan-error-card h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.scan-error-card p {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12.5px;
  line-height: 1.5;
}

.scan-error-card .btn {
  width: 100%;
  margin-top: 10px;
}

.scan-error-card .btn:first-of-type {
  margin-top: 18px;
}

/* ---------- Общий архив ---------- */

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

.cloud-lead {
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.5;
}

.cloud-warning {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11.5px;
  line-height: 1.45;
}

.cloud-warning svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cloud-block h3 {
  margin-bottom: 9px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cloud-block .btn {
  margin-top: 10px;
}

.text-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.text-input::placeholder {
  color: #a5a198;
}

.text-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.code-input {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cloud-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cloud-divider::before,
.cloud-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.cloud-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

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

.cloud-label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cloud-current-main b {
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.cloud-current-main small {
  color: var(--muted);
  font-size: 10.5px;
}

.cloud-status {
  margin-top: -7px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.cloud-status.is-bad {
  color: var(--bad);
}

.cloud-status.is-warn {
  color: var(--warn);
}

.cloud-code {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-align: center;
  word-break: break-all;
  user-select: all;
}

.cloud-code-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.cloud-code-actions .btn {
  min-height: 38px;
  padding: 0 8px;
  font-size: 11.5px;
}

.cloud-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
}

.cloud-actions .btn {
  min-height: 44px;
}

.cloud-actions .btn svg {
  width: 16px;
  height: 16px;
}

.cloud-danger {
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.cloud-danger summary {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.cloud-danger-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
}

.cloud-danger-body p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.cloud-danger-body .btn {
  min-height: 38px;
  font-size: 11.5px;
}

.cloud-danger-btn {
  color: var(--bad);
  border-color: rgba(165, 35, 29, 0.28);
}

.cloud-danger-btn:hover {
  border-color: var(--bad);
  background: var(--accent-soft);
}

#cloud-dialog .sheet-body {
  overflow-y: auto;
}

#cloud-dialog .form-error {
  margin-top: 0;
}

#cloud-dialog .hint {
  margin-top: 8px;
}

/* ---------- Диалог ---------- */

dialog.sheet {
  width: 100%;
  max-width: 540px;
  max-height: calc(100% - 20px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -20px 80px rgba(0, 0, 0, 0.3);
}

dialog.sheet::backdrop {
  background: rgba(20, 20, 17, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

dialog.sheet form {
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.sheet-head h2 {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 650;
}

textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

textarea:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 11px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-soft);
}

.segmented label {
  position: relative;
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 8px 6px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(20, 20, 18, 0.08);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

.form-error {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--bad);
  font-size: 11.5px;
  line-height: 1.4;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 2000;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(23, 23, 21, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

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

/* ---------- Спиннер ---------- */

.spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  opacity: 0.75;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Печать ---------- */

#print-area {
  display: none;
}

.print-page {
  position: relative;
  overflow: hidden;
  background: #fff;
  color: #000;
}

@media print {
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  body > .page,
  .scanner,
  .toast,
  dialog.sheet {
    display: none !important;
  }

  #print-area {
    display: block !important;
  }

  #print-area svg {
    display: block;
  }

  .print-page {
    break-after: page;
    page-break-after: always;
  }

  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-page .sheet-label {
    font-family: Arial, Helvetica, sans-serif;
  }

  .print-page .sheet-guide {
    border: 0.15mm dashed #999;
  }

  .print-page .sheet-calib {
    border: 0.3mm solid #000;
  }

  .print-page .sheet-calib span {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 2mm;
    padding-right: 1.5mm;
  }
}

/* ---------- Шире телефона ---------- */

@media (min-width: 560px) {
  .page {
    padding-left: 20px;
    padding-right: 20px;
  }

  .hero {
    padding: 34px 32px 30px;
  }

  .hero h1 {
    font-size: 56px;
  }

  .hero-copy > p {
    font-size: 15px;
  }

  .hero .btn-xl {
    width: auto;
    min-width: 240px;
  }

  .hero-actions {
    max-width: 360px;
  }

  .hero-art {
    position: absolute;
    top: 50%;
    right: 30px;
    display: block;
    width: 170px;
    transform: translateY(-50%) rotate(5deg);
  }

  .hero-copy {
    max-width: 66%;
  }

  .label-card {
    padding: 10px;
    border-radius: 15px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
  }

  .label-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
  }

  .label-chip {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
  }

  .label-lines {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
  }

  .label-lines i {
    display: block;
    height: 4px;
    border-radius: 2px;
    background: #e9e7e0;
  }

  .label-lines i:nth-child(2) {
    width: 70%;
  }

  .label-lines i:nth-child(3) {
    width: 45%;
  }

  .label-dm {
    width: 100%;
    height: auto;
    border: 1px solid #eeece5;
    border-radius: 5px;
    background: #fff;
  }

  .label-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    color: var(--muted);
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .label-card-bottom b {
    display: grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 8px;
  }

  .art-badge {
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 8.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
  }

  .result-card {
    padding: 22px;
  }

  .preview {
    width: 250px;
  }

  .export-grid {
    gap: 9px;
  }

  .btn-outline {
    min-height: 48px;
    font-size: 13px;
  }
}

@media (min-width: 720px) {
  .page {
    padding-top: 22px;
  }

  .topbar {
    padding-bottom: 20px;
  }

  dialog.sheet.sheet-wide {
    margin: auto;
    border-radius: 24px;
    max-height: calc(100% - 40px);
  }
}

@media (max-width: 719px) {
  dialog.sheet-wide .print-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .print-preview {
    flex: 0 0 auto;
    max-height: 42vh;
    min-height: 0;
  }

  .archive-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .archive-actions {
    display: grid;
    grid-template-columns: 0.8fr 0.8fr 1.2fr;
  }

  .archive-actions .btn {
    padding: 0 8px;
  }
}

@media (max-width: 370px) {
  .page {
    padding-left: 11px;
    padding-right: 11px;
  }

  .hero {
    padding: 22px 17px 18px;
    border-radius: 23px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .brand-text small {
    display: none;
  }

  .steps {
    flex-wrap: wrap;
    gap: 10px 6px;
    padding: 18px 4px;
  }

  .step {
    gap: 5px;
  }

  .step p {
    font-size: 11.5px;
  }

  .step-line {
    display: none;
  }

  .local-pill {
    padding: 5px 8px;
  }

  .archive-btn {
    padding: 6px 8px;
  }

  .archive-btn span {
    display: none;
  }

  .result-card {
    padding: 14px;
  }

  .chips {
    gap: 5px;
  }

  .chip {
    min-width: 44px;
    padding: 7px 8px;
  }

  .btn-outline {
    font-size: 11.5px;
  }

  .btn-outline svg {
    width: 15px;
    height: 15px;
  }

  .data-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .scan-line {
    top: 50%;
    opacity: 0.8;
  }
}
