:root {
    --bg-page:        rgb(18, 22, 28);
    --text-primary:   rgb(229, 231, 235);
    --text-muted:     #999;
    --section-color:  rgb(229, 231, 235);
    --box-border:     rgba(255, 255, 255, 0.10);
    --row-sep:        rgba(255, 255, 255, 0.10);
    --surface:        rgb(32, 38, 48);
    --text-axis:      rgb(146, 154, 165);
    --grid-line:      #323946;
    --tooltip-bg:     rgba(40, 40, 40, 0.95);
    --color-neg:      #f6465d;
    --color-pos:      #2ebd85;
    --color-strategy: #4a90e2;
    --color-btc:      #f97316;
    --color-usdt:     #8e44ad;
    --color-cdi:      #2ebd85;
    --color-subtitle: #06b6d4;
    --color-btc-soft: #fdba74;
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --- shared page components --- */

.neg { color: var(--color-neg); }
.pos { color: var(--color-pos); }

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    color: var(--section-color);
}

.last-update {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 0.4rem;
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(146, 154, 165, 0.25);
    color: var(--text-axis);
    border-radius: 50%;
    cursor: pointer;
    vertical-align: middle;
}

.help-icon:hover {
    background: rgba(146, 154, 165, 0.45);
    color: var(--text-primary);
}

.popover { font-size: 0.75rem; max-width: 280px; }
.popover-header { font-size: 0.8rem; font-weight: 600; }
.popover-body { line-height: 1.5; }

.chart-wrap { margin-bottom: 1rem; }

.chart-box {
    padding: 0.25rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--box-border);
}

.table-box {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--box-border);
    margin-bottom: 1rem;
    color: var(--text-axis);
}

.table-box table {
    margin-bottom: 0;
    --bs-table-bg: transparent;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
}

.table-box .table > :not(caption) > * > * { background-color: transparent; }

.table-box th {
    font-weight: 600;
    color: var(--text-axis);
    text-align: right;
}

.table-box th:first-child { text-align: left; }

.table-box td {
    text-align: right;
    color: var(--text-axis);
}

.table-box td:first-child { text-align: left; }
.table-box td.pos { color: var(--color-pos); }
.table-box td.neg { color: var(--color-neg); }

.table-box tbody td { border-bottom: 1px solid var(--row-sep); }
.table-box tbody tr:last-child td { border-bottom: none; }

.table-note { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }

/* --- Layout: topbar + sidebar blade --- */

.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(48px + env(safe-area-inset-top));
    z-index: 1045;
    background: var(--bg-page);
    border-bottom: 1px solid var(--box-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: env(safe-area-inset-top) calc(0.75rem + env(safe-area-inset-right)) 0 calc(0.75rem + env(safe-area-inset-left));
    transition: left 0.25s ease;
}

.hamburger-btn {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    box-sizing: content-box;
    width: 24px;
    height: 18px;
    flex: 0 0 24px;
    color: var(--text-primary);
}

.tog-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    flex: 0 0 2px;
}

.topbar-brand {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-strategy);
    text-decoration: none;
    letter-spacing: 0.03em;
}

.topbar-brand:hover {
    color: var(--color-strategy);
    text-decoration: none;
}

.brand-dot { color: var(--color-btc-soft); }

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.topbar-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.topbar-action:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-strategy);
    text-decoration: none;
}

.topbar-action-form {
    margin: 0;
    display: inline;
}

.topbar-action-install {
    background: rgba(56, 189, 248, 0.12);
    color: rgb(125, 211, 252);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.topbar-action-install:hover {
    background: rgba(56, 189, 248, 0.22);
    color: rgb(186, 230, 253);
}

.pwa-install-nav {
    display: inline-flex;
}

@media (max-width: 480px) {
    .topbar-action span {
        display: none;
    }
    .topbar-action {
        padding: 0.35rem;
    }
}
.brand-trade { color: var(--color-subtitle); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1039;
}

.app-sidebar {
    position: fixed;
    top: calc(48px + env(safe-area-inset-top));
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--box-border);
    z-index: 1040;
    transform: translateX(-260px);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
}

.page-wrap {
    padding-top: calc(48px + env(safe-area-inset-top));
    transition: margin-left 0.25s ease;
}

body.sidebar-open .app-sidebar {
    transform: translateX(0);
}

@media (max-width: 991.98px) {
    body.sidebar-open .sidebar-backdrop {
        display: block;
    }
}

@media (min-width: 992px) {
    .hamburger-btn {
        display: none;
    }

    .app-topbar {
        left: 260px;
        height: 48px;
        padding: 0 0.75rem;
    }

    .app-sidebar {
        top: 0;
        transform: translateX(0);
        padding-bottom: 0;
    }

    .page-wrap {
        margin-left: 260px;
        padding-top: 48px;
    }
}

/* --- Sidebar internals --- */

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--box-border);
    flex-shrink: 0;
}

.sidebar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--color-strategy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-action {
    font-size: 0.75rem;
    color: var(--color-strategy);
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.sidebar-user-action:hover {
    text-decoration: underline;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: var(--text-axis);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(74, 144, 226, 0.12);
    color: var(--color-strategy);
    font-weight: 600;
}

.sidebar-footer {
    flex-shrink: 0;
}


/* --- Auth pages --- */

.auth-page {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--box-border);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-strategy);
    text-align: center;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 1.25rem 0;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--box-border);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--box-border);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-google:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
}

/* --- App footer --- */

.app-footer {
    padding: 1.5rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--box-border);
    color: var(--text-muted);
    font-size: 0.78rem;
}

.app-footer p {
    margin: 0;
}

.app-footer .footer-contact {
    margin-top: 0.5rem;
}

.app-footer .footer-contact a {
    color: var(--color-strategy);
    text-decoration: none;
}

.app-footer .footer-contact a:hover {
    text-decoration: underline;
}

.app-footer .brand {
    font-weight: 700;
    color: var(--color-strategy);
}

.demo-banner {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.5rem 0.6rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    background: rgba(250, 204, 21, 0.10);
    border: 1px solid rgba(250, 204, 21, 0.30);
    border-left: 3px solid #facc15;
    font-size: 0.78rem;
    color: #facc15;
}

.demo-banner-title {
    display: block;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.demo-banner-text {
    color: var(--text-primary);
    font-size: 0.85rem;
}

.demo-banner-text a {
    color: #facc15;
    font-weight: 600;
    text-decoration: underline;
}
