/* Map the offline portal's existing tokens to the signed-in XPAY theme. */
body {
  --canvas: #0d0d0d;
  --surface: #1c1c1c;
  --ink: #d2d2d2;
  --muted: #868686;
  --secondary: #77818d;
  --line: #444;
  --field: #2b2b2b;
  --button: #444;
  --blue: #00a3fb;
  --green: #05cf2a;
  --danger: #ff4747;
  --edge: var(--line);
  --gutter: 32px;
}
body.light {
  --canvas: #f7f9fc;
  --surface: #eceff3;
  --ink: rgb(0 0 0 / 90%);
  --muted: #4f5965;
  --secondary: #77818d;
  --line: #d4d7dc;
  --field: #fff;
  --button: #818b97;
}
#navigation {z-index: 4; padding-inline: var(--gutter);}
#navigation .brand picture {display: flex;}
#navigation .brand .xpay-wordmark-light, body.light #navigation .brand .xpay-wordmark-dark {display: none;}
body.light #navigation .brand .xpay-wordmark-light {display: flex;}
#navigation .brand img {display: block; width: auto; height: 40px; max-width: 26vw; object-fit: contain;}
#navigation .topbar .row {flex-wrap: nowrap;}
#navigation #theme, #navigation #menu {background: var(--button); color: #f7f9fc;}
#navigation #menu {display: inline-grid; place-items: center; padding: 0; width: 44px; height: 44px; border: 0; border-radius: 6px;}
#navigation .switch input:checked {background: var(--green);}
#sidebar:not([hidden]) {
  position: relative; inset: auto; z-index: 3;
  display: block; width: 100%; padding: 12px var(--gutter) 0;
  overflow: visible; background: var(--canvas);
}
#sidebar nav {
  display: flex; position: relative; flex-flow: row nowrap; align-items: center;
  gap: 6px; min-height: 52px; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
#sidebar nav a {
  flex: none; white-space: nowrap; padding: 10px;
  min-height: 52px; font-size: 16px; font-weight: 500;
}
#sidebar nav a.active {color: var(--ink); background: var(--surface);}
#sidebar .nav-icon {background: var(--surface); color: var(--muted);}
#sidebar .active .nav-icon {color: var(--blue);}
#native-nav-extras {
  display: none; position: absolute; right: var(--gutter); top: 100%;
  width: min(288px, calc(100vw - 20px)); max-height: 65vh; overflow-y: auto;
  padding: 16px; border-radius: 24px; background: var(--canvas);
  box-shadow: 0 5px 20px rgb(0 0 0 / 25%);
}
#sidebar.open #native-nav-extras {display: block;}
#native-nav-extras .side-info {margin-top: 0; background: var(--surface);}
#native-nav-extras a.side-info {margin-top: 8px;}
#native-nav-extras .side-account {padding-bottom: 4px;}
body:not(.logged-out) #app {max-width: 100%; margin-inline: 0; padding: 24px var(--gutter) 40px;}
.home-balance {border-radius: 24px;}
.home-wallet .tether-coin {width: 75px; height: 75px;}
.home-wallet .wallet-value {padding-top: 0;}
.home-wallet .wallet-value > strong {font-weight: 600; font-size: 32px; line-height: 1.25;}
.home-wallet .wallet-value p {font-size: 16px; color: var(--secondary);}

.home-wallet .filled {background: var(--button); border-color: var(--button); color: #f7f9fc;}
.home-security {
  margin: 0; gap: 0; padding: 16px 0 16px 96px;
  border-bottom: 1px dashed rgb(0 0 0 / 20%);
}
.home-security > div {width: 300px; gap: 8px;}
.home-security .ui-icon {width: 40px; height: 40px; padding: 8px; border-radius: 50%; color: var(--blue); background: var(--canvas);}
.home-security span {font-size: 16px;}
.home-security strong {font-size: 16px; font-weight: 600;}
.home-rewards {display: grid; gap: 8px; padding-top: 16px;}
.home-rewards h2 {margin: 0; font-size: 16px;}
.home-rewards > div {gap: 8px;}
.home-rewards > div > span {width: auto;}
.home-rewards .tag {padding: 8px; border-radius: 8px; font-size: 14px;}
.home-disputes {color: var(--danger);}

/* Share a left edge between the wordmark, section links and page content. */
body {
  --compact-gutter: max(clamp(16px, 3.5vw, 56px), calc((100% - 1440px) / 2));
  --compact-rule: color-mix(in srgb, var(--ink) 13%, var(--surface));
}
body:not(.logged-out) #navigation {
  height: 60px;
  padding-inline: var(--compact-gutter);
  border-bottom: 1px solid var(--compact-rule);
}
#navigation .topbar { height: 100%; }
#navigation .brand-group { display: flex; align-items: center; gap: 5px; }
#navigation #sections-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}
#navigation #sections-toggle svg { width: 21px; height: 21px; }
#navigation #sections-toggle:is(:hover,[aria-expanded=true]) { background: var(--field); }
#navigation .brand img { height: 30px; }
#navigation .topbar .row { gap: 14px; align-items: center; }
#navigation .top-rate {
  order: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#navigation .top-rate .tether-icon { width: 21px; height: 21px; }
#navigation .top-rate .tron-badge { width: 10px; height: 10px; }
#navigation .top-rate b { font-size: 14px; line-height: 1.2; }
#navigation .top-rate small:not([hidden]) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

#navigation .topbar .switch { order: 1; }
#navigation .topbar #theme { order: 2; }
#navigation .account-wrap {
  order: 3;
  position: relative;
  margin-left: 2px;
  padding-left: 12px;
  border-left: 1px solid var(--compact-rule);
  min-width: 0;
}
#navigation :is(#theme, #menu) {
  position: static;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
#navigation :is(#theme, #menu) .ui-icon { width: 16px; height: 16px; }
#navigation .switch { font-size: 13px; gap: 6px; }
#navigation .switch input { width: 30px; height: 18px; }
#navigation .switch input::after { width: 14px; height: 14px; }
#navigation .switch input:checked::after { left: 14px; }
#navigation #menu {
  display: flex;
  align-items: center;
  gap: 9px;
  width: auto;
  padding-inline: 8px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}
#navigation #menu:is(:hover,[aria-expanded=true]) { background: var(--field); }
#navigation .header-account-email { max-width: 28ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-chevron { width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
#menu[aria-expanded=true] .account-chevron { transform: translateY(2px) rotate(225deg); }
#navigation #native-nav-extras {
  top: calc(100% + 6px);
  left: auto;
  right: 0;
  width: max-content;
  min-width: 140px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--compact-rule);
  border-radius: 9px;
}
#navigation #menu[aria-expanded=true] + #native-nav-extras { display: block; }
#navigation #logout { display: flex; align-items: center; gap: 8px; width: 100%; color: var(--ink); font-size: 13px; padding: 8px 12px; background: transparent; }
#navigation #logout:hover { background: var(--field); }
#navigation :is(#theme,#menu,#logout,#sections-toggle):focus-visible { outline: 2px solid var(--brand-gold); outline-offset: -2px; }
#sidebar:not([hidden]) {
  padding: 0 var(--compact-gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--compact-rule);
}
#sidebar nav {
  min-height: 0;
  gap: clamp(16px, 2.6vw, 36px);
}
#sidebar nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 2px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  line-height: 18px;
}
#sidebar nav a:hover { color: var(--ink); }
#sidebar nav a.active { color: var(--brand-gold); border-bottom-color: currentColor; }
#sidebar nav a.active .nav-icon { color: inherit; }
body.light #sidebar nav a.active {
  --nav-accent: var(--brand-gold);
  color: var(--ink);
  font-weight: 650;
  border-bottom-color: var(--nav-accent);
}
body.light #sidebar nav a.active .nav-icon { color: var(--nav-accent); background: var(--accent-support); border-radius: 4px; }
#sidebar nav a:focus-visible { outline-offset: -3px; }
#sidebar nav .nav-icon { display: inline-flex; align-items: center; justify-content: center; line-height: 1; width: 18px; height: 18px; padding: 0; background: transparent; }
#sidebar nav .nav-icon .ui-icon { display: block; width: 16px; height: 16px; margin: 0; }
#native-nav-extras { right: var(--compact-gutter); left: auto; }
body:not(.logged-out) #app { padding: 18px var(--compact-gutter) 32px; }
#app .compact-home-title { margin: 0 0 12px; font-size: 28px; line-height: 1.15; letter-spacing: -.025em; }
@media (max-width: 760px) {
  body { --compact-gutter: 12px; }
  #navigation #sections-toggle { display: inline-flex; }
  #navigation .topbar { gap: 6px; }
  #navigation .brand img { height: 26px; }
  #navigation .topbar .row { gap: 4px; }
  #navigation #theme { width: 44px; height: 44px; }
  #navigation #menu { width: auto; min-height: 44px; }
  #navigation .switch { display: flex; flex-direction: column-reverse; margin: 0; min-width: 44px; min-height: 44px; justify-content: center; gap: 3px; font-size: 11px; }
  #navigation .switch span { position: static; transform: none; line-height: 1.15; }
  #sidebar[popover]:not(:popover-open) { display: none; }
  #sidebar[popover]:popover-open {
    display: block;
    position: fixed;
    inset: var(--menu-top) auto auto var(--compact-gutter);
    margin: 0;
    width: min(292px, calc(100vw - 2 * var(--compact-gutter)));
    max-height: calc(100dvh - var(--menu-top) - 12px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 6px;
    border: 1px solid var(--compact-rule);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 7px 25px rgb(0 0 0 / 18%);
  }
  #sidebar[popover]::backdrop { background: rgb(0 0 0 / 12%); }
  #sidebar[popover] nav { flex-flow: column; align-items: stretch; gap: 1px; overflow: visible; }
  #sidebar[popover] nav a { gap: 12px; padding: 0 12px; min-height: 44px; border: 0; border-radius: 7px; }
  #sidebar[popover] nav a.active { background: var(--field); }
  body:not(.logged-out) #app { padding-top: 12px; }
  #app .compact-home-title { font-size: 22px; margin-bottom: 10px; }
}
@media (max-width: 660px) {
  body:not(.logged-out) #navigation { height: auto; }
  #navigation .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content max-content 44px;
    align-items: center;
    gap: 0 8px;
  }
  #navigation .topbar .row { display: contents; }
  #navigation .brand-group { grid-area: 1 / 1 / 2 / 3; justify-self: start; }
  #navigation .account-wrap { grid-area: 1 / 3 / 2 / -1; justify-self: end; padding-left: 0; border: 0; }
  #navigation #menu { height: 44px; margin: 0; }
  #navigation .header-account-email { max-width: min(45vw, 28ch); }
  #navigation .top-rate { grid-area: 2 / 1; justify-self: start; }
  #navigation .switch:has(#trafficIn) { grid-area: 2 / 2; }
  #navigation .switch:has(#trafficOut) { grid-area: 2 / 3; }
  #navigation .topbar #theme { grid-area: 2 / 4; }
  #navigation .topbar .switch { flex-direction: row; gap: 5px; }
  #navigation .topbar { padding-bottom: 6px; }
}
@media (max-width: 400px) {
  #navigation .topbar { column-gap: 5px; }
  #navigation .topbar .switch { flex-direction: column-reverse; gap: 2px; }
}

/* Keep the trader's data, controls and status colours; change their grouping. */
body[data-view="home"] .home-accounts { gap: 12px; }
.home-accounts .home-balance {
  --wallet-yellow: var(--brand-gold);
  --wallet-icon: var(--wallet-yellow);
  --wallet-soft: color-mix(in srgb, var(--wallet-yellow) 13%, var(--surface));
  --wallet-coin-size: 74px;
  --wallet-column-gap: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  padding: 22px 24px;
  border: 1px solid color-mix(in srgb, var(--ink) 13%, var(--surface));
  border-radius: 12px;
}
body.light .home-accounts .home-balance {
  --wallet-soft: var(--accent-support);
}
.home-balance .home-wallet {
  display: grid;
  grid-template-columns: var(--wallet-coin-size) minmax(0, 1fr) auto;
  gap: 12px var(--wallet-column-gap);
  align-items: center;
}
.home-wallet .tether-coin { width: var(--wallet-coin-size); height: var(--wallet-coin-size); }
.home-wallet .tether-coin > svg.tron-badge { width: 36%; height: 36%; }
.home-wallet .wallet-value { min-width: 0; }
.home-wallet .wallet-value > strong {
  font-size: clamp(25px, 2.2vw, 34px);
  letter-spacing: -.035em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.home-wallet .wallet-number { white-space: nowrap; }
.home-wallet .wallet-precision { color: var(--muted); font-weight: 400; }
.home-wallet .wallet-unit { font-size: .72em; letter-spacing: 0; }
.home-wallet .wallet-value p { margin-top: 4px; font-size: 14px; color: var(--muted); }
.home-wallet .wallet-actions {
  width: auto;
  margin: 0;
  justify-self: end;
  align-self: start;
  gap: 8px;
  display: flex;
  align-items: center;
}
.home-wallet .wallet-actions :is([data-withdraw], [data-history]) {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; border-radius: 7px;
  color: var(--control-on-gold); background: var(--wallet-yellow);
}
.home-wallet .wallet-actions [data-history] { background: var(--wallet-soft); color: var(--wallet-icon); }
.home-wallet .wallet-actions [data-withdraw]:hover { border-color: var(--control-on-gold); }
.home-wallet .wallet-actions [data-history]:hover { border-color: var(--wallet-icon); }
.home-wallet .wallet-actions .compact-stroke { width: 15px; height: 15px; fill: none; }
.home-balance .home-security {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 300px));
  align-items: start;
  padding: 0 0 0 calc(var(--wallet-coin-size) + var(--wallet-column-gap));
  gap: 0;
  border: 0;
  margin: 0;
}
.home-balance .home-security > div { gap: 9px; width: auto; min-width: 0; }
.home-balance .home-security .ui-icon {
  width: 34px; height: 34px; box-sizing: border-box; padding: 7px;
  background: var(--wallet-soft); color: var(--wallet-icon); fill: currentColor; border-radius: 8px;
}
.home-balance .home-security span { font-size: 13px; line-height: 1.45; }
.home-balance .home-security strong { font-size: 14px; line-height: 1.45; }
.home-balance .home-rewards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 6px;
  padding: 16px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--ink) 13%, var(--surface));
}
.home-balance .home-rewards h2 { margin: 0 0 2px; font-size: 14px; line-height: 1.35; font-weight: 600; color: var(--ink); }
.home-balance .home-rewards > div {
  display: grid; grid-template-columns: 61px minmax(0, 1fr);
  align-items: baseline; min-height: 22px; gap: 8px;
}
.home-balance .home-rewards > div > span { width: auto; font-size: 13px; }
.home-balance .home-rewards > div > div { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.home-balance .home-rewards .tag {
  padding: 5px 8px; border-radius: 5px; font-size: 13px;
  max-width: 100%; white-space: normal; overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--ink) 6%, var(--surface)); color: var(--ink);
}

#app .home-today {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 16px 0;
  padding: 14px 0;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--ink) 13%, var(--surface));
  border-radius: 12px;
}
#app .home-today .daily-card { margin: 0; padding: 0 20px; border: 0; background: transparent; border-radius: 0; }
#app .home-today .daily-card + .daily-card { border-left: 1px solid color-mix(in srgb, var(--ink) 14%, var(--surface)); }
body[data-view="home"] #app .daily-card h3 { font-size: 13px; line-height: 1.35; font-weight: 500; color: var(--muted); }
body[data-view="home"] #app .daily-value { margin-top: 4px; font-size: 24px; line-height: 1.25; letter-spacing: -.03em; }
body[data-view="home"] #app .daily-counts { margin-top: 3px; gap: 4px 12px; font-size: 12px; }
#app .home-disputes { margin: 0 0 7px; font-size: 16px; }
.home-disputes + .deal-list { padding: 0; }
.home-disputes + .deal-list .deal-line {
  min-width: 0;
  min-height: 70px;
  padding: 10px 14px;
  gap: 12px;
  border-radius: 10px;
  grid-template-columns: 1.2fr 1.15fr .77fr 1.15fr .85fr .7fr 1.2fr auto;
}
.home-disputes + .deal-list .deal-line > div { min-width: 0; }
.home-disputes + .deal-list .deal-buttons .square { width: 34px; height: 34px; padding: 5px; }
.home-disputes + .deal-list .deal-requisite .bank-mark { width: 26px; height: 26px; font-size: 15px; flex-shrink: 0; }
.home-disputes + .deal-list .deal-symbol { width: 25px; height: 25px; }

@media (min-width: 681px) and (max-width: 1050px) {
  .home-disputes + .deal-list .deal-line {
    grid-template-columns: 1fr 1fr 1.25fr 1.3fr;
    row-gap: 10px;
  }
}
@media (max-width: 680px) {
  .home-accounts .home-balance { --wallet-coin-size: 40px; --wallet-column-gap: 9px; padding: 15px; gap: 14px; }
  .home-balance .home-wallet { grid-template-columns: var(--wallet-coin-size) minmax(0, 1fr); }
  .home-wallet .wallet-value > strong { font-size: clamp(20px, 5.3vw, 25px); }
  .home-wallet .wallet-value p { font-size: 12px; }
  .home-wallet .wallet-number { white-space: normal; overflow-wrap: anywhere; }
  .home-wallet .wallet-actions { grid-column: 1 / -1; justify-self: start; }
  .home-wallet .wallet-actions :is([data-withdraw], [data-history]) { min-height: 44px; padding: 7px 13px; }
  .home-balance .home-security { padding-left: 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .home-balance .home-security > div { align-items: start; gap: 5px; }
  .home-balance .home-security .ui-icon { width: 21px; height: 21px; padding: 3px; }
  .home-balance .home-security strong { font-size: 12px; overflow-wrap: anywhere; }
  .home-balance .home-rewards { padding-top: 12px; }
  .home-balance .home-rewards > div { grid-template-columns: 53px minmax(0, 1fr); gap: 6px; }
  .home-balance .home-rewards .tag { padding: 4px 6px; font-size: 12px; }
  #app .home-today { grid-template-columns: 1fr 1fr; margin: 12px 0; padding: 12px 0; }
  #app .home-today .daily-card { padding: 0 12px; }
  body[data-view="home"] #app .daily-value { font-size: 18px; }
  .home-disputes + .deal-list .deal-line { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 12px; padding: 11px 12px; }
  .home-disputes + .deal-list .deal-buttons .square { width: 44px; height: 44px; }
  .home-disputes + .deal-list .deal-buttons { justify-content: end; }
}

/* The authenticated content area only. Dialogs and navigation keep their own sizing. */
body:is([data-view="deals"], [data-view="disputes"], [data-view="stats"],
        [data-view="requisites"], [data-view="operators"], [data-view="settings"]) #app {
  --control-h: 34px;

  & > h1 { margin: 0 0 14px; font-size: 24px; line-height: 1.2; }
  & .section-heading { margin: 18px 0 8px; font-size: 17px; }
  & > h1 + .section-heading { margin-top: 0; }
  & .card, & .filters { border-radius: 12px; }
  & .card { padding: 14px 16px; }
  & .actions { gap: 6px; }
  & .filters { gap: 8px; padding: 12px; margin: 0 0 12px; }
  & .filters label { min-width: 0; }
  & .compact-filters .actions { flex-wrap: wrap; }
  & :is(button:not(.copy), input:not([type="checkbox"]), select:not(.pp-select-native)) {
    min-height: var(--control-h); padding: 5px 10px;
  }
  & .square, & .deal-buttons .square { width: var(--control-h); height: var(--control-h); padding: 0; }
  & .page-size { min-height: var(--control-h); padding: 2px 8px; }
  & .page-size select { min-height: 26px; padding: 0; }
  & .deal-tabs { gap: 6px; margin: 0 0 12px; }
  & .deal-tabs a {
    min-height: var(--control-h); padding: 4px 10px; gap: 6px;
    font-size: 14px; border-radius: 8px;
  }
  & .deal-tabs a b { width: 22px; height: 22px; }
  & .deal-tabs a b img, & .deal-tabs a b svg { width: 15px; height: 15px; }
  & .deal-filters { margin: 0 0 10px; }
  & .deal-filters .filters { margin: 0; }
  & .deal-list { gap: 3px; }
  & [data-deal-rows] { max-width: 100%; overflow-x: auto; }
  & .deal-line, & .deal-list-heading {
    grid-template-columns: minmax(114px,1fr) minmax(134px,1.15fr) minmax(80px,.65fr)
      minmax(125px,1fr) minmax(76px,.7fr) minmax(66px,.6fr) minmax(140px,1.25fr)
      calc(var(--control-h) + var(--control-h) + 4px);
    min-width: 950px; gap: 9px; padding-inline: 12px;
  }
  & .deal-list-heading { padding-block: 4px 6px; }
  & .deal-line { min-height: 58px; padding-block: 8px; border-radius: 9px; }
  & .bank-mark { width: 30px; height: 30px; font-size: 18px; }
  & .table-wrap table { border-spacing: 0 3px; }
  & .table-wrap td { padding: 7px 8px; }
  & .table-wrap td:first-child { padding-left: 12px; border-radius: 9px 0 0 9px; }
  & .table-wrap td:last-child { padding-right: 12px; border-radius: 0 9px 9px 0; }
  & .requisite-table td { height: 56px; }
  & .requisite-table .group-row td { height: auto; padding: 5px 12px; border-radius: 6px; }
  & .requisite-table .actions { gap: 4px; }
  & .requisite-toolbar, & .operator-toolbar { margin-bottom: 8px; }
  & .pagebar { margin-top: 8px; }
  & .empty { padding: 16px; border-radius: 10px; }
  & .deal-tabs button[data-stats-tab].blue {
    background: var(--brand-gold); border-color: var(--brand-gold); color: var(--control-on-gold); font-weight: 650;
  }
  & .deal-tabs button[data-stats-tab].blue:hover { border-color: var(--control-on-gold); }
  & .stats-card, & .setting { margin-bottom: 10px; }
  & .stat-count { font-size: 25px; line-height: 1.25; }
  & .stats-values { gap: 8px 26px; margin-top: 8px; }
  & .stats-values strong { margin-top: 2px; }
  & .setting label:not(:has(input[type="checkbox"])), & .setting .form-line {
    margin-block: 8px; column-gap: 12px;
  }
  & .telegram-settings .notification-row { margin-bottom: 8px; }

  @media (max-width: 760px) {
    --control-h: 44px;
    & > h1 { margin-bottom: 10px; font-size: 22px; }
    & .card, & .filters { padding: 10px; }
    & .filters { grid-template-columns: repeat(auto-fit,minmax(min(150px,100%),1fr)); }
    & .filters .actions { grid-column: 1 / -1; flex-wrap: wrap; }
    & .deal-tabs a { padding-inline: 8px; }
    & .deal-tabs a b { width: 18px; height: 18px; }
    & .deal-amount-search { margin: 0; }
    & .switch, & .notification-options label { min-height: 44px; }
    & .stats-values { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; }
    & .deal-list, & .table-wrap { max-width: 100%; }
  }
}

body[data-view="requisites"] #app .requisite-table {
  position: relative;
  --req-yellow: var(--brand-gold);
  --req-meter-fill: color-mix(in srgb, var(--brand-gold) 56%, #57595b);
  --req-meter-ink: #242011;
  --req-track: #393a3b;
  --req-track-ink: #f5f5f5;
}
body.light[data-view="requisites"] #app .requisite-table {
  --req-meter-fill: color-mix(in srgb, var(--brand-gold) 53%, #332f25);
  --req-meter-ink: #161307;
  --req-track: #dde1e6;
  --req-track-ink: #293039;
}
.req-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.req-device { position: relative; display: inline-flex; align-items: center; gap: 7px; }
#app .req-device svg { width: 17px; height: 21px; flex: none; color: var(--muted); }
body { --req-device-on: #60d992; --req-device-off: #ff616b; }
body.light { --req-device-on: #137545; --req-device-off: #c73543; }
#app .req-device svg[data-state="on"] { color: var(--req-device-on); }
#app .req-device svg[data-state="off"] { color: var(--req-device-off); }
.requisite-table .req-meter {
  position: relative;
  max-width: 190px;
  min-width: max-content;
  overflow: hidden;
  border-radius: 999px;
  background: var(--req-track);
  color: var(--req-track-ink);
  text-align: center;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 16px;
}
.requisite-table .req-meter + .req-meter { margin-top: 4px; }
.requisite-table .req-meter-caption,
.requisite-table .req-meter-fill {
  display: block;
  padding-inline: 9px;
}
/* Clip the fill and its dark lettering together so text crossing the edge
   stays legible at every percentage and is announced only once. */
.requisite-table .req-meter-fill {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--req-fill)) 0 0);
  background: var(--req-meter-fill);
  color: var(--req-meter-ink);
  pointer-events: none;
  user-select: none;
}
.requisite-table .req-meter-fill::after { content: attr(data-caption); }
@media (forced-colors: active) {
  .requisite-table .req-meter { outline: 1px solid CanvasText; outline-offset: -1px; }
  .requisite-table .req-meter-fill { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}
body[data-view="requisites"] #app .requisite-table :is(th,td):last-child:not([colspan]) {
  position: static;
  box-shadow: none;
  border-inline-start: 0;
}
body[data-view="requisites"] #app .requisite-table th:last-child { background: transparent; }
body[data-view="requisites"] #app .requisite-table td:last-child .actions {
  justify-content: flex-end;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
body[data-view="requisites"] #app .requisite-table tr:hover td:last-child:not([colspan]) { background: var(--surface); }
body[data-view="requisites"] #app .requisite-table input[data-toggle]:checked { background: var(--brand-gold); }
body[data-view="requisites"] #app .requisite-table input[data-toggle]:checked::after { background: #2a2514; }
body[data-view="requisites"] #app .requisite-table input[data-toggle]:focus-visible { outline: 2px solid var(--req-yellow); outline-offset: 2px; }

/* Keep the direction easy to recognize even when the colour is unavailable. */
#app {
  --trade-gold: var(--brand-gold);
  --trade-tab-edge: var(--brand-gold);
  --trade-in: #58c9da;
  --trade-out: var(--brand-gold);
  --trade-alert: #ff8587;
  --trade-done: #67d79f;
  --trade-neutral: var(--muted);
}
body.light #app {
  --trade-in: #126979;
  --trade-alert: #a72c38;
  --trade-done: #16704b;
}
#app :is([data-tab="in"], [data-symbol="in"], [data-direction="in"]) { --mark-tone: var(--trade-in); }
#app :is([data-tab="out"], [data-symbol="out"], [data-direction="out"]) { --mark-tone: var(--trade-out); }
#app :is([data-symbol="dispute"], [data-tab="dispute"]) { --mark-tone: var(--trade-alert); }
#app [data-symbol="completed"] { --mark-tone: var(--trade-done); }
#app :is([data-tab="all"], [data-symbol="canceled"]) { --mark-tone: var(--trade-neutral); }
#app .deal-tabs a[data-tab] {
  border: 1px solid transparent;
  gap: 7px; color: var(--muted); box-shadow: none;
}
#app .deal-tabs a[data-tab]:hover { color: var(--ink); background: var(--field); }
#app .deal-tabs a[data-tab].active {
  border-color: var(--trade-tab-edge); color: var(--ink); font-weight: 600;
  background: var(--surface);
}
#app .deal-tabs a[data-tab]:focus-visible,
#app .deal-tabs #auto:focus-visible,
#app .deal-buttons button:focus-visible {
  outline: 2px solid var(--control-focus); outline-offset: 2px;
}
#app .deal-tabs a[data-tab] b, #app .deal-symbol[data-symbol] {
  display: inline-grid; place-items: center;
  background: transparent;
  color: var(--mark-tone);
}
body.light #app :is(.deal-tabs a[data-tab=out] b, .deal-symbol[data-symbol=out], .deal-line[data-direction=out] .direction-badge) {
  background: var(--accent-support); border-radius: 4px;
}
#app .deal-symbol[data-symbol] { width: 26px; height: 26px; }
#app .deal-symbol[data-symbol] svg, #app .deal-tabs a[data-tab] b svg {
  width: 18px; height: 18px; fill: none; stroke-width: 2;
}
#app .deal-tabs a[data-tab] b svg { stroke-width: 2.5; }
#app .deal-buttons [data-confirm] .ui-icon { fill: none; stroke-width: 2; }
#app .deal-line .direction-badge {
  background: color-mix(in srgb, var(--mark-tone) 13%, var(--surface));
  color: var(--mark-tone) !important;
}
#app .deal-tabs #auto:checked, #app .deal-buttons button[data-confirm]:enabled {
  background: var(--trade-gold); border-color: transparent; color: #242119;
}
#app .deal-tabs #auto:checked::after { background: #302919; }
#app .deal-buttons button[data-confirm]:enabled:hover { border-color: var(--control-on-gold); }
#app .deal-buttons button[data-confirm]:disabled {
  background: var(--field); border-color: var(--line); color: var(--muted); opacity: .58;
}
#app .deal-buttons button .compact-stroke { fill: none; }
@media (min-width: 1280px) {
  body:is([data-view="deals"], [data-view="disputes"]) #app :is(.deal-line, .deal-list-heading) {
    grid-template-columns: minmax(114px,1fr) minmax(134px,1.15fr) minmax(80px,.65fr)
      minmax(125px,1fr) minmax(76px,.7fr) minmax(66px,.6fr) minmax(140px,1.25fr) 76px;
  }
}

@media (max-width: 760px) {
  body:is([data-view="deals"], [data-view="disputes"]) #app .deal-list-heading { display: none; }
  body:is([data-view="deals"], [data-view="disputes"]) #app .deal-list { gap: 8px; }
  body:is([data-view="deals"], [data-view="disputes"]) #app .deal-line {
    min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 14px; padding: 12px;
  }
  body:is([data-view="deals"], [data-view="disputes"]) #app .deal-line > div { min-width: 0; }
  #app .deal-line .deal-buttons { justify-content: flex-end; }
  #app .deal-line .deal-state { text-align: right; }
  #app .deal-line .deal-state .state-with-timer { justify-content: flex-end; }
  #app .deal-line .deal-amount { text-align: right; }
  #app .deal-line [data-mobile-label]::before {
    content: attr(data-mobile-label); display: block;
    color: var(--muted); font-size: 11px; line-height: 1.4;
  }
  #app .deal-line .deal-device { white-space: normal; }
}
@media (max-width: 465px) {
  #app .deal-line .deal-requisite { grid-column: 1 / -1; }
  #app .deal-line .deal-buttons { grid-column: 1 / -1; }
}

body[data-view="settings"] #app {
  --settings-accent: var(--brand-gold);
  --settings-on-accent: var(--control-on-gold);
  --settings-edge: color-mix(in srgb, var(--ink) 15%, var(--surface));
}

body[data-view="settings"] #app .setting { min-width: 0; }
@media (min-width: 1060px) {
  body[data-view="settings"] #app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
    grid-template-areas:
      "title title"
      "security-title telegram-title"
      "security telegram"
      "profile-title telegram"
      "profile telegram"
      ". telegram";
    grid-template-rows: auto auto max-content max-content max-content 1fr;
    align-content: start;
    align-items: start;
    column-gap: clamp(18px, 2vw, 32px);
  }
  body[data-view="settings"] #app > h1 { grid-area: title; }
  body[data-view="settings"] #app > h1 + h2 { grid-area: security-title; }
  body[data-view="settings"] #app > h2:has(+ .telegram-settings) { grid-area: telegram-title; margin-top: 0; }
  body[data-view="settings"] #app > .profile-heading { grid-area: profile-title; }
  body[data-view="settings"] #app > .setting:has(#passwordForm) { grid-area: security; }
  body[data-view="settings"] #app > .telegram-settings { grid-area: telegram; }
  body[data-view="settings"] #app > .setting.profile { grid-area: profile; }
  body[data-view="settings"] #app > .setting { margin: 0; }
}
body[data-view="settings"] #app .setting button:is(.gold, .blue) {
  background: var(--settings-accent);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--settings-on-accent);
  font-weight: 650;
}
body[data-view="settings"] #app .setting button:is(.gold, .blue):enabled:hover {
  border-color: var(--settings-on-accent);
}
body[data-view="settings"] #app .setting button:is(.gold, .blue):disabled {
  background: var(--field);
  color: var(--muted);
  border-color: var(--settings-edge);
  opacity: 1;
}
body[data-view="settings"] #app .setting :is(button,input,select):focus-visible {
  outline: 2px solid var(--control-focus);
  outline-offset: 2px;
}
body[data-view="settings"] #app .telegram-settings {
  & > .notification-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--settings-edge);
    padding-bottom: 10px;
    margin-bottom: 10px;
    color: var(--ink);
    font-weight: 650;
  }
  & .notification-row { font-size: 13px; }
  & #preferences { padding: 0; }
  & #preferences .notification-row {
    display: block;
    margin: 0;
  }
  & .notification-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
    margin: 4px 0 10px;
  }
  & .notification-options label {
    display: grid;
    grid-template-columns: 17px minmax(0, 1fr);
    align-content: center;
    align-items: center;
    gap: 2px 8px;
    min-height: 30px;
    margin: 0;
    color: var(--ink);
    cursor: pointer;
  }
  & .notification-options label > span { margin: 0; line-height: 1.3; }
  & .notification-options small {
    grid-column: 2;
    margin: 0;
    color: var(--muted);
    line-height: 1.35;
  }
  & .notification-options input {
    width: 17px; height: 17px; min-height: 17px; margin: 0;
    border: 1px solid color-mix(in srgb, var(--ink) 48%, var(--surface));
    background: var(--field);
  }
  & .notification-options input:checked {
    background: var(--settings-accent);
    border-color: var(--settings-accent);
  }
  & .notification-options input:checked::after {
    color: var(--settings-on-accent);
    font-size: 13px; line-height: 15px; font-weight: 750;
  }
  & .notification-options label:has(input:disabled) { color: var(--muted); cursor: default; }
  & .notification-options input:disabled { opacity: .55; }
  & #preferences .notification-row:has(> #telegramGroupId) {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--settings-edge);
  }
  & label[for="telegramGroupId"] { display: block; margin: 0; }
  & #telegramGroupId { width: min(230px, 100%); }
  & #preferences .notification-row:last-child > div {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
  }
  & #preferences p.muted { margin: 0; color: var(--muted); font-size: 12px; }
}
@media (max-width: 760px) {
  body[data-view="settings"] #app .telegram-settings {
    & .notification-options { grid-template-columns: minmax(0, 1fr); }
    & .notification-options label { min-height: 44px; }
    & #preferences .notification-row:has(> #telegramGroupId) { flex-wrap: wrap; gap: 6px 12px; }
    & #telegramGroupId { flex: 1 1 152px; }
    & #preferences .notification-row:last-child > div { align-items: flex-start; flex-direction: column; gap: 6px; }
  }
}

/* Keep action colour independent of the colours used for transaction states. */
body {
  --brand-gold: #ffbd56;
  --accent-support: #303136;
  --control-gold: var(--brand-gold);
  --control-on-gold: #211b0a;
  --control-focus: var(--brand-gold);
  --control-switch-off: #444;
  --control-switch-thumb: #fff;
  --control-switch-thumb-on: #292412;
}
body.light {
  --control-switch-off: #b7c0ca;
  --control-switch-thumb-on: #fff;
}
:focus-visible { outline-color: var(--control-focus); }

/* Confirmation, editing and resource pickers all use the same portal dialog. */
button:is(.gold, .blue):not([data-stats-tab]),
dialog :is(button.blue, button.gold, button[data-save-device]) {
  background: var(--control-gold);
  border-color: transparent;
  color: var(--control-on-gold);
  font-weight: 650;
}
button:is(.gold, .blue):not([data-stats-tab]):enabled:hover,
dialog :is(button.blue, button.gold, button[data-save-device]):enabled:hover {
  background: var(--control-gold);
  border-color: var(--control-on-gold);
  color: var(--control-on-gold);
}
button:is(.gold, .blue):not([data-stats-tab]):disabled,
dialog :is(button.blue, button.gold, button[data-save-device]):disabled {
  background: var(--field);
  border-color: var(--line);
  color: var(--muted);
}
body .copy:hover { color: var(--brand-gold); }
body.light .copy:hover { background: var(--accent-support); }

body :is(#app,dialog,.pp-select-popover) :where(button, a, summary, input, select, textarea):focus-visible {
  outline: 2px solid var(--control-focus);
  outline-offset: 1px;
}
/* A single tight edge marks the insertion point without a second outer halo. */
body :is(#app,dialog,.pp-select-popover) :is(input:not([type=checkbox],[type=radio]),select,textarea):focus {
  border-color: var(--control-focus);
  outline: 1px solid var(--control-focus);
  outline-offset: -1px;
  box-shadow: none;
}
body :is(.pp-select, .pp-select-popover) { --pp-select-accent: var(--control-focus); }
body .pp-select:is(.is-open,:focus-within) .pp-select-button {
  border-color: var(--control-focus);
  outline: 1px solid var(--control-focus);
  outline-offset: -1px;
  box-shadow: none;
}
body .pp-select .pp-select-button[aria-invalid=true] { border-color: var(--danger); }
.pp-select-popover .pp-select-option[aria-selected=true] { font-weight: 650; }
.pp-select-popover .pp-select-option[aria-selected=true] .pp-select-check {
  background: var(--control-gold);
  border-color: transparent;
  color: var(--control-on-gold);
}
body :is(#app,dialog) input[type=checkbox] { accent-color: var(--control-gold); }
#app .trader-deal-filters .filter-check input:checked {
  background: var(--control-gold);
  border-color: var(--control-gold);
}
#app .trader-deal-filters .filter-check input:checked::after { color: var(--control-on-gold); }

dialog .switch input[type=checkbox] { background: var(--control-switch-off); }
dialog .switch input[type=checkbox]:checked { background: var(--control-gold); }
dialog .switch input[type=checkbox]::after { background: var(--control-switch-thumb); }
dialog .switch input[type=checkbox]:checked::after { background: var(--control-switch-thumb-on); }
body.light[data-view=requisites] #app .requisite-table input[data-toggle],
body.light #app .deal-tabs input#auto { background: var(--control-switch-off); }
body.light[data-view=requisites] #app .requisite-table input[data-toggle]:checked,
body.light #app .deal-tabs input#auto:checked { background: var(--control-gold); }
body.light[data-view=requisites] #app .requisite-table input[data-toggle]::after,
body.light #app .deal-tabs input#auto::after,
body.light dialog .switch input[type=checkbox]::after {
  background: var(--control-switch-thumb);
  box-shadow: 0 1px 3px rgb(26 33 42 / 25%);
}

/* The cabinet supplies the theme and gutters. Article content flows with the
   document; only the long list of contents has independent scrolling. */
#sidebar .nav-icon svg[data-doc-book] { fill: none; }
.doc-page {
  --doc-edge: color-mix(in srgb, var(--ink) 16%, var(--surface));
  --doc-quiet: color-mix(in srgb, var(--ink) 5%, var(--surface));
  --doc-accent-ink: var(--brand-gold);
  --doc-scroll-offset: 78px;
  min-width: 0;
  color: var(--ink);
}
body.light .doc-page { --doc-accent-ink: var(--ink); }
.doc-page *, .doc-page *::before, .doc-page *::after { box-sizing: border-box; }
.doc-page [hidden] { display: none; }
.doc-page h1 { margin: 0 0 14px; font-size: 24px; font-weight: 600; line-height: 1.2; }
.doc-library {
  display: inline-flex; gap: 3px; align-items: stretch; margin: 0 0 16px; max-width: 100%;
  padding: 3px; border: 1px solid var(--doc-edge); border-radius: 9px; background: var(--surface);
}
.doc-library button {
  min-height: 34px; padding: 6px 12px; border: 0; border-radius: 5px;
  background: transparent; color: var(--muted); font: inherit; line-height: 1.35;
}
.doc-library button:hover { color: var(--ink); background: var(--doc-quiet); }
.doc-library button[aria-pressed=true] {
  background: var(--doc-quiet); color: var(--doc-accent-ink); font-weight: 600;
  box-shadow: inset 0 -2px var(--brand-gold);
}
.doc-layout {
  display: grid; grid-template-columns: minmax(225px, 288px) minmax(0, 1fr);
  align-items: start; gap: clamp(14px, 2vw, 28px);
}
.doc-index, .doc-reader { min-width: 0; background: var(--surface); border: 1px solid var(--doc-edge); border-radius: 12px; }
.doc-index { position: sticky; top: var(--doc-scroll-offset); }
.doc-index > summary {
  display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 9px 14px;
  color: var(--ink); font-size: 14px; font-weight: 600; list-style: none; cursor: pointer;
}
.doc-index > summary::-webkit-details-marker { display:none; }
.doc-index > summary svg { color: var(--muted); flex: none; }
.doc-index > summary svg:last-child { margin-left:auto; }
.doc-index[open] > summary svg:last-child { transform: rotate(180deg); }
.doc-index-body { padding: 0 9px 9px; }
.doc-index-body .doc-search { position: relative; display: flex; align-items: center; margin: 0 3px 8px; }
.doc-search svg { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.doc-page .doc-search input {
  width: 100%; min-width: 0; height: 36px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--field); color: var(--ink); padding: 6px 8px 6px 34px; font-size: 13px;
}
.doc-page .doc-index-list {
  display: grid; gap: 2px; max-height: min(60vh, 680px); overflow-y: auto;
  scrollbar-width: thin; overscroll-behavior: contain;
}
.doc-page .doc-index-list button {
  min-width: 0; display: block; min-height: 34px; padding: 7px 9px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); text-align: left;
  font-size: 13px; font-weight: 400; line-height: 1.45; overflow-wrap: anywhere;
}
.doc-page .doc-index-list button:hover { background: var(--doc-quiet); }
.doc-page .doc-index-list button[aria-current] {
  background: var(--doc-quiet); color: var(--doc-accent-ink);
  box-shadow: inset 2px 0 var(--brand-gold); font-weight: 600;
}
.doc-hit-title,.doc-snippet { display: block; }
.doc-hit-title { font-weight: 600; }
.doc-snippet { margin-top: 3px; color: var(--muted); font-size: 12px; }
.doc-snippet mark { background: var(--brand-gold); color: var(--control-on-gold); }
.doc-search-status { margin: 6px 9px 8px; color: var(--muted); font-size: 12px; }
.doc-reader {
  --doc-padding: clamp(18px, 3.2vw, 46px);
  padding: 0 var(--doc-padding) var(--doc-padding);
}
.doc-reader-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px 20px; padding-block: 21px; border-bottom: 1px solid var(--doc-edge);
}
.doc-identity { min-width: 0; }
.doc-page .doc-reader h2 {
  margin: 0; padding: 0; font-size: clamp(20px,1.8vw,25px); font-weight: 600;
  line-height: 1.25; color: var(--ink); overflow-wrap: anywhere;
}
.doc-page .doc-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.doc-file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.doc-page .doc-file-actions a {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 6px 11px; border: 1px solid var(--doc-edge); border-radius: 6px;
  background: var(--surface); color: var(--ink); font-size: 13px; text-decoration: none; line-height: 1.2;
}
.doc-file-actions a svg { flex: none; }
.doc-page .doc-file-actions a:hover { background: var(--doc-quiet); }
.doc-page .doc-file-actions [data-doc-file="open"] {
  background: var(--brand-gold); border-color: transparent; color: var(--control-on-gold); font-weight: 600;
}
.doc-page .doc-file-actions [data-doc-file="open"]:hover { background: var(--brand-gold); text-decoration: underline; }
.doc-prose {
  max-width: 77ch; padding-top: clamp(17px,2.1vw,30px);
  font-size: clamp(15px,1.15vw,17px); line-height: 1.65;
  color: var(--ink); overflow-wrap: break-word;
}
.doc-chapter + .doc-chapter { margin-top: 32px; border-top: 1px solid var(--doc-edge); padding-top: 26px; }
.doc-prose :is(h3,h4,p,li,ul,figure,figcaption) { font-family: inherit; }
.doc-page .doc-prose h3 {
  margin: 0 0 14px; font-size: clamp(19px,1.55vw,23px); font-weight: 600;
  line-height: 1.32; color: var(--ink); text-wrap: pretty;
}
.doc-page .doc-prose h4 { margin: 21px 0 9px; font-size: 1.03em; font-weight: 600; line-height: 1.45; }
.doc-page .doc-prose p, .doc-page .doc-prose .doc-list { margin: 0 0 12px; font-size: inherit; line-height: inherit; }
.doc-page .doc-prose p { white-space: pre-line; }
.doc-prose .doc-label { margin-inline-end: .45em; font-weight: 600; }
.doc-prose .doc-list > .doc-label { display: block; margin-bottom: 4px; }
.doc-page .doc-prose ul { padding-inline-start: 1.35em; margin: 0 0 15px; list-style: disc; }
.doc-page .doc-prose li { margin: .25em 0; }
.doc-prose a { color: var(--doc-accent-ink); text-decoration: underline var(--brand-gold); text-underline-offset: .15em; overflow-wrap: anywhere; }
body.light .doc-prose a { text-decoration-thickness: 2px; }
.doc-prose figure { width: fit-content; max-width: 100%; margin: 16px 0 20px; }
.doc-prose figure img { display: block; width: auto; max-width: 100%; height: auto; border-radius: 5px; background: var(--doc-quiet); }
.doc-prose figcaption { margin-top: 6px; color: var(--muted); font-size: .85em; line-height: 1.45; }
.doc-prose :is([tabindex="-1"],.doc-chapter) { scroll-margin-block-start: var(--doc-scroll-offset); }
.doc-prose .doc-hit { box-shadow: -3px 0 var(--brand-gold); padding-inline-start: 9px; }
.doc-page :is(button,a,summary):focus-visible { outline: 2px solid var(--control-focus); outline-offset: -2px; }
.doc-prose [tabindex="-1"]:focus { outline: none; }

.doc-page .doc-search input::placeholder { color: var(--muted); opacity: 1; }

/* Preserve the cabinet's compact type scale and the PDF's hanging numbers. */
.doc-page[data-document="regulation"] .doc-reader { --doc-padding: clamp(16px, 2vw, 28px); }
.doc-page[data-document="regulation"] .doc-reader-head { padding-block: 16px; }
.doc-page[data-document="regulation"] .doc-reader h2 { font-size: 18px; line-height: 24px; }
.doc-page[data-document="regulation"] .doc-subtitle { margin-top: 3px; font-size: 12px; }
.doc-page[data-document="regulation"] .doc-prose {
  --doc-number-width: 2.85rem;
  --doc-number-gap: clamp(7px, 1vw, 12px);
  max-width: 76ch; padding-top: 18px;
  font-size: 14px; line-height: 21px;
}
.doc-page[data-document="regulation"] .doc-prose h3 {
  margin-bottom: 8px; font-size: 16px; line-height: 22px;
}
.doc-page[data-document="regulation"] .doc-prose h4 { margin: 14px 0 6px; }
.doc-page[data-document="regulation"] .doc-reader :is(h2,h3,h4) { color: var(--ink); }
.doc-page[data-document="regulation"] .doc-prose :is(p,.doc-list) { margin-bottom: 8px; }
.doc-page[data-document="regulation"] .doc-label { font-weight: 500; }
.doc-page[data-document="regulation"] :is(.doc-number,.doc-term-name,.doc-result > .doc-label,.doc-rates > .doc-label) {
  color: var(--doc-accent-ink); font-weight: 600;
}
/* On a light surface a short gold highlighter stroke keeps small type legible. */
body.light .doc-page[data-document="regulation"] :is(.doc-number,.doc-term-name,.doc-result > .doc-label,.doc-rates > .doc-label) {
  box-shadow: inset 0 -.22em var(--brand-gold);
  width: fit-content;
}
.doc-page[data-document="regulation"] :is(.doc-clause,.doc-numbered-heading) {
  display: grid;
  grid-template-columns: var(--doc-number-width) minmax(0, 1fr);
  column-gap: var(--doc-number-gap);
  align-items: baseline;
}
.doc-page[data-document="regulation"] .doc-number {
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.doc-page[data-document="regulation"] .doc-prose .doc-continuation {
  margin-inline-start: calc(var(--doc-number-width) + var(--doc-number-gap));
}
.doc-page[data-document="regulation"] .doc-prose .doc-term {
  padding-block: 8px; margin-block: 0;
}
.doc-page[data-document="regulation"] .doc-term + .doc-term { border-top: 1px solid var(--doc-edge); }
.doc-page[data-document="regulation"] .doc-result,
.doc-page[data-document="regulation"] .doc-rates {
  padding: 10px 14px; border-inline-start: 2px solid var(--brand-gold);
  background: var(--doc-quiet);
}
.doc-page[data-document="regulation"] .doc-prose li::marker { color: var(--brand-gold); }
.doc-page[data-document="regulation"] .doc-rates ul { margin-block-end: 0; }
.doc-page[data-document="regulation"] .doc-chapter + .doc-chapter { margin-top: 20px; padding-top: 16px; }
.doc-page[data-document="regulation"] .doc-prose a {
  color: var(--doc-accent-ink); text-underline-offset: 3px;
}
.doc-page[data-document="regulation"] .doc-prose a:is(:hover,:focus-visible) {
  text-decoration-thickness: 2px;
}
@media (max-width: 760px) {
  .doc-page { --doc-scroll-offset: 110px; }
  .doc-page h1 { font-size: 22px; margin-bottom: 10px; }
  .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .doc-library { margin-bottom: 10px; }
  .doc-library button { min-height: 44px; }
  .doc-index { position: static; }
  .doc-page .doc-index-list { max-height: 44vh; }
  .doc-page .doc-index-list button { min-height: 40px; }
  .doc-reader { --doc-padding: 16px; }
  .doc-reader-head { padding-block: 15px; }
  .doc-page .doc-file-actions a { min-height: 44px; }
  .doc-chapter + .doc-chapter { margin-top: 25px; padding-top: 19px; }
  .doc-prose { font-size: 16px; line-height: 1.6; }
  .doc-page[data-document="regulation"] .doc-prose { font-size: 15px; line-height: 23px; }
}

/* Live trader controls and content that extend the supplied compact layout. */
#navigation { position: sticky; top: 0; }
#navigation .account-wrap .header-account-email { display: block; }
#account-menu {
  position: fixed; inset: auto; margin: 0;
  background: var(--surface); color: var(--ink); border: 1px solid var(--compact-rule);
  border-radius: 9px; padding: 5px; min-width: 140px;
}
#sidebar nav { flex-wrap: wrap; column-gap: clamp(12px,2.4vw,36px); }
.home-wallet .wallet-value small { display: block; color: var(--muted); font-size: 13px; }
.home-wallet .wallet-value strong { overflow-wrap: anywhere; }
.home-wallet .wallet-actions { flex-wrap: wrap; }
.home-wallet .wallet-actions [data-deposit] {
  display: inline-flex; align-items: center; min-height: 42px; padding: 8px 14px;
  color: var(--control-on-gold); background: var(--brand-gold); border: 1px solid transparent; border-radius: 7px;
}
.home-balance .home-security { grid-template-columns: minmax(0,1fr); gap: 8px; }
.home-balance .home-rewards .trader-display-labels { display:flex; flex-wrap:wrap; gap:6px; }
.home-balance .term-chip { display:inline-flex; align-items:baseline; gap:6px; }
#app .home-today details.card { min-width:0; margin:0; padding:0 18px; border:0; background:transparent; }
#app .deal-line .bank-mark { border-radius:50%; overflow:hidden; }
#dialog.confirm-deal-dialog h2 { margin:0 0 16px; }
#dialog.confirm-deal-dialog .receipt-amount { font-size:26px; font-weight:650; line-height:1.2; margin-bottom:12px; }
#dialog.confirm-deal-dialog .receipt-bank { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
#dialog.confirm-deal-dialog .receipt-bank .bank-mark { width:28px; height:28px; }
#dialog.confirm-deal-dialog [type=submit] { background:var(--brand-gold); color:var(--control-on-gold); border-color:transparent; }
@media (max-width:760px) {
  #sidebar:not([hidden]) { display:none; }
  #sidebar.open:not([hidden]) {
    display:block; position:fixed; z-index:5; inset:60px auto auto var(--compact-gutter);
    width:min(292px,calc(100vw - 2 * var(--compact-gutter))); max-height:calc(100dvh - 106px);
    overflow:auto; padding:6px; border:1px solid var(--compact-rule); border-radius:12px;
  }
  #sidebar.open nav { flex-flow:column; align-items:stretch; gap:2px; }
  #sidebar.open nav a { min-height:44px; padding:0 12px; }
  #app .trader-filter-panel:not(.is-open) > .filters { display:none; }
  #app .wallet-actions { width:100%; margin:0; }
  #app .home-today { grid-template-columns:minmax(0,1fr); gap:10px; }
}
@media (max-width:660px) {
  #sidebar.open:not([hidden]) { top:89px; }
  .home-wallet .wallet-actions button { min-height:44px; }
}
@media (min-width:1151px) {
  #app .deal-line { grid-template-areas:none; }
  #app .deal-line > div { grid-area:auto; min-width:0; }
  #app .deal-line :is(.deal-rate,.deal-group)::before { content:none; }
  #app .deal-list-heading { display:grid; }
}
@media (max-width:1150px) {
  body:is([data-view="home"],[data-view="deals"],[data-view="disputes"]) #app .deal-list-heading { display:none; }
  body:is([data-view="home"],[data-view="deals"],[data-view="disputes"]) #app .deal-line {
    min-width:0; display:grid; grid-template-columns:repeat(4,minmax(0,1fr));
    grid-template-areas:"identity state amount actions" "rate device group requisite";
    align-items:center; gap:8px 12px; padding:12px;
  }
  #app .deal-line > div { min-width:0; overflow-wrap:anywhere; }
  #app .deal-line .deal-identity { grid-area:identity; }
  #app .deal-line .deal-state { grid-area:state; }
  #app .deal-line .deal-rate { grid-area:rate; }
  #app .deal-line .deal-device { grid-area:device; }
  #app .deal-line .deal-group { grid-area:group; }
  #app .deal-line .deal-amount { grid-area:amount; }
  #app .deal-line .deal-requisite { grid-area:requisite; }
  #app .deal-line .deal-buttons { grid-area:actions; justify-content:flex-end; }
  #app .deal-line .deal-buttons button { min-width:44px; min-height:44px; }
}
@media (max-width:760px) {
  body:is([data-view="home"],[data-view="deals"],[data-view="disputes"]) #app .deal-line {
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-areas:"identity state" "rate amount" "device group" "requisite actions";
  }
}
@media (max-width:465px) {
  body:is([data-view="home"],[data-view="deals"],[data-view="disputes"]) #app .deal-line {
    grid-template-areas:"identity state" "rate amount" "device group" "requisite requisite" "actions actions";
  }
}
@media (max-width:760px) {
  #app .home-today .daily-card + .daily-card { border:0; }
  .home-wallet .wallet-number { white-space:normal; overflow-wrap:anywhere; }
}

/* A full-width header with independent content gutters on larger screens. */
@media (min-width:761px) {
  body:not(.logged-out) #navigation { width:100%; max-width:none; padding-inline:clamp(16px,1.5vw,36px); }
  #navigation .topbar { width:100%; max-width:none; margin:0; }
  #navigation .topbar .row { margin-inline-start:auto; }
}
#navigation #menu { height:36px; border:1px solid var(--compact-rule); border-radius:8px; padding:0 10px; }
#navigation .header-account-email { margin:0; font-size:13px; font-weight:600; line-height:1.2; }
#navigation .account-wrap { padding-left:0; border:0; }
#navigation .top-rate { align-items:center; gap:5px; }
#navigation .top-rate small:not([hidden]) { position:static; width:auto; height:auto; clip-path:none; color:var(--muted); font-size:10px; }
body:not(.logged-out),body.logged-out { font-weight:500; }
#app :is(label,th,summary,button),#sidebar nav a,#navigation .switch { font-weight:600; }
#app :is(.deal-id,.deal-amount strong,.wallet-value strong,.doc-page h2) { font-weight:700; }
#app .deal-line .deal-group::before { content:attr(data-label); }
@media (min-width:1151px) { #app .deal-line .deal-group::before { content:none; } }
body.logged-out #app { min-height:100dvh; width:100%; max-width:none; margin:0; padding:24px 16px; display:grid; place-items:center; background:var(--canvas); }
#app .trader-signin { width:min(100%,400px); min-width:0; margin:0; padding:clamp(22px,4vw,36px); background:var(--surface); border:1px solid var(--compact-rule); border-radius:16px; box-shadow:0 8px 32px rgb(0 0 0 / 10%); }
.trader-signin .signin-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:28px; }
.trader-signin .brand { display:flex; align-items:center; gap:5px; }
.trader-signin .brand b { font-size:32px; line-height:1; }
.trader-signin .brand strong { font-size:19px; line-height:1; }
.trader-signin h1 { font-size:24px; font-weight:700; margin:0 0 22px; color:var(--ink); }
#app .trader-signin form { display:grid; gap:16px; padding:0; border:0; margin:0; background:transparent; }
#app .trader-signin label { display:grid; gap:6px; margin:0; }
#app .trader-signin input { width:100%; min-height:44px; margin:0; font:inherit; border:1px solid var(--line); background:var(--field); color:var(--ink); border-radius:7px; padding:9px 12px; }
#app .trader-signin input:focus-visible { outline:2px solid var(--brand-gold); outline-offset:1px; }
#app .trader-signin .signin-submit,body.logged-out .login-challenge button[type=submit] { min-height:44px; border-radius:7px; background:var(--brand-gold); color:var(--control-on-gold); font-weight:700; }
#app .trader-signin .signin-note { font-size:13px; line-height:1.5; color:var(--muted); margin:18px 0 0; }
.trader-signin form .error:empty { display:none; }
.trader-signin [data-language-picker] { float:none!important; margin:0!important; border-color:var(--compact-rule)!important; }
.receipt-actual { margin-top:16px; }
@media(max-width:660px) {
 #navigation #menu { max-width:min(44vw,28ch); padding-inline:6px; }
 #navigation .top-rate { flex-wrap:wrap; row-gap:0; }
 #navigation .top-rate small { flex-basis:100%; }
}

/* Keep the dispute reason beside the status and directly before the quote. */
.deal-state.has-dispute-info {
 display:flex; flex-wrap:wrap; align-items:center; gap:4px 12px;
}
.deal-state.has-dispute-info > div { min-width:0; max-width:100%; }
.deal-dispute-info { display:grid; gap:2px; overflow-wrap:anywhere; }
.deal-dispute-info small b { font-weight:600; font-variant-numeric:tabular-nums; }
@media (max-width:760px) {
 .deal-state.has-dispute-info { flex-direction:column; align-items:flex-end; text-align:right; }
}
