/* ================================================================
   CrypTracker – Stylesheet (v2 — animations, glassmorphism, polish)
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */

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

:root {
    --bg:          #0b0d14;
    --bg-card:     rgba(22, 25, 38, .85);
    --bg-card-solid: #161926;
    --bg-input:    #1e2235;
    --border:      rgba(255,255,255,.06);
    --border-hover:rgba(255,255,255,.12);
    --text:        #e4e7ef;
    --text-muted:  #7c819a;
    --primary:     #7c6aef;
    --primary-h:   #9584ff;
    --primary-glow:rgba(124,106,239,.25);
    --green:       #00d4a1;
    --green-bg:    rgba(0,212,161,.10);
    --green-glow:  rgba(0,212,161,.25);
    --red:         #ff5c6c;
    --red-bg:      rgba(255,92,108,.10);
    --red-glow:    rgba(255,92,108,.25);
    --yellow:      #ffc048;
    --radius:      14px;
    --radius-sm:   8px;
    --shadow:      0 4px 24px rgba(0,0,0,.4);
    --shadow-lg:   0 8px 40px rgba(0,0,0,.5);
    --transition:  .25s cubic-bezier(.4,0,.2,1);
    --bounce:      .4s cubic-bezier(.34,1.56,.64,1);
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124,106,239,.08) 0%, transparent 100%);
}

::selection { background: var(--primary); color: #fff; }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-h); }

/* ── Animations ───────────────────────────────────────────── */

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

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .6; }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 8px var(--primary-glow); }
    50%      { box-shadow: 0 0 20px var(--primary-glow); }
}

@keyframes spinFade {
    0%   { transform: rotate(0deg); opacity: .4; }
    50%  { opacity: 1; }
    100% { transform: rotate(360deg); opacity: .4; }
}

@keyframes liveFlash {
    0%   { background-color: rgba(0, 212, 161, .18); }
    100% { background-color: transparent; }
}

@keyframes ripple {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: .35; }
    100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

@keyframes subtleBounce {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.live-flash {
    animation: liveFlash .6s ease-out;
    border-radius: 4px;
}

.animate-fade-in     { animation: fadeIn .5s ease both; }
.animate-fade-in-up  { animation: fadeInUp .5s ease both; }
.animate-slide-down  { animation: slideDown .4s ease both; }
.animate-scale-in    { animation: scaleIn .4s ease both; }

.stagger-1 { animation-delay: .05s; }
.stagger-2 { animation-delay: .10s; }
.stagger-3 { animation-delay: .15s; }
.stagger-4 { animation-delay: .20s; }

/* ── Navbar ───────────────────────────────────────────────── */

.navbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: .85rem 2rem;
    background: rgba(22,25,38,.92);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    animation: slideDown .4s ease both;
}

.nav-brand {
    font-size: 1.25rem; font-weight: 700; color: var(--primary);
    letter-spacing: .5px; display: flex; align-items: center; gap: .5rem;
    transition: color var(--transition);
}

.nav-brand:hover { color: var(--primary-h); }

.brand-icon {
    font-size: 1.4rem;
    display: inline-block;
    animation: spinFade 3s ease-in-out infinite;
}

.nav-right { display: flex; align-items: center; gap: 1rem; }

.source-indicator {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .28rem .65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .2px;
}

.source-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(0,212,161,.35);
}

.source-indicator.fallback-active {
    border-color: rgba(255,192,72,.35);
    color: var(--yellow);
}

.source-indicator.fallback-active .source-dot {
    background: var(--yellow);
    box-shadow: 0 0 8px rgba(255,192,72,.45);
}

.nav-user {
    color: var(--text-muted); font-size: .87rem;
    display: flex; align-items: center; gap: .5rem;
}

.user-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    color: #fff; font-size: .75rem; font-weight: 700;
}

/* ── Mode Toggle ──────────────────────────────────────────── */

.mode-toggle-form { margin: 0; }

.mode-toggle {
    display: flex; align-items: center; gap: .5rem;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .3rem .7rem .3rem .8rem;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text);
    font-family: inherit;
}

.mode-toggle:hover {
    border-color: var(--primary);
    background: rgba(124,106,239,.08);
}

.mode-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    min-width: 52px;
    text-align: center;
}

.mode-switch {
    display: flex;
    align-items: center;
    width: 32px; height: 18px;
    background: rgba(255,255,255,.1);
    border-radius: 10px;
    padding: 2px;
    transition: background var(--transition);
    position: relative;
}

.mode-switch.active {
    background: linear-gradient(135deg, var(--primary), #9584ff);
}

.mode-knob {
    width: 14px; height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.mode-switch.active .mode-knob {
    transform: translateX(14px);
}

/* ── User Context Menu ────────────────────────────────────── */

.user-menu-wrapper { position: relative; }

.nav-user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: none; border: 1px solid transparent;
    color: var(--text-muted); font-size: .87rem;
    cursor: pointer; border-radius: var(--radius-sm);
    padding: .3rem .6rem; transition: all var(--transition);
    font-family: inherit;
}

.nav-user-btn:hover {
    border-color: var(--border-hover);
    background: rgba(255,255,255,.04);
    color: var(--text);
}

.user-name { font-weight: 500; }

.user-caret {
    font-size: .65rem; transition: transform var(--transition);
    margin-left: .1rem;
}

.user-menu-wrapper.open .user-caret { transform: rotate(180deg); }

.user-menu {
    display: none;
    position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 190px;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    animation: slideDown .2s ease both;
    overflow: hidden;
}

.user-menu-wrapper.open .user-menu { display: block; }

.user-menu-item {
    display: flex; align-items: center; gap: .6rem;
    width: 100%; padding: .65rem 1rem;
    background: none; border: none;
    color: var(--text); font-size: .85rem;
    cursor: pointer; text-decoration: none;
    transition: background var(--transition);
    font-family: inherit; text-align: left;
}

.user-menu-item:hover { background: rgba(124,106,239,.08); }

.menu-logout-form { margin: 0; }

.user-menu-item .menu-icon {
    font-size: 1rem; width: 1.2rem; text-align: center;
    opacity: .7;
}

.menu-danger { color: var(--red); }
.menu-danger:hover { background: var(--red-bg); }

.user-menu-divider {
    height: 1px; background: var(--border); margin: .2rem 0;
}

/* ── Customize Modal ──────────────────────────────────────── */

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
    z-index: 500; justify-content: center; align-items: center;
    padding: 1rem;
    transition: opacity .25s ease;
    opacity: 0;
}

.modal-overlay.open { display: flex; opacity: 1; }

.modal {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%; max-width: 480px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.3rem 1.5rem .8rem;
}

.modal-header h2 { font-size: 1.15rem; font-weight: 700; }

.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; transition: color var(--transition);
    line-height: 1; padding: .2rem; border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

.modal-body { padding: .5rem 1.5rem 1.5rem; }

.setting-group {
    padding: .8rem 0;
    display: flex; flex-direction: column; gap: .5rem;
}

.setting-label {
    font-size: .78rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .5px;
}

.setting-divider {
    height: 1px; background: var(--border); margin: .5rem 0;
}

.settings-form {
    display: flex; flex-direction: column; gap: .5rem;
}

.settings-form .btn { align-self: flex-start; }

/* ── Precision Slider ─────────────────────────────────────── */

.precision-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px;
    background: var(--bg-input);
    border-radius: 3px; outline: none;
    border: 1px solid var(--border);
    cursor: pointer;
}

.precision-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #9584ff);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    border: 2px solid #fff;
}

.precision-slider::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #9584ff);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    border: 2px solid #fff;
}

.precision-range-labels {
    display: flex; justify-content: space-between;
    font-size: .7rem; color: var(--text-muted); padding: 0 2px;
}

.precision-form .btn { align-self: flex-start; }

.wz-checkbox {
    display: flex; align-items: center; gap: .45rem;
    margin-top: .4rem; cursor: pointer; font-size: .85rem;
    color: var(--text-muted);
}
.wz-checkbox input[type="checkbox"] {
    accent-color: var(--primary);
    width: 15px; height: 15px; cursor: pointer;
}
.wz-checkbox span { user-select: none; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .6rem 1.4rem; gap: .4rem;
    border: none; border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 600; cursor: pointer;
    transition: all var(--transition);
    text-align: center; color: #fff; position: relative;
    overflow: hidden;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.98); }

.btn::before {
    content: ''; position: absolute;
    width: 100%; height: 100%;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,.25) 0%, transparent 70%);
    opacity: 0; transition: opacity .4s ease;
    pointer-events: none;
}
.btn:active::before { opacity: 1; }

.btn::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(255,255,255,.15);
    border-radius: inherit; opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}
.btn:active::after { opacity: 1; }

.btn-primary   { background: linear-gradient(135deg, var(--primary), #9584ff); box-shadow: 0 2px 12px var(--primary-glow); }
.btn-primary:hover { box-shadow: 0 4px 20px var(--primary-glow); }

.btn-buy       { background: linear-gradient(135deg, var(--green), #00eab5); width: 100%; box-shadow: 0 2px 12px var(--green-glow); }
.btn-buy:hover { box-shadow: 0 4px 20px var(--green-glow); }

.btn-sell      { background: linear-gradient(135deg, var(--red), #ff8090); width: 100%; box-shadow: 0 2px 12px var(--red-glow); }
.btn-sell:hover { box-shadow: 0 4px 20px var(--red-glow); }

.btn-danger    { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); box-shadow: 0 0 16px var(--red-glow); }

.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); background: rgba(255,255,255,.04); }

.btn-sm        { padding: .35rem .9rem; font-size: .8rem; }
.btn-block     { width: 100%; display: flex; }

.btn:disabled  { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Container ────────────────────────────────────────────── */

.container {
    max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem;
    animation: fadeInUp .5s ease both;
}

/* ── Auth Pages ───────────────────────────────────────────── */

.auth-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 1rem;
    background-image:
        radial-gradient(ellipse 60% 40% at 50% 40%, rgba(124,106,239,.12) 0%, transparent 100%);
}

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn .5s ease both;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.auth-card h1 {
    text-align: center; color: var(--primary);
    font-size: 1.6rem; margin-bottom: .25rem;
}

.auth-card h2 {
    text-align: center; color: var(--text-muted);
    font-size: 1rem; font-weight: 400; margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center; margin-top: 1.4rem;
    font-size: .85rem; color: var(--text-muted);
}

/* ── Forms ────────────────────────────────────────────────── */

label {
    display: block; font-size: .8rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: .3rem; margin-top: .9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    width: 100%; padding: .7rem .9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text); font-size: .95rem;
    transition: all var(--transition);
    font-variant-numeric: tabular-nums;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 11px) calc(50% - 3px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2rem;
}

.setting-note {
    color: var(--text-muted);
    font-size: .76rem;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    transform: translateY(-1px);
}

input::placeholder { color: var(--text-muted); opacity: .5; }

form .btn { margin-top: 1.2rem; }

/* ── Alerts ───────────────────────────────────────────────── */

.alert {
    padding: .8rem 1.1rem; border-radius: var(--radius-sm);
    margin-bottom: 1rem; font-size: .88rem;
    animation: slideDown .4s ease both;
    backdrop-filter: blur(8px);
    position: relative;
}

.alert-error {
    background: var(--red-bg); border: 1px solid rgba(255,92,108,.3);
    color: var(--red);
    box-shadow: 0 0 16px rgba(255,92,108,.08);
}

.alert-success {
    background: var(--green-bg); border: 1px solid rgba(0,212,161,.3);
    color: var(--green);
    box-shadow: 0 0 16px rgba(0,212,161,.08);
}

.alert p { margin: 0; }
.alert p + p { margin-top: .3rem; }

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.app-toast {
    min-width: 260px;
    max-width: 420px;
    padding: .75rem .95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    background: var(--bg-card-solid);
    color: var(--text);
    font-size: .84rem;
    line-height: 1.35;
    transform: translateY(16px) scale(.96);
    opacity: 0;
    transition: opacity .25s ease, transform .3s cubic-bezier(.34,1.56,.64,1);
}

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

.app-toast-info {
    border-color: rgba(124,106,239,.35);
}

/* ── Portfolio Summary Cards ──────────────────────────────── */

.portfolio-summary {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}

.summary-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.3rem 1.5rem;
    display: flex; flex-direction: column;
    transition: all var(--transition);
    animation: fadeInUp .5s ease both;
    position: relative;
    overflow: hidden;
}

.summary-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.summary-card.highlight {
    border-color: rgba(124,106,239,.3);
    background: linear-gradient(135deg, rgba(124,106,239,.08), transparent);
}

.summary-card.highlight:hover { box-shadow: 0 0 24px var(--primary-glow); border-color: rgba(124,106,239,.45); }

.summary-label {
    font-size: .72rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .8px;
}

.summary-value {
    font-size: 1.45rem; font-weight: 700; margin-top: .3rem;
    transition: color var(--transition);
    font-variant-numeric: tabular-nums;
}

/* ── Profit / Loss colors ────────────────────────────────── */

.profit { color: var(--green) !important; }
.loss   { color: var(--red) !important; }
.profit, .loss { transition: color .3s ease; }

/* ── Add Token Section ────────────────────────────────────── */

.add-token-section { margin-bottom: 2rem; animation: fadeInUp .5s ease .1s both; position: relative; z-index: 100; }
.add-token-section h2 { margin-bottom: .75rem; font-size: 1.1rem; font-weight: 600; }

.search-wrapper { position: relative; max-width: 480px; }

.search-wrapper input {
    width: 100%; padding: .75rem 1rem .75rem 2.8rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: .95rem;
    transition: all var(--transition);
}

.search-wrapper input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.search-wrapper::before {
    content: '⌕'; position: absolute;
    left: .9rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 1.1rem; pointer-events: none;
    z-index: 2;
}

.search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #252940;
    border: 1px solid rgba(124,106,239,.35);
    border-radius: var(--radius-sm);
    max-height: 340px; overflow-y: auto;
    display: none; z-index: 9999;
    box-shadow: 0 12px 40px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.08);
    animation: slideDown .2s ease both;
    backdrop-filter: none;
}

.search-results.open { display: block; }

.search-result-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: .8rem 1rem; cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,.08);
    transition: background var(--transition);
    background: #252940;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #2f3455; }

.search-result-item .coin-name { font-weight: 600; font-size: .92rem; color: #f0f1f5; }
.search-result-item .coin-symbol { color: #a8adc6; font-size: .82rem; margin-left: .5rem; }

.search-result-item form { margin: 0; }
.search-result-item .btn { padding: .3rem .8rem; font-size: .75rem; }

/* ── Token Table ──────────────────────────────────────────── */

.token-table-section { animation: fadeInUp .5s ease .15s both; position: relative; z-index: 1; }
.token-table-section h2 { font-size: 1.1rem; margin-bottom: .75rem; font-weight: 600; }

.table-responsive { overflow-x: auto; border-radius: var(--radius); }

.token-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .86rem;
}

.token-table th {
    text-align: left; padding: .8rem 1rem;
    font-size: .72rem; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
    white-space: nowrap;
}

.token-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.token-table td strong { display: block; }
.token-table td small  { color: var(--text-muted); font-size: .76rem; }

.token-table tbody tr:last-child td { border-bottom: none; }

.clickable-row {
    cursor: pointer;
    transition: all var(--transition);
}
.clickable-row:hover {
    background: rgba(124,106,239,.05);
    box-shadow: inset 3px 0 0 var(--primary);
}
.clickable-row:active {
    transform: scale(.998);
    opacity: .8;
}

.empty-state {
    text-align: center; padding: 3rem 2rem;
    color: var(--text-muted); font-size: .95rem;
}

.empty-state::before {
    content: '📊'; display: block;
    font-size: 2.5rem; margin-bottom: .75rem; opacity: .5;
}

/* ── Single Token Page ────────────────────────────────────── */

.back-link {
    display: inline-flex; align-items: center; gap: .3rem;
    margin-bottom: 1.2rem;
    font-size: .85rem; color: var(--text-muted);
    transition: all var(--transition);
}
.back-link:hover { color: var(--text); transform: translateX(-4px); }

.token-header { margin-bottom: 1.5rem; animation: fadeInUp .4s ease both; }
.token-header h1 { font-size: 1.6rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.symbol-badge {
    background: rgba(124,106,239,.12); padding: .2rem .65rem;
    border-radius: var(--radius-sm); font-size: .85rem;
    color: var(--primary); font-weight: 700;
    border: 1px solid rgba(124,106,239,.2);
}

.live-price {
    color: var(--text-muted); font-size: .9rem; margin-top: .35rem;
    display: flex; align-items: center; gap: .5rem;
}
.live-price strong { color: var(--text); font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.price-badge {
    font-size: .78rem; padding: .15rem .5rem;
    border-radius: 20px; font-weight: 600;
}

.price-badge.profit { background: var(--green-bg); }
.price-badge.loss   { background: var(--red-bg); }

/* ── P/L Cards ────────────────────────────────────────────── */

.pl-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}

.pl-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.4rem 1.5rem;
    transition: all var(--transition);
    animation: fadeInUp .5s ease both;
    position: relative; overflow: hidden;
}

.pl-card:nth-child(2) { animation-delay: .08s; }
.pl-card:nth-child(3) { animation-delay: .16s; }

.pl-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.pl-card.highlight {
    border-color: rgba(124,106,239,.3);
    background: linear-gradient(135deg, rgba(124,106,239,.08), transparent);
}

.pl-card h3 {
    font-size: .78rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .6px; margin-bottom: .5rem;
}

.pl-value { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-percent { font-size: .85rem; font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }

.pl-card small { display: block; margin-top: .5rem; color: var(--text-muted); font-size: .76rem; }

/* ── Holdings Info ────────────────────────────────────────── */

.holdings-info {
    background: var(--bg-card); backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.3rem 1.5rem;
    margin-bottom: 1.5rem;
    animation: fadeInUp .5s ease .2s both;
}

.info-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
}

.info-grid > div { padding: .5rem 0; transition: all var(--transition); }

.info-grid .label {
    display: block; font-size: .72rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
}
.info-grid .val { font-size: 1.08rem; font-weight: 600; margin-top: .15rem; display: block; font-variant-numeric: tabular-nums; }

/* ── Trade Forms ──────────────────────────────────────────── */

.trade-forms {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1rem; margin-bottom: 2rem;
}

.trade-card {
    background: var(--bg-card); backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.4rem 1.5rem;
    transition: all var(--transition);
    animation: fadeInUp .5s ease .25s both;
    position: relative; overflow: hidden;
}

.trade-card:nth-child(2) { animation-delay: .3s; }

.trade-card:hover { border-color: var(--border-hover); }

.buy-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--green), transparent);
}

.sell-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--red), transparent);
}

.trade-card h3 { font-size: 1rem; margin-bottom: .5rem; font-weight: 600; }

/* ── Badges ───────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; padding: .2rem .6rem;
    border-radius: 20px; font-size: .72rem;
    font-weight: 700; text-transform: uppercase;
    letter-spacing: .3px;
    transition: transform .15s ease, box-shadow .15s ease;
}

.badge:hover { transform: scale(1.05); }

.badge-buy  { background: var(--green-bg); color: var(--green); }
.badge-sell { background: var(--red-bg); color: var(--red); }
.badge-now  {
    background: rgba(108, 92, 231, .15);
    color: #6c5ce7;
    animation: pulse 2s ease-in-out infinite;
}

.now-row {
    border-top: 2px dashed rgba(108, 92, 231, .35);
    background: rgba(108, 92, 231, .04);
}
.now-row td { font-style: italic; }

/* ── Future Rows (What-If Preview) ────────────────────────── */

.future-row {
    border-top: 1px dashed rgba(162, 155, 254, .25);
    background: rgba(162, 155, 254, .04);
    opacity: 0.55;
    transition: opacity .25s ease;
}
.future-row:hover { opacity: 0.8; }
.future-row td { font-style: italic; font-size: .82em; }

.future-invalid-row td { color: var(--text-muted) !important; }
.future-invalid { color: var(--text-muted) !important; font-weight: 400 !important; }

.badge-future-buy {
    background: rgba(0, 184, 148, .10);
    color: rgba(0, 184, 148, .7);
    border: 1px dashed rgba(0, 184, 148, .3);
}
.badge-future-sell {
    background: rgba(255, 118, 117, .10);
    color: rgba(255, 118, 117, .7);
    border: 1px dashed rgba(255, 118, 117, .3);
}

/* ── Future Preview Boxes (in trade forms) ────────────────── */

.future-preview {
    margin: .75rem 0;
    padding: .65rem .85rem;
    background: rgba(162, 155, 254, .06);
    border: 1px dashed rgba(162, 155, 254, .25);
    border-radius: var(--radius);
    animation: fadeInUp .25s ease both;
    transition: border-color .3s ease, background .3s ease;
}

.future-preview:hover {
    border-color: rgba(162, 155, 254, .4);
    background: rgba(162, 155, 254, .09);
}

.future-preview-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #a29bfe;
    margin-bottom: .4rem;
}

.future-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .15rem 0;
    font-size: .82rem;
}

.future-preview-row .label {
    color: var(--text-muted);
    font-size: .78rem;
}

.future-preview-row .val {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: color .3s ease;
}

/* ── Tx History ───────────────────────────────────────────── */

.tx-history { margin-bottom: 2rem; animation: fadeInUp .5s ease .3s both; }
.tx-history h2 { font-size: 1.1rem; margin-bottom: .75rem; font-weight: 600; }

/* ── Market Data ──────────────────────────────────────────── */

.market-data-section {
    margin-bottom: 1.5rem;
}

.market-data-section h2 {
    font-size: 1.1rem; margin-bottom: .75rem; font-weight: 600;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .6rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
}

.market-item {
    padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.market-item:hover {
    background: rgba(124,106,239,.06);
    transform: translateY(-1px);
}

.market-item .label {
    display: block;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.market-item .val {
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: .15rem;
    display: block;
    font-variant-numeric: tabular-nums;
}

/* ── Rank Badge ───────────────────────────────────────────── */

.rank-badge {
    background: rgba(255,192,72,.12);
    color: var(--yellow);
    padding: .15rem .55rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 700;
    border: 1px solid rgba(255,192,72,.2);
    margin-right: .3rem;
}

/* ── P/L Analytics ────────────────────────────────────────── */

.pl-analytics {
    margin-bottom: 2rem;
}

.pl-analytics h2 {
    font-size: 1.1rem; margin-bottom: .75rem; font-weight: 600;
}

.graph-container {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    overflow: visible;
    position: relative;
    transition: border-color .3s ease, box-shadow .3s ease;
}

.graph-container:hover {
    border-color: rgba(108,92,231,.25);
    box-shadow: 0 0 24px rgba(108,92,231,.08);
}

.graph-container canvas {
    display: block;
    width: 100%;
}

/* ── Graph Tooltip ────────────────────────────────────────── */

.graph-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    background: rgba(24, 26, 39, 0.5);
    border: 1px solid rgba(108,92,231,.25);
    border-radius: 10px;
    padding: .6rem .8rem;
    min-width: 155px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2), 0 0 0 1px rgba(108,92,231,.06);
    opacity: 0;
    transform: translateY(4px) scale(.96);
    transition: opacity .15s ease, transform .15s ease;
    font-size: .78rem;
    line-height: 1.4;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.graph-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.graph-tooltip-date {
    color: var(--text-muted, #9ca3b8);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .35rem;
    padding-bottom: .3rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    white-space: nowrap;
}

.theme-light .graph-tooltip {
    background: rgba(255, 255, 255, 0.56);
    border-color: rgba(108, 92, 231, .2);
    box-shadow: 0 8px 24px rgba(0,0,0,.08), 0 0 0 1px rgba(108,92,231,.06);
}

.theme-light .graph-tooltip-date,
.theme-light .graph-tooltip-label {
    color: #4f566f;
}

.theme-light .graph-tooltip-date {
    border-bottom-color: rgba(0,0,0,.08);
}

.graph-tooltip-rows {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.graph-tooltip-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}

.graph-tooltip-swatch {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.graph-tooltip-label {
    color: var(--text-muted, #9ca3b8);
    font-size: .72rem;
    flex: 1;
}

.graph-tooltip-val {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: .78rem;
}

.graph-tooltip-val.profit { color: #00b894; }
.graph-tooltip-val.loss   { color: #ff6b6b; }

.graph-tooltip-badge {
    margin-top: .3rem;
    padding: .1rem .45rem;
    border-radius: 4px;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: center;
}

.badge-now-tip {
    background: rgba(108,92,231,.18);
    color: #a29bfe;
}

.badge-future-tip {
    background: rgba(162,155,254,.12);
    color: #a29bfe;
}

/* ── Graph Selection Rectangle ───────────────────────────── */

.graph-sel-rect {
    display: none;
    position: absolute;
    border: 2px dashed rgba(108,92,231,.7);
    background: rgba(108,92,231,.08);
    border-radius: 4px;
    pointer-events: none;
    z-index: 25;
    box-shadow: 0 0 12px rgba(108,92,231,.15);
}
.graph-sel-rect.active {
    display: block;
}
.graph-container.selecting {
    cursor: crosshair !important;
}
.graph-container.selecting canvas {
    cursor: crosshair !important;
}

/* ── Screenshot Modal ────────────────────────────────────── */

.graph-screenshot-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,.72);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s ease;
}
.graph-screenshot-overlay.visible {
    opacity: 1;
}
.graph-screenshot-modal {
    position: relative;
    background: var(--bg-card-solid, #181a27);
    border: 1px solid rgba(108,92,231,.2);
    border-radius: 14px;
    padding: 0;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.5), 0 0 0 1px rgba(108,92,231,.1);
    overflow: hidden;
}
.graph-screenshot-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1rem;
    background: rgba(255,255,255,.03);
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.graph-screenshot-toolbar .ss-title {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-main, #e4e7ef);
    margin-right: auto;
    letter-spacing: .02em;
}
.graph-screenshot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    padding: .35rem .65rem;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.04);
    color: var(--text-muted, #9ca3b8);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    user-select: none;
}
.graph-screenshot-btn:hover {
    background: rgba(108,92,231,.15);
    color: #a29bfe;
    border-color: rgba(108,92,231,.3);
}
.graph-screenshot-btn.primary {
    background: rgba(108,92,231,.18);
    color: #a29bfe;
    border-color: rgba(108,92,231,.3);
}
.graph-screenshot-btn.primary:hover {
    background: rgba(108,92,231,.3);
    color: #c4b5fd;
}
.graph-screenshot-btn.close-btn {
    padding: .3rem .45rem;
    font-size: .9rem;
    line-height: 1;
}
.graph-screenshot-viewport {
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    min-height: 180px;
    max-height: calc(90vh - 52px);
    cursor: grab;
    touch-action: none;
    background: repeating-conic-gradient(rgba(255,255,255,.02) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}
.graph-screenshot-viewport:active {
    cursor: grabbing;
}
.graph-screenshot-viewport.panning {
    cursor: grabbing;
}
.graph-screenshot-viewport img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0,0,0,.3);
    transition: transform .2s ease;
    transform-origin: center center;
    image-rendering: auto;
}
.graph-screenshot-zoom-info {
    font-size: .68rem;
    color: var(--text-muted, #9ca3b8);
    font-variant-numeric: tabular-nums;
    min-width: 3.5em;
    text-align: center;
}

/* ── Graph Legend (interactive) ───────────────────────────── */

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .9rem;
    padding: .5rem .3rem 0;
    justify-content: center;
}

.graph-legend-item {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-muted, #9ca3b8);
    cursor: pointer;
    padding: .2rem .5rem;
    border-radius: 4px;
    user-select: none;
    transition: opacity .2s ease, background .15s ease;
}

.graph-legend-item:hover {
    background: rgba(162, 155, 254, .08);
}

.graph-legend-item.disabled {
    opacity: .35;
    text-decoration: line-through;
}

.graph-legend-swatch {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.analytics-table th,
.analytics-table td {
    font-size: .78rem;
    padding: .6rem .7rem;
}

/* ── Danger Zone ──────────────────────────────────────────── */

.danger-zone {
    text-align: right; margin-bottom: 2rem; padding-top: 1rem;
    border-top: 1px solid var(--border);
    animation: fadeIn .5s ease .35s both;
}

/* ── Search Loading / Spinner ─────────────────────────────── */

.search-loading {
    padding: 1.2rem; text-align: center; color: var(--text-muted); font-size: .85rem;
    display: flex; align-items: center; justify-content: center; gap: .5rem;
}

.search-loading::before {
    content: ''; width: 16px; height: 16px;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinFade .8s linear infinite;
}

.search-no-results {
    padding: 1.2rem; text-align: center; color: var(--text-muted); font-size: .85rem;
}

/* ── Skeleton loading ─────────────────────────────────────── */

.loading-skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, rgba(255,255,255,.04) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
    min-height: 20px;
}

.loading-inline {
    display: inline-block;
    min-width: 48px;
    min-height: 1em;
    vertical-align: middle;
    color: transparent;
    user-select: none;
}

/* ── Tooltip ──────────────────────────────────────────────── */

[data-tooltip] { position: relative; }

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%) scale(.9);
    background: var(--bg-card-solid); border: 1px solid var(--border);
    color: var(--text); padding: .3rem .6rem;
    font-size: .75rem; border-radius: var(--radius-sm);
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: all var(--transition);
    box-shadow: var(--shadow);
    z-index: 200;
}

[data-tooltip]:hover::after {
    opacity: 1; transform: translateX(-50%) scale(1);
}

/* ── Scrollbar ────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 700px) {
    .navbar { padding: .7rem 1rem; }
    .container { padding: 1rem 1rem 2rem; }
    .portfolio-summary { grid-template-columns: 1fr 1fr; }
    .trade-forms { grid-template-columns: 1fr; }
    .pl-cards { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
    .market-grid { grid-template-columns: 1fr 1fr; }
    .auth-card { padding: 2rem 1.5rem; }
    .source-indicator { display: none; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .portfolio-summary { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .market-grid { grid-template-columns: 1fr; }
    .navbar { flex-wrap: wrap; gap: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Light Theme ───────────────────────────────────────────── */

.theme-light {
    --bg:          #f0f2f5;
    --bg-card:     rgba(255,255,255,.92);
    --bg-card-solid: #ffffff;
    --bg-input:    #e9ecf0;
    --border:      rgba(0,0,0,.08);
    --border-hover:rgba(0,0,0,.15);
    --text:        #1a1d2e;
    --text-muted:  #6b7084;
    --primary:     #6c5ce7;
    --primary-h:   #7e6ff0;
    --primary-glow:rgba(108,92,231,.18);
    --green:       #00b894;
    --green-bg:    rgba(0,184,148,.10);
    --green-glow:  rgba(0,184,148,.18);
    --red:         #e74c5c;
    --red-bg:      rgba(231,76,92,.10);
    --red-glow:    rgba(231,76,92,.18);
    --yellow:      #f0a030;
    --shadow:      0 4px 24px rgba(0,0,0,.08);
    --shadow-lg:   0 8px 40px rgba(0,0,0,.12);
    color-scheme: light;
}

.theme-light {
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108,92,231,.06) 0%, transparent 100%);
}

.theme-light .navbar {
    background: rgba(255,255,255,.92);
    border-bottom-color: rgba(0,0,0,.06);
}

.theme-light .search-results,
.theme-light .search-result-item {
    background: #fff;
}
.theme-light .search-result-item:hover { background: #f4f5f8; }
.theme-light .search-result-item .coin-name { color: #1a1d2e; }
.theme-light .search-result-item .coin-symbol { color: #6b7084; }
.theme-light .search-results {
    border-color: rgba(108,92,231,.25);
    box-shadow: 0 12px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
}

.theme-light .user-menu { background: #fff; }
.theme-light .user-menu-item:hover { background: rgba(108,92,231,.06); }

.theme-light .modal { background: #fff; }

.theme-light .precision-slider { background: #dde0e6; border-color: rgba(0,0,0,.1); }

.theme-light ::selection { background: var(--primary); color: #fff; }

.theme-light .brand-icon { color: var(--primary); }

.theme-light ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); }
.theme-light ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }

/* ── Print ────────────────────────────────────────────────── */

@media print {
    .navbar, .btn, .search-wrapper, .trade-forms, .danger-zone { display: none !important; }
    body { background: #fff; color: #000; }
    .summary-card, .pl-card, .holdings-info { border: 1px solid #ddd; background: #fff; }
    .profit { color: #008040 !important; }
    .loss   { color: #cc0000 !important; }
}
