/* Valuta — основа: сброс, набор, примитивы дизайн-системы «Ценная бумага». */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0; min-height: 100vh;
  background: var(--paper); color: var(--ink);
  font: 400 var(--t-body)/1.55 var(--f-text);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
/* Фактура хлопковой бумаги */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08  0 0 0 0 0.08  0 0 0 0 0.1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.16; mix-blend-mode: multiply;
}
:root[data-theme="dark"] body::before { opacity: 0.22; mix-blend-mode: screen; filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { opacity: 0.22; mix-blend-mode: screen; filter: invert(1); } }
#root { position: relative; z-index: 1; }
/* УФ-волокна тёмной темы (js/fx.js) */
.fibers { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0.9; }

img, svg, canvas { display: block; max-width: 100%; }
canvas { max-width: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, ol, ul, dl, dd, figure, blockquote { margin: 0; }
ol, ul { padding: 0; list-style: none; }
::selection { background: var(--violet); color: #fff; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--r-sm); }
.skip:focus { top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: calc(var(--maxw) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Набор ---------- */
.display, .d1, .d2, .d3, .d4 {
  font-family: var(--f-display); font-weight: 300; line-height: 0.98; letter-spacing: -0.022em;
  font-variation-settings: "wdth" 82; font-optical-sizing: auto;
}
.display { font-size: var(--t-hero); line-height: 0.92; letter-spacing: -0.028em; font-variation-settings: "wdth" 74; }
.d1 { font-size: var(--t-d1); }
.d2 { font-size: var(--t-d2); line-height: 1.02; }
.d3 { font-size: var(--t-d3); line-height: 1.06; letter-spacing: -0.016em; }
.d4 { font-size: var(--t-d4); line-height: 1.12; letter-spacing: -0.01em; font-weight: 400; }
.display i, .d1 i, .d2 i, .d3 i, .d4 i, em.it { font-style: italic; font-weight: 300; color: var(--violet); }
.lead { font-size: var(--t-lead); line-height: 1.5; color: var(--ink-2); max-width: 36em; }
.muted { color: var(--muted); }
.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.amount { font-family: var(--f-display); font-weight: 300; font-variation-settings: "wdth" 70; letter-spacing: -0.02em; font-variant-numeric: lining-nums tabular-nums; }
.mono { font-family: var(--f-mono); }

/* Надзаголовок: моноширинный, разрядкой, с номером раздела */
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 var(--t-micro)/1 var(--f-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.eyebrow b { color: var(--serial); font-weight: 500; }
.eyebrow::before { content: ""; width: 22px; height: 1px; background: currentColor; opacity: 0.6; }
.eyebrow.plain::before { display: none; }

/* Серийный номер — как на купюре */
.serial { font: 500 13px/1 var(--f-mono); letter-spacing: 0.12em; color: var(--serial); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Микротекст: строка мелкого текста, повторённая до края */
.micro {
  display: block; overflow: hidden; white-space: nowrap;
  font: 500 7.5px/1.4 var(--f-mono); letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); opacity: 0.85;
  user-select: none;
}
.micro-rule { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 3px 0; }

/* Гравировка: текст, заполненный тонкими линиями */
.engrave {
  color: transparent;
  background: repeating-linear-gradient(0deg, var(--ink) 0 1px, transparent 1px 3.2px);
  -webkit-background-clip: text; background-clip: text;
}

/* ---------- Иконки ---------- */
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 28px; height: 28px; stroke-width: 1.25; }

/* ---------- Гильош: печати и ленты ---------- */
.seal { display: block; overflow: visible; }
.seal path, .seal circle { fill: none; vector-effect: non-scaling-stroke; stroke-width: 0.6; }
.seal .g-a { stroke: var(--g-a); opacity: 0.55; }
.seal .g-b { stroke: var(--g-b); opacity: 0.8; }
.seal .g-c { stroke: var(--g-c); opacity: 0.75; }
.band { width: 100%; height: 100%; }
.band path { fill: none; stroke: currentColor; stroke-width: 0.6; vector-effect: non-scaling-stroke; }

/* ---------- Голограмма ---------- */
.foil {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--foil); background-size: 260% 260%;
  background-position: calc(var(--fx, 0.5) * 100%) calc(var(--fy, 0.5) * 100%);
  transition: background-position 0.5s var(--ease);
}
.foil::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: repeating-linear-gradient(62deg, rgba(255, 255, 255, 0.45) 0 1px, transparent 1px 3.5px),
              repeating-linear-gradient(-28deg, rgba(20, 22, 27, 0.06) 0 1px, transparent 1px 5px);
  mix-blend-mode: overlay;
}
.foil::after {
  content: ""; position: absolute; inset: -40%; z-index: -1;
  background: radial-gradient(closest-side at calc(var(--fx, 0.5) * 100%) calc(var(--fy, 0.5) * 100%), rgba(255, 255, 255, 0.85), transparent 70%);
  mix-blend-mode: soft-light;
}

/* ---------- Штамп ---------- */
.stamp {
  --c: var(--violet);
  display: inline-grid; place-items: center; gap: 2px;
  padding: 8px 14px 7px; border: 2px solid var(--c); border-radius: 7px;
  color: var(--c); font: 600 12px/1.05 var(--f-mono); letter-spacing: 0.14em; text-transform: uppercase; text-align: center;
  box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 3.5px color-mix(in srgb, var(--c) 55%, transparent);
  transform: rotate(var(--rot, -7deg));
  filter: url(#ink-rough);
  mix-blend-mode: multiply;
  opacity: 0.92;
}
:root[data-theme="dark"] .stamp { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stamp { mix-blend-mode: screen; } }
.stamp small { font-size: 9px; letter-spacing: 0.18em; opacity: 0.85; font-weight: 500; }
.stamp.ok { --c: var(--ok); }
.stamp.serial { --c: var(--serial); }
.stamp.hit { animation: stamp-hit 0.5s var(--spring) both; }
@keyframes stamp-hit {
  0% { opacity: 0; transform: rotate(var(--rot, -7deg)) scale(1.9); }
  60% { opacity: 1; }
  100% { opacity: 0.92; transform: rotate(var(--rot, -7deg)) scale(1); }
}

/* ---------- Кнопки ---------- */
.btn {
  --bg: transparent; --fg: var(--ink); --bd: var(--line-3);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 46px; padding: 0 22px; border-radius: var(--r-pill);
  background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
  font: 500 15px/1 var(--f-text); letter-spacing: -0.005em; white-space: nowrap;
  transition: background var(--d-1), border-color var(--d-1), color var(--d-1), transform var(--d-1) var(--ease), box-shadow var(--d-2);
  overflow: hidden; isolation: isolate;
}
.btn:hover { --bd: var(--ink); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn .arrow { transition: transform var(--d-2) var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn-primary { --bg: var(--violet); --fg: #fff; --bd: var(--violet); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 10px 24px -12px var(--violet); }
.btn-primary:hover { --bg: var(--violet-2); --bd: var(--violet-2); }
/* блик по кнопке: гильош-лента пробегает при наведении */
.btn-primary::after, .btn-ink::after {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-100%); transition: transform 0.7s var(--ease), opacity 0.3s;
}
.btn-primary:hover::after, .btn-ink:hover::after { transform: translateX(100%); opacity: 1; }
:root[data-theme="dark"] .btn-primary { --fg: #0d0e12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { --fg: #0d0e12; } }
.btn-ink { --bg: var(--ink); --fg: var(--paper); --bd: var(--ink); }
.btn-ink:hover { --bg: var(--ink-2); --bd: var(--ink-2); }
.btn-ghost { --bd: transparent; }
.btn-ghost:hover { --bg: var(--line-2); --bd: transparent; }
.btn-sm { height: 36px; padding: 0 15px; font-size: 14px; gap: 8px; }
.btn-lg { height: 56px; padding: 0 28px; font-size: 16px; }
.btn-icon { width: 40px; height: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; height: 34px; }
.btn-block { width: 100%; }
.on-night .btn { --fg: var(--night-ink); --bd: var(--night-line); }
.on-night .btn:hover { --bd: var(--night-ink); }
.on-night .btn-primary { --bg: #fff; --fg: #0d0e12; --bd: #fff; box-shadow: none; }
.on-night .btn-primary:hover { --bg: #e8e5ff; --bd: #e8e5ff; }
.on-night .btn-primary::after { background: linear-gradient(105deg, transparent 30%, rgba(74, 61, 196, 0.25) 50%, transparent 70%); }

.link { color: var(--violet); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--violet) 40%, transparent); transition: text-decoration-color var(--d-1); }
.link:hover { text-decoration-color: currentColor; }
.lnk { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.lnk .arrow { transition: transform var(--d-2) var(--ease); }
.lnk:hover .arrow { transform: translateX(4px); }

/* ---------- Поля ---------- */
.fields { display: grid; gap: 18px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > label, .lbl { font: 500 var(--t-micro)/1.2 var(--f-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea, .inp {
  width: 100%; height: 50px; padding: 0 16px;
  background: var(--card); border: 1px solid var(--line-3); border-radius: var(--r-sm);
  font-size: 16px; outline: none; transition: border-color var(--d-1), box-shadow var(--d-2);
  -webkit-appearance: none; appearance: none;
}
.field select { padding-right: 40px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6066' stroke-width='1.5' stroke-linecap='round'><path d='M7 10l5 5 5-5'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.field input:hover, .field select:hover { border-color: var(--muted); }
.field input:focus, .field select:focus, .inp:focus { border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-soft); }
.field input::placeholder { color: var(--faint); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field[data-invalid] input { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.field[data-invalid] .hint { color: var(--bad); }
.check-row { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--violet); flex: none; }

/* ---------- Переключатели ---------- */
.seg { position: relative; display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: var(--paper-2); border: 1px solid var(--line-2); }
.seg button { position: relative; z-index: 1; height: 36px; padding: 0 16px; border-radius: var(--r-pill); font-size: 14px; font-weight: 500; color: var(--muted); transition: color var(--d-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { color: var(--ink); }
.seg-thumb { position: absolute; top: 4px; left: 4px; height: 36px; border-radius: var(--r-pill); background: var(--card); box-shadow: var(--shadow-1), 0 0 0 1px var(--line-2); transition: transform var(--d-3) var(--ease), width var(--d-3) var(--ease); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line-3); font-size: 13.5px; font-weight: 500; color: var(--ink-2); transition: all var(--d-1); white-space: nowrap; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--paper-3); transition: background var(--d-2); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform var(--d-2) var(--ease); }
.switch input:checked + span { background: var(--violet); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 2px; }

/* ---------- Статусы и «чей ход» ---------- */
.status { --c: var(--muted); --b: var(--line-2); display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 11px 0 9px; border-radius: var(--r-pill); background: var(--b); color: var(--c); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-go { --c: var(--violet); --b: var(--violet-soft); }
.status-go::before { animation: blink 1.6s infinite; }
.status-wait { --c: var(--wait); --b: var(--wait-soft); }
.status-ok { --c: var(--ok); --b: var(--ok-soft); }
.status-bad { --c: var(--bad); --b: var(--bad-soft); }
@keyframes blink { 50% { opacity: 0.25; } }
.who { display: inline-flex; align-items: center; gap: 7px; font: 500 var(--t-micro)/1 var(--f-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--violet); }
.who::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.who.me { color: var(--serial); }

/* ---------- Флаги ---------- */
.flag { display: inline-block; width: 20px; height: 20px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 1px var(--line); }
.flag svg { width: 100%; height: 100%; }

/* ---------- Тосты ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px 12px 14px; border-radius: var(--r-pill); background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: var(--shadow-3); animation: toast-in 0.45s var(--spring) both; }
.toast .i { color: var(--teal); }
:root[data-theme="dark"] .toast .i { color: #0f7a6c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }

/* ---------- Модальное окно ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(13, 14, 18, 0.5); backdrop-filter: blur(6px); animation: fade 0.25s both; }
.modal-box { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 28px; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-3); display: grid; gap: 16px; animation: pop 0.4s var(--ease) both; }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.modal-head h2 { font: 300 32px/1.05 var(--f-display); font-variation-settings: "wdth" 82; letter-spacing: -0.015em; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* ---------- Появление ---------- */
.rv { opacity: 0; transform: translateY(26px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: calc(var(--i, 0) * 80ms); }
.rv.in { opacity: 1; transform: none; }
.lines .ln { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.lines .ln > span { display: inline-block; transform: translateY(105%); transition: transform 1.1s var(--ease); transition-delay: calc(var(--i, 0) * 110ms + 80ms); }
.lines.in .ln > span { transform: none; }
.fade-up { animation: fade-up 0.9s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
  .rv { opacity: 1; transform: none; }
  .lines .ln > span { transform: none; }
}

/* ---------- Переходы между страницами ---------- */
::view-transition-old(root) { animation: 0.32s var(--ease) both vt-out; }
::view-transition-new(root) { animation: 0.5s var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px); } }
