/* Affnex design tokens + components. Quiet, neutral, one accent. No glows, no motion beyond hover color. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* metric-matched fallback so the swap does not shift layout */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light;
  --font: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f4f4f3;
  --surface-3: #ececea;
  --border: #e5e5e2;
  --border-strong: #d3d3cf;
  --text: #191918;
  --text-2: #4f4f4c;
  --text-3: #7c7c78;
  --accent: #3451d1;
  --accent-hover: #2c45b8;
  --accent-text: #2f49c0;
  --accent-soft: #eef1fd;
  --on-accent: #ffffff;
  --ok: #18794e;
  --ok-soft: #e9f6ef;
  --warn: #a35200;
  --warn-soft: #fdf3e6;
  --danger: #c62a2f;
  --danger-soft: #fdeded;
  --focus: #3451d1;
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .08);

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0f;
  --surface: #151516;
  --surface-2: #1b1b1d;
  --surface-3: #232326;
  --border: #262628;
  --border-strong: #35353a;
  --text: #ececeb;
  --text-2: #b0b0ac;
  --text-3: #7f7f7b;
  --accent: #5b74e6;
  --accent-hover: #6d84ec;
  --accent-text: #9aaeff;
  --accent-soft: #1b2142;
  --on-accent: #ffffff;
  --ok: #4cc38a;
  --ok-soft: #12261c;
  --warn: #f0a33a;
  --warn-soft: #2a1f10;
  --danger: #f2686c;
  --danger-soft: #2c1415;
  --focus: #8ea2ff;
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0f;
    --surface: #151516;
    --surface-2: #1b1b1d;
    --surface-3: #232326;
    --border: #262628;
    --border-strong: #35353a;
    --text: #ececeb;
    --text-2: #b0b0ac;
    --text-3: #7f7f7b;
    --accent: #5b74e6;
    --accent-hover: #6d84ec;
    --accent-text: #9aaeff;
    --accent-soft: #1b2142;
    --on-accent: #ffffff;
    --ok: #4cc38a;
    --ok-soft: #12261c;
    --warn: #f0a33a;
    --warn-soft: #2a1f10;
    --danger: #f2686c;
    --danger-soft: #2c1415;
    --focus: #8ea2ff;
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .4);
  }
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--text); }
.no-transition * { transition: none !important; }
[hidden] { display: none !important; }

.i { width: 16px; height: 16px; flex: none; }
.i-lg { width: 20px; height: 20px; }
.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.link { color: var(--accent-text); }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- logo */
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 640; letter-spacing: -.02em; font-size: 17px; color: var(--text); }
.logo-mark { width: 22px; height: 22px; color: var(--text); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 520; line-height: 1; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-dark:hover { background: var(--text-2); border-color: var(--text-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: 6px; align-content: start; }
.field + .field { margin-top: 14px; }
.grid > .field, .gen-grid > .field, .row > .field { margin-top: 0; }
.label { font-size: 13px; font-weight: 520; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color .12s;
}
.textarea { height: auto; min-height: 96px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c7c78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input-code { font-family: var(--mono); font-size: 22px; letter-spacing: .35em; text-align: center; height: 48px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.input-group { display: flex; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; flex: none; transition: background-color .12s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .12s; }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* segmented choice (radio buttons that look like tabs) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  font-size: 13.5px; font-weight: 500; color: var(--text-2); cursor: pointer; user-select: none;
  transition: border-color .12s, background-color .12s, color .12s;
}
.seg label:hover { color: var(--text); border-color: var(--text-3); }
.seg input:checked + label { border-color: var(--text); color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--text); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-pad { padding: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 53px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.card-h h2, .card-h h3 { font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.card-b { padding: 20px; }
.card-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  font-size: 13.5px; line-height: 1.5; color: var(--text-2);
}
.alert .i { margin-top: 2px; }
.alert strong { color: var(--text); font-weight: 600; }
.alert.ok { background: var(--ok-soft); border-color: transparent; color: var(--text); }
.alert.ok .i { color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.alert.warn .i { color: var(--warn); }
.alert.error { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.alert.error .i { color: var(--danger); }
.alert.info .i { color: var(--accent-text); }

/* tables: on narrow screens .table-stack rows turn into labelled blocks */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 550; color: var(--text-3); padding: 10px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link:hover td { background: var(--surface-2); }
.table .r { text-align: right; }
.amount-pos { color: var(--ok); }
@media (max-width: 720px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; gap: 16px; text-align: right; }
  .table-stack td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; text-align: left; }
  .table-stack td.r { text-align: right; }
  .table-stack td[data-label=""]::before { display: none; }
}

/* key → value with copy */
.kv { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; border-top: 1px solid var(--border); }
.kv > div { display: flex; align-items: center; min-height: 50px; padding: 6px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.kv > .k { color: var(--text-3); font-size: 13px; }
.kv > .v { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 13px; }
.kv > .v span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } .kv > .k { border-bottom: 0; padding-bottom: 0; } }

.copy-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--text-3); flex: none; }
.copy-btn:hover { background: var(--surface-2); color: var(--text); }
.copy-btn.done { color: var(--ok); }

.code-block {
  margin: 0; padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65; color: var(--text); overflow: auto; white-space: pre; max-height: 360px;
}

.empty { text-align: center; padding: 48px 24px; }
.empty .i { width: 24px; height: 24px; margin: 0 auto 14px; color: var(--text-3); }
.empty h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty p { color: var(--text-3); font-size: 13.5px; max-width: 360px; margin: 0 auto 18px; line-height: 1.5; }

.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); border: 0; margin: 20px 0; }

/* cookie / consent bar */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; max-width: 440px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); font-size: 13px; color: var(--text-2);
}
@media (min-width: 720px) { .consent { left: 24px; bottom: 24px; } }
@media (max-width: 520px) {
  .kv > .k { min-height: 0; padding-top: 10px; }
  .card-h > .hint { display: none; }
}
