/* ============================================
   SimulaBolsa — Dark Trading Theme
   ============================================ */

/* ---------- Variables ---------- */
:root {
    --bg-primary:   #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary:  #21262d;
    --bg-card:      #1c2128;
    --bg-hover:     #262c36;
    --bg-input:     #0d1117;

    --border:       #30363d;
    --border-light: #21262d;

    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --text-muted:     #6e7681;

    --accent:       #58a6ff;
    --accent-hover: #79c0ff;
    --green:        #3fb950;
    --green-bg:     rgba(63,185,80,0.12);
    --red:          #f85149;
    --red-bg:       rgba(248,81,73,0.12);
    --yellow:       #d29922;
    --yellow-bg:    rgba(210,153,34,0.12);
    --purple:       #bc8cff;

    --radius:       8px;
    --radius-lg:    12px;
    --radius-xl:    16px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.3);

    --sidebar-width: 240px;
    --header-height: 64px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

input, select, button, textarea { font-family: inherit; font-size: inherit; }

::-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); }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-secondary); }
.text-mono { font-family: var(--mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }

/* ---------- Modal Overlay ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.15s;
    z-index: 10;
}
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* ---------- Onboarding ---------- */
.onboarding-modal {
    width: 420px;
    padding: 48px 40px;
    text-align: center;
}
.onboarding-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}
.onboarding-logo h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.onboarding-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}
.onboarding-disclaimer {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 24px;
}

/* ---------- Form Elements ---------- */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}
input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}
input::placeholder { color: var(--text-muted); }

.input-password-wrapper {
    position: relative;
}
.input-password-wrapper input { padding-right: 44px; }
.btn-toggle-pw {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.5;
    padding: 4px;
}
.btn-toggle-pw:hover { opacity: 0.9; }

.password-strength {
    height: 4px;
    border-radius: 2px;
    margin-top: 8px;
    background: var(--border);
    overflow: hidden;
}
.password-strength .pw-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

.form-row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 13px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}
.auth-link {
    color: var(--accent);
    font-size: 13px;
}
.auth-link:hover { text-decoration: underline; }

.form-error {
    color: var(--red);
    font-size: 12px;
    margin-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-green {
    background: var(--green);
    color: #fff;
}
.btn-green:hover:not(:disabled) { background: #46d15a; }

.btn-red {
    background: var(--red);
    color: #fff;
}
.btn-red:hover:not(:disabled) { background: #ff6961; }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg-tertiary); border-color: var(--text-muted); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 12px;
    font-size: 12px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; width: 100%; }
.btn-xl { padding: 16px 36px; font-size: 17px; font-weight: 700; }

.btn-accent-gradient {
    background: linear-gradient(135deg, #58a6ff, #3fb950);
    color: #fff;
    border: none;
    box-shadow: 0 4px 20px rgba(88,166,255,0.25);
}
.btn-accent-gradient:hover:not(:disabled) {
    box-shadow: 0 6px 30px rgba(88,166,255,0.4);
    transform: translateY(-1px);
}

.btn-outline-light {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-primary);
}
.btn-outline-light:hover {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.05);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* ---------- App Layout ---------- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 100;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.sidebar-logo span {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.15s;
}
.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.nav-item.active {
    background: rgba(88,166,255,0.1);
    color: var(--accent);
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.market-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.status-dot.open { background: var(--green); box-shadow: 0 0 6px rgba(63,185,80,0.5); }
.status-dot.closed { background: var(--red); }

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.main-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-left h1 {
    font-size: 18px;
    font-weight: 700;
}
#sidebar-toggle { display: none; }

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.balance-display {
    text-align: right;
}
.balance-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.balance-value {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--green);
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ---------- Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--mono);
}
.stat-card .stat-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

/* ---------- Sections ---------- */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
}
.section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.section-header h2 {
    font-size: 15px;
    font-weight: 600;
}
.section-body {
    padding: 0;
}
.section-body.padded { padding: 20px; }

/* ---------- Tables ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.data-table th:hover { color: var(--text-secondary); }
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .ticker {
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
}
.data-table .ticker:hover { text-decoration: underline; }
.data-table .stock-name {
    color: var(--text-secondary);
    font-size: 12px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-table .price {
    font-family: var(--mono);
    font-weight: 500;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-sector {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: var(--font);
    font-weight: 500;
    font-size: 11px;
}

/* ---------- Search Bar ---------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.search-input-wrapper {
    flex: 1;
    position: relative;
}
.search-input-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.1);
}
.search-input::placeholder { color: var(--text-muted); }

.filter-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.chip:hover { border-color: var(--text-muted); color: var(--text-primary); }
.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ---------- Stock Detail Modal ---------- */
.stock-detail-modal {
    width: 600px;
    max-width: 95vw;
    padding: 32px;
}
.stock-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}
.stock-detail-header .stock-info h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.stock-detail-header .stock-info .stock-fullname {
    color: var(--text-secondary);
    font-size: 13px;
}
.stock-price-big {
    text-align: right;
}
.stock-price-big .price {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--mono);
}
.stock-price-big .change {
    font-size: 14px;
    font-weight: 600;
}

.stock-chart-container {
    height: 200px;
    margin-bottom: 24px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 12px;
}
.stock-chart-container canvas { width: 100% !important; height: 100% !important; }

.stock-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.metric {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius);
    text-align: center;
}
.metric .metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.metric .metric-value {
    font-size: 15px;
    font-weight: 600;
    font-family: var(--mono);
    margin-top: 4px;
}

/* ---------- Trade Form ---------- */
.trade-tabs {
    display: flex;
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.trade-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.trade-tab:first-child { border-right: 1px solid var(--border); }
.trade-tab.active-buy {
    background: var(--green-bg);
    color: var(--green);
}
.trade-tab.active-sell {
    background: var(--red-bg);
    color: var(--red);
}

.trade-form { margin-top: 16px; }
.trade-form .form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.trade-form .form-row label {
    font-size: 13px;
    color: var(--text-secondary);
}
.trade-form .qty-input {
    display: flex;
    align-items: center;
    gap: 0;
}
.trade-form .qty-input input {
    width: 80px;
    text-align: center;
    border-radius: 0;
    border-left: none;
    border-right: none;
}
.trade-form .qty-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: background 0.15s;
}
.trade-form .qty-btn:hover { background: var(--bg-hover); }
.trade-form .qty-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.trade-form .qty-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.trade-form .total-line {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    font-weight: 600;
}
.trade-form .total-value {
    font-family: var(--mono);
    font-size: 16px;
}

.position-info {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

/* ---------- Watchlist ---------- */
.watchlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}
.watchlist-item:hover { background: var(--bg-hover); }
.watchlist-item:last-child { border-bottom: none; }
.watchlist-item .wl-ticker {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent);
    min-width: 60px;
}
.watchlist-item .wl-name {
    color: var(--text-secondary);
    font-size: 12px;
    flex: 1;
    margin: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.watchlist-item .wl-price {
    font-family: var(--mono);
    font-weight: 500;
    min-width: 80px;
    text-align: right;
}
.watchlist-item .wl-change {
    min-width: 70px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
}

/* Price flash animation */
@keyframes flashGreen {
    0% { background: transparent; }
    50% { background: var(--green-bg); }
    100% { background: transparent; }
}
@keyframes flashRed {
    0% { background: transparent; }
    50% { background: var(--red-bg); }
    100% { background: transparent; }
}
.flash-green { animation: flashGreen 0.6s ease; }
.flash-red { animation: flashRed 0.6s ease; }

/* ---------- Portfolio Charts ---------- */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}
.chart-card canvas {
    max-height: 220px;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* ---------- Toast ---------- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ---------- Confirm Modal ---------- */
.confirm-modal {
    width: 380px;
    padding: 32px;
    text-align: center;
}
.confirm-modal h3 { margin-bottom: 12px; font-size: 18px; }
.confirm-modal p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.confirm-modal .confirm-actions { display: flex; gap: 12px; }
.confirm-modal .confirm-actions .btn { flex: 1; }

/* ---------- Loading ---------- */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Add to Watchlist ---------- */
.btn-watchlist {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 4px 8px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.15s;
}
.btn-watchlist:hover { border-color: var(--yellow); color: var(--yellow); }
.btn-watchlist.active { color: var(--yellow); border-color: var(--yellow); }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 0;
}
.pagination .btn { min-width: 36px; padding: 6px 10px; }
.pagination .page-info { font-size: 13px; color: var(--text-secondary); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    #sidebar-toggle { display: flex; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .charts-row { grid-template-columns: 1fr; }
    .stock-metrics { grid-template-columns: 1fr 1fr; }

    .main-header { padding: 0 16px; }
    .content-area { padding: 16px; }

    .header-right .balance-display { display: none; }
    .onboarding-modal { padding: 32px 24px; width: 95vw; }
    .filter-chips { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stock-detail-modal { padding: 20px; }
}

/* ============================================
   LANDING PAGE — Inspired by SmartCodex
   ============================================ */
.landing-page {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    scroll-behavior: smooth;
}

.gradient-text {
    background: linear-gradient(135deg, #58a6ff, #3fb950);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---- Navbar ---- */
.lp-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: rgba(13,17,23,0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.lp-navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}
.lp-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    color: var(--text-primary);
}
.lp-brand:hover { color: var(--text-primary); }
.lp-nav-links {
    display: flex;
    gap: 32px;
}
.lp-nav-links a {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s;
}
.lp-nav-links a:hover { color: var(--text-primary); }
.lp-nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.lp-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}
.lp-hamburger span {
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.3s;
}
.lp-mobile-menu {
    display: none;
    flex-direction: column;
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border);
    gap: 12px;
}
.lp-mobile-menu a {
    color: var(--text-secondary);
    font-size: 15px;
    padding: 8px 0;
}
.lp-mobile-menu hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}
.lp-mobile-menu.open { display: flex; }

/* ---- Hero ---- */
.lp-hero {
    padding: 140px 0 80px;
    position: relative;
    overflow: hidden;
}
.lp-hero-glow {
    position: absolute;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(88,166,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.lp-hero-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}
.lp-hero-content { z-index: 1; }
.lp-tag {
    display: inline-block;
    background: rgba(88,166,255,0.1);
    border: 1px solid rgba(88,166,255,0.2);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    margin-bottom: 24px;
    letter-spacing: 0.3px;
}
.lp-hero-content h1 {
    font-size: 48px;
    font-weight: 900;
    line-height: 1.12;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}
.lp-hero-sub {
    font-size: 17px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 32px;
    max-width: 520px;
}
.lp-hero-ctas {
    display: flex;
    gap: 16px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}
.lp-hero-stats {
    display: flex;
    gap: 40px;
}
.lp-stat {
    display: flex;
    flex-direction: column;
}
.lp-stat strong {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #58a6ff, #3fb950);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.lp-stat span {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Mock dashboard */
.lp-hero-visual {
    display: flex;
    justify-content: center;
    z-index: 1;
}
.lp-mock-dashboard {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow), 0 0 60px rgba(88,166,255,0.06);
    width: 100%;
    max-width: 500px;
    overflow: hidden;
}
.lp-mock-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}
.lp-mock-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.lp-mock-dot.green { background: #3fb950; }
.lp-mock-dot.yellow { background: #d29922; }
.lp-mock-dot.red { background: #f85149; }
.lp-mock-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}
.lp-mock-body { padding: 16px; }
.lp-mock-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.lp-mock-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lp-mock-card small { font-size: 11px; color: var(--text-muted); }
.lp-mock-card strong { font-size: 17px; font-family: var(--mono); }
.lp-mock-chart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 8px 4px;
    margin-bottom: 12px;
}
.lp-chart-svg { width: 100%; height: auto; }
.lp-mock-tickers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.lp-mock-ticker {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
}

/* ---- Trust bar ---- */
.lp-trust {
    padding: 40px 0;
    border-bottom: 1px solid var(--border);
}
.lp-trust-label {
    text-align: center;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.lp-trust-logos {
    display: flex;
    justify-content: center;
    gap: 48px;
    flex-wrap: wrap;
}
.lp-trust-item {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    opacity: 0.6;
}

/* ---- Sections ---- */
.lp-section {
    padding: 100px 0;
}
.lp-section-alt {
    background: var(--bg-secondary);
}
.lp-section-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
    margin-bottom: 16px;
}
.lp-section-title {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
    max-width: 650px;
}
.lp-section-sub {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.7;
    max-width: 600px;
    margin-bottom: 48px;
}

/* Features grid */
.lp-features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.lp-feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    transition: all 0.3s;
}
.lp-feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.lp-feature-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.lp-feature-icon.green  { background: rgba(63,185,80,0.12); color: var(--green); }
.lp-feature-icon.blue   { background: rgba(88,166,255,0.12); color: var(--accent); }
.lp-feature-icon.purple { background: rgba(188,140,255,0.12); color: var(--purple); }
.lp-feature-icon.yellow { background: rgba(210,153,34,0.12); color: var(--yellow); }
.lp-feature-icon.red    { background: rgba(248,81,73,0.12); color: var(--red); }
.lp-feature-icon.cyan   { background: rgba(88,166,255,0.12); color: #56d4dd; }
.lp-feature-card h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 10px;
}
.lp-feature-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* Steps */
.lp-steps {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    justify-content: center;
    margin-top: 48px;
}
.lp-step {
    flex: 1;
    max-width: 300px;
    text-align: center;
    padding: 32px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.lp-step-number {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #58a6ff, #3fb950);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
.lp-step h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 10px;
}
.lp-step p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}
.lp-step-arrow {
    font-size: 28px;
    color: var(--text-muted);
    margin-top: 60px;
    flex-shrink: 0;
}

/* Benefits */
.lp-benefits-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}
.lp-benefit {
    padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.3s;
}
.lp-benefit:hover { border-color: var(--accent); }
.lp-benefit-num {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, #58a6ff, #3fb950);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    display: block;
}
.lp-benefit h4 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
}
.lp-benefit p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* FAQ */
.lp-faq-list {
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 40px;
}
.lp-faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.lp-faq-item summary {
    padding: 18px 24px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color 0.15s;
}
.lp-faq-item summary::-webkit-details-marker { display: none; }
.lp-faq-item summary::after {
    content: '+';
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.3s;
}
.lp-faq-item[open] summary::after {
    transform: rotate(45deg);
    color: var(--accent);
}
.lp-faq-item summary:hover { color: var(--accent); }
.lp-faq-item p {
    padding: 0 24px 18px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

/* CTA */
.lp-cta-section {
    padding: 100px 0;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-primary) 0%, rgba(88,166,255,0.04) 100%);
}
.lp-cta-inner h2 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 16px;
}
.lp-cta-inner p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 32px;
}

/* Footer */
.lp-footer {
    border-top: 1px solid var(--border);
    padding: 40px 0;
}
.lp-footer-inner {
    text-align: center;
}
.lp-footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
    font-weight: 700;
    font-size: 16px;
}
.lp-footer-text {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}
.lp-footer-copy {
    color: var(--text-muted);
    font-size: 12px;
    opacity: 0.6;
}

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-page {
    height: 100vh;
    overflow: hidden;
}
.auth-container {
    display: grid;
    grid-template-columns: 420px 1fr;
    height: 100%;
}

/* Left brand panel */
.auth-brand-panel {
    background: linear-gradient(160deg, #0d1117 0%, #101820 50%, #0a1628 100%);
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}
.auth-brand-panel::before {
    content: '';
    position: absolute;
    top: -100px;
    left: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(88,166,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.auth-brand-panel::after {
    content: '';
    position: absolute;
    bottom: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(63,185,80,0.06) 0%, transparent 70%);
    pointer-events: none;
}
.auth-brand-content {
    position: relative;
    z-index: 1;
}
.auth-brand-content svg { margin-bottom: 24px; }
.auth-brand-content h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #58a6ff, #3fb950);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-brand-content > p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 32px;
}
.auth-brand-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.auth-brand-feat {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}
.auth-brand-feat span {
    color: var(--green);
    font-weight: 700;
}

/* Right form panel */
.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow-y: auto;
}
.auth-back-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.auth-back-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.auth-form-wrapper {
    width: 100%;
    max-width: 420px;
}
.auth-form-wrapper h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 32px;
}
.auth-form {
    display: flex;
    flex-direction: column;
}
.auth-switch {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}
.auth-switch a {
    color: var(--accent);
    font-weight: 600;
}
.auth-switch a:hover { text-decoration: underline; }

/* ============================================
   SETTINGS SCREEN (change password)
   ============================================ */
.settings-section {
    max-width: 560px;
}
.settings-section .section-body.padded { padding: 24px; }
.settings-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}
.settings-field:last-child { border-bottom: none; }
.settings-field .sf-label {
    font-size: 13px;
    color: var(--text-secondary);
}
.settings-field .sf-value {
    font-size: 14px;
    font-weight: 500;
}

/* ---- Landing Responsive ---- */
@media (max-width: 1024px) {
    .lp-hero-inner { grid-template-columns: 1fr; gap: 40px; }
    .lp-hero-visual { display: none; }
    .lp-hero { padding: 120px 0 60px; }
    .lp-features-grid { grid-template-columns: 1fr 1fr; }
    .lp-steps { flex-direction: column; align-items: center; }
    .lp-step-arrow { transform: rotate(90deg); margin: 0; }
    .auth-container { grid-template-columns: 1fr; }
    .auth-brand-panel { display: none; }
}

@media (max-width: 768px) {
    .lp-nav-links, .lp-nav-actions { display: none; }
    .lp-hamburger { display: flex; }

    .lp-hero-content h1 { font-size: 32px; }
    .lp-hero-sub { font-size: 15px; }
    .lp-hero-stats { gap: 24px; flex-wrap: wrap; }
    .lp-hero-ctas .btn-xl { width: 100%; text-align: center; }

    .lp-section-title { font-size: 26px; }
    .lp-features-grid { grid-template-columns: 1fr; }
    .lp-benefits-grid { grid-template-columns: 1fr; }

    .lp-cta-inner h2 { font-size: 26px; }

    .auth-form-panel { padding: 24px; }
    .auth-form-wrapper h1 { font-size: 22px; }
}

/* ── Ranking ── */
.ranking-section { max-width: 800px; }
.ranking-section .section-header { display: flex; align-items: baseline; gap: 12px; }
.ranking-subtitle { font-size: 13px; color: var(--text-secondary); font-weight: 400; }

.ranking-rank-cell { width: 60px; text-align: center; }
.ranking-pos { font-weight: 700; color: var(--text-secondary); font-size: 15px; }
.ranking-medal { font-size: 20px; }

.ranking-user { display: flex; align-items: center; gap: 10px; }
.ranking-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg-tertiary); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.ranking-me { background: rgba(88,166,255,0.06); }
.ranking-me td { font-weight: 600; }
