/* ==========================================
   DESIGN SYSTEM & HSL CSS VARIABLES
   ========================================== */
:root {
    /* Fonts */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Theme Colors (Midnight Dark & Translucent White) */
    --bg-base: hsl(230, 25%, 7%);
    --bg-surface: hsla(230, 20%, 12%, 0.45);
    --border-color: hsla(0, 0%, 100%, 0.08);
    --border-glow: hsla(260, 80%, 60%, 0.15);

    /* Text Colors */
    --text-primary: hsl(0, 0%, 96%);
    --text-secondary: hsl(230, 10%, 65%);
    --text-muted: hsl(230, 10%, 45%);

    /* Interactive / Brand Colors */
    --color-primary: hsl(260, 75%, 65%);
    --color-primary-hover: hsl(260, 80%, 72%);
    --color-primary-alpha: hsla(260, 75%, 65%, 0.15);

    --color-danger: hsl(350, 75%, 55%);
    --color-danger-hover: hsl(350, 80%, 62%);
    --color-danger-alpha: hsla(350, 75%, 55%, 0.12);

    --color-success: hsl(150, 70%, 45%);
    --color-success-alpha: hsla(150, 70%, 45%, 0.12);

    --color-warning: hsl(38, 90%, 55%);
    --color-warning-alpha: hsla(38, 90%, 55%, 0.12);

    /* Shadows and Blurs */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --blur-strength: 14px;
}

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

html, body {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 1.5rem;
}

/* Decorative Background Glows */
.glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
}
.glow-1 {
    width: 450px;
    height: 450px;
    top: -50px;
    right: -50px;
    background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
    animation: driftGlow1 25s infinite alternate ease-in-out;
}

.glow-2 {
    width: 600px;
    height: 600px;
    bottom: -150px;
    left: -150px;
    background: radial-gradient(circle, hsl(190, 70%, 50%) 0%, transparent 70%);
    animation: driftGlow2 30s infinite alternate ease-in-out;
}

@keyframes driftGlow1 {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-40px, 30px) scale(1.1);
        opacity: 0.45;
    }
    100% {
        transform: translate(20px, -20px) scale(0.9);
        opacity: 0.25;
    }
}

@keyframes driftGlow2 {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.35;
    }
    50% {
        transform: translate(30px, -45px) scale(0.9);
        opacity: 0.2;
    }
    100% {
        transform: translate(-30px, 40px) scale(1.15);
        opacity: 0.5;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: hsla(0, 0%, 100%, 0.12);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: hsla(0, 0%, 100%, 0.25);
}

/* ==========================================
   GLASSMORPHIC STYLING COMPONENT
   ========================================== */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: 16px;
}

/* ==========================================
   BUTTONS AND CONTROLS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 14px 0 hsla(260, 75%, 65%, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: hsla(0, 0%, 100%, 0.06);
    color: var(--text-primary);
    border: 1px solid hsla(0, 0%, 100%, 0.08);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    box-shadow: 0 4px 14px 0 hsla(350, 75%, 55%, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 1.1rem;
    background: hsla(0, 0%, 100%, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
}

@media (hover: hover) {
    .btn-primary:hover {
        background: var(--color-primary-hover);
        transform: translateY(-1px);
        box-shadow: 0 6px 20px 0 hsla(260, 75%, 65%, 0.35);
    }
    .btn-secondary:hover {
        background: hsla(0, 0%, 100%, 0.1);
        border-color: hsla(0, 0%, 100%, 0.15);
    }
    .btn-danger:hover {
        background: var(--color-danger-hover);
        transform: translateY(-1px);
    }
    .btn-icon:hover {
        color: var(--text-primary);
        background: hsla(0, 0%, 100%, 0.1);
        transform: rotate(30deg);
    }
}

.btn-block {
    width: 100%;
    display: flex;
}

/* ==========================================
   FORMS AND INPUTS
   ========================================== */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
    background: hsla(0, 0%, 0%, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.order-form-row {
    display: grid;
    gap: 1rem;
}
.order-form-row-2 {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 1rem;
}
.order-form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
    margin-bottom: 1.5rem;
}
.order-form-row .form-group {
    margin-bottom: 0;
}
.order-form-row .form-group input,
.order-form-row .form-group select {
    width: 100%;
    height: 46px; /* Ensure uniform height across all form controls */
    box-sizing: border-box;
}
.order-modal .select-control {
    width: 100%;
    height: 46px; /* Ensure uniform height across all form controls */
    border-radius: 10px;
    background: hsla(0, 0%, 0%, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0 2.25rem 0 1rem; /* 0 vertical padding prevents cutoff on iOS Safari */
    box-sizing: border-box;
    font-size: 0.95rem; /* Matches input font size */
}
.order-modal .modal-actions {
    margin-top: 1rem;
}
.order-modal .modal-actions button {
    flex: 1;
}

#order-symbol {
    text-transform: uppercase;
}

#order-symbol::placeholder {
    text-transform: none;
}

#order-symbol::-webkit-input-placeholder {
    text-transform: none;
}


.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Switch Custom Checkbox */
.inline-checkbox {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: hsla(0, 0%, 100%, 0.1);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-primary);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--color-success);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* ==========================================
   LOGIN SCREEN
   ========================================== */
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    z-index: 10;
    animation: fadeInScale 0.4s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.logo-icon {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 0 auto 1rem;
    background: rgba(255, 255, 255, 0.05) url('/static/icon-192.png') no-repeat center;
    background-image: image-set(
        url('/static/icon-192.webp') type('image/webp'),
        url('/static/icon-192.png') type('image/png')
    );
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-blend-mode: screen;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 4px 20px hsla(260, 75%, 65%, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.22),
        inset 0 -1px 2px rgba(0, 0, 0, 0.4);
    animation: iconPulseGlow 4s infinite ease-in-out;
    overflow: hidden;
    backdrop-filter: blur(8px);
}


.logo-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.16) 0%,
        rgba(255, 255, 255, 0.03) 49%,
        rgba(255, 255, 255, 0) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    pointer-events: none;
    z-index: 1;
}


@keyframes iconPulseGlow {
    0%, 100% {
        box-shadow: 0 4px 20px hsla(260, 75%, 65%, 0.4),
                    0 0 15px hsla(260, 75%, 65%, 0.2);
        transform: translateY(0) scale(1);
    }
    50% {
        box-shadow: 0 6px 30px hsla(190, 80%, 60%, 0.6),
                    0 0 25px hsla(190, 80%, 60%, 0.4);
        transform: translateY(-2px) scale(1.02);
    }
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, #b55fe6 0%, #4bc5d8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(181, 95, 230, 0.25));
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: hsla(0, 0%, 0%, 0.2);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 1.75rem;
    border: 1px solid var(--border-color);
}

.login-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.login-tab.active {
    background: var(--color-primary-alpha);
    color: var(--color-primary-hover);
    border: 1px solid hsla(260, 75%, 65%, 0.2);
}

.login-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}


/* ==========================================
   MAIN DASHBOARD SCREEN LAYOUT
   ========================================== */
.dashboard-layout {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 10;
    animation: fadeIn 0.4s ease-out;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.75rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-small {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05) url('/static/icon-192.png') no-repeat center;
    background-image: image-set(
        url('/static/icon-192.webp') type('image/webp'),
        url('/static/icon-192.png') type('image/png')
    );
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-blend-mode: screen;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 3px 15px hsla(260, 75%, 65%, 0.4),
        inset 0 1px 1.5px rgba(255, 255, 255, 0.22),
        inset 0 -1px 1.5px rgba(0, 0, 0, 0.4);
    animation: iconPulseGlow 4s infinite ease-in-out;
    overflow: hidden;
    backdrop-filter: blur(6px);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.logo-small:hover {
    transform: scale(1.08) rotate(2deg);
    box-shadow: 
        0 6px 25px hsla(260, 75%, 65%, 0.6),
        inset 0 1px 1.5px rgba(255, 255, 255, 0.3),
        inset 0 -1px 1.5px rgba(0, 0, 0, 0.4);
}

.logo-small::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.16) 0%,
        rgba(255, 255, 255, 0.03) 49%,
        rgba(255, 255, 255, 0) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.header-logo h1 {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #b55fe6 0%, #4bc5d8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(181, 95, 230, 0.25));
}

.header-logo #dry-run-badge {
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}


/* Badges */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.badge-warning {
    background: var(--color-warning-alpha);
    color: var(--color-warning);
    border: 1px solid hsla(38, 90%, 55%, 0.2);
}

.badge-success {
    background: var(--color-success-alpha);
    color: var(--color-success);
    border: 1px solid hsla(150, 70%, 45%, 0.2);
}

/* Broker Status Indicator Lights */
.broker-status-container {
    display: flex;
    gap: 1.25rem;
}

.status-light {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    display: inline-block;
}

.status-light.connected .status-dot {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    animation: pulse 1.8s infinite;
}

.status-light.error .status-dot {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

/* ==========================================
   METRICS GRID
   ========================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    padding: 1.5rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
    cursor: help;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-card h2 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Metric Tooltips */
.metric-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 220px;
    background: rgba(12, 15, 22, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.metric-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent rgba(255, 255, 255, 0.12) transparent;
}

.metric-card:hover {
    z-index: 10;
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.metric-card:hover .metric-tooltip {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tooltip-row:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.tooltip-row span:first-child {
    font-weight: 500;
}

.tooltip-row span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}


/* ==========================================
   P&L SPARK CARDS
   ========================================== */
.pnl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.pnl-card {
    padding: 1.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.pnl-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.pnl-value-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.pnl-value-row h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.pnl-badge {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

/* Color Classes for yielding positive/negative value */
.yield-positive {
    color: var(--color-success);
}
.yield-positive .pnl-badge {
    background: var(--color-success-alpha);
    border: 1px solid hsla(150, 70%, 45%, 0.15);
}

.yield-negative {
    color: var(--color-danger);
}
.yield-negative .pnl-badge {
    background: var(--color-danger-alpha);
    border: 1px solid hsla(350, 75%, 55%, 0.15);
}

/* ==========================================
   CONTENT LAYOUT: POSITIONS TABLE & SIDEBAR
   ========================================== */
.content-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .content-split {
        grid-template-columns: 1fr;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.title-with-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#btn-close-all {
    animation: panic-pulse 1.8s infinite;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#btn-close-all:hover {
    transform: translateY(-1px);
    background-color: #e11d48; /* Slightly darker shade on hover */
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}

@keyframes panic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.6);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(244, 63, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0);
    }
}

.positions-container {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
}

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

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

.positions-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.positions-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.positions-table tbody tr:hover {
    background: hsla(0, 0%, 100%, 0.02);
}

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem !important;
}

.col-symbol {
    font-weight: 600;
    color: var(--text-primary);
}

/* ==========================================
   SIDEBAR PANELS (SETTINGS & SECURITY)
   ========================================== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-container,
.security-container,
.password-container,
.mfa-container {
    padding: 1.75rem;
}

.settings-container h3,
.security-container h3,
.password-container h3,
.mfa-container h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}


.panel-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* ==========================================
   MODAL DIALOG (CONFIRM CLOSE)
   ========================================== */
.confirm-modal {
    margin: auto;
    background: hsl(230, 20%, 10%);
    border: 1px solid hsla(0, 0%, 100%, 0.15);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
    border-radius: 16px;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    color: var(--text-primary);
    outline: none;
}

.confirm-modal.order-modal {
    max-width: 460px;
}

.confirm-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
}

.modal-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-warning {
    color: var(--color-warning) !important;
    background: var(--color-warning-alpha);
    border: 1px solid hsla(38, 90%, 55%, 0.15);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem !important;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* ==========================================
   TOAST SLIDER NOTIFICATIONS
   ========================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: hsla(260, 25%, 15%, 0.9);
    border: 1px solid var(--color-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(10px);
}

.toast.hidden {
    transform: translateY(120px) scale(0.9);
    opacity: 0;
    pointer-events: none;
}

/* ==========================================
   UTILITY CLASSES & INTERACTION ANIMATIONS
   ========================================== */
.hidden {
    display: none !important;
}

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0% { transform: scale(0.98); opacity: 0.85; box-shadow: 0 0 0 0 hsla(150, 70%, 45%, 0.4); }
    70% { transform: scale(1.02); opacity: 1; box-shadow: 0 0 0 6px hsla(150, 70%, 45%, 0); }
    100% { transform: scale(0.98); opacity: 0.85; box-shadow: 0 0 0 0 hsla(150, 70%, 45%, 0); }
}

/* ==========================================
   MOBILE RESPONSIVENESS AND PORTRAIT LAYOUT
   ========================================== */
@media (max-width: 768px) {
    html {
        font-size: 19px; /* Increases all rem-based typography by ~18.7% on mobile screens for improved readability */
    }
    body {
        padding: 1rem 0.75rem;
        align-items: flex-start; /* Prevent stretching and bouncing vertically on tall contents */
    }

    body:has(#login-screen:not(.hidden)) {
        align-items: center;
    }

    .order-form-row-2,
    .order-form-row-3 {
        grid-template-columns: 1fr;
    }

    /* Header adjustments */
    .dashboard-header {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding: 1.25rem 1rem;
        text-align: center;
    }

    .header-logo {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
        margin-top: 0.25rem;
    }
    
    .broker-status-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }

    /* Grids */
    .metrics-grid,
    .pnl-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Panel header responsiveness */
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .panel-actions {
        width: 100%;
        display: flex;
        gap: 0.75rem;
    }

    .panel-actions .btn {
        flex: 1;
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        justify-content: center;
        text-align: center;
    }

    /* Mobile positions table column hide and padding adjustments */
    .positions-table th,
    .positions-table td {
        padding: 0.6rem 0.4rem;
    }

    .positions-table th:nth-child(2),
    .positions-table td:nth-child(2),
    .positions-table th:nth-child(3),
    .positions-table td:nth-child(3),
    .positions-table th:nth-child(4),
    .positions-table td:nth-child(4),
    .positions-table th:nth-child(5),
    .positions-table td:nth-child(5),
    .positions-table th:nth-child(6),
    .positions-table td:nth-child(6),
    .positions-table th:nth-child(7),
    .positions-table td:nth-child(7) {
        display: none !important;
    }

    /* Mobile full-screen override for order modal */
    .confirm-modal.order-modal {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
        padding: calc(1.5rem + env(safe-area-inset-top)) 1.5rem calc(1.5rem + env(safe-area-inset-bottom)) 1.5rem;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.75rem 1.25rem;
    }

    .login-header h2 {
        font-size: 1.35rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .metric-card,
    .pnl-card {
        padding: 1.25rem;
    }

    .metric-card h2 {
        font-size: 1.8rem;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        text-align: center;
    }
}

/* ==========================================
   PULL TO REFRESH STYLING
   ========================================== */
.pull-to-refresh {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: height 0.15s ease-out, opacity 0.15s ease-out;
    opacity: 0;
    z-index: 100;
    background: transparent;
    pointer-events: none;
}

.pull-to-refresh .ptr-icon {
    font-size: 1.2rem;
    display: inline-block;
    transition: transform 0.2s ease;
}

.pull-to-refresh.ready .ptr-icon {
    transform: rotate(180deg);
}

.pull-to-refresh.loading .ptr-icon {
    animation: ptr-spinner-rot 0.8s linear infinite;
}

@keyframes ptr-spinner-rot {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ptr-loader-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 0 10px var(--color-primary-alpha);
}

/* Password Visibility Toggle */
.input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
}

.input-wrapper input {
    width: 100%;
    padding-right: 2.75rem !important;
}

.toggle-password-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    outline: none;
    transition: color 0.2s ease, transform 0.1s ease;
}

.toggle-password-btn:hover {
    color: var(--text-primary);
}

.toggle-password-btn:active {
    transform: translateY(-50%) scale(0.92);
}

.toggle-password-btn svg {
    display: block;
    stroke: currentColor;
}

/* Header Action controls & Select dropdowns */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.market-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.market-status-badge.open {
    color: var(--color-success);
    border-color: hsla(150, 70%, 45%, 0.25);
    background: var(--color-success-alpha);
}

/* Pulsating green badge wrapper for final hour countdown */
.market-status-badge.final-hour {
    color: var(--color-success);
    border-color: hsla(150, 70%, 45%, 0.4);
    background: var(--color-success-alpha);
    animation: final-hour-pulse 2s infinite ease-in-out;
}

.market-status-badge.closed {
    color: var(--color-warning);
    border-color: hsla(38, 90%, 55%, 0.25);
    background: var(--color-warning-alpha);
}

/* Pulsating warning badge wrapper for the hour prior to open */
.market-status-badge.opening-soon {
    color: var(--color-warning);
    border-color: hsla(38, 90%, 55%, 0.4);
    background: var(--color-warning-alpha);
    animation: warning-pulse 2s infinite ease-in-out;
}

/* Pulsating warning badge wrapper for final 30m before close */
.market-status-badge.closing-soon {
    color: var(--color-warning);
    border-color: hsla(38, 90%, 55%, 0.4);
    background: var(--color-warning-alpha);
    animation: warning-pulse 2s infinite ease-in-out;
}

@keyframes final-hour-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 hsla(150, 70%, 45%, 0.1);
    }
    50% {
        box-shadow: 0 0 8px 1px hsla(150, 70%, 45%, 0.35);
    }
}

@keyframes warning-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 hsla(38, 90%, 55%, 0.1);
    }
    50% {
        box-shadow: 0 0 8px 1px hsla(38, 90%, 55%, 0.35);
    }
}

.select-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.5rem 2.25rem 0.5rem 1rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255, 255, 255, 0.6)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.select-control:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.select-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-alpha);
}

.select-control option {
    background: #11141c;
    color: var(--text-primary);
}

.select-control.header-dropdown {
    font-size: 0.85rem;
    padding: 0.3rem 1.75rem 0.3rem 0.6rem;
    border-radius: 6px;
    background-position: right 8px center;
}

/* Chart Modal and Net Liquidation card styles */
#card-net-liq {
    cursor: pointer;
}

.confirm-modal.chart-modal {
    max-width: 680px;
    padding: 1.5rem 1.75rem;
}

.chart-modal-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.75rem;
}

.chart-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.chart-header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.select-control.chart-dropdown {
    font-size: 0.8rem;
    padding: 0.25rem 1.75rem 0.25rem 0.5rem;
    border-radius: 6px;
    background-position: right 8px center;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

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

.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
}

/* Alert Banner styles */
.alert-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    animation: slide-down 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-banner.warning {
    background: rgba(217, 119, 6, 0.12); /* warning-tinted */
    border-color: rgba(217, 119, 6, 0.25);
    color: #f59e0b; /* Amber */
}

.alert-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    flex-grow: 1;
}

.alert-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.alert-message {
    flex-grow: 1;
}

.alert-message strong {
    font-weight: 600;
}

.btn-warning-action {
    background: #f59e0b;
    color: #121212;
    border: none;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-warning-action:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.btn-close-banner {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 1.35rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-close-banner:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.alert-banner.hidden {
    display: none !important;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Collapsible Advanced Settings Panel styling */
.settings-toggle-wrapper {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.btn-toggle-advanced {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: none;
    letter-spacing: normal;
}

.btn-toggle-advanced:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.btn-toggle-advanced.active {
    background: var(--color-primary-alpha);
    color: var(--color-primary-hover);
    border-color: hsla(260, 75%, 65%, 0.3);
}

.btn-toggle-advanced .toggle-arrow {
    font-size: 0.7rem;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}

.btn-toggle-advanced.active .toggle-arrow {
    transform: rotate(180deg);
}

#advanced-settings-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 0.75rem;
}

#advanced-settings-section:not(.hidden) {
    animation: slideDownFade 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Settings actions button group row layout */
.settings-actions-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.settings-actions-row .btn {
    flex: 1;
    margin-top: 0 !important;
}

#btn-save-settings, #btn-reset-settings {
    white-space: nowrap;
}

/* Save configuration button pulsing highlight when unsaved changes exist */
.btn-primary.pulse-glow {
    animation: savePulseGlow 2s infinite ease-in-out;
    border-color: hsla(260, 75%, 65%, 0.8) !important;
}

@keyframes savePulseGlow {
    0%, 100% {
        box-shadow: 
            0 4px 14px hsla(260, 75%, 65%, 0.5),
            0 0 0 1px hsla(260, 75%, 65%, 0.2);
    }
    50% {
        box-shadow: 
            0 6px 22px hsla(260, 80%, 70%, 0.95),
            0 0 0 4px hsla(260, 80%, 70%, 0.3);
    }
}

/* Active Brokers toggle buttons style */
.broker-toggle-group {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    margin-bottom: 6px;
}

.btn-broker-toggle {
    flex: 1;
    background: hsla(0, 0%, 0%, 0.25);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-broker-toggle.active {
    background: var(--color-success) !important;
    color: #ffffff !important;
    border-color: var(--color-success) !important;
    box-shadow: 0 0 10px var(--color-success-alpha) !important;
}

@media (hover: hover) {
    .btn-broker-toggle:hover {
        background: hsla(0, 0%, 100%, 0.05);
        color: var(--text-primary);
    }
    .btn-broker-toggle.active:hover {
        background: hsl(150, 70%, 38%) !important;
    }
}

/* Individual modified input highlight style */
.form-group input.input-changed,
.form-group select.input-changed,
.form-group button.input-changed {
    border-color: var(--color-warning) !important;
    box-shadow: 0 0 0 2px var(--color-warning-alpha) !important;
}

/* Sibling slider highlight for checkbox inputs */
input.input-changed + .slider {
    border-color: var(--color-warning) !important;
    box-shadow: 0 0 0 3px var(--color-warning-alpha) !important;
}

/* Individual invalid input highlight style */
.form-group input.input-invalid,
.form-group select.input-invalid,
.form-group button.input-invalid {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 2px var(--color-danger-alpha) !important;
}

/* ==========================================
   VIDEO EASTER EGG MODAL STYLES
   ========================================== */
.confirm-modal.video-modal {
    max-width: 640px;
    padding: 1.5rem;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #000;
}

.video-container iframe,
.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==========================================
   iOS PWA STANDALONE & TOUCH UX OPTIMIZATIONS
   ========================================== */

/* 1. iOS Status Bar Safe Area offsets */
.ios-standalone .dashboard-header {
    padding-top: calc(env(safe-area-inset-top) + 0.75rem) !important;
}

.ios-standalone .login-card {
    margin-top: env(safe-area-inset-top);
}

/* 2. iOS Touch/Tap UX Overrides */
.is-ios * {
    -webkit-tap-highlight-color: transparent; /* Remove default touch flash highlights */
}

/* Prevent text highlighting on buttons, tabs, status elements on double tap */
.is-ios button,
.is-ios .login-tab,
.is-ios .logo-small,
.is-ios .logo-icon,
.is-ios .status-light,
.is-ios .badge,
.is-ios .metric-card {
    -webkit-user-select: none;
    user-select: none;
}

/* 3. iOS PWA Install Banner styling */
.ios-install-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    width: calc(100% - 32px);
    max-width: 420px;
    background: hsla(230, 20%, 12%, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    opacity: 0;
}

.ios-install-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.ios-install-banner .banner-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

.ios-install-banner .banner-icon {
    font-size: 2rem;
    line-height: 1;
}

.ios-install-banner .banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ios-install-banner .banner-text strong {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ios-install-banner .banner-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.ios-install-banner .ios-share-icon {
    display: inline-block;
    vertical-align: middle;
    color: #007aff; /* Apple Blue color */
    margin: 0 4px;
}

.ios-install-banner .btn-close-banner {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s ease;
}

.ios-install-banner .btn-close-banner:hover {
    color: var(--text-primary);
}

/* ==========================================
   RANGE SLIDER & SETTINGS STYLINGS
   ========================================== */
.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0 16px 0;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
}

.settings-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.range-group {
    margin-bottom: 18px;
}

.range-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.range-header label {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.range-val {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
    text-shadow: 0 0 8px var(--color-primary-alpha);
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

/* Custom Range Input */
input[type="range"].range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    outline: none;
    margin: 8px 0;
    transition: background 0.3s ease;
    cursor: pointer;
}

input[type="range"].range-input:hover {
    background: rgba(255, 255, 255, 0.12);
}

input[type="range"].range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
    transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
}

input[type="range"].range-input::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

input[type="range"].range-input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
    transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

input[type="range"].range-input::-moz-range-thumb:hover {
    transform: scale(1.25);
}

/* Changed state when values are dirty */
input[type="range"].range-input.input-changed::-webkit-slider-thumb {
    background: var(--color-warning);
    box-shadow: 0 0 8px var(--color-warning);
}

input[type="range"].range-input.input-changed::-moz-range-thumb {
    background: var(--color-warning);
    box-shadow: 0 0 8px var(--color-warning);
}

.range-val.val-changed {
    color: var(--color-warning);
    text-shadow: 0 0 8px var(--color-warning-alpha);
}

/* Pre-flight check loading spinner & pulse */
.preflight-loading-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.preflight-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: preflight-spin 0.8s linear infinite;
}

@keyframes preflight-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.preflight-pulse-text {
    animation: preflight-pulse 1.5s ease-in-out infinite;
}

@keyframes preflight-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ==========================================
   ORDER EXECUTION OVERLAY STYLES
   ========================================== */
.execution-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #06070a; /* Matches deep dark workspace background */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.execution-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.loading-image-wrapper {
    position: relative;
    height: 100vh;
    width: 100vh; /* Always a square based on screen height to prevent squishing */
    flex-shrink: 0; /* Prevents flex shrink */
    background: url('/static/loading_bkgd.webp') no-repeat center center;
    background-size: 100% 100%;
}

.loading-image-wrapper::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(to right, #06070a 0%, #06070a 3%, rgba(6, 7, 10, 0.8) 7%, rgba(6, 7, 10, 0.3) 15%, rgba(6, 7, 10, 0) 25%),
        linear-gradient(to left, #06070a 0%, #06070a 3%, rgba(6, 7, 10, 0.8) 7%, rgba(6, 7, 10, 0.3) 15%, rgba(6, 7, 10, 0) 25%),
        linear-gradient(to bottom, #06070a 0%, #06070a 2%, rgba(6, 7, 10, 0.7) 5%, rgba(6, 7, 10, 0) 12%),
        linear-gradient(to top, #06070a 0%, #06070a 2%, rgba(6, 7, 10, 0.7) 5%, rgba(6, 7, 10, 0) 12%);
    box-shadow: inset 0 0 100px 30px #06070a; /* Smoothly fades edges into workspace background */
    pointer-events: none;
    z-index: 2; /* Sits above the background image but below the spinner */
}

.neon-spinner {
    position: absolute;
    left: 50.44%; /* Calculated exact center of user's green circle */
    top: 83.25%;  /* Calculated exact center of user's green circle */
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 3.5px solid rgba(120, 255, 146, 0.08); /* Matches robot eye green (#78ff92) */
    border-top: 3.5px solid #78ff92; /* Perfect match for robot eye green */
    border-radius: 50%;
    z-index: 3; /* Sits on top of the vignette overlay */

    animation: spin 0.9s linear infinite, neon-pulse 1.5s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 10px #78ff92) drop-shadow(0 0 4px #78ff92);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes neon-pulse {
    0% { opacity: 0.85; filter: drop-shadow(0 0 8px #78ff92) drop-shadow(0 0 3px #78ff92); }
    100% { opacity: 1; filter: drop-shadow(0 0 16px #78ff92) drop-shadow(0 0 6px #78ff92); }
}


