:root {
    --bg: #0b0f14;
    --bg-elevated: #121820;
    --bg-card: #161d27;
    --bg-hover: #1c2533;
    --border: rgba(255, 255, 255, 0.08);
    --text: #eef2f7;
    --text-muted: #8b95a5;
    --accent: #4f8cff;
    --accent-hover: #6b9dff;
    --accent-glow: rgba(79, 140, 255, 0.25);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --long: #34d399;
    --short: #f87171;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --sidebar-w: 260px;
    --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 140, 255, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(52, 211, 153, 0.06), transparent);
}

.hidden { display: none !important; }

.text-muted { color: var(--text-muted); }
.mb { margin-bottom: 1rem; }
.mt { margin-top: 1.25rem; }
.hint { font-size: 0.85rem; margin-top: 0.75rem; }

/* Auth */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    padding: 2.25rem;
    box-shadow: var(--shadow);
}

.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand h1 { font-size: 1.5rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
.auth-brand p { color: var(--text-muted); font-size: 0.9rem; }

.logo-mark {
    width: 52px; height: 52px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.logo-mark.sm { width: 36px; height: 36px; font-size: 0.75rem; border-radius: 10px; margin: 0; }

.auth-tabs {
    display: flex; gap: 0.5rem;
    background: var(--bg-elevated);
    padding: 4px; border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1; padding: 0.6rem;
    border: none; background: transparent;
    color: var(--text-muted); font-family: inherit;
    font-size: 0.9rem; font-weight: 500;
    border-radius: 6px; cursor: pointer;
    transition: all 0.2s;
}
.auth-tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

.auth-form label { display: block; margin-bottom: 1rem; }
.auth-form label span { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.auth-form label small { font-weight: 400; opacity: 0.7; }

input, select, textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.amount-input {
    font-variant-numeric: tabular-nums;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 1.25rem 1rem;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 10;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 0.65rem;
    font-weight: 600; font-size: 0.95rem;
    padding: 0.5rem 0.75rem; margin-bottom: 1.5rem;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }

.nav-item {
    display: flex; align-items: center; gap: 0.65rem;
    width: 100%; padding: 0.7rem 0.85rem;
    border: none; background: transparent;
    color: var(--text-muted); font-family: inherit;
    font-size: 0.92rem; font-weight: 500;
    border-radius: var(--radius-sm); cursor: pointer;
    text-align: left; transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: rgba(79, 140, 255, 0.12); color: var(--accent); }
.nav-icon { opacity: 0.8; width: 1.2rem; text-align: center; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 1rem; margin-top: 1rem;
}

.user-chip { display: flex; gap: 0.65rem; align-items: center; margin-bottom: 0.75rem; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem;
}
.user-name { font-weight: 600; font-size: 0.88rem; }
.user-email { font-size: 0.75rem; color: var(--text-muted); }

.content {
    flex: 1; margin-left: var(--sidebar-w);
    padding: 1.75rem 2rem 2.5rem;
    max-width: 1200px;
}

.content-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.75rem; gap: 1rem;
}
.content-header h2 { font-size: 1.65rem; font-weight: 700; }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.65rem 1.15rem;
    border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.82rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
}
.card h3 { font-size: 1.05rem; margin-bottom: 1rem; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .content { margin-left: 0; padding: 1rem; }
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; }

/* Balance cards */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.balance-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    position: relative; overflow: hidden;
}
.balance-card::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), #6366f1);
}
.balance-symbol { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.balance-total { font-size: 1.75rem; font-weight: 700; margin: 0.35rem 0 0.75rem; font-variant-numeric: tabular-nums; }
.balance-row { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); }
.balance-row + .balance-row { margin-top: 0.25rem; }
.balance-row strong { color: var(--text); font-weight: 500; }

.info-banner {
    display: flex; align-items: center; gap: 1rem;
    background: rgba(79, 140, 255, 0.08);
    border: 1px solid rgba(79, 140, 255, 0.2);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.banner-icon { font-size: 1.5rem; opacity: 0.9; }
.info-banner p { font-size: 0.85rem; margin-top: 0.15rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%; border-collapse: collapse; font-size: 0.88rem;
}
table.data-table th {
    text-align: left; padding: 0.65rem 0.75rem;
    color: var(--text-muted); font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data-table td {
    padding: 0.75rem; border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.empty-state {
    text-align: center; padding: 2.5rem 1rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block; padding: 0.2rem 0.55rem;
    border-radius: 999px; font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-warning { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.badge-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.badge-neutral { background: rgba(139, 149, 165, 0.15); color: var(--text-muted); }
.badge-long { background: rgba(52, 211, 153, 0.15); color: var(--long); }
.badge-short { background: rgba(248, 113, 113, 0.15); color: var(--short); }

.side-long { color: var(--long); font-weight: 600; }
.side-short { color: var(--short); font-weight: 600; }
.amount-pos { color: var(--success); }
.amount-neg { color: var(--danger); }

.instruction-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}
.instruction-item .addr {
    font-family: ui-monospace, monospace;
    font-size: 0.82rem; word-break: break-all;
    margin: 0.5rem 0; color: var(--accent);
}

.address-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    font-size: 0.88rem;
}
.address-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}
.address-item code { font-size: 0.8rem; word-break: break-all; color: var(--text-muted); }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon-danger:hover {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.08);
}

.alert {
    padding: 0.75rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.88rem; margin-top: 1rem;
}
.alert-error { background: rgba(248, 113, 113, 0.12); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.25); }
.alert-success { background: rgba(52, 211, 153, 0.12); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.25); }
.auth-link { margin-top: 0.5rem; }

.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 0.85rem 1.25rem; border-radius: var(--radius-sm);
    box-shadow: var(--shadow); z-index: 100;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(11, 15, 20, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.assets-summary { margin-bottom: 1.25rem; }
.assets-summary-total {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0 1rem;
    font-variant-numeric: tabular-nums;
}
.assets-summary-rows { max-width: 360px; }

.deposit-card { max-width: 720px; }

.deposit-wizard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.deposit-step-image-wrap {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.deposit-step-image {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    border-radius: calc(var(--radius-sm) - 2px);
}

.deposit-step-text {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.deposit-wizard-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.deposit-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.deposit-details { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

.asset-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.asset-toggle-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 3rem;
    text-align: center;
    transition: color 0.2s;
}
.asset-toggle-label.active { color: var(--text); }
.asset-toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}
.asset-toggle-knob {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
    transition: transform 0.2s, background 0.2s;
}
.asset-toggle-switch.is-usdc .asset-toggle-knob {
    transform: translateX(-24px);
    background: #6366f1;
}

.history-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.page-size-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.page-size-label select { width: auto; min-width: 72px; padding: 0.45rem 0.6rem; }

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.filters-grid label span {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}
.filter-wide { grid-column: span 2; }
.filter-actions {
    display: flex;
    align-items: end;
    gap: 0.5rem;
    padding-bottom: 0.1rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.85rem; color: var(--text-muted); }
.pagination-actions { display: flex; gap: 0.5rem; }

@media (max-width: 720px) {
    .filter-wide { grid-column: span 1; }
}

.settings-card {
    max-width: 480px;
}

.settings-form label span {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

/* Landing */
.landing-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-header,
.landing-footer {
    padding: 1.25rem 2rem;
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.landing-nav {
    display: flex;
    gap: 0.5rem;
}

.landing-main {
    flex: 1;
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    gap: 2rem;
}

.landing-hero {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
    align-items: center;
}

.landing-badge {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(79, 140, 255, 0.12);
    color: var(--accent-hover);
    font-size: 0.85rem;
}

.landing-hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.15;
    margin-bottom: 1rem;
}

.landing-lead {
    color: var(--text-muted);
    max-width: 38rem;
    margin-bottom: 1.5rem;
}

.landing-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.landing-hero-card h3 {
    margin-bottom: 1rem;
}

.landing-features {
    list-style: none;
    display: grid;
    gap: 0.75rem;
}

.landing-features li {
    padding-left: 1.25rem;
    position: relative;
    color: var(--text-muted);
}

.landing-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
}

.landing-auth {
    display: flex;
    justify-content: center;
}

.landing-auth .auth-card {
    max-width: 460px;
}

@media (max-width: 900px) {
    .landing-hero {
        grid-template-columns: 1fr;
    }

    .landing-header,
    .landing-footer,
    .landing-main {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
