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

html, body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #020617;
    color: #e5e7eb;
}

/* Auth layout */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 16px;
}

.auth-card {
    background: #020617;
    border-radius: 12px;
    padding: 24px 24px 28px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65);
    border: 1px solid #1f2937;
}

.auth-title {
    font-size: 1.5rem;
    margin-bottom: 4px;
    color: #f9fafb;
}

.auth-subtitle {
    font-size: 0.93rem;
    color: #9ca3af;
    margin-bottom: 20px;
}

.auth-footer-text {
    margin-top: 16px;
    font-size: 0.9rem;
    color: #9ca3af;
    text-align: center;
}

.auth-footer-text a {
    color: #38bdf8;
    text-decoration: none;
}

/* Forms */

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #e5e7eb;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 11px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #020617;
    color: #e5e7eb;
    font-size: 0.95rem;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #38bdf8;
}

/* Buttons */

.btn {
    display: inline-block;
    border-radius: 999px;
    border: none;
    padding: 9px 18px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #022c22;
    box-shadow: 0 12px 30px rgba(34, 197, 94, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.02);
}

.btn-block {
    width: 100%;
}

.btn-ghost {
    border: 1px solid #4b5563;
    background: transparent;
    color: #e5e7eb;
    padding-inline: 14px;
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.08);
}

/* CALL / PUT buttons */

.btn-call {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #022c22;
    box-shadow: 0 12px 30px rgba(34, 197, 94, 0.35);
}

.btn-call:hover {
    filter: brightness(1.04);
}

.btn-put {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fee2e2;
    box-shadow: 0 12px 30px rgba(248, 113, 113, 0.35);
}

.btn-put:hover {
    filter: brightness(1.04);
}

/* Alerts */

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 14px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.09);
    border: 1px solid rgba(248, 113, 113, 0.7);
    color: #fecaca;
}

.alert-success {
    background: rgba(34, 197, 94, 0.09);
    border: 1px solid rgba(52, 211, 153, 0.7);
    color: #bbf7d0;
}

/* Main app layout */

.layout {
    display: flex;
    min-height: 100vh;
    background: #020617;
}

.sidebar {
    width: 240px;
    background: radial-gradient(circle at top left, #020617 0, #020617 35%, #020617 100%);
    border-right: 1px solid #111827;
    padding: 18px 16px;
}

.sidebar-section {
    margin-bottom: 18px;
}

.sidebar-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 9px;
}

.sidebar-link {
    display: block;
    padding: 8px 9px;
    border-radius: 8px;
    text-decoration: none;
    color: #e5e7eb;
    font-size: 0.9rem;
    margin-bottom: 4px;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-link:hover {
    background: #0b1120;
}

.sidebar-link-active {
    background: linear-gradient(135deg, #0f172a, #020617);
    border: 1px solid #1f2937;
}

/* Main area */

.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid #111827;
    background: #020617;
}

.brand {
    font-weight: 700;
    margin-right: 10px;
}

.topbar-section {
    font-size: 0.9rem;
    color: #9ca3af;
}

.topbar-user {
    font-size: 0.9rem;
    margin-right: 12px;
    color: #9ca3af;
}

.layout-content {
    padding: 20px 18px;
}

/* Topbar balances */

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-balances {
    display: flex;
    align-items: center;
    gap: 6px;
}

.balance-tag {
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #020617;
    white-space: nowrap;
}

.balance-tag-live {
    border-color: rgba(34, 197, 94, 0.7);
}

.balance-tag-demo {
    border-color: rgba(56, 189, 248, 0.7);
}

/* Cards and grids */

.card {
    background: #020617;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #111827;
}

.card h2 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.card p {
    font-size: 0.92rem;
    color: #9ca3af;
}

.grid {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Tables */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #111827;
    white-space: nowrap;
}

.table th {
    text-align: left;
    font-weight: 600;
    color: #9ca3af;
}

.table tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.6);
}

/* OTC helpers */

.iqfx-help {
    display: block;
    margin-top: 3px;
    font-size: 0.8rem;
    color: #9ca3af;
}

.iqfx-button-group {
    display: flex;
    gap: 8px;
}

.iqfx-toggle-button {
    flex: 1;
    border-radius: 999px;
    border: 1px solid #334155;
    padding: 5px 10px;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #020617;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.iqfx-toggle-button input {
    display: none;
}

.iqfx-toggle-button span {
    color: #e5e7eb;
}

.iqfx-toggle-button:hover {
    border-color: #38bdf8;
}

/* Active state for toggles (via JS) */
.iqfx-toggle-active {
    background: #0f172a;
    border-color: #38bdf8;
}

/* Range pills, KPI cards, badges, P&L colors */

.range-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #334155;
    font-size: 0.85rem;
    text-decoration: none;
    color: #e5e7eb;
}

.range-pill:hover {
    background: #020617;
    border-color: #38bdf8;
}

.range-pill-active {
    background: #0f172a;
    border-color: #38bdf8;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: #f9fafb;
}

.kpi-sub {
    font-size: 0.82rem;
    color: #9ca3af;
}

.pnl-positive {
    color: #4ade80;
}

.pnl-negative {
    color: #f97373;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    border: 1px solid transparent;
}

.badge-green {
    border-color: rgba(34, 197, 94, 0.7);
    background: rgba(22, 163, 74, 0.18);
    color: #bbf7d0;
}

.badge-gray {
    border-color: rgba(107, 114, 128, 0.7);
    background: rgba(31, 41, 55, 0.7);
    color: #e5e7eb;
}

.badge-blue {
    border-color: rgba(56, 189, 248, 0.7);
    background: rgba(15, 23, 42, 0.8);
    color: #bae6fd;
}

/* Trading layout (chart left, ticket right) */

.trading-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.3fr) minmax(320px, 1.1fr);
    gap: 16px;
    margin-top: 12px;
}

.trading-left,
.trading-right {
    min-width: 0;
}

.trading-chart-card {
    display: flex;
    flex-direction: column;
    min-height: 360px;
}

.trading-chart-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.trading-chart-header > div {
    min-width: 0;
}

.trading-chart-body {
    flex: 1;
    margin-top: 4px;
    border-radius: 10px;
    border: 1px solid #111827;
    background: radial-gradient(circle at 10% 20%, #020617, #020617 35%, #020617 100%);
    padding: 0;
    overflow: hidden;
}

.chart-shell {
    width: 100%;
    height: 100%;
}

#otcChartCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.trading-ticket-card {
    margin-bottom: 12px;
}

.trading-ticket-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 12px;
}

.trading-ticket-actions {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trading-submit-button {
    margin-top: 4px;
}

.trading-open-positions h2 {
    margin-bottom: 2px;
}

.trading-wallet-summary {
    align-items: flex-start;
}

.trading-funding-links {
    align-self: center;
}

/* Small tweaks */

a {
    color: inherit;
}

a:hover {
    color: inherit;
}

/* Responsive */

@media (max-width: 1024px) {
    .trading-layout {
        grid-template-columns: 1fr;
    }

    .trading-chart-card {
        min-height: 280px;
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        display: flex;
        overflow-x: auto;
    }

    .sidebar-link {
        margin-right: 8px;
        white-space: nowrap;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }
}
otc-timeframe-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.otc-tf-btn {
    border: none;
    outline: none;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: transparent;
    color: rgba(148, 163, 184, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
}

.otc-tf-btn:hover {
    background: rgba(148, 163, 184, 0.15);
    color: #e5e7eb;
}

.otc-tf-btn.active {
    background: linear-gradient(90deg, #06b6d4, #a855f7);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.otc-timeframe-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    font-size: 11px;
}

.otc-tf-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.otc-tf-btn {
    border: none;
    outline: none;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: transparent;
    color: rgba(148, 163, 184, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
}

.otc-tf-btn:hover {
    background: rgba(148, 163, 184, 0.15);
    color: #e5e7eb;
}

.otc-tf-btn.active {
    background: linear-gradient(90deg, #06b6d4, #a855f7);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.otc-zoom-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.otc-zoom-label {
    color: rgba(148, 163, 184, 0.9);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.otc-zoom-btn {
    border: none;
    outline: none;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 1);
    color: #e5e7eb;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.otc-zoom-btn:hover {
    background: rgba(148, 163, 184, 0.25);
}