:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --text-primary: #f8fafc;
    --text-dim: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(59,130,246,0.3) 0%, rgba(15,23,42,0) 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, rgba(16,185,129,0.2) 0%, rgba(15,23,42,0) 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

.container {
    width: 100%;
    max-width: 800px;
    padding: 24px;
    z-index: 1;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--glass-shadow);
    margin-bottom: 24px;
}

/* View Logic */
.view {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.view.active-view {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

#auth-view {
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
    display: none;
}

#auth-view.active-view {
    display: block;
}

/* Typography & Layout */
.text-dim { color: var(--text-dim); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    border-radius: 8px;
    transform: rotate(45deg);
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 32px;
}

/* Forms */
.input-group {
    text-align: left;
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-dim);
}

.input-group input {
    width: 100%;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 16px;
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.primary-btn {
    background: var(--accent);
    color: white;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ghost-btn {
    background: transparent;
    color: var(--text-dim);
    width: auto;
    padding: 8px 16px;
}

.ghost-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 8px;
    padding: 6px;
    display: inline-flex;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* Tabs & Account Opening Actions */
.tabs-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.tabs {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    padding: 10px 24px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: white;
    border-radius: 2px 2px 0 0;
    opacity: 0.5;
}

.add-wallet-actions {
    display: flex;
    gap: 10px;
}

.add-btn {
    width: auto;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.trx-add-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.trx-add-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.usdt-add-btn {
    background: rgba(16, 185, 129, 0.1);
    color: #4ade80;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.usdt-add-btn:hover {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.25rem;
}

/* Balance Card */
.balance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.currency-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.balance-amount {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 32px;
}

.balance-amount h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.balance-amount .currency {
    font-size: 1.5rem;
    color: var(--text-dim);
    font-weight: 500;
}

.address-box {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--glass-border);
}

.address-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.address-wrapper code {
    font-family: monospace;
    color: white;
    word-break: break-all;
    font-size: 0.95rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.tx-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.tx-table th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.875rem;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
}

.tx-table td {
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.tx-type {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tx-type-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tx-type-icon.deposit {
    background: var(--success-light);
    color: var(--success);
}

.tx-type-icon.withdrawal {
    background: var(--danger-light);
    color: var(--danger);
}

.tx-amount {
    font-weight: 600;
}

.tx-amount.positive { color: var(--success); }
.tx-amount.negative { color: var(--text-primary); }

.tx-status {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
}
.tx-status.COMPLETED { background: var(--success-light); color: var(--success); }

.tx-hash {
    font-family: monospace;
    color: var(--text-dim);
    font-size: 0.8rem;
    display: block;
}
.tx-date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Spinner */
.spinner {
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

/* ── Sweep amount cell ─────────────────────────────────────────────────────── */
.sweep-amount-usdt {
    font-weight: 600;
    color: #4ade80;
}

.sweep-amount-trx {
    font-weight: 600;
    color: #facc15;
}

.sweep-amount-residual-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.3);
    vertical-align: middle;
}

/* ── Admin page layout ─────────────────────────────────────────────────────── */
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.filter-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 20px; flex-wrap: wrap; }
.filter-row .input-group { margin-bottom: 0; flex: 1; min-width: 160px; }
.detail-panel { margin-top: 20px; padding: 20px; background: rgba(255,255,255,0.04); border-radius: 12px; border: 1px solid rgba(255,255,255,0.08); }
.detail-panel h4 { margin: 0 0 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.detail-item label { display: block; font-size: 11px; color: var(--text-dim, #888); margin-bottom: 2px; }
.detail-item span { font-size: 13px; word-break: break-all; }
.status-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.section-divider { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 40px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full-width { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.checkbox-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.source-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; background: rgba(99,102,241,0.2); color: #a5b4fc; }
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: rgba(255,255,255,0.04); }
.clickable-code { cursor: pointer; transition: color 0.1s; display: inline-block; }
.clickable-code:hover { color: var(--accent, #3b82f6); text-decoration: underline; }
#detail-panel { display: none; }

/* ── Allocation / wallet status badges ─────────────────────────────────────── */
.status-ALLOCATED { background: rgba(59,130,246,0.2); color: #60a5fa; }
.status-DISPLAYED { background: rgba(168,85,247,0.2); color: #c084fc; }
.status-USED { background: rgba(34,197,94,0.2); color: #4ade80; }
.status-EXPIRED { background: rgba(107,114,128,0.2); color: #9ca3af; }
.status-CANCELLED { background: rgba(239,68,68,0.2); color: #f87171; }
.status-CLOSED_FOR_NEW_DEPOSITS { background: rgba(245,158,11,0.15); color: #f59e0b; }
.status-ASSET_MISMATCH { background: rgba(245,158,11,0.2); color: #fbbf24; }
.status-UNSUPPORTED_ASSET { background: rgba(245,158,11,0.2); color: #fbbf24; }
.status-ACTIVE { background: rgba(34,197,94,0.2); color: #4ade80; }
.status-INACTIVE { background: rgba(107,114,128,0.2); color: #9ca3af; }
.status-RETIRED { background: rgba(239,68,68,0.2); color: #f87171; }

/* ── Sweep status badges ───────────────────────────────────────────────────── */
.sweep-status-NEW           { background: rgba(99,102,241,0.2);  color: #a5b4fc; }
.sweep-status-ELIGIBLE      { background: rgba(59,130,246,0.2);  color: #60a5fa; }
.sweep-status-IN_PROGRESS   { background: rgba(245,158,11,0.2);  color: #fbbf24; }
.sweep-status-BROADCASTED   { background: rgba(168,85,247,0.2);  color: #c084fc; }
.sweep-status-CONFIRMED     { background: rgba(34,197,94,0.2);   color: #4ade80; }
.sweep-status-FAILED        { background: rgba(239,68,68,0.2);   color: #f87171; }
.sweep-status-MANUAL_REVIEW { background: rgba(239,68,68,0.15);  color: #fb923c; }
.sweep-status-CANCELLED     { background: rgba(107,114,128,0.2); color: #9ca3af; }
.sweep-status-AWAITING_RESOURCES { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ── Sweep category badges ─────────────────────────────────────────────────── */
.sweep-cat-eligible_for_sweep           { background: rgba(59,130,246,0.15);  color: #60a5fa; }
.sweep-cat-in_progress                  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.sweep-cat-awaiting_resources           { background: rgba(168,85,247,0.15);  color: #c084fc; }
.sweep-cat-eligible_with_existing_trx   { background: rgba(251,146,60,0.15);  color: #fb923c; }
.sweep-cat-waiting_for_resource_recovery{ background: rgba(14,165,233,0.15);  color: #38bdf8; }
.sweep-cat-requires_top_up              { background: rgba(239,68,68,0.15);   color: #fca5a5; }
.sweep-cat-failed                       { background: rgba(239,68,68,0.15);   color: #f87171; }
.sweep-cat-manual_review                { background: rgba(239,68,68,0.10);   color: #fb923c; }
.sweep-cat-swept                        { background: rgba(34,197,94,0.15);   color: #4ade80; }
.sweep-cat-cancelled                    { background: rgba(107,114,128,0.15); color: #9ca3af; }

/* ── Sweep action buttons ──────────────────────────────────────────────────── */
.sweep-btn { padding: 4px 10px; font-size: 12px; }
.sweep-force-btn   { color: #c084fc; border-color: rgba(168,85,247,0.4); }
.sweep-approve-btn { color: #fb923c; border-color: rgba(251,146,60,0.4); }
.sweep-recheck-btn { color: #38bdf8; border-color: rgba(14,165,233,0.4); }
.sweep-action-approve { background: rgba(251,146,60,0.3);  border-color: rgba(251,146,60,0.6); }
.sweep-action-recheck  { background: rgba(14,165,233,0.2); border-color: rgba(14,165,233,0.5); }
.sweep-action-force    { background: rgba(168,85,247,0.3); border-color: rgba(168,85,247,0.6); }
.sweep-action-cancel   { border-color: rgba(239,68,68,0.4); color: #f87171; }

/* ── Sweep detail panel inline highlights ──────────────────────────────────── */
.sweep-detail-decision  { font-weight: 600; color: #fb923c; }
.sweep-detail-dim       { font-size: 12px; color: #ccc; }
.sweep-detail-topup-trx { color: #fbbf24; font-weight: 600; }
.sweep-detail-topup-hint{ font-size: 11px; color: #888; }
.sweep-detail-ok        { color: #4ade80; font-weight: 600; }
.sweep-detail-warn      { color: #fbbf24; font-weight: 600; }
.sweep-detail-err       { color: #f87171; font-weight: 600; }

/* ── Resources grid ────────────────────────────────────────────────────────── */
.res-grid-label { font-size: 11px; color: var(--text-dim, #888); margin-bottom: 2px; }
.res-grid-value { font-weight: 600; }
.res-grid-full  { grid-column: 1 / -1; }

/* ── Detail created-at small text ──────────────────────────────────────────── */
.sweep-created-at { font-size: 12px; }

/* Модальное окно «Мой профиль» (нативный <dialog>) */
.profile-dialog {
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    margin: auto;
    padding: 28px;
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.profile-dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

/* TASK-37: справка к разделам ЛК */
.help-q {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-left: 6px; padding: 0; vertical-align: middle;
    border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); background: transparent;
    color: var(--text-dim, #9ca3af); font-size: 12px; font-weight: 700; cursor: pointer;
}
.help-q:hover { color: #fff; border-color: #fff; }
.help-body { font-size: 14px; line-height: 1.55; }
.help-body h2, .help-body h3 { font-size: 15px; margin: 14px 0 8px; }
.help-body ul, .help-body ol { padding-left: 20px; margin: 0 0 10px; }
.help-body table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 13px; }
.help-body th, .help-body td { border: 1px solid rgba(255,255,255,0.12); padding: 6px 10px; text-align: left; }
.help-body code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 4px; }

/* TASK-45: RUB payout form inside the existing balance surface. */
.fiat-payout-panel {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
}
.fiat-payout-recipient {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.fiat-payout-recipient strong { font-size: 14px; }
.fiat-payout-notice {
    padding: 10px 12px;
    margin-bottom: 12px;
    border-left: 3px solid #f59e0b;
    background: rgba(245,158,11,0.09);
    color: #fbbf24;
    font-size: 13px;
    line-height: 1.45;
}
#fiat-payout-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
}
#fiat-payout-fields .input-group { margin-bottom: 0; }
#fiat-payout-fields select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(30,30,50,0.8);
    color: #e2e8f0;
}
#fiat-payout-fields.is-disabled { opacity: .55; pointer-events: none; }
#fiat-payout-error { grid-column: 1 / -1; margin-top: 8px; }

@media (max-width: 720px) {
    #fiat-payout-fields { grid-template-columns: 1fr; }
    #fiat-payout-fields .btn { width: 100%; }
    .fiat-payout-recipient { align-items: flex-start; flex-direction: column; gap: 4px; }
}
