:root,
[data-theme="dark"] {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface2: #1a2236;
  --surface3: #222938;
  --border: #243049;
  --text: #eef1f7;
  --muted: #8b95a8;
  --accent: #06B6D4;
  --accent-dim: rgba(6, 182, 212, .12);
  --accent-hover: #22d3ee;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --purple: #1E3A8A;
  --radius: 14px;
  --sidebar-w: 220px;
  --shadow: 0 24px 48px rgba(0, 0, 0, .35);
  --login-glow: rgba(6, 182, 212, .18);
  --topbar-bg: rgba(17, 24, 39, .85);
}

[data-theme="light"] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface2: #f3f5f9;
  --surface3: #e8ecf2;
  --border: #d5dbe6;
  --text: #1a2233;
  --muted: #5c677a;
  --accent: #0891b2;
  --accent-dim: rgba(8, 145, 178, .1);
  --accent-hover: #06B6D4;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --purple: #1E3A8A;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
  --login-glow: rgba(6, 182, 212, .12);
  --topbar-bg: rgba(255, 255, 255, .92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--login-glow) 0%, transparent 60%),
    var(--bg);
}

.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-theme-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
}

.login-logo {
  width: 52px;
  height: 52px;
  background: var(--accent-dim);
  border: 1px solid rgba(6, 182, 212, .3);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

.logo { font-size: 1.4rem; text-align: center; margin-bottom: .25rem; font-weight: 700; }
.subtitle { text-align: center; color: var(--muted); margin-bottom: 2rem; font-size: .9rem; }

.twofa-hint { color: var(--muted); font-size: .82rem; text-align: center; margin: 0 0 1rem; line-height: 1.45; }
.twofa-qr {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto 1rem;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}
.twofa-secret {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  margin-bottom: 1rem;
  font-size: .78rem;
  color: var(--muted);
}
.twofa-secret code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1px;
  color: var(--text, #e6e6e6);
  background: var(--surface2);
  padding: .4rem .6rem;
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
}
#twofa-code {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: .5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

label { display: block; font-size: .8rem; color: var(--muted); margin: 1rem 0 .35rem; font-weight: 500; }
input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1rem;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--accent); }

.btn {
  border: none;
  border-radius: 10px;
  padding: .65rem 1.1rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #052e1a; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface2); }
.btn.success { background: var(--success); color: #052e16; }
.btn.danger { background: var(--danger); color: white; }
.btn.sm { padding: .45rem .85rem; font-size: .82rem; }
#login-form .btn.primary { width: 100%; margin-top: 1.5rem; }

.error { color: var(--danger); font-size: .85rem; margin-top: .75rem; }
.muted { color: var(--muted); font-size: .9rem; }

/* App layout */
#app-screen {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem .85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .35rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-dim);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.brand-title { font-weight: 700; font-size: .95rem; }
.brand-sub { font-size: .72rem; color: var(--muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: .65rem .85rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { font-size: 1rem; }

.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--border); }
.uid-badge {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: .72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: .35rem .55rem;
  border-radius: 8px;
  color: var(--accent);
  word-break: break-all;
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.15rem; font-weight: 600; }
.topbar-left { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.app-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.page-subtitle {
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
}
.page-subtitle::before {
  content: '·';
  margin-right: .75rem;
  color: var(--border);
}
.topbar-right { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
#refresh-btn { font-size: 1.1rem; line-height: 1; padding: .5rem .7rem; }

.balance-box {
  background: var(--accent-dim);
  border: 1px solid rgba(16, 185, 129, .3);
  border-radius: 12px;
  padding: .5rem .9rem;
  text-align: right;
  line-height: 1.25;
}
.balance-label {
  display: block;
  font-size: .65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.balance-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}
.balance-rate {
  display: block;
  font-size: .7rem;
  color: var(--muted);
}

.hint-banner {
  margin: 1rem 1.5rem 0;
  padding: .75rem 1rem;
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .3);
  border-radius: 10px;
  font-size: .88rem;
}
.hint-banner code { color: var(--warning); font-family: ui-monospace, monospace; }

.content-section { flex: 1; }

.tabs {
  display: flex;
  gap: .5rem;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
}
.tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
}
.tab:hover { border-color: rgba(16, 185, 129, .4); color: var(--text); }
.tab.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.badge {
  display: inline-block;
  min-width: 1.25rem;
  text-align: center;
  background: var(--border);
  border-radius: 999px;
  font-size: .72rem;
  padding: 0 .35rem;
  margin-left: .25rem;
}
.tab.active .badge { background: var(--accent); color: #fff; }

.theme-toggle {
  min-width: 2.5rem;
  padding: .5rem .65rem;
  font-size: 1rem;
  line-height: 1;
}

.requests-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.5rem .75rem;
  flex-wrap: wrap;
}

.req-search {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .9rem;
  color: var(--text);
  font-size: .9rem;
  outline: none;
}

.req-search:focus { border-color: var(--accent); }

.search-hint {
  font-size: .8rem;
  color: var(--muted);
}

.requests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  padding: 0 1.5rem 2rem;
}

.req-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color .2s, box-shadow .2s;
}
.req-card:hover { box-shadow: var(--shadow); }
.req-card.urgency-warn { border-color: var(--warning); }
.req-card.urgency-critical { border-color: var(--danger); animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .3); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, .1); }
}

.req-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.req-uid { font-family: ui-monospace, monospace; font-weight: 600; color: var(--accent); font-size: .88rem; }
.status-pill {
  font-size: .7rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--surface2);
  white-space: nowrap;
  font-weight: 500;
}
.status-pill.check { background: rgba(99, 102, 241, .2); color: var(--purple); }
.status-pill.rek { background: rgba(245, 158, 11, .2); color: var(--warning); }

.req-text { font-size: .93rem; line-height: 1.45; }
.req-meta { font-size: .8rem; color: var(--muted); }
.extension-info { color: var(--accent); font-size: .82rem; }
.timer {
  font-size: .85rem;
  color: var(--warning);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.timer.critical { color: var(--danger); }
.partner-info {
  font-size: .82rem;
  background: var(--surface2);
  border-radius: 10px;
  padding: .6rem .75rem;
  line-height: 1.5;
}
.partner-info b { color: var(--text); }

.req-requisites {
  font-size: .82rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .65rem .75rem;
  line-height: 1.55;
}
.req-requisites-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: .45rem;
}
.req-requisite-line {
  margin-bottom: .2rem;
}
.req-requisite-line:last-child { margin-bottom: 0; }
.req-req-label {
  display: inline-block;
  min-width: 4.5rem;
  color: var(--muted);
  font-size: .78rem;
}
.req-requisites code {
  font-family: ui-monospace, monospace;
  font-size: .85rem;
  color: var(--text);
}

.req-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 3rem;
}
.empty-state.sm { padding: 1.5rem; font-size: .88rem; }

/* Wallet */
.hint-banner.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
html[data-theme="light"] .hint-banner.error-banner {
  color: #b91c1c;
}
.hint-banner.info-banner {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--text);
}

.wallet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.wallet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.wallet-main {
  background: linear-gradient(135deg, rgba(16, 185, 129, .08) 0%, var(--surface) 60%);
  border-color: rgba(16, 185, 129, .25);
}
.wallet-card-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: .35rem;
}
.wallet-big {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: .5rem;
}
.wallet-notice {
  font-size: .82rem;
  color: var(--warning);
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.wallet-slot-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.shift-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.shift-status { font-weight: 600; color: var(--text); }
.shift-actions { display: flex; gap: 0.5rem; }
.wallet-addr-label {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.wallet-address {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .65rem .85rem;
  word-break: break-all;
  color: var(--text);
  line-height: 1.4;
}
.payout-btn { width: 100%; padding: .85rem; font-size: .95rem; }

.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.stat-label {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .35rem;
  font-weight: 500;
}
.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
}
.stat-value.accent { color: var(--accent); }

.wallet-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0 1.5rem 2rem;
}
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.panel-card h2 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}
.panel-card-wide {
  grid-column: 1 / -1;
}
.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.inline-form input {
  flex: 1;
  min-width: 160px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
}
.htx-trader-form input { min-width: 200px; }

.history-table-wrap { overflow-x: auto; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.history-table th {
  text-align: left;
  padding: .5rem .65rem;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.history-table td {
  padding: .6rem .65rem;
  border-bottom: 1px solid rgba(45, 53, 72, .5);
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table .mono { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--accent); }
.history-table .usdt { color: var(--accent); font-weight: 600; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 560px; }
.modal-card h2 { margin-bottom: 1rem; font-size: 1.1rem; }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }

.check-preview {
  min-height: 120px;
  background: var(--surface2);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 1rem;
}
.check-preview img { max-width: 100%; max-height: 400px; object-fit: contain; align-self: center; }
.check-pdf-frame {
  width: 100%;
  min-height: 420px;
  border: none;
  background: #fff;
}
.check-pdf-link {
  display: block;
  text-align: center;
  padding: .65rem;
  font-size: .85rem;
  color: var(--accent);
}
.check-info { font-size: .88rem; line-height: 1.5; color: var(--muted); }

.bank-combobox { position: relative; }
.bank-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.bank-list-item {
  padding: .55rem .85rem;
  font-size: .88rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.bank-list-item:last-child { border-bottom: none; }
.bank-list-item:hover { background: var(--accent-dim); color: var(--accent); }
.bank-list-empty {
  padding: .75rem;
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
}

.cards-intro { margin-bottom: 1rem; }
#cards-section .panel-card-wide,
#cards-section .cards-list {
  margin-left: 1.5rem;
  margin-right: 1.5rem;
}
.card-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem 1rem;
  align-items: end;
}
.form-field label {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .35rem;
}
.form-field input {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.form-field-action { display: flex; align-items: flex-end; }
.cards-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.card-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.card-item-title { font-weight: 600; font-size: 1.05rem; }
.card-item-sub { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.card-limits { margin-bottom: 1rem; }
.limit-row {
  display: flex;
  justify-content: space-between;
  font-size: .88rem;
  margin-bottom: .35rem;
}
.limit-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: .75rem 0 .35rem;
}
.limit-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  border-radius: 999px;
  transition: width .3s ease;
}
.limit-bar.ok .limit-bar-fill { background: #22c55e; }
.limit-bar.warn .limit-bar-fill { background: #eab308; }
.limit-bar.danger .limit-bar-fill { background: #ef4444; }
.topbar-online {
  flex-direction: row;
  align-items: center;
  gap: .45rem;
  padding: .15rem .35rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.topbar-online .toggle-slider { flex-shrink: 0; }
.topbar-online-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  min-width: 4.5rem;
}
.topbar-online input:not(:checked) ~ .topbar-online-label { color: var(--muted); }
.modal-actions-stack {
  flex-direction: column;
  align-items: stretch;
}
.modal-actions-stack .btn { width: 100%; }
  padding: .45rem .65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: .85rem;
}
.limit-hint { font-size: .78rem; color: var(--muted); }
.card-active-reqs h3 {
  font-size: .85rem;
  color: var(--muted);
  margin: 0 0 .5rem;
  font-weight: 500;
}
.card-item-actions { margin-top: .75rem; text-align: right; }
.toggle-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input { display: none; }
.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background .2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(20px);
}
.toggle-label { font-size: .72rem; color: var(--muted); }

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  padding: .85rem 1rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0;
  transform: translateX(1rem);
  transition: opacity .25s, transform .25s;
  pointer-events: auto;
}
.toast.show {
  opacity: 1;
  transform: translateX(0);
}
.toast-title { font-weight: 600; font-size: .95rem; margin-bottom: .2rem; }
.toast-msg { font-size: .85rem; color: var(--muted); }
.toast-success { border-left: 4px solid #22c55e; }
.toast-success .toast-title { color: #22c55e; }
.toast-slice { border-left: 4px solid #ef4444; }
.toast-slice .toast-title { color: #ef4444; }
.toast-problem { border-left: 4px solid #f59e0b; }
.toast-problem .toast-title { color: #f59e0b; }

@media (max-width: 900px) {
  .wallet-grid,
  .wallet-panels { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .content-section .panel-card-wide,
  #cards-section .panel-card-wide,
  #cards-section .cards-list { margin-left: 1rem; margin-right: 1rem; }
}

@media (max-width: 680px) {
  #app-screen { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    padding: .5rem .65rem;
    gap: .35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    gap: .25rem;
    min-width: 0;
  }
  .nav-item {
    flex-shrink: 0;
    font-size: .78rem;
    padding: .55rem .7rem;
    white-space: nowrap;
  }
  .sidebar-footer {
    border-top: none;
    padding-top: 0;
    flex-shrink: 0;
  }
  .uid-badge { font-size: .65rem; max-width: 88px; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: .65rem;
    padding: .75rem 1rem;
  }
  .topbar-left { gap: .35rem; }
  .app-brand { font-size: .95rem; }
  .page-subtitle { font-size: .82rem; }
  .page-subtitle::before { display: none; }
  .topbar-right {
    justify-content: space-between;
    gap: .5rem;
  }
  .balance-box { flex: 1; text-align: left; }

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: .65rem 1rem;
    gap: .4rem;
    -webkit-overflow-scrolling: touch;
  }
  .tab { flex-shrink: 0; padding: .55rem .85rem; font-size: .8rem; }

  .requests-toolbar { padding: 0 1rem .65rem; }
  .req-search { max-width: none; min-width: 0; width: 100%; }
  .requests-grid { grid-template-columns: 1fr; padding: 0 1rem 1.5rem; }
  .hint-banner { margin: .65rem 1rem 0; font-size: .82rem; }

  .stat-cards { grid-template-columns: 1fr; }
  .card-form-grid { grid-template-columns: 1fr; }
  .cards-list { grid-template-columns: 1fr; margin-top: .75rem; }
  .form-field-action .btn { width: 100%; min-height: 44px; }
  .form-field-bank .bank-list { max-height: min(240px, 40vh); }

  .req-actions .btn { flex: 1 1 calc(50% - .25rem); min-height: 44px; }
  .card-item-actions .btn { min-height: 44px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card {
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  }
  .modal-actions {
    flex-direction: column-reverse;
    gap: .65rem;
  }
  .modal-actions .btn {
    width: 100%;
    min-height: 46px;
  }

  .toast-container {
    top: auto;
    bottom: calc(.75rem + env(safe-area-inset-bottom));
    left: .75rem;
    right: .75rem;
    max-width: none;
  }

  input, select, textarea, .req-search, .form-field input {
    font-size: 16px;
  }

  .bank-list-item { padding: .75rem .85rem; min-height: 44px; display: flex; align-items: center; }
  .history-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form .btn { width: 100%; }
}

@media (max-width: 420px) {
  .nav-label { display: none; }
  .nav-item { padding: .55rem .6rem; }
  .balance-rate { display: none; }
  #logout-btn { padding: .5rem .65rem; font-size: .82rem; }
}

/* Уведомления */
.notify-wrap { position: relative; z-index: 100; }
.notify-btn { position: relative; font-size: 1.1rem; padding: .45rem .65rem; }
.notify-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.notify-panel {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  width: min(360px, calc(100vw - 2rem));
  max-height: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notify-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
}
.notify-list {
  overflow-y: auto;
  max-height: 360px;
  padding: .35rem 0;
}
.notify-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}
.notify-item {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.notify-item:last-child { border-bottom: none; }
.notify-item:hover { background: var(--bg-hover, rgba(255,255,255,.04)); }
.notify-item.unread { background: rgba(59,130,246,.08); }
.notify-item-title { font-weight: 600; font-size: .85rem; margin-bottom: .15rem; }
.notify-item-msg { font-size: .8rem; color: var(--muted); }
.notify-item-time { font-size: .7rem; color: var(--muted); margin-top: .2rem; }
.notify-item.type-waiting .notify-item-title { color: #3b82f6; }
.notify-item.type-check .notify-item-title { color: #8b5cf6; }
.notify-item.type-nocheck .notify-item-title { color: #f59e0b; }
.notify-item.type-problem .notify-item-title { color: #f59e0b; }
.notify-item.type-paid .notify-item-title { color: #22c55e; }
.notify-item.type-slice .notify-item-title { color: #ef4444; }

.reject-evidence-wrap { margin-top: .75rem; }
.reject-evidence-wrap input[type=file] {
  width: 100%;
  margin-top: .35rem;
  font-size: .85rem;
}
.req-actions .btn + .btn { margin-left: .4rem; }

/* ---- Новые вкладки: Статистика, Партнёры, Уведомления, Профиль ---- */
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.xs { padding: .1rem .35rem; font-size: .72rem; line-height: 1; }

.timer.warn { color: var(--warning); }

.stats-period-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.stats-period h2 { margin: 0 0 .75rem; font-size: 1rem; }

#premium-flow-section {
  padding: 1rem 1.5rem 1.5rem;
}
.premium-flow-top {
  margin-bottom: 1.25rem;
}
.premium-bind-form {
  margin-bottom: 1.25rem;
}
.premium-bind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}
@media (max-width: 768px) {
  .premium-bind-grid {
    grid-template-columns: 1fr;
  }
}
.pf-select {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.premium-subtitle {
  margin: 0 0 .75rem;
  font-size: 1rem;
}
.premium-summary-cards {
  margin-bottom: 1.25rem;
}
.premium-uid-badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .5rem;
  border-radius: 6px;
  background: var(--accent-dim, rgba(99, 102, 241, .15));
  font-size: .8rem;
}
.pf-hint {
  margin: 0;
  font-size: .85rem;
}
.pf-load-error {
  margin: 0 0 1rem;
  padding: .75rem 1rem;
  border-radius: 8px;
}
.pf-steps {
  line-height: 1.55;
}
  line-height: 1.55;
}
.pf-chats-panel {
  margin-bottom: 1rem;
}
.pf-chats-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.pf-chat-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-radius: 8px;
  background: var(--surface-2, rgba(255,255,255,.04));
}
.pf-chat-uid {
  font-weight: 600;
  font-size: .85rem;
}
.pf-chat-title {
  color: var(--text-muted);
  font-size: .9rem;
}
.pf-cards-list {
  margin-top: .75rem;
}
.pf-card-item {
  border: 1px solid var(--border, rgba(255,255,255,.08));
}
.pf-card-flow-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border, rgba(255,255,255,.12));
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.pf-card-uid-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.pf-card-uid-label {
  font-size: .8rem;
  color: var(--text-muted);
}
.pf-card-bindings {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.pf-bound-chat {
  font-size: .8rem;
  padding: .2rem .5rem;
  border-radius: 6px;
  background: var(--accent-dim, rgba(99, 102, 241, .12));
}
.pf-inline-bind {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.pf-inline-bind .pf-select {
  min-width: 200px;
  flex: 1;
}

#payouts-section {
  padding: 1rem 1.5rem 1.5rem;
}
.payouts-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.payouts-top .partners-intro {
  flex: 1;
  min-width: 220px;
  margin-bottom: 0;
}
.payouts-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.payouts-summary-cards {
  margin-bottom: 1.25rem;
}
.partner-payout-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: auto;
  padding-top: .25rem;
}
.partner-payout-block {
  font-size: .85rem;
}

/* ---- Партнёры ---- */
#partners-section {
  padding: 1rem 1.5rem 1.5rem;
}
.partners-top {
  margin-bottom: 1.25rem;
}
.partners-intro {
  margin-bottom: 1rem;
}
.partners-title {
  margin: 0 0 .35rem;
  font-size: 1.15rem;
  font-weight: 700;
}
.partners-stat-cards {
  grid-template-columns: repeat(4, 1fr);
}
.partners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.partner-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.partner-card:hover {
  border-color: rgba(16, 185, 129, .35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .12);
}
.partner-card-top {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.partner-uid-block {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.partner-uid-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}
.partner-uid-row {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.partner-uid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(16, 185, 129, .2);
  padding: .35rem .65rem;
  border-radius: 8px;
  flex: 1;
  min-width: 0;
}
.partner-rate-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.partner-pill {
  font-size: .78rem;
  font-weight: 600;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.partner-pill-coef {
  color: #8b5cf6;
  border-color: rgba(139, 92, 246, .35);
  background: rgba(139, 92, 246, .1);
}
.partner-pill-rate {
  color: var(--accent);
  border-color: rgba(16, 185, 129, .35);
  background: var(--accent-dim);
}
.partner-pill-muted {
  color: var(--muted);
  font-weight: 500;
}
.partner-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem .85rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.partner-metric {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.partner-metric-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.partner-metric-value {
  font-size: .95rem;
  font-weight: 700;
}
.partner-metric-value.accent { color: var(--accent); }
.partner-metric-value.ok { color: #22c55e; }
.partner-metric-value.warn { color: var(--warning); }
.partner-metric-value.low { color: var(--danger); }
.partner-conv-bar {
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.partner-conv-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--muted);
  transition: width .4s ease;
}
.partner-conv-bar.ok .partner-conv-fill { background: linear-gradient(90deg, #22c55e, var(--accent)); }
.partner-conv-bar.warn .partner-conv-fill { background: linear-gradient(90deg, var(--warning), #eab308); }
.partner-conv-bar.low .partner-conv-fill { background: linear-gradient(90deg, var(--danger), #f97316); }
.req-partner-conv {
  font-size: .82rem;
  margin-top: .35rem;
  padding: .35rem .55rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
}
.req-partner-conv.ok { color: #22c55e; border-color: rgba(34, 197, 94, .25); }
.req-partner-conv.warn { color: var(--warning); border-color: rgba(234, 179, 8, .25); }
.req-partner-conv.low { color: var(--danger); border-color: rgba(239, 68, 68, .25); }
.req-partner-conv-sub {
  font-size: .76rem;
  opacity: .92;
  margin-top: .2rem;
  padding: .28rem .5rem;
}
.req-partner-conv-system {
  font-size: .76rem;
  opacity: .88;
  margin-top: .2rem;
  border-style: dashed;
}
.partner-metric-hint {
  display: block;
  font-size: .62rem;
  margin-top: .15rem;
  line-height: 1.2;
}
.stat-cards.compact {
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: .45rem;
}
.stat-cards.compact .stat-card { padding: .45rem .5rem; }
.stat-cards.compact .stat-value { font-size: .95rem; }

@media (max-width: 900px) {
  .partners-stat-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  #partners-section { padding: 1rem; }
  .partners-stat-cards { grid-template-columns: 1fr 1fr; }
  .partners-grid { grid-template-columns: 1fr; }
}

.notif-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.notif-filter { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; }
.notif-feed { display: flex; flex-direction: column; gap: .5rem; }
.notif-feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.notif-feed-item:hover { background: var(--surface3); }
.notif-feed-item.unread { border-color: var(--accent); }
.notif-feed-title { font-weight: 600; font-size: .92rem; }
.notif-feed-msg { font-size: .82rem; color: var(--muted); }
.notif-feed-time { font-size: .75rem; color: var(--muted); white-space: nowrap; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
}
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--surface3);
  font-size: .9rem;
}
.profile-key { color: var(--muted); }
.profile-val { font-weight: 600; }
.profile-val.ok { color: var(--accent); }
.profile-val.warn { color: var(--warning); }
.profile-toggle { margin-top: .75rem; }
.profile-form { display: flex; flex-direction: column; gap: .4rem; margin-top: .75rem; }
.profile-form label { font-size: .82rem; color: var(--muted); }
.profile-form-head { margin-bottom: .75rem; }
.profile-theme { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; }
.theme-choices { display: flex; gap: .4rem; }
.profile-rest-wrap { margin-top: .85rem; }
.rest-video {
  width: 100%;
  max-height: 65vh;
  border-radius: 12px;
  background: #000;
}

.card-over-limit { border-color: var(--warning) !important; }
.card-limit-alert {
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
  font-size: .8rem;
  font-weight: 600;
  padding: .4rem .6rem;
  border-radius: 8px;
  margin-bottom: .6rem;
}
.card-copy-btn { margin-left: .35rem; vertical-align: middle; }

.stats-extended { margin-top: 1rem; }
.stats-compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.compare-block h3 { font-size: .9rem; margin: 0 0 .6rem; color: var(--muted); }
.compare-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; font-size: .85rem; }
.compare-metrics div { display: flex; flex-direction: column; gap: .15rem; }
.compare-metrics small { color: var(--muted); font-size: .75rem; }
.chart-bars {
  display: flex; align-items: flex-end; gap: 4px; min-height: 120px; padding: .5rem 0;
}
.chart-bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
}
.chart-bar-fill {
  width: 100%; max-width: 28px; background: linear-gradient(180deg, var(--accent), #22c55e);
  border-radius: 4px 4px 0 0; min-height: 4px;
}
.chart-bar-label { font-size: .65rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stage-times-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; }
.stage-time { padding: .6rem; background: var(--surface2); border-radius: 8px; font-size: .85rem; }
.stage-time span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: .25rem; }

.partner-card-click { cursor: pointer; transition: border-color .15s, transform .1s; }
.partner-card-click:hover { border-color: var(--accent); transform: translateY(-1px); }
.partner-card-hint { margin-top: .5rem; font-size: .72rem; }
.partner-detail-stats { margin-bottom: 1rem; }
.stat-cards.compact { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }

.cards-queue-preview {
  margin-bottom: 1rem; padding: .75rem 1rem;
  background: rgba(99, 102, 241, .1); border: 1px solid var(--accent);
  border-radius: 10px; font-size: .88rem;
}
.queue-preview-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }

.card-item { position: relative; padding-left: 1.75rem; }
.card-drag-handle {
  position: absolute; left: .5rem; top: 1rem; cursor: grab; color: var(--muted);
  font-size: 1.1rem; user-select: none;
}
.card-item.dragging { opacity: .5; }
.card-item.drag-over { outline: 2px dashed var(--accent); }
.card-schedule-badge {
  font-size: .7rem; padding: .1rem .4rem; border-radius: 6px;
  background: var(--surface3); color: var(--muted); margin-left: .35rem;
}
.form-field-full { grid-column: 1 / -1; }
.toggle-switch.inline { flex-direction: row; align-items: center; gap: .5rem; }
.stat-value.warn { color: var(--warning); }
.partner-metric-value.warn { color: var(--warning); }

.card-block-alert {
  margin: .35rem 0 .5rem;
  padding: .4rem .55rem;
  border-radius: 8px;
  font-size: .78rem;
  background: rgba(234, 179, 8, .12);
  border: 1px solid rgba(234, 179, 8, .35);
  color: var(--warning);
}
