:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-hover: #242938;
    --border: #2a3142;
    --text-primary: #f0f4f8;
    --text-secondary: #8b95a5;
    --text-muted: #5a6478;
    --accent: #00d4aa;
    --accent-dim: rgba(0, 212, 170, 0.15);
    --danger: #ff4757;
    --danger-dim: rgba(255, 71, 87, 0.15);
    --warning: #ffa502;
    --success: #2ed573;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Background atmosphere */
.bg-atmosphere {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 10%, rgba(0, 212, 170, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 90%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, #0d1220 100%);
}

.grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(42, 49, 66, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(42, 49, 66, 0.3) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse at center, black 0%, transparent 70%);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(0, 212, 170, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card-glow {
    position: relative;
}

.card-glow::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 17px;
    padding: 1px;
    background: linear-gradient(135deg, var(--accent), transparent 50%);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-glow:hover::before {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: #00e6b8;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 212, 170, 0.3);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-muted);
}

.btn-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-icon {
    padding: 10px;
    width: 40px;
    height: 40px;
}

/* Inputs */
.input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input::placeholder {
    color: var(--text-muted);
}

/* Select */
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238b95a5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Labels */
.label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 14px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-hover);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent);
    color: var(--bg-primary);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: rgba(46, 213, 115, 0.15);
    color: #2ed573;
}

.badge-danger {
    background: rgba(255, 71, 87, 0.15);
    color: #ff4757;
}

.badge-neutral {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* Stats */
.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.3s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.4s; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 10;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

/* Dashboard */
.dashboard {
    display: none;
    position: relative;
    z-index: 10;
}

.dashboard.active {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar.open {
    transform: translateX(0);
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 260px;
    }
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    border-radius: 12px;
    overflow: hidden;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-color: rgba(46, 213, 115, 0.3);
}

.toast.error {
    border-color: rgba(255, 71, 87, 0.3);
}

/* Asset list */
.asset-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.asset-item:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.asset-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* File drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* Loading */
.loading {
    display: inline-flex;
    gap: 4px;
}

.loading span {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading span:nth-child(1) { animation-delay: 0s; }
.loading span:nth-child(2) { animation-delay: 0.2s; }
.loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile menu button */
.mobile-menu-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 60;
    display: none;
}

@media (max-width: 1023px) {
    .mobile-menu-btn {
        display: flex;
    }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

/* Positive/Negative values */
.value-positive {
    color: var(--success);
}

.value-negative {
    color: var(--danger);
}

/* Period Filter Buttons */
.btn-period {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-period:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-period.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* Custom Chart Tooltip */
.chart-tooltip {
    position: absolute;
    display: none;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    pointer-events: none; /* Чтобы не мешал кликам */
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    transition: left 0.05s ease, top 0.05s ease;
}

/* Portfolio Snapshot Pills */
.snapshot-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.snapshot-pill:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.snapshot-pill .symbol {
    font-weight: 600;
    color: var(--accent);
}

.snapshot-pill .value {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
    font-size: 11px;
}

/* ===== What-If Plan Styles ===== */
.asset-item--plan {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.08), rgba(99, 102, 241, 0.06));
    border: 1px solid rgba(0, 212, 170, 0.35);
}

.asset-item--plan:hover {
    border-color: rgba(0, 212, 170, 0.6);
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.1);
}

.asset-item--plan-new {
    background: linear-gradient(135deg, rgba(201, 146, 42, 0.10), rgba(201, 146, 42, 0.04));
    border: 1px dashed rgba(201, 146, 42, 0.5);
}

.asset-item--plan-new:hover {
    border-color: rgba(201, 146, 42, 0.7);
    box-shadow: 0 0 20px rgba(201, 146, 42, 0.1);
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
}

.plan-badge--new {
    background: rgba(201, 146, 42, 0.15);
    color: #d4a52e;
}

.whatif-detail-block {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.06), rgba(99, 102, 241, 0.04));
    border: 1px solid rgba(0, 212, 170, 0.25);
    border-radius: 12px;
}

.whatif-detail-block__title {
    font-size: 12px;
    font-weight: 600;
    color: #00d4aa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.whatif-detail-block__row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.whatif-detail-block__row + .whatif-detail-block__row {
    border-top: 1px solid rgba(42, 49, 66, 0.5);
}

.whatif-detail-block__label {
    color: var(--text-muted);
}

.whatif-detail-block__value {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

/* Login Logo */
.login-logo {
    max-width: 280px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    /*box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background-color: rgba(255, 255, 255, 0.05);
    padding: 8px;
    object-fit: contain;*/
}

/* Sidebar Logo */
.sidebar-logo {
    max-width: 200px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    /*box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    background-color: rgba(255, 255, 255, 0.03);
    padding: 6px;
    object-fit: contain;*/
}

/* Mobile adjustments for logos */
@media (max-width: 640px) {
    .login-logo {
        max-width: 220px;
        padding: 6px;
    }
    .sidebar-logo {
        max-width: 160px;
        padding: 4px;
    }
}