:root {
  --pending-candle: #b7ebca;
  --deposit-pending: #b7ebca;
  --deposit-confirmed: #22c55e;
  --buyback-pending: #ebb7b7;
  --buyback-confirmed: #ef4444;
  --stack-bg: #0f172a;
  --panel-bg: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #020617;
  color: var(--text);
  min-height: 100vh;
}

a {
  color: #38bdf8;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.balances {
  display: flex;
  gap: 1.25rem;
  flex: 1;
  flex-wrap: wrap;
}

.balances .rate {
  color: var(--muted);
}

.rate-spread-hint {
  font-size: 0.85em;
  color: #86efac;
}

.balances-dropdown-wrap {
  position: relative;
}

.balances-trigger {
  cursor: default;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.balances-caret {
  font-size: 0.7rem;
  color: var(--muted);
}

.balances-dropdown-wrap:hover .balances-popover,
.balances-dropdown-wrap:focus-within .balances-popover {
  display: block;
}

.balances-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  min-width: 220px;
  margin-top: 0.35rem;
  padding: 0.5rem 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.balances-popover-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.balances-popover-row.active {
  background: rgba(51, 65, 85, 0.5);
}

.balances-popover-usdt {
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  padding-top: 0.5rem;
}

.qr-manual-rate {
  margin: 0.75rem 0;
}

.qr-manual-rate input {
  width: 100%;
}

.pending-rate-label {
  display: block;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.pending-rate-label input {
  margin-left: 0.35rem;
  width: 7rem;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-email {
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
}

.product-view {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  flex: 1;
}

@media (max-width: 900px) {
  .product-view {
    grid-template-columns: 1fr;
  }
}

.stack-panel {
  padding: 1rem;
  background: var(--stack-bg);
}

.stack-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-height: 400px;
}

.stack-col h2,
.stack-col h3 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.stack-col-left h2 { color: var(--deposit-confirmed); }
.stack-col-right h2 { color: var(--buyback-confirmed); }

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stack-row {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.stack-row:hover {
  border-color: #475569;
  background: rgba(30, 41, 59, 0.8);
}

.stack-row.expanded {
  border-color: #64748b;
  background: rgba(30, 41, 59, 0.95);
}

.stack-row-main {
  pointer-events: none;
}

.stack-row-details {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.5;
  cursor: default;
}

.stack-row-details.hidden {
  display: none;
}

.stack-row-details.loading {
  color: var(--muted);
}

.deal-details dl {
  margin: 0;
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.2rem 0.75rem;
}

.deal-details dt {
  color: var(--muted);
  margin: 0;
}

.deal-details dd {
  margin: 0;
  word-break: break-word;
}

.deal-details h4 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.deal-details h4:first-child {
  margin-top: 0;
}

.deal-details ul {
  margin: 0;
  padding-left: 1.1rem;
}

.deal-details li {
  margin-bottom: 0.25rem;
}

.deal-id-short {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

.history-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.history-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.history-toggle-icon {
  color: var(--muted);
  font-size: 0.75rem;
}

.history-toggle[aria-expanded="true"] .history-toggle-icon {
  transform: rotate(180deg);
}

.history-hint {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.history-panel.hidden {
  display: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  font-size: 0.85rem;
}

.history-item:hover {
  border-color: #475569;
}

.history-item.expanded {
  flex-direction: column;
  align-items: stretch;
}

.history-item .badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-deposit { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-buyback { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-cancelled { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-pending { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }
.badge-confirmed { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }
.badge-closed { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }

/* generic badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 18px; }
.badge-warn { background: rgba(251, 191, 36, 0.18); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.35); }

.history-item-meta {
  flex: 1;
  min-width: 140px;
}

.history-item-details {
  width: 100%;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.history-item-details.hidden {
  display: none;
}

.rates-page {
  padding: 1.25rem 1.5rem;
  max-width: 1200px;
}

.rates-header-meta {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.rates-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.rates-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.parser-card-calc {
  border-color: #475569;
}

.rates-db-section {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.rates-db-section h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.rates-intro {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.markets-overview h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.markets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.market-chip {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.5);
  min-width: 140px;
}

.market-chip .market-pair {
  display: block;
  font-weight: 600;
}

.market-chip .market-code {
  font-size: 0.7rem;
  color: var(--muted);
}

.market-chip .market-note {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.market-live { border-color: #22c55e; }
.market-parser { border-color: #38bdf8; }
.market-planned { border-color: #64748b; opacity: 0.85; }

.rates-grid-title {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.qr-rub-section {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid #475569;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(15, 23, 42, 0.6));
}

.qr-rub-section-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.qr-rub-section-header .hint {
  margin: 0 0 0.75rem;
}

.qr-rub-card {
  border-color: #22c55e;
}

.qr-rub-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  padding: 0.75rem 1rem 0;
}

.qr-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.qr-metric-highlight .qr-metric-value {
  color: #86efac;
}

.qr-metric-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.qr-metric-value {
  font-size: 1.5rem;
  line-height: 1.2;
}

.qr-metric-unit {
  font-size: 0.8rem;
  color: var(--muted);
}

.parsers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.parser-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
}

.parser-card header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.parser-card header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.parser-card-body {
  padding: 0.75rem 1rem;
  flex: 1;
  font-size: 0.85rem;
}

.parser-card footer {
  padding: 0.5rem 1rem 0.75rem;
}

.rate-hero {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.rate-json {
  margin: 0;
  padding: 0.5rem;
  background: #0f172a;
  border-radius: 6px;
  font-size: 0.75rem;
  overflow-x: auto;
  max-height: 220px;
}

.rate-meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.rate-details summary {
  cursor: pointer;
  color: var(--muted);
  margin-top: 0.5rem;
}

.rate-details p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.stack-row-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.stack-bar-wrap {
  height: 10px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
}

.stack-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s, background 0.3s;
}

.stack-bar.deposit.stack-bar-gradient {
  /* цвет задаётся inline (градиент по fill_ratio) */
}

.stack-bar.deposit:not(.stack-bar-gradient).pending {
  background: var(--deposit-pending);
}

.stack-bar.deposit:not(.stack-bar-gradient).confirmed {
  background: var(--deposit-confirmed);
}
.stack-bar.buyback.pending { background: var(--buyback-pending); }
.stack-bar.buyback.confirmed { background: var(--buyback-confirmed); }

.order-panel {
  background: var(--panel-bg);
  padding: 1.25rem;
  border-left: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

.tab.active {
  background: #334155;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f172a;
  color: var(--text);
  font-size: 1rem;
}

.usdt-preview {
  color: var(--muted);
  font-size: 0.9rem;
}

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
}

.btn-primary {
  background: var(--deposit-confirmed);
  color: #052e16;
  font-weight: 600;
}

.btn-danger {
  background: var(--buyback-confirmed);
  color: #fff;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 0;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  margin-top: 0;
  margin-right: 0.35rem;
}

.btn-confirm {
  background: var(--deposit-confirmed);
  color: #052e16;
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--buyback-confirmed);
  color: var(--buyback-confirmed);
}

.form-error {
  color: #f87171;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.form-error.hidden {
  display: none;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2rem;
  background: var(--panel-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.login-card h1 {
  margin: 0;
}

.subtitle {
  color: var(--muted);
  margin: 0.25rem 0 1.5rem;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

.stack-reconcile {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  line-height: 1.4;
}

.alert {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.manager-layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
}

.product-mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.product-mode-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.product-mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.product-view.hidden,
.workspace-panel.hidden {
  display: none;
}

.manager-stack-layout {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1000px) {
  .manager-stack-layout {
    grid-template-columns: 1fr;
  }
}

.queue-filters {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.queue-filter {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.queue-filter.active {
  color: var(--text);
  border-color: var(--accent);
}

.spend-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.spend-card {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.spend-card[role="button"] {
  cursor: pointer;
}

.spend-card:hover {
  border-color: #64748b;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.spend-card-selected {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 18px rgba(0, 0, 0, 0.3);
}

.spend-card--pending {
  border-left: 4px solid #fbbf24;
}

.spend-card--confirmed {
  border-left: 4px solid #22c55e;
}

.spend-card--failed,
.spend-card--cancelled {
  border-left: 4px solid #94a3b8;
  opacity: 0.88;
}

.spend-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.spend-status-pill {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.spend-status-pill--pending {
  background: rgba(251, 191, 36, 0.22);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.spend-status-pill--confirmed {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.spend-status-pill--failed,
.spend-status-pill--cancelled {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.spend-card-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.spend-card-amount {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
}

.spend-card-fiat {
  font-size: 1.05rem;
  font-weight: 600;
}

.spend-card-usdt {
  font-size: 0.9rem;
  color: #7dd3fc;
}

.spend-card-requisites {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.35;
}

.spend-card:hover .spend-card-requisites {
  color: var(--text);
}

.spend-card.expanded {
  cursor: default;
}

.spend-row-details {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.spend-row-details.hidden {
  display: none;
}

.spend-row-details.loading {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.spend-select-btn {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.spend-select-btn:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.btn-spend-confirm-main {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  transition: filter 0.15s, transform 0.12s, box-shadow 0.15s;
}

.btn-spend-confirm-main:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35);
}

.confirm-facts {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
}

.confirm-facts-dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.85rem;
  font-size: 0.85rem;
}

.confirm-facts-dl dt {
  margin: 0;
  color: var(--text-muted);
}

.confirm-facts-dl dd {
  margin: 0;
  font-weight: 500;
  white-space: pre-wrap;
}

.deal-plaque-client {
  font-size: 0.9rem;
  margin-right: auto;
}

.deal-plaque-type {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.deal-plaque-list .spend-card-head {
  flex-wrap: wrap;
}

.deal-details-actions {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}

.workspace-tab-btn {
  position: relative;
}

.deposit-requisite-card {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px solid #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.deposit-requisite-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.deposit-requisite-text {
  margin: 0.5rem 0;
  padding: 0.65rem;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.deposit-requisite-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.payment-req-details {
  white-space: pre-wrap;
}

.requisites-page {
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.requisites-form-panel {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 480px;
}

.requisites-form-panel label {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.requisites-form-panel input,
.requisites-form-panel select,
.requisites-form-panel textarea {
  width: 100%;
  margin-top: 0.25rem;
}

.requisites-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.requisites-toolbar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.req-details-cell {
  max-width: 280px;
  white-space: pre-wrap;
  font-size: 0.8rem;
}

.req-row-inactive {
  opacity: 0.55;
}

.req-logs-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
}

.req-log-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.requisites-logs-section {
  margin-top: 2rem;
}

.deposit-requisite-actions .btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.deposit-requisite-actions .btn:active {
  transform: translateY(0);
}

.deposit-payment-method-wrap {
  margin: 0.75rem 0;
}

.deposit-payment-method-wrap select {
  width: 100%;
  margin-top: 0.25rem;
}

.deposit-expires-hint {
  color: #fbbf24;
}

.stack-expires-hint {
  font-size: 0.75rem;
  color: #fbbf24;
}

.manager-client-balances {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.35);
}

.manager-client-balances h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.manager-balances-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.manager-balances-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.82rem;
}

.manager-balances-list li span {
  color: var(--text-muted);
}

.manager-balances-usdt {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.stack-col-hint {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
}

.requisites-ttl-section {
  margin: 2rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 640px;
}

.requisites-ttl-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-top: 0.5rem;
}

.requisites-ttl-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.requisites-ttl-form input,
.requisites-ttl-form select {
  margin-top: 0.25rem;
  min-width: 5rem;
}

.qr-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.qr-create-panel {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.35);
}

.qr-create-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.qr-create-result {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
}

.qr-toolbar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.qr-toolbar label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.qr-toolbar input,
.qr-toolbar select {
  margin-top: 0.25rem;
}

.qr-diagnostic-output {
  margin-top: 0.75rem;
  padding: 0.65rem;
  font-size: 0.75rem;
  max-height: 220px;
  overflow: auto;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.workspace-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
  box-shadow: 0 0 0 2px var(--stack-bg, #0f172a);
  pointer-events: none;
}

.spend-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.spend-attachments--compact {
  margin-top: 0.4rem;
}

.spend-att-thumb {
  display: block;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.12s, box-shadow 0.12s;
}

.spend-att-thumb:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.spend-att-thumb img {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  background: #0f172a;
}

.spend-attachments--compact .spend-att-thumb img {
  width: 56px;
  height: 56px;
}

.spend-att-file {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: #7dd3fc;
  text-decoration: none;
}

.spend-att-file:hover {
  background: rgba(56, 189, 248, 0.1);
}

.deal-details .spend-att-thumb img {
  width: 120px;
  height: 120px;
}

.spend-att-thumb img.img-error {
  display: none;
}

.spend-att-thumb.img-error-fallback::after {
  content: "нет превью";
  font-size: 0.75rem;
  color: var(--text-muted);
}

.attachment-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-lightbox.hidden {
  display: none;
}

.attachment-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.attachment-lightbox-inner {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 900px);
  max-height: 92vh;
  padding: 1rem;
  background: var(--panel-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.attachment-lightbox-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 6px;
}

.attachment-lightbox-close {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.attachment-lightbox-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  padding-right: 1.5rem;
  word-break: break-all;
}

.attachment-lightbox-open {
  font-size: 0.85rem;
  color: #7dd3fc;
}

.pending-item .type-spend {
  color: #7eb8eb;
}

.workspace-panel {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

.pending-panel {
  padding: 1rem;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.pending-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--stack-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.pending-item .type-deposit { color: var(--deposit-confirmed); }
.pending-item .type-buyback { color: var(--buyback-pending); }

.pending-actions {
  margin-top: 0.5rem;
}

.client-stack {
  padding: 1rem;
  background: var(--stack-bg);
}

.client-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.client-select {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.client-settings-panel {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.6);
}

.client-settings-panel.hidden {
  display: none;
}

.client-settings-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.settings-markets {
  display: grid;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.market-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.market-switch {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.market-switch.active {
  background: #334155;
  border-color: #64748b;
}

.market-switch:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-market-row {
  display: grid;
  grid-template-columns: 1fr auto 100px;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.5);
}

.settings-market-row.inactive {
  opacity: 0.45;
}

.settings-market-row .market-label {
  font-size: 0.85rem;
}

.settings-market-row .market-enabled {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.settings-market-row input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.admin-page {
  padding: 1.5rem;
  max-width: 900px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.create-user form {
  max-width: 400px;
}

.empty-stack {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 0;
}

/* Внутренний P&L / факт USDT */
.finance-page {
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.finance-intro {
  margin-bottom: 1rem;
}

.finance-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.finance-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.finance-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.finance-table-wrap {
  overflow-x: auto;
}

.finance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.finance-table th,
.finance-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.finance-table .pnl-positive {
  color: #4ade80;
}

.finance-table .pnl-negative {
  color: #f87171;
}

.settle-dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--panel-bg);
  color: var(--text);
  max-width: 420px;
}

.settle-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.settle-dialog-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.settlement-layout .settlement-form-panel {
  min-width: 280px;
}

.settlement-form-panel label {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
