/* ============================================
   Quotex Coin - Professional Mobile Trading App
   Mobile-First Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
    /* Stone fintech — calm, high contrast */
    --bg-app: #f5f5f4;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #fafaf9;
    --bg-elevated: #e7e5e4;
    --border: #e7e5e4;
    --border-light: #f5f5f4;

    --text-white: #334155;
    --text-primary: #334155;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-dim: #cbd5e1;

    /* Brand — deep teal (not black / not bright blue) */
    --accent: #0f766e;
    --accent-light: #14b8a6;
    --accent-dark: #115e59;
    --accent-glow: rgba(15, 118, 110, 0.2);
    --accent-bg: rgba(15, 118, 110, 0.08);

    --green: #059669;
    --green-dark: #047857;
    --green-glow: rgba(5, 150, 105, 0.2);
    --green-bg: rgba(5, 150, 105, 0.08);

    --red: #e11d48;
    --red-dark: #be123c;
    --red-glow: rgba(225, 29, 72, 0.2);
    --red-bg: rgba(225, 29, 72, 0.08);

    --blue: #44403c;
    --yellow: #d97706;
    --purple: #7c3aed;

    --glass: #ffffff;
    --glass-border: #e7e5e4;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.07);

    --radius: 8px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-max: 480px;
}

html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
    background: #ececec;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: var(--font);
    background: var(--bg-app);
    color: var(--text-primary);
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body.trading-app {
    height: 100dvh;
    overflow: hidden;
}

a { color: var(--accent-light); text-decoration: none; }

/* ============================================
   TRADING APP LAYOUT
   ============================================ */
.trading-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* === APP HEADER === */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    padding-top: calc(8px + var(--safe-top));
    background: linear-gradient(180deg, var(--bg-panel) 0%, rgba(10, 22, 40, 0.98) 100%);
    border-bottom: 1px solid var(--border);
    z-index: 10;
    flex-shrink: 0;
    min-height: 52px;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 4px; }

.app-logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 16px; color: #fff;
}

.header-balance {
    display: flex; flex-direction: column;
}
.bal-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.bal-amount { font-size: 16px; font-weight: 800; color: var(--text-primary); }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.icon-btn:active { background: var(--bg-card); }

/* === ASSET TABS === */
.asset-strip {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-panel);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.asset-strip::-webkit-scrollbar { display: none; }

.asset-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.asset-tab .tab-payout {
    font-size: 9px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 4px;
}

.asset-tab.active {
    background: var(--bg-panel);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.asset-tab.active .tab-payout {
    background: var(--bg-input);
    color: var(--text-secondary);
}

/* === CHART ZONE === */
.chart-zone {
    flex: 1 1 0;
    position: relative;
    background: var(--bg-app);
    overflow: hidden;
    min-height: 120px;
    max-height: 42vh;
}

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

/* Price Overlay */
.price-overlay {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-price {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: none;
    letter-spacing: -0.5px;
}

.price-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.price-badge.up {
    background: var(--green-bg);
    color: var(--green);
}
.price-badge.down {
    background: var(--red-bg);
    color: var(--red);
}

.change-arrow { font-size: 8px; }

/* Countdown Ring */
.countdown-ring-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    width: 120px;
    height: 120px;
}

.ring-svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 4;
}

.ring-progress {
    fill: none;
    stroke: var(--green);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 326.726;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.3s linear, stroke 0.3s;
    filter: drop-shadow(0 0 6px var(--green-glow));
}

.ring-progress.losing {
    stroke: var(--red);
    filter: drop-shadow(0 0 6px var(--red-glow));
}

.ring-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ring-seconds {
    font-size: 36px;
    font-weight: 900;
    color: var(--text-white);
    line-height: 1;
}

.ring-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* Result Splash */
.result-splash {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15;
    animation: splashIn 0.4s ease;
    backdrop-filter: blur(4px);
}

.result-splash.win { background: rgba(0, 212, 170, 0.12); }
.result-splash.lose { background: rgba(255, 71, 87, 0.12); }

.splash-icon {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin-bottom: 10px;
    animation: splashPop 0.5s ease;
}

.result-splash.win .splash-icon {
    background: var(--green);
    color: #000;
    box-shadow: 0 0 30px var(--green-glow);
}

.result-splash.lose .splash-icon {
    background: var(--red);
    color: #fff;
    box-shadow: 0 0 30px var(--red-glow);
}

.splash-text {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -1px;
}

.result-splash.win .splash-text { color: var(--green); }
.result-splash.lose .splash-text { color: var(--red); }

.splash-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

@keyframes splashPop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Strike Line */
.strike-line {
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    border-top: 1px dashed var(--yellow);
    z-index: 4;
    pointer-events: none;
}

.strike-label {
    position: absolute;
    right: 8px;
    top: -10px;
    background: var(--yellow);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

/* === BOTTOM TRADE PANEL === */
.trade-panel {
    flex-shrink: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 10px 12px 8px;
}

/* Amount Row */
.amount-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.amt-btn {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    font-family: var(--font);
}
.amt-btn:active { transform: scale(0.92); }
.amt-btn.minus { color: var(--red); }
.amt-btn.plus { color: var(--green); }

.amount-display {
    flex: 1;
    position: relative;
}

.amount-display input {
    width: 100%;
    padding: 8px 12px;
    padding-left: 24px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    font-family: var(--font);
    -moz-appearance: textfield;
}
.amount-display input::-webkit-inner-spin-button,
.amount-display input::-webkit-outer-spin-button { -webkit-appearance: none; }
.amount-display input:focus { outline: none; border-color: var(--green); }

.amt-currency {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

/* Quick Amounts */
.quick-row {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.quick-row::-webkit-scrollbar { display: none; }

.qk {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}
.qk:active { transform: scale(0.94); }
.qk.active {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Payout Row */
.payout-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    margin-bottom: 8px;
}

.payout-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pi-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.pi-value { font-size: 14px; font-weight: 700; color: var(--text-white); margin-top: 1px; }
.pi-value.green { color: var(--green); }
.pi-value.red { color: var(--red); }

/* Live P&L during active trade */
.live-pnl-badge {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 6;
    background: var(--glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 12px;
    text-align: center;
    min-width: 88px;
}

.live-pnl-label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
}

.live-pnl-value {
    display: block;
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.live-pnl-value.win { color: var(--green); }
.live-pnl-value.lose { color: var(--red); }

/* === BOTTOM TRADE PANEL === */
.trade-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.trade-btn-up,
.trade-btn-down {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 15px;
    font-weight: 800;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.5px;
    min-height: 48px;
}

.trade-btn-up {
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    color: #fff;
    box-shadow: 0 4px 15px var(--green-glow);
}

.trade-btn-down {
    background: linear-gradient(135deg, #ff4757, #e8364a);
    color: #fff;
    box-shadow: 0 4px 15px var(--red-glow);
}

.trade-btn-up:active, .trade-btn-down:active {
    transform: scale(0.96);
}

.trade-btn-up:disabled, .trade-btn-down:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.tb-text { letter-spacing: 2px; }

/* === HISTORY DRAWER === */
.drawer-overlay, .menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.25);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.drawer-overlay.open, .menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.history-drawer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    background: var(--bg-panel);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 95;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
}
.history-drawer.open {
    transform: translateX(-50%) translateY(0);
}

.drawer-handle {
    padding: 10px;
    text-align: center;
    cursor: pointer;
}
.drawer-handle span {
    display: inline-block;
    width: 36px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 12px;
}
.drawer-header h3 { font-size: 16px; font-weight: 700; }
.drawer-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 24px;
    cursor: pointer;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 20px;
}

.history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 6px;
}

.hr-left { display: flex; align-items: center; gap: 10px; }

.hr-dir {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.hr-dir.up { background: var(--green-bg); color: var(--green); }
.hr-dir.down { background: var(--red-bg); color: var(--red); }

.hr-info { display: flex; flex-direction: column; }
.hr-asset { font-size: 13px; font-weight: 600; color: var(--text-white); }
.hr-time { font-size: 10px; color: var(--text-muted); }

.hr-right { text-align: right; }
.hr-amount { display: block; font-size: 12px; color: var(--text-secondary); }
.hr-result { display: block; font-size: 13px; font-weight: 700; }
.hr-result.win { color: var(--green); }
.hr-result.lose { color: var(--red); }
.hr-result.pending { color: var(--yellow); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 32px; opacity: 0.3; margin-bottom: 8px; }

/* === MENU DRAWER === */
.menu-drawer {
    position: fixed;
    top: 0;
    right: max(0px, calc(50vw - var(--mobile-max) / 2));
    width: min(280px, calc(100vw - 20px));
    max-width: var(--mobile-max);
    height: 100dvh;
    background: var(--bg-panel);
    z-index: 200;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    will-change: transform;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
}
.menu-drawer.open {
    transform: translateX(0);
}

.menu-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    padding-top: calc(12px + var(--safe-top));
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.menu-drawer-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-white);
}

.menu-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.menu-close-btn:active {
    background: var(--bg-elevated);
    color: var(--accent-light);
    border-color: var(--accent);
}

.menu-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.profile-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; color: #fff;
}

.profile-info { display: flex; flex-direction: column; }
.profile-name { font-size: 14px; font-weight: 700; color: var(--text-white); }
.profile-email { font-size: 11px; color: var(--text-muted); }

.menu-items { padding: 10px 0; }

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.menu-item:active { background: var(--bg-card); }
.menu-item.active { color: var(--accent-light); }

/* === TOAST === */
.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--bg-elevated);
    color: var(--text-white);
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    max-width: 80%;
    text-align: center;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.success { border: 1px solid var(--green); }
.toast.error { border: 1px solid var(--red); }

/* ============================================
   AUTH PAGES (Login/Register/Verify)
   ============================================ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-app);
    padding: 0;
}

.auth-container {
    width: 100%;
    max-width: 1200px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

.auth-side-image {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.auth-side-image::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 212, 170, 0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.auth-side-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.auth-side-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.auth-side-logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 24px;
    color: #fff;
}

.auth-side-logo h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-white);
}

.auth-side-image-placeholder {
    width: 100%;
    max-width: 400px;
    border-radius: 24px;
    margin-bottom: 30px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.auth-side-text h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-white);
    margin-bottom: 12px;
}

.auth-side-text p {
    font-size: 14px;
    color: var(--text-muted);
}

.auth-card-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    border-radius: 14px;
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 12px;
}

.auth-logo h1 {
    font-size: 20px;
    color: var(--text-white);
    font-weight: 800;
}
.auth-logo .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.auth-form {
    margin-top: 4px;
}

.auth-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-muted);
}

.otp-input {
    text-align: center !important;
    font-size: 28px !important;
    letter-spacing: 10px !important;
    font-weight: 800 !important;
}

.otp-info {
    text-align: center;
    padding: 14px;
    background: var(--bg-input);
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Mobile Responsive for Auth Pages */
@media (max-width: 968px) {
    .auth-container {
        grid-template-columns: 1fr;
    }

    .auth-side-image {
        display: none;
    }

    .auth-card-container {
        min-height: 100vh;
        padding: 20px;
    }
}

/* --- Forms (Global) --- */
.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-white);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--green);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-danger {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* --- Alerts --- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 500;
}
.alert-error { background: var(--red-bg); border: 1px solid rgba(255,71,87,0.2); color: var(--red); }
.alert-success { background: var(--green-bg); border: 1px solid rgba(0,212,170,0.2); color: var(--green); }
.alert-warning { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2); color: var(--yellow); }

/* ============================================
   ADMIN PANEL (kept responsive too)
   ============================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    overflow-y: auto;
}

.admin-sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.admin-sidebar-header h2 { font-size: 16px; color: var(--accent-light); font-weight: 800; }
.admin-sidebar-header p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.admin-nav { list-style: none; }
.admin-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; font-size: 13px;
    color: var(--text-secondary); transition: all 0.2s;
}
.admin-nav a:hover, .admin-nav a.active {
    background: var(--accent-bg);
    color: var(--accent-light);
    border-right: 3px solid var(--accent);
}

.admin-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    min-width: 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 10px;
}
.admin-header h1 { font-size: 20px; font-weight: 800; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-card .stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.stat-card .stat-value.green { color: var(--green); }
.stat-card .stat-value.red { color: var(--red); }
.stat-card .stat-value.blue { color: var(--blue); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
    text-align: left; padding: 8px 10px;
    background: var(--bg-input); color: var(--text-muted);
    font-weight: 600; font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-danger { background: var(--red-bg); color: var(--red); }
.badge-warning { background: rgba(245,158,11,0.1); color: var(--yellow); }
.badge-info { background: rgba(59,130,246,0.1); color: var(--blue); }
.badge-purple { background: rgba(139,92,246,0.1); color: var(--purple); }

.panel-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
}
.panel-section h3 {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* === ADMIN RESPONSIVE === */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px 0;
    }
    .admin-sidebar-header { padding: 0 16px 12px; }
    .admin-nav {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .admin-nav::-webkit-scrollbar { display: none; }
    .admin-nav li { flex-shrink: 0; }
    .admin-nav a {
        padding: 8px 14px;
        white-space: nowrap;
        border-right: none !important;
        border-bottom: 2px solid transparent;
        font-size: 12px;
    }
    .admin-nav a.active {
        border-bottom-color: var(--green);
        background: transparent;
    }
    .admin-content { padding: 16px; }
    .admin-header h1 { font-size: 18px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .data-table { font-size: 11px; }
    .data-table th, .data-table td { padding: 6px 8px; }
}

/* === LOADING SPINNER === */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === HISTORY ITEMS (used by API) === */
.dir-up { color: var(--green); }
.dir-down { color: var(--red); }
.result-win { color: var(--green); }
.result-lose { color: var(--red); }
.result-pending { color: var(--yellow); }
.history-asset { color: var(--text-white); font-weight: 500; }
.history-dir { font-size: 11px; }
.history-result { font-weight: 700; font-size: 12px; }
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}

/* ====== BOTTOM NAVIGATION ====== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: calc(8px + var(--safe-bottom));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 8px;
}

.nav-item.active {
    color: var(--text-primary);
    background: var(--bg-input);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
}

/* Bottom nav is fixed — pages reserve space individually */

/* ====== LIVE CHAT ====== */
.chat-btn {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 99;
    transition: transform 0.2s;
}

.chat-btn:active {
    transform: scale(0.95);
}

.chat-btn .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-window {
    position: fixed;
    bottom: 140px;
    right: 16px;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 101;
    display: none;
    flex-direction: column;
    max-height: 400px;
}

.chat-window.open {
    display: flex;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h4 {
    font-size: 14px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header .status-dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
}

.chat-message.received {
    background: var(--bg-input);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message.sent {
    background: var(--green-bg);
    color: var(--green);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--text-white);
    font-family: var(--font);
    font-size: 13px;
}

.chat-input-area button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ====== PAGE CONTENT AREAS ====== */
.page-content {
    display: none;
    padding: 16px;
}

.page-content.active {
    display: block;
}

.trading-app > .page-content.active {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.trading-app > #page-trade.active {
    display: grid;
    grid-template-rows: auto auto minmax(120px, 1fr) auto;
    overflow: hidden;
    padding: 0;
    padding-bottom: calc(54px + var(--safe-bottom));
    overflow-y: hidden;
}

/* Profile Page */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 0;
}

.profile-avatar-large {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 40px;
    font-weight: 900;
    color: #fff;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.profile-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.profile-stat-value {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent-light);
}

.profile-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Wallet Page */
.wallet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
}

.wallet-balance {
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-light);
    margin-bottom: 4px;
}

.wallet-balance-label {
    font-size: 12px;
    color: var(--text-muted);
}

.wallet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.wallet-btn {
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wallet-btn.deposit {
    background: var(--green-bg);
    color: var(--green);
}

.wallet-btn.withdraw {
    background: var(--bg-input);
    color: var(--text-white);
}

/* Time selection buttons */
.time-selection {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.time-btn {
    flex: 1;
    min-width: 50px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.time-btn:hover {
    background: var(--border);
}

.time-btn.active {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

/* ============================================
   MOBILE-ONLY GLOBAL (480px app shell)
   ============================================ */
body.mobile-only {
    overflow-x: hidden;
    background: #ececec;
}

body.mobile-only:not(.trading-app) {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: auto;
    min-height: 100dvh;
    touch-action: pan-y;
}

body.landing-page,
body.auth-page {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.mobile-shell {
    width: 100%;
    max-width: var(--mobile-max);
    margin: 0 auto;
    min-height: 100dvh;
    position: relative;
    background: var(--bg-app);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

/* Center fixed UI inside phone shell */
.bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--mobile-max);
}

.chat-btn {
    right: max(12px, calc(50% - (var(--mobile-max) / 2) + 12px));
}

.chat-window {
    right: max(12px, calc(50% - (var(--mobile-max) / 2) + 12px));
}

.toast {
    left: 50%;
    max-width: calc(var(--mobile-max) - 32px);
}

/* Auth — mobile-only single column */
.auth-page .auth-container {
    grid-template-columns: 1fr;
    max-width: var(--mobile-max);
    margin: 0 auto;
    min-height: 100dvh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

.auth-side-image {
    display: none;
}

.auth-mobile-top {
    padding: calc(20px + var(--safe-top)) 20px 8px;
    text-align: center;
}

.auth-mobile-top .logo-icon {
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
}

.auth-mobile-top h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-white);
}

.auth-mobile-top p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.auth-card-container {
    min-height: auto;
    padding: 8px 16px calc(24px + var(--safe-bottom));
    align-items: flex-start;
}

.auth-page.mobile-only .auth-card-container {
    padding: 8px 16px calc(24px + var(--safe-bottom));
}

.auth-page.mobile-only .auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px 20px;
    box-shadow: var(--shadow-md);
}

.auth-card .auth-logo {
    display: none;
}

.auth-form .btn-primary,
.auth-form .btn-block,
.auth-form .btn-full {
    min-height: 48px;
    font-size: 15px;
}

.form-group input,
.form-group select,
.form-group textarea {
    min-height: 48px;
    font-size: 16px;
}

/* Wallet / profile scroll inside app */
#page-wallet.page-content.active,
#page-profile.page-content.active,
#page-home.page-content.active {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(60px + var(--safe-bottom));
}

.trading-app > #page-trade.active {
    display: grid;
    grid-template-rows: auto auto minmax(120px, 1fr) auto;
    overflow: hidden;
    padding: 0;
    padding-bottom: calc(54px + var(--safe-bottom));
    flex: 1;
    min-height: 0;
}

.trading-app #page-trade.active {
    display: grid;
    grid-template-rows: auto auto minmax(120px, 1fr) auto;
    overflow: hidden;
    padding-bottom: calc(54px + var(--safe-bottom));
}

.trading-app #page-trade .chart-zone {
    flex: none;
    min-height: 0;
    max-height: none;
    height: 100%;
}

.trading-app #page-trade .trade-panel {
    flex-shrink: 0;
    z-index: 2;
}

/* Admin — mobile-only panel */
body.mobile-only .admin-layout {
    flex-direction: column;
    max-width: var(--mobile-max);
    margin: 0 auto;
    min-height: 100dvh;
    max-height: 100dvh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
    background: var(--bg-app);
    overflow: hidden;
}

body.mobile-only .admin-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: calc(12px + var(--safe-top)) 0 12px;
}

body.mobile-only .admin-sidebar-header {
    padding: 0 16px 12px;
}

body.mobile-only .admin-nav {
    display: flex;
    overflow-x: auto;
    padding: 0 12px;
    gap: 6px;
    scrollbar-width: none;
}

body.mobile-only .admin-nav::-webkit-scrollbar {
    display: none;
}

body.mobile-only .admin-nav li {
    flex-shrink: 0;
}

body.mobile-only .admin-nav a {
    padding: 8px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    font-size: 12px;
    white-space: nowrap;
}

body.mobile-only .admin-nav a:hover,
body.mobile-only .admin-nav a.active {
    border-right: 1px solid var(--accent);
    border-color: var(--accent);
}

body.mobile-only .admin-content {
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

body.mobile-only .admin-header h1 {
    font-size: 18px;
}

body.mobile-only .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

body.mobile-only .stat-card .stat-value {
    font-size: 18px;
}

body.mobile-only .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
}

body.mobile-only .data-table {
    font-size: 11px;
}

body.mobile-only .data-table th,
body.mobile-only .data-table td {
    padding: 8px 6px;
}

/* ============================================
   ADMIN PANEL — responsive (mobile + desktop)
   ============================================ */
body.admin-panel {
    overflow-x: hidden;
    background: #ececec;
    min-height: 100dvh;
}

body.admin-panel .admin-layout {
    min-height: 100dvh;
}

.admin-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: -12px 0 16px;
    line-height: 1.45;
    padding: 10px 12px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
}

.admin-mode-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    max-width: 140px;
}

/* Mobile: horizontal nav (same as before) */
@media (max-width: 767px) {
    body.admin-panel .admin-layout {
        flex-direction: column;
        max-width: 100%;
        margin: 0 auto;
        min-height: 100dvh;
        background: var(--bg-app);
    }

    body.admin-panel .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: calc(12px + var(--safe-top)) 0 12px;
    }

    body.admin-panel .admin-sidebar-header {
        padding: 0 16px 12px;
    }

    body.admin-panel .admin-nav {
        display: flex;
        overflow-x: auto;
        padding: 0 12px;
        gap: 6px;
        scrollbar-width: none;
    }

    body.admin-panel .admin-nav::-webkit-scrollbar {
        display: none;
    }

    body.admin-panel .admin-nav li {
        flex-shrink: 0;
    }

    body.admin-panel .admin-nav a {
        padding: 8px 14px;
        border-radius: var(--radius-full);
        border: 1px solid var(--border);
        font-size: 12px;
        white-space: nowrap;
    }

    body.admin-panel .admin-nav a:hover,
    body.admin-panel .admin-nav a.active {
        border-color: var(--accent);
        border-right: 1px solid var(--accent);
    }

    body.admin-panel .admin-content {
        padding: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.admin-panel .admin-header h1 {
        font-size: 18px;
    }

    body.admin-panel .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    body.admin-panel .data-table {
        font-size: 11px;
    }

    body.admin-panel .data-table th,
    body.admin-panel .data-table td {
        padding: 8px 6px;
    }
}

/* Desktop / PC: full sidebar layout */
@media (min-width: 768px) {
    body.admin-panel .admin-layout {
        flex-direction: row;
        max-width: none;
        box-shadow: none;
        max-height: none;
        overflow: visible;
    }

    body.admin-panel .admin-sidebar {
        width: 260px;
        border-right: 1px solid var(--border);
        border-bottom: none;
        padding: 20px 0;
        position: sticky;
        top: 0;
        height: 100dvh;
    }

    body.admin-panel .admin-nav {
        display: block;
        overflow-x: visible;
        padding: 0;
    }

    body.admin-panel .admin-nav li {
        flex-shrink: unset;
    }

    body.admin-panel .admin-nav a {
        padding: 10px 20px;
        border-radius: 0;
        border: none;
        font-size: 13px;
        white-space: normal;
    }

    body.admin-panel .admin-nav a:hover,
    body.admin-panel .admin-nav a.active {
        border-right: 3px solid var(--accent);
        border-color: transparent;
        border-right-color: var(--accent);
    }

    body.admin-panel .admin-content {
        padding: 28px 32px;
        max-width: 1400px;
    }

    body.admin-panel .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    body.admin-panel .admin-mode-select {
        max-width: 180px;
    }
}
