/* Alif payout console — dark, responsive, mobile-first operator UI.
   The console never moves money itself: every action is a command / control row for the daemon. */

/* ----------------------------------------------------- self-hosted brand font */
/* ALS Hauss — the Alif mobile app typeface (receipt card + headings). Self-hosted; no font CDN. */
@font-face {
  font-family: "ALS Hauss";
  src: url("/static/fonts/als_hauss_regular.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "ALS Hauss";
  src: url("/static/fonts/als_hauss_medium.otf") format("opentype");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "ALS Hauss";
  src: url("/static/fonts/als_hauss_bold.otf") format("opentype");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ------------------------------------------------------------------- tokens */
:root {
  --bg: #0a0c0e;
  --bg-2: #0f1215;
  --card: #13171b;
  --card-2: #191e23;
  --card-3: #20262c;
  --line: #252b31;
  --line-soft: #1c2126;
  --text: #e8ecef;
  --text-2: #c3cad1;
  --muted: #8a939c;
  --accent: #19d39a;      /* alif teal/green = ok */
  --accent-dim: #10936c;
  --accent-soft: rgba(25, 211, 154, 0.12);
  --accent-line: rgba(25, 211, 154, 0.35);
  --warn: #f0b429;
  --warn-soft: rgba(240, 180, 41, 0.13);
  --warn-line: rgba(240, 180, 41, 0.38);
  --danger: #f3603c;
  --danger-soft: rgba(243, 96, 60, 0.12);
  --danger-line: rgba(243, 96, 60, 0.4);
  --info: #7c8cff;
  --info-soft: rgba(124, 140, 255, 0.14);
  --info-line: rgba(124, 140, 255, 0.38);
  --neutral-soft: rgba(139, 148, 158, 0.12);

  /* spacing scale (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "ALS Hauss", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.18);
  --gutter: 16px;         /* phone side gutter */
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;              /* belt-and-braces: no sideways page scroll on phones */
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
h1, h2, h3 { font-weight: 700; }
[x-cloak] { display: none !important; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: 10px var(--gutter) 8px;
  background: rgba(10, 12, 14, .88);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.brand-mark {
  font-weight: 700; font-size: 22px; letter-spacing: -0.6px; line-height: 1;
  color: var(--accent);
}
.brand-sub { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ro-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
/* nav — a horizontally scrollable segmented strip on phones, a single row on desktop */
.nav {
  display: flex; gap: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter) 2px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
  flex: 0 0 auto;
  padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.nav a:hover { background: var(--card-2); color: var(--text); }
.nav a.is-active {
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line);
}
.nav-logout { color: var(--muted) !important; }
.nav-logout:hover { color: var(--danger) !important; }

/* -------------------------------------------------------------------- layout */
/* fluid: comfortable width on huge monitors, full use of mid screens, 16px gutter on phones. */
.wrap { width: 100%; max-width: min(1560px, 100%); margin: 0 auto; padding: var(--s4) var(--gutter) var(--s2); flex: 1 0 auto; }
.grid { display: grid; gap: var(--s4); margin-bottom: var(--s4); grid-template-columns: 1fr; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s4);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3);
  margin-bottom: var(--s4); flex-wrap: wrap;
}
.card-head h2 {
  font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.1px;
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.card-head .head-side { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-left: auto; }
.card-sub { margin: -6px 0 var(--s4); font-size: 13.5px; color: var(--muted); }
.card-nested { background: var(--card-2); box-shadow: none; margin: var(--s4) 0 0; }
.section-title {
  font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  margin: var(--s5) 0 var(--s2);
}

/* -------------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px; border: 1px solid var(--line);
  white-space: nowrap; line-height: 1.4;
  background: var(--neutral-soft); color: var(--text-2);
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}
.badge-count::before { display: none; }
.badge-running, .badge-ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge-stale, .badge-warn { background: var(--warn-soft);   color: var(--warn);   border-color: var(--warn-line); }
.badge-down, .badge-danger { background: var(--danger-soft);  color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-muted { background: var(--neutral-soft); color: var(--muted); }

/* ----------------------------------------------------------------- key-value */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; text-align: right; }

.bignum { font-size: 40px; font-weight: 800; line-height: 1.1; }
.bignum.ok { color: var(--accent); }
.bignum.alert { color: var(--danger); }
.followup-card { display: flex; flex-direction: column; justify-content: center; }

/* -------------------------------------------------------------------- tables */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  scrollbar-width: thin;
  max-width: 100%;
}
.table-scroll.tall { max-height: 70vh; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
th {
  color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  position: sticky; top: 0; background: var(--card-2); z-index: 1;
}
td.num, th.num { text-align: right; }
/* long text cells wrap on tablet/desktop; on phones they stay one line and scroll inside the card */
@media (min-width: 640px) { td.wrap-cell { white-space: normal; min-width: 180px; max-width: 360px; overflow-wrap: anywhere; } }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--card-2); }
tbody tr:last-child td { border-bottom: 0; }
.deal { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* phone: keep the first column pinned so wide rows stay legible while scrolling */
@media (max-width: 640px) {
  th:first-child, td:first-child {
    position: sticky; left: 0; z-index: 2; background: var(--card);
    box-shadow: 1px 0 0 var(--line-soft);
  }
  th:first-child { z-index: 3; background: var(--card-2); }
  tbody tr:hover td:first-child { background: var(--card-2); }
}

/* --------------------------------------------------------------- limit cards */
.limit-cards { display: grid; gap: 10px; grid-template-columns: 1fr; }
.limit-card { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.limit-card.stale { border-color: var(--warn-line); }
.limit-card.over { border-color: var(--danger-line); }
.limit-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.limit-head .window { color: var(--accent); font-size: 12px; font-weight: 700; }
.limit-headroom { font-size: 26px; font-weight: 800; margin: 6px 0 4px; }
.limit-meta { font-size: 12px; }
.over-txt { color: var(--danger); font-weight: 700; }
.stale-txt {
  color: var(--warn); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px;
  padding: 1px 6px; border-radius: 6px; background: var(--warn-soft);
}

/* ---------------------------------------------------------------- misc atoms */
.mono { font-family: var(--mono); font-size: .94em; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.money-moved { color: var(--danger); font-weight: 600; }
.alert {
  color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line);
  padding: 10px 13px; border-radius: var(--radius-sm); margin: 10px 0; font-size: 14px;
}
.alert-warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
/* informational (non-error) banner — teal accent */
.alert-info { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.empty {
  color: var(--muted); text-align: center; font-size: 14px;
  padding: var(--s6) var(--s4); border: 1px dashed var(--line); border-radius: var(--radius-sm); margin: 0;
}
.loading { color: var(--muted); font-size: 14px; padding: var(--s3) 0; }
.loading::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--card-3);
  border: 1px solid var(--line); font-size: 12px; white-space: nowrap; color: var(--text-2);
}
.pill-ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.pill-manual { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.pill-payout { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.pill-alert { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.pill-bad { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px; font-size: 13px; }
.chip-total { background: var(--accent-soft); border-color: var(--accent-line); }

/* stat tiles */
.status-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.status-grid > div {
  background: var(--card-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 10px 12px; min-width: 0;
}
.status-grid > div > span {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  display: block; margin-bottom: 4px;
}
.status-grid > div > div { font-size: 14px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ controls */
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: var(--s4); }
.actions-row .spacer { flex: 1 1 auto; }
select, button, input { font-family: inherit; }
select, button {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 14px; font-size: 14px; cursor: pointer;
  min-height: 38px;
  transition: border-color .12s, background .12s, color .12s, opacity .12s;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  max-width: 100%;
}
button { font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn { /* neutral secondary button (alias of the default button look) */ }
.btn-sm { padding: 4px 10px; font-size: 12.5px; font-weight: 500; min-height: 30px; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--card-2); }
.nowrap { white-space: nowrap; }
select:hover, button:hover { border-color: var(--accent-dim); }
button:focus-visible, select:focus-visible, a:focus-visible, .switch:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: 0.5; cursor: default; }
button:active:not(:disabled) { transform: translateY(1px); }
a { color: var(--accent); text-underline-offset: 3px; }
.link-more { font-size: 14px; text-decoration: none; white-space: nowrap; }
.link-more:hover { text-decoration: underline; }
label.muted { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
label.muted select { padding-top: 6px; padding-bottom: 6px; }

/* action buttons: primary (ok), caution (warn), destructive (danger) */
.btn-danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: rgba(243,96,60,.2); }
.btn-danger.solid { background: var(--danger); border-color: var(--danger); color: #1a0703; }
.btn-danger.solid:hover { background: #ff7a58; }
.btn-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.btn-warn:hover { border-color: var(--warn); background: rgba(240,180,41,.22); }
.btn-ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn-ok:hover { border-color: var(--accent); background: rgba(25,211,154,.2); }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }

.field {
  background-color: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 14px; min-width: 220px; max-width: 100%;
  min-height: 40px;
}
input.field::placeholder { color: #5f6870; }
.field:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-soft); }
.result-box {
  margin-top: 12px; padding: 10px 13px; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* labelled form grid (manual transfer) */
.form-grid { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.fld .field { min-width: 0; width: 100%; }
.fld-hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: var(--s4); }
.steps { display: flex; gap: var(--s2); flex-wrap: wrap; margin: 0 0 var(--s4); padding: 0; list-style: none; }
.steps li {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2);
  background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 999px; padding: 5px 12px 5px 6px;
}
.steps b {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
}
.steps li.step-danger b { background: var(--danger-soft); color: var(--danger); }
.notes { margin: var(--s3) 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.notes li { margin: 2px 0; }

/* ------------------------------------------------------------- toggle switches */
/* One switch replaces a pair of on/off buttons. ON = «работает» (daemon running, payouts flowing,
   source taking deals, account in the selector). The click still calls the SAME endpoint the old
   paired button did, chosen by the current state, and keeps the confirm() before it. */
.switch-list { display: flex; flex-direction: column; gap: var(--s2); }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  background: var(--card-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.switch-row.is-off { border-color: var(--danger-line); background: linear-gradient(90deg, var(--danger-soft), var(--card-2) 70%); }
.switch-row.is-mid { border-color: var(--warn-line); background: linear-gradient(90deg, var(--warn-soft), var(--card-2) 70%); }
.switch-text { min-width: 0; }
.switch-title { font-weight: 700; font-size: 15px; }
.switch-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.switch-row.is-off .switch-sub { color: var(--danger); }
.switch-row.is-mid .switch-sub { color: var(--warn); }
.switch-row.is-muted { opacity: .55; }
.switch-row.is-muted .switch-sub { color: var(--muted); }
.switch-row.is-muted .switch.is-on { background: var(--card-3); border-color: var(--line); }
.switch {
  position: relative; flex: none;
  width: 52px; height: 30px; min-height: 30px; padding: 0;
  border-radius: 999px; border: 1px solid var(--danger-line);
  background: var(--danger-soft);
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: transform .18s ease, background .18s;
}
.switch.is-on { background: var(--accent-soft); border-color: var(--accent-line); }
.switch.is-on::after { transform: translateX(22px); background: var(--accent); }
.switch.is-unknown { background: var(--card-3); border-color: var(--line); }
.switch.is-unknown::after { background: var(--muted); transform: translateX(11px); }
.switch:hover:not(:disabled) { border-color: var(--text-2); }
.switch:active:not(:disabled) { transform: none; }
.switch-inline { display: inline-flex; align-items: center; gap: 10px; }
.switch-inline .switch-label { font-size: 13px; color: var(--text-2); }

.logs {
  background: #07090b; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  overflow-x: auto; white-space: pre; max-height: 60vh; margin-top: 10px;
}
.raw-logs summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; list-style-position: inside; }
.raw-logs summary:hover { color: var(--text); }
.raw-logs[open] summary { margin-bottom: 10px; }

/* pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.pager span { font-size: 13px; }

tr.clickable { cursor: pointer; }
.clickable { cursor: pointer; }
td.clickable:hover { color: var(--accent); }

/* ------------------------------------------------------- per-account cards */
.acct-cards { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
.acct-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--card-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s4); padding-left: calc(var(--s4) + 3px);
  transition: border-color .15s, transform .15s;
  min-width: 0;
}
.acct-card::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.acct-card.acct-off { background: linear-gradient(170deg, rgba(243,96,60,.05), var(--card-2) 40%); }
.acct-card.acct-off::before { background: var(--danger); }
.acct-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.acct-ident { min-width: 0; }
.acct-person { font-size: 18px; font-weight: 700; letter-spacing: -.2px; line-height: 1.2; overflow-wrap: anywhere; }
.acct-id { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.acct-role-chip {
  flex: 0 0 auto; align-self: flex-start;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-2); background: var(--card-3);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
}
.acct-status-row { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.acct-limits { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.acct-lim-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: center; }
.acct-lim-period { color: var(--muted); font-size: 13px; }
.acct-lim-body { min-width: 0; }
.acct-lim-nums { font-size: 12.5px; display: block; color: var(--text-2); overflow-wrap: anywhere; }
.acct-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-bottom: 5px; }
.acct-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }
.acct-bar.low > span { background: linear-gradient(90deg, #a8521f, var(--danger)); }
.acct-nolim { font-size: 13px; margin: 6px 0; }
.acct-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.acct-limits + .acct-foot, .acct-nolim + .acct-foot, .acct-status-row + .acct-foot { margin-top: 14px; }

/* legacy aliases kept for safety (older markup) */
.acct-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.acct-name { font-weight: 700; font-size: 15px; }
.acct-role { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.acct-limit { font-size: 12px; margin: 4px 0; }
.acct-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding: 2px 0; }
.acct-period { color: var(--muted); min-width: 56px; font-size: 13px; }
.acct-nums { font-size: 13px; }

/* --------------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.66);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 760px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 16px 0 8px; }
.part-card { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.part-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kv2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; }
.kv2 > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.kv2 .muted { font-size: 11px; }
.flags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.flag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.flag-ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.flag-no { background: var(--neutral-soft); color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }

/* --------------------------------------------------------- alif receipt card */
/* Mirrors the Alif mobile receipt: ALS Hauss, teal wordmark, big amount, cheque rows. */
.alif-receipt {
  width: 100%; max-width: 400px; background: #0f1316; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px 22px 20px; margin-top: 6vh;
  font-family: "ALS Hauss", var(--sans);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.ar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ar-logo { font-family: "ALS Hauss", var(--sans); font-weight: 700; font-size: 24px; color: var(--accent); letter-spacing: -.5px; }
.ar-close { background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; min-height: 0; }
.ar-close:hover { color: var(--text); }
.ar-amount { font-family: "ALS Hauss", var(--sans); font-size: 34px; font-weight: 700; text-align: center; margin: 18px 0 2px; letter-spacing: -.5px; }
.ar-sub { text-align: center; color: var(--muted); font-size: 15px; }
.ar-status {
  display: block; width: fit-content; margin: 12px auto 18px; padding: 4px 14px;
  border-radius: 999px; text-transform: uppercase; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: var(--muted); background: var(--neutral-soft); border: 1px solid var(--line);
}
.ar-status.ar-ok { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.ar-status.ar-bad { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.ar-rows { display: grid; grid-template-columns: auto 1fr; gap: 11px 14px; margin: 0; }
.ar-rows dt { color: var(--muted); font-size: 13px; font-weight: 400; }
.ar-rows dd { margin: 0; text-align: right; font-size: 13.5px; font-weight: 500; word-break: break-word; }
.ar-rows-totals { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.ar-foot { margin-top: 18px; text-align: center; border-top: 1px dashed var(--line); padding-top: 16px; }
.ar-foot:empty { display: none; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 32px; }

/* ------------------------------------------------------------------ login page */
.login-body { min-height: 100dvh; display: flex; flex-direction: row; align-items: flex-start; justify-content: center;
  background: radial-gradient(900px 500px at 50% -10%, rgba(25,211,154,.10), transparent 70%), var(--bg); }
.login-card {
  width: 100%; max-width: 380px; margin: 14vh 16px 0; padding: 30px 24px 26px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.login-brand { margin-bottom: 6px; }
.login-hint { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.login-err {
  margin: 0 0 12px; padding: 9px 11px;
  background: var(--danger-soft); border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm); color: var(--danger); font-size: 13px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.login-form input {
  width: 100%; padding: 12px 13px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-size: 16px;
}
.login-form input:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-form button {
  margin-top: 6px; padding: 12px; min-height: 46px;
  background: var(--accent); color: #04120d;
  border: 0; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.login-form button:hover { background: #3be3b0; }

/* ===================================================================== breakpoints */

/* tablet and up: topbar back to one row, grids open up */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .topbar { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 10px var(--gutter); }
  .nav { overflow: visible; flex-wrap: wrap; margin: 0; padding: 0; }
  .grid { grid-template-columns: 2fr 1fr; }
  .card { padding: 20px; }
  .acct-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .limit-cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .status-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .switch-list.two { display: grid; grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* desktop: hover lift on cards, a touch more breathing room */
@media (min-width: 1024px) {
  .wrap { padding: 24px var(--gutter) 10px; }
  .acct-card:hover { border-color: var(--accent-line); transform: translateY(-1px); }
  .form-grid { grid-template-columns: 2fr 2fr 1.4fr 0.8fr; }
  .form-grid .fld-wide { grid-column: span 2; }
}

/* wide: let the account grid use the extra width without stretching cards too far */
@media (min-width: 1500px) {
  .acct-cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
@media (min-width: 1700px) { .wrap { max-width: 1760px; } }
@media (min-width: 2100px) { .wrap { max-width: 1960px; } }

/* cleaner numbers in account cards — tabular figures instead of the dated monospace look
   (Papa: "шрифты в карточках всё ещё убогие из 2006"). */
.acct-card .mono,
.acct-lim-nums,
.acct-balance-val {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
  font-size: inherit;
}
.acct-id { letter-spacing: .1px; font-size: 12.5px !important; }

/* account ЛК balance row on each dashboard card */
.acct-balance {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px;
  margin: 2px 0 12px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.acct-balance-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; width: 100%; }
.acct-balance-val { font-size: 20px; font-weight: 700; }
.acct-balance-card { color: var(--muted); font-size: 12px; }

/* manual: selected-cabinet balance hint */
.cabinet-balance b { color: var(--text); }

/* ---- manual send gate (confirm checkbox before the red Отправить) ---- */
.send-gate {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 14px;
  padding: 14px; border: 1px solid var(--danger-line); border-radius: var(--radius-sm); background: var(--danger-soft);
}
.confirm-check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.confirm-check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--danger); flex: none; cursor: pointer; }
.confirm-check b { color: var(--text); }

/* ===================== Alif history — bank-app style ===================== */
.alif-hist .field { min-width: 180px; }

.alif-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 6px; }
.sum-card { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.sum-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.sum-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-expense .sum-val { color: var(--text); }
.sum-income  .sum-val { color: var(--accent); }

.alif-feed { margin-top: 10px; }
.alif-day-group { margin-bottom: 6px; }
.alif-day-head {
  position: sticky; top: calc(var(--topbar-h) + 50px); z-index: 1;
  color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: capitalize;
  padding: 12px 2px 6px; background: var(--card);
}
.alif-row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  padding: 11px 8px; border-bottom: 1px solid var(--line-soft); cursor: pointer; border-radius: 10px;
}
.alif-row:hover { background: var(--card-2); }
.alif-row.is-canceled { opacity: .55; }
.alif-row.is-canceled .alif-amt { text-decoration: line-through; }
.alif-ic {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
}
.alif-ic.ic-out { background: var(--danger-soft); color: var(--danger); }
.alif-ic.ic-in  { background: var(--accent-soft); color: var(--accent); }
.alif-main { min-width: 0; }
.alif-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alif-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alif-right { text-align: right; white-space: nowrap; }
.alif-amt { font-size: 15.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.alif-amt.pos { color: var(--accent); }
.alif-amt.neg { color: var(--text); }
.alif-card { font-size: 12px; margin-top: 2px; }

@media (min-width: 640px) {
  .alif-day-head { top: var(--topbar-h); }
}
@media (max-width: 640px) {
  .alif-summary { grid-template-columns: 1fr 1fr; }
  .sum-val { font-size: 17px; }
  .alif-title, .alif-sub { white-space: normal; }
  .card-head .head-side { margin-left: 0; width: 100%; }
  .card-head .head-side select { flex: 1 1 auto; }
}

/* ---- 20.10 v3: compact sources, account head switch, dual limit bars, copyable PAN ---- */
.src-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.src-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2);
  border-left: 3px solid var(--accent); }
.src-row.is-off { border-left-color: var(--danger); }
.src-name { font-weight: 600; font-size: 15px; }
.src-list .result-box { grid-column: 1 / -1; }
.acct-top .switch { flex: none; }
.acct-person .acct-role-chip { margin-left: 6px; vertical-align: middle; }
.acct-person .badge { margin-left: 6px; vertical-align: middle; }
.pan-copy { background: none; border: 0; padding: 0; color: var(--accent); cursor: copy;
  font-size: inherit; border-bottom: 1px dashed currentColor; }
.pan-copy:hover { opacity: .85; }
.pan-copy.copied { color: var(--muted); border-bottom-color: transparent; }
.lim-row { padding: 8px 0; }
.lim-row + .lim-row { border-top: 1px solid var(--line); }
.lim-period { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.lim-metric { display: grid; grid-template-columns: 1fr; gap: 3px; }
.lim-metric + .lim-metric { margin-top: 4px; }
.lim-head { display: contents; }
.lim-v { font-size: 13px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lim-of { color: var(--muted); }
.lim-cur { color: var(--muted); font-size: 11px; }
.lim-metric .acct-bar { margin: 0; }
.dest-amount .mono { color: var(--accent); font-weight: 600; font-size: 16px; }
.acct-bar.bar-count > span { background: linear-gradient(90deg, #4f5bd5, var(--info)); }
.acct-bar.bar-count.low > span { background: linear-gradient(90deg, #a8521f, var(--danger)); }
