/* RunPay · MikroBILL — только тёмная тема. */

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-2: #10151c;
  --surface: #141a22;
  --surface-2: #1a212b;
  --line: #232c38;
  --line-2: #2e3947;
  --text: #e6eaf0;
  --text-2: #b7c0cc;
  --muted: #8a96a6;
  --accent: #2dd4bf;
  --accent-ink: #062a26;
  --accent-soft: rgba(45, 212, 191, .12);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --info: #93c5fd;
  --info-soft: rgba(147, 197, 253, .12);
  --radius: 10px;
  --radius-sm: 7px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --gutter: 24px;
  --topbar: 56px;
}

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

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

body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 85% -120px, rgba(45, 212, 191, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--sans);
  font-feature-settings: "tnum" 1, "lnum" 1;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.mono { font-family: var(--mono); font-size: 13px; }

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

.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 15, 20, .86);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top__in {
  max-width: 1600px; margin: 0 auto; height: var(--topbar);
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg, #2dd4bf, #0d9488); color: var(--accent-ink);
  font: 800 15px/1 var(--sans);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 6px 18px -8px rgba(45, 212, 191, .7);
}
.brand__sep { color: var(--muted); margin: 0 2px; }
.brand__sub { color: var(--text-2); font-weight: 500; }

.nav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.nav a {
  color: var(--text-2); padding: 7px 12px; border-radius: var(--radius-sm); white-space: nowrap; font-size: 14px;
}
.nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav a.is-active { color: var(--text); background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-2) inset; }

.who { display: flex; align-items: center; gap: 10px; margin: 0; }
.who__name { color: var(--muted); font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Страница ---------- */

.page { max-width: 1600px; margin: 0 auto; padding: 28px var(--gutter) 64px; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.head__title { min-width: 0; }
.head__meta { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.head__meta time { color: var(--text-2); }
.head__action { margin: 0; }

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

.btn {
  --b: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--b); background: var(--surface-2); color: var(--text);
  font: 600 14px/1 var(--sans); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #212a36; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; --b: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface); color: var(--text); }
.btn--primary { background: var(--accent); --b: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #5eead4; }
.btn--danger { background: var(--bad-soft); --b: rgba(248, 113, 113, .45); color: #fecaca; }
.btn--danger:hover { background: rgba(248, 113, 113, .22); }
.btn[disabled], .btn.is-busy { opacity: .75; cursor: progress; }
.btn.is-busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Сообщения ---------- */

.notice {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface);
}
.notice p { margin: 0; flex: 1 1 320px; }
.notice form { margin: 0; }
.notice--ok { border-color: rgba(74, 222, 128, .35); background: linear-gradient(0deg, var(--ok-soft), var(--ok-soft)), var(--surface); }
.notice--error { border-color: rgba(248, 113, 113, .45); background: linear-gradient(0deg, var(--bad-soft), var(--bad-soft)), var(--surface); }
.notice--warn { border-color: rgba(251, 191, 36, .4); background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--surface); }
.notice__more { font-size: 14px; }

/* ---------- Сводка ---------- */

.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2);
  margin-bottom: 20px; overflow: hidden;
}
.stat { padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat__v { display: block; font: 650 22px/1.2 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat__k { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.stat--off .stat__v { color: var(--bad); }
.stat--debt .stat__v { color: #fca5a5; }

/* ---------- Поиск и отбор ---------- */

.tools { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin-bottom: 12px; }

.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  flex: 1 1 380px; min-width: 0; margin: 0;
}
.search__icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search__input {
  flex: 1; min-width: 0; height: 38px; padding: 0 36px 0 36px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  font: 14px var(--sans);
}
.search__input::placeholder { color: #7a8697; }
.search__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search__input::-webkit-search-cancel-button { filter: invert(.7); }
.search__kbd {
  position: absolute; right: calc(8px + var(--btns, 70px)); top: 50%; transform: translateY(-50%);
  font: 12px var(--mono); color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px;
  pointer-events: none;
}
.search__input:focus ~ .search__kbd, .search__input:not(:placeholder-shown) ~ .search__kbd { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.chip:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.chip__n { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.chip.is-on { background: var(--accent-soft); border-color: rgba(45, 212, 191, .5); color: var(--text); }
.chip.is-on .chip__n { color: var(--accent); }
.chip--off.is-on { background: var(--bad-soft); border-color: rgba(248, 113, 113, .5); }
.chip--off.is-on .chip__n { color: var(--bad); }

.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); }
.seg__label { color: var(--muted); font-size: 13px; padding: 0 8px 0 6px; white-space: nowrap; }
.seg__item { padding: 4px 10px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-family: var(--mono); }
.seg__item:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.seg__item.is-on { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2) inset; }

.count { margin: 8px 0 10px; color: var(--muted); font-size: 13px; }

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

.table-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2);
  overflow: auto; max-height: calc(100vh - var(--topbar) - 40px);
  overscroll-behavior: contain;
}
.table-wrap:focus-visible { outline-offset: -2px; }

.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.grid th, .grid td { padding: 9px 12px; text-align: left; vertical-align: top; white-space: nowrap; }
.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line-2);
}
.grid thead th a { color: inherit; display: inline-flex; align-items: center; gap: 5px; }
.grid thead th a:hover { color: var(--text); text-decoration: none; }
.grid thead th.is-sorted { color: var(--text); }
.grid .sort { font-size: 11px; opacity: .55; }
.grid th.is-sorted .sort { opacity: 1; color: var(--accent); }

.grid tbody td { border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.grid tbody tr.is-off td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.grid tbody tr.is-current td { background: var(--accent-soft); }

.c-num { color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: right !important; width: 1%; }
.c-login { color: var(--text); }
.c-name { min-width: 200px; white-space: normal !important; }
.c-name .name { display: block; }
.c-name .sub { display: block; color: var(--muted); font-size: 12.5px; }
.c-tariff { color: var(--text-2); }
.c-money { text-align: right !important; }
.grid td.c-money { font-weight: 600; }
.grid td.is-neg { color: var(--bad); }
.c-mac { color: var(--text-2); }
.c-date { color: var(--muted); font-size: 13px; }
.c-wrap { white-space: normal !important; min-width: 180px; max-width: 360px; }
.c-msg a { color: var(--text-2); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5;
  border: 1px solid transparent; white-space: nowrap; vertical-align: 1px;
}
.badge + .badge { margin-left: 4px; }
.badge--ok { color: var(--ok); background: var(--ok-soft); border-color: rgba(74, 222, 128, .25); }
.badge--bad { color: #fca5a5; background: var(--bad-soft); border-color: rgba(248, 113, 113, .3); }
.badge--warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(251, 191, 36, .3); }
.badge--info { color: var(--info); background: var(--info-soft); border-color: rgba(147, 197, 253, .3); }
.badge--muted { color: var(--muted); border-color: var(--line-2); }

/* ---------- Страницы ---------- */

.pager { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 18px; }
.pager__item {
  min-width: 36px; height: 36px; padding: 0 10px; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--text-2); font-family: var(--mono); font-size: 13px;
}
.pager__item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.pager__item.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pager__gap { color: var(--muted); padding: 0 4px; align-self: center; }

/* ---------- Пусто ---------- */

.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 48px 24px; text-align: center; background: var(--bg-2);
}
.empty p { color: var(--muted); margin: 8px auto 16px; max-width: 520px; }

/* ---------- Журнал ---------- */

.panel { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; margin-bottom: 20px; }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel__head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel__sub { margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.log {
  margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line);
  font: 12.5px/1.55 var(--mono); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 480px; overflow: auto;
}

/* ---------- Вход ---------- */

.login {
  max-width: 380px; margin: 9vh auto 0; padding: 32px 28px 28px;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .8);
}
.login__lead { margin: 6px 0 22px; color: var(--muted); font-size: 14px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { color: var(--text-2); font-size: 13px; }
.field input {
  height: 42px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font: 15px var(--sans);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Пополнение ---------- */

.muted { color: var(--muted); }
.btn--lg { height: 46px; padding: 0 22px; font-size: 15px; }
.c-contract { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.c-contract:hover { color: var(--accent); text-decoration-color: var(--accent); }

.lookup { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 0 0 18px; }
.field--inline { flex: 0 1 320px; }
.field small { color: var(--muted); font-size: 12px; }
.field input { width: 100%; }

.card { border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); padding: 22px 24px; margin-bottom: 26px; }
.card__main { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.card__who h2 { font-size: 22px; }
.card__sub { margin: 2px 0 0; color: var(--text-2); }
.card__ids { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.card__ids b { color: var(--text); font-weight: 600; }
.card__bal { text-align: right; display: grid; gap: 2px; }
.card__k { color: var(--muted); font-size: 12px; }
.card__v { font-size: 28px; font-weight: 700; line-height: 1.15; }
.card__v.is-neg { color: var(--bad); }
.kv--row { grid-template-columns: repeat(4, max-content 1fr); margin: 16px 0 4px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }

.pay { display: grid; grid-template-columns: minmax(160px, 220px) minmax(200px, 1fr); gap: 14px 16px; align-items: start; margin-top: 18px; }
.pay > .btn { grid-column: 1 / -1; justify-self: start; min-width: 220px; }
.pay .check { grid-column: 1 / -1; }
.pay__amount { font-size: 20px !important; font-weight: 700; text-align: right; }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.card .notice { margin: 16px 0 0; }

.block { margin-top: 8px; }
.block__title { font-size: 16px; margin: 0 0 12px; color: var(--text-2); }
.grid .sub { color: var(--muted); font-size: 12px; margin-left: 4px; }

.paysum { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; border: 1px solid var(--line-2);
  border-left-width: 4px; border-radius: 12px; background: var(--surface); padding: 18px 22px; margin-bottom: 18px; }
.paysum.status--confirmed { border-left-color: var(--ok); }
.paysum.status--failed { border-left-color: var(--bad); }
.paysum.status--unknown { border-left-color: var(--warn); }
.paysum.status--sent { border-left-color: var(--info); }
.paysum__amount { font-size: 30px; font-weight: 700; white-space: nowrap; }
.paysum__amount small { font-size: 15px; color: var(--muted); font-weight: 500; }
.paysum__who { display: grid; gap: 2px; min-width: 0; }
.paysum__who span { color: var(--muted); font-size: 14px; }
.paysum__bal { display: grid; text-align: right; gap: 2px; font-size: 16px; }
.panel h2 { margin-bottom: 8px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 18px; }
.actions form { margin: 0; }
.mark fieldset { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; display: grid; gap: 10px; }
.mark legend { color: var(--text-2); font-size: 13px; padding: 0 6px; }
.mark .btn { justify-self: start; }

/* ---------- RunPay ---------- */

.stats--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lookup .btn--ghost { align-self: flex-end; }

/* ---------- Узкие экраны ---------- */

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; --topbar: auto; }
  body { font-size: 14px; }
  .top__in { height: auto; flex-wrap: wrap; gap: 6px 12px; padding-top: 10px; padding-bottom: 8px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; margin: 0 -6px; }
  .who { margin-left: auto; }
  .who__name { display: none; }
  .page { padding-top: 20px; }
  h1 { font-size: 22px; }
  .head { align-items: stretch; }
  .head__action, .head__action .btn { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--line); padding: 12px 14px; }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat--debt { grid-column: 1 / -1; border-left: 0 !important; }
  .stat__v { font-size: 19px; }
  .search { flex-basis: 100%; }
  .search__kbd { display: none; }
  .seg { width: 100%; justify-content: space-between; }
  .table-wrap { max-height: none; }
  .grid { font-size: 13px; }
  .grid th, .grid td { padding: 8px 10px; }
  .login { margin-top: 4vh; padding: 24px 18px; }
  .card { padding: 18px 16px; }
  .card__bal { text-align: left; }
  .kv--row { grid-template-columns: max-content 1fr; }
  .pay { grid-template-columns: 1fr; }
  .pay .btn { width: 100%; }
  .paysum { grid-template-columns: 1fr; gap: 10px; }
  .paysum__bal { text-align: left; }
  .lookup .field--inline { flex: 1 1 100%; }
  .stats--3 { grid-template-columns: 1fr 1fr; }
  .stats--3 .stat:nth-child(3) { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
