:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Arrière-plan animé */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.5;
    border-radius: 50%;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(16,185,129,0.2) 0%, rgba(15,23,42,0) 70%);
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, rgba(15,23,42,0) 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Structure */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Glassmorphism */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}

/* Header */
header {
    padding: 2rem;
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-weight: 800;
    font-size: 2.5rem;
    letter-spacing: -1px;
}

h1 span {
    color: var(--accent-blue);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 0.5rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; box-shadow: 0 0 10px var(--accent-green); }
    50% { opacity: 0.4; box-shadow: 0 0 2px var(--accent-green); }
    100% { opacity: 1; box-shadow: 0 0 10px var(--accent-green); }
}

.balance-card {
    text-align: right;
}

.balance-card .label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.balance-card h2 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pnl-indicator {
    font-weight: 600;
    margin-top: 0.5rem;
}

.pnl-positive { color: var(--accent-green); }
.pnl-negative { color: var(--accent-red); }

/* Layout Grid */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

/* Sections */
.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--accent-blue);
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Position Cards */
.positions-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.position-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.position-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
}

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

.pos-symbol {
    font-size: 1.2rem;
    font-weight: 800;
}

.pos-type {
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 800;
}

.type-short { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
.type-long { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }

.pos-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.detail-val {
    font-weight: 600;
    font-size: 1.1rem;
}

.sl-val { color: var(--accent-red); }
.tp-val { color: var(--accent-green); }

.free-ride-badge {
    margin-top: 1rem;
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

/* Table Historique */
.history-panel {
    padding: 1.5rem;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
}

.history-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.history-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.pnl-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
}

.bg-positive { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.bg-negative { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
.bg-neutral { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }

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

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsiveness */
@media (max-width: 1024px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    .balance-card {
        text-align: center;
    }
}

/* Agent d'Audit */
.audit-panel {
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.audit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 1rem;
}

.audit-item {
    display: flex;
    flex-direction: column;
}

.audit-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.audit-val {
    font-weight: 800;
    font-size: 1.1rem;
}

.subsection-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.accuracies-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.acc-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
}

.acc-good {
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.3);
}

.acc-bad {
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.text-warning {
    color: #f59e0b;
}

.warnings-list {
    list-style-type: none;
    font-size: 0.85rem;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.warnings-list li {
    margin-bottom: 0.3rem;
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
    padding-bottom: 0.3rem;
}

.warnings-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.badge-online {
    background: var(--accent-green) !important;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.badge-offline {
    background: var(--accent-red) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* ===========================
   LIVE MONITOR
   =========================== */

.live-monitor {
    margin: 0 0 24px 0;
    padding: 20px 24px;
}

.live-monitor #live-positions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
}

.live-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 18px 20px;
    flex: 1 1 300px;
    min-width: 280px;
    max-width: 480px;
}

.live-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.live-symbol {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.live-pnl {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.live-pnl-positive { color: var(--accent-green); }
.live-pnl-negative { color: var(--accent-red); }

.live-prices {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.live-price-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.live-price-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-price-val {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
}

.live-price-current {
    color: #60a5fa;
    font-size: 0.95rem;
}

/* Barre de progression SL → TP */
.live-progress-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.live-bar-label {
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 60px;
}

.live-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 99px;
    position: relative;
    overflow: visible;
}

.live-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s ease, background 0.4s;
}

.live-progress-cursor {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    border: 2px solid #1e293b;
    box-shadow: 0 0 6px rgba(255,255,255,0.5);
    pointer-events: none;
}

.live-meta {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.live-refresh-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 12px;
    text-align: right;
}

.sl-val { color: #f87171; }
.tp-val { color: #4ade80; }

/* Dashboard controls and login */
.control-panel { margin: 1.25rem 0; padding: 1.25rem; }
.public-view-note { margin: 1.25rem 0; color: var(--text-muted, #aab1c0); font-size: .9rem; }
.control-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.control-button { border: 1px solid var(--border-color, rgba(255,255,255,.16)); border-radius: .7rem; padding: .7rem 1rem; color: var(--text-primary, #f5f7fb); background: rgba(255,255,255,.06); cursor: pointer; font: inherit; }
.control-button:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.control-button.primary { background: rgba(34,197,94,.2); border-color: rgba(34,197,94,.5); }
.control-button.danger { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.5); }
.control-button:disabled { opacity: .45; cursor: not-allowed; }
.control-note { margin: .8rem 0 0; color: var(--text-muted, #aab1c0); font-size: .9rem; }
.login-card { width: min(26rem, calc(100% - 2rem)); margin: 10vh auto; padding: 2rem; }
.login-card form { display: grid; gap: .7rem; }
.login-card input { border: 1px solid rgba(255,255,255,.2); border-radius: .5rem; padding: .7rem; background: rgba(0,0,0,.2); color: white; }
