/* Nexora — кабинет мерчанта, тема «Контроль»: тёмная шапка с вкладками, светлое рабочее поле.
   Поверх Bootstrap 5.1: компоненты перекрашены здесь, разметка страниц остаётся бутстраповской. */

@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/onest-latin.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: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/onest-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.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: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("../fonts/jetbrains-mono-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("../fonts/jetbrains-mono-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }

:root {
  --navy: #0D1B2A;
  --navy-2: #16283C;
  --navy-3: #22374F;
  --on-navy: #FFFFFF;
  --on-navy-2: #A9B8CC;
  --bg: #EEF2F5;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --line: #DCE3EA;
  --line-soft: #E9EEF2;
  --text: #13202F;
  --text-2: #2C3A4D;
  --muted: #52617A;
  --teal: #2DD4BF;
  --accent: #0B7C7B;
  --accent-hover: #086362;
  --accent-soft: #DDF5F2;
  --ok: #0B7C5A;
  --ok-bg: #E2F5EE;
  --fail: #C0352B;
  --fail-bg: #FDECEA;
  --warn: #8F5400;
  --warn-bg: #FFF1D6;
  --info: #1F5FAF;
  --info-bg: #E5F0FC;
  --unk: #6A45D1;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
::selection { background: rgba(45, 212, 191, .3); }

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5 { color: var(--text); letter-spacing: -.015em; }
h1.h4, .page > .h4:first-child { font-size: 1.75rem; font-weight: 700; margin-bottom: 1.25rem !important; }
.h6, h6 { color: var(--muted); }
h2.h6.text-muted, .h6.text-muted { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.text-muted { color: var(--muted) !important; }
.text-danger { color: var(--fail) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.border-top { border-top-color: var(--line) !important; }
hr { border-color: var(--line); opacity: 1; }
code { color: #B0306A; }

/* fw-semibold появился в Bootstrap 5.2, в шаблоне — 5.1. */
.fw-semibold { font-weight: 600 !important; }

.mono, .table td.mono, code.secret, .otp-input { font-family: var(--mono); }
.mono { font-size: .92em; }

/* ---------- Шапка ---------- */

.app-header { background: var(--navy); color: var(--on-navy); }
.app-header-inner { max-width: 1440px; margin: 0 auto; padding: 0 32px; }

.topbar { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--on-navy); text-decoration: none; }
.brand:hover { color: var(--on-navy); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark rect { fill: var(--teal); }
.brand-mark path { stroke: var(--navy); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 700; font-size: 1.3rem; letter-spacing: -.01em; }
.brand-dark, .brand-dark:hover { color: var(--text); }

.mode-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px; border-radius: 999px;
  font-family: var(--mono); font-size: .75rem; font-weight: 600; letter-spacing: .04em;
}
.mode-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mode-test { color: #FFD48A; background: #3A2E14; }
.mode-live { color: #FFB1A8; background: #46201F; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-link { display: flex; align-items: center; gap: 10px; color: var(--on-navy); text-decoration: none; padding: 4px 8px; border-radius: 10px; }
.user-link:hover { color: var(--on-navy); background: var(--navy-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--teal); color: var(--navy); font-weight: 700; font-size: .85rem;
}
.user-text { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: .9rem; }
.user-role { font-size: .78rem; color: var(--on-navy-2); }

.btn-header { color: var(--on-navy); background: var(--navy-2); border: 1px solid var(--navy-3); }
.btn-header:hover, .btn-header:focus { color: var(--on-navy); background: var(--navy-3); }

.menu-toggle {
  display: none; width: 44px; height: 44px;
  align-items: center; justify-content: center;
  background: var(--navy-2); color: var(--on-navy);
  border: 0; border-radius: 10px;
}
.menu-toggle svg { width: 20px; height: 20px; }

.tabs { display: block !important; }
.tabs .nav { gap: 2px; flex-wrap: wrap; }
.tabs .nav-link {
  display: inline-flex; align-items: center;
  min-height: 46px; padding: 0 14px;
  color: var(--on-navy-2); font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tabs .nav-link:hover, .tabs .nav-link:focus { color: var(--on-navy); }
.tabs .nav-link.active, .tabs .show > .nav-link { color: var(--on-navy); border-bottom-color: var(--teal); }

@media (max-width: 991.98px) {
  .app-header-inner { padding: 0 16px; }
  .user-text { display: none; }
  .menu-toggle { display: inline-flex; }
  .tabs { display: none !important; padding-bottom: 8px; }
  .tabs.show, .tabs.collapsing { display: block !important; }
  .tabs .nav { flex-direction: column; }
  .tabs .nav-link { min-height: 44px; border-bottom: 0; border-left: 2px solid transparent; }
  .tabs .nav-link.active { border-left-color: var(--teal); }
  .tabs .dropdown-menu { position: static !important; transform: none !important; }
}

/* ---------- Каркас ---------- */

.page { max-width: 1440px; margin: 0 auto; padding: 28px 32px 48px; }
.page-footer { max-width: 1440px; margin: 0 auto; padding: 16px 32px 28px; color: var(--muted); font-size: .82rem; }
.guest { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.app-guest { background: linear-gradient(180deg, var(--navy) 0, var(--navy) 38vh, var(--bg) 38vh); }
.app-guest .login-card { box-shadow: 0 24px 60px rgba(13, 27, 42, .25); }

@media (max-width: 991.98px) {
  .page { padding: 20px 16px 40px; }
  .page-footer { padding: 16px; }
}

/* ---------- Карточки и показатели ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 20px;
  font-weight: 600;
}
.card-header:first-child { border-radius: 16px 16px 0 0; }
.card-body { padding: 20px; }

.kpi .label { color: var(--muted); font-size: .9rem; }
.kpi .value {
  font-size: clamp(1.35rem, 1.5vw, 1.85rem); font-weight: 700; letter-spacing: -.02em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-top: 4px;
}

/* ---------- Главный экран ---------- */

.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dash-head h1.h4 { margin-bottom: 4px !important; }
.dash-sub { margin: 0; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 12px; }
.stat { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: .95rem; color: var(--muted); }
.stat-value {
  font-size: clamp(1.45rem, 1.9vw, 2rem); font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat-unit { font-size: .55em; font-weight: 600; color: var(--muted); }
.delta { font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.delta.up { color: var(--ok); background: var(--ok-bg); }
.delta.down { color: var(--warn); background: var(--warn-bg); }
.delta.flat { color: var(--info); background: var(--info-bg); }
.spark { width: 100%; height: 34px; display: block; }
.spark rect { fill: #9FD9D2; }
.spark rect.today { fill: var(--accent); }
.other-currencies { color: var(--muted); font-size: .9rem; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.empty-card .card-body { display: flex; flex-direction: column; gap: 4px; }

.dash-row { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 8px; }
.dash-main { flex: 3 1 600px; min-width: 0; }
.dash-main .panel-head { padding: 18px 20px 4px; }
.dash-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-title { margin: 0; font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
.panel-link { font-size: .9rem; font-weight: 500; text-decoration: none; }

.side-card { padding: 20px; }
.queue-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; border-bottom: 1px solid var(--line-soft); color: var(--text); text-decoration: none;
}
.queue-row:last-child { border-bottom: 0; }
a.queue-row:hover { color: var(--accent); }
.queue-sub { font-size: .8rem; color: var(--muted); margin-top: 14px; }
.queue-count { font-size: .85rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #EDF0F4; color: var(--text-2); }
.queue-count.fail { color: var(--fail); background: var(--fail-bg); }
.queue-count.ok { color: var(--ok); background: var(--ok-bg); }
.queue-amount { font-weight: 600; white-space: nowrap; }

.dark-panel { background: var(--navy); color: var(--on-navy); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.dark-panel .panel-title { color: var(--on-navy); }
.dark-panel .panel-head { margin-bottom: 4px; }
.dark-panel .panel-link { color: var(--teal); }
.dark-muted { color: var(--on-navy-2); font-size: .9rem; }
.chain-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 12px; background: #13253A; }
.chain-top { display: flex; align-items: center; gap: 10px; }
.chain-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chain-dot.ok { background: var(--teal); }
.chain-dot.info { background: #7DB8FF; }
.chain-dot.idle { background: #7F92AA; }
.chain-dot.warn { background: #F5B547; }
.chain-dot.fail { background: #FF7A7A; }
.chain-name { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain-state { font-size: .8rem; color: #CFE9E4; text-align: right; }
.chain-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--on-navy-2); }

.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.5rem; }
.dl-grid dt { color: var(--muted); font-weight: normal; }
.dl-grid dd { margin: 0; }

.narrow-card { max-width: 560px; }
.login-card { width: 100%; max-width: 440px; margin: 0 auto; }
.login-card .card-body { padding: 32px !important; }

/* ---------- Таблицы ---------- */

.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--surface-2);
  --bs-table-striped-bg: var(--surface-2);
  color: var(--text);
  border-color: var(--line-soft);
}
.table > :not(:first-child) { border-top: 1px solid var(--line); }
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table-sm > :not(caption) > * > * { padding: .6rem .85rem; }
.table > thead > tr > *, .table-light th {
  color: var(--muted);
  font-size: .82rem; font-weight: 500;
  white-space: nowrap;
}
.table-light { --bs-table-bg: var(--surface-2); --bs-table-hover-bg: var(--surface-2); color: var(--muted); border-color: var(--line); }
.table a { text-decoration: none; font-weight: 500; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.num { font-weight: 600; }
.table td.mono { font-size: .85em; }
/* Широкая таблица прокручивается внутри карточки, а не вылезает за её край. */
.card:has(> .table), .card-body:has(> .table) { overflow-x: auto; }
.card > .table, .card > .table-responsive > .table { margin: 0; }
.card > .table tr:last-child > *, .card > .table-responsive > .table tr:last-child > * { border-bottom: 0; }

/* ---------- Бейджи статусов ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .3em .7em;
  border-radius: 6px;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
}
.badge[class*="text-bg-"]::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.text-bg-primary { color: var(--accent) !important; background-color: var(--accent-soft) !important; }
.text-bg-secondary { color: #4A5568 !important; background-color: #EDF0F4 !important; }
.text-bg-success { color: var(--ok) !important; background-color: var(--ok-bg) !important; }
.text-bg-danger { color: var(--fail) !important; background-color: var(--fail-bg) !important; }
.text-bg-warning { color: var(--warn) !important; background-color: var(--warn-bg) !important; }
.text-bg-info { color: var(--info) !important; background-color: var(--info-bg) !important; }
.text-bg-light { color: var(--text-2) !important; background-color: #F1F4F7 !important; }
.text-bg-dark { color: #fff !important; background-color: var(--navy) !important; }

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

.btn { font-weight: 600; border-radius: 10px; padding: .5rem 1rem; }
.btn-sm { border-radius: 8px; padding: .3rem .7rem; font-size: .85rem; }
.btn:focus, .btn:focus-visible, .btn-check:focus + .btn { box-shadow: 0 0 0 3px rgba(11, 124, 123, .22); }

.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { color: #fff; background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success { color: #fff; background: var(--ok); border-color: var(--ok); }
.btn-success:hover { color: #fff; background: #08634A; border-color: #08634A; }
.btn-danger { color: #fff; background: var(--fail); border-color: var(--fail); }
.btn-danger:hover { color: #fff; background: #A02A21; border-color: #A02A21; }

.btn-outline-primary { color: var(--accent); border-color: #9CCFCB; background: var(--surface); }
.btn-outline-primary:hover, .btn-check:checked + .btn-outline-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-outline-secondary { color: var(--text-2); border-color: var(--line); background: var(--surface); }
.btn-outline-secondary:hover, .btn-check:checked + .btn-outline-secondary { color: var(--text); background: var(--surface-2); border-color: #C5CFD9; }
.btn-outline-danger { color: var(--fail); border-color: #EDB4AE; background: var(--surface); }
.btn-outline-danger:hover, .btn-check:checked + .btn-outline-danger { color: #fff; background: var(--fail); border-color: var(--fail); }
.btn-outline-warning { color: var(--warn); border-color: #EBCB8F; background: var(--surface); }
.btn-outline-warning:hover, .btn-check:checked + .btn-outline-warning { color: #3A2300; background: #FFC85C; border-color: #FFC85C; }
.btn-link { color: var(--accent); }

/* ---------- Формы ---------- */

.form-label { color: var(--text-2); font-weight: 500; }
.form-text { color: var(--muted); }
.form-control, .form-select { border: 1px solid #CBD5DF; border-radius: 10px; color: var(--text); }
.form-control::placeholder { color: #7D8AA0; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 124, 123, .15); }
.form-control:disabled, .form-control[readonly] { background-color: var(--surface-2); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 124, 123, .15); }

.filters .form-label { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }

.otp-input { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }

/* ---------- Сообщения, списки, меню ---------- */

.alert { border-radius: 12px; border: 1px solid; }
.alert-warning { color: #6B3F00; background: #FFF7E6; border-color: #F3D9A4; }
.alert-danger { color: #8C2119; background: #FEF1EF; border-color: #F3C2BC; }
.alert-success { color: #075E44; background: #ECF8F3; border-color: #B7E3D1; }
.alert-info { color: #17497F; background: #EEF5FD; border-color: #C3DAF3; }
.alert-secondary { color: var(--text-2); background: var(--surface-2); border-color: var(--line); }

.list-group-item { border-color: var(--line-soft); }

.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 14px 36px rgba(13, 27, 42, .16); }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--accent); color: #fff; }

/* Резервные коды и секреты: по одному на строку. */
code.secret {
  display: block;
  padding: .6rem .75rem;
  background: #FFFBF2;
  color: #6B3F00;
  border: 1px solid #F0C36D;
  border-radius: 10px;
  word-break: break-all;
  white-space: pre-line;
}

/* QR-код подключения MFA: чёткие модули при любом масштабе, светлая рамка для сканера. */
img.qr {
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-width: 100%;
  height: auto;
}

/* ---------- Страница оплаты для покупателя ---------- */

.checkout-body { background: linear-gradient(180deg, var(--navy) 0, var(--navy) 220px, var(--bg) 220px); min-height: 100vh; }
.checkout { max-width: 640px; }
.checkout-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 24px; color: var(--on-navy); }
.checkout-head .brand-name { font-size: 1.15rem; }
.checkout-secure { font-size: .82rem; color: var(--on-navy-2); display: inline-flex; align-items: center; gap: 6px; }
.checkout-secure svg { width: 14px; height: 14px; }
.checkout .card { box-shadow: 0 24px 60px rgba(13, 27, 42, .18); }
.checkout .card-body { padding: 28px; }
.checkout-amount { font-variant-numeric: tabular-nums; font-weight: 700; font-size: clamp(1.4rem, 5vw, 1.9rem) !important; letter-spacing: -.02em; white-space: nowrap; }
.checkout-qr { width: 100%; max-width: 220px; height: auto; image-rendering: pixelated; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.checkout-foot { color: var(--muted); }
.refund-amount { max-width: 9rem; }
.refund-address { max-width: 22rem; }
.unmatched-invoice { max-width: 20rem; }
.refund-qr { width: 100%; max-width: 160px; height: auto; image-rendering: pixelated; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
