/* ============================================================
   VARIABLES THÈME
   ============================================================ */
:root {
    --bg:           #0f1117;
    --bg-card:      #1a1d2e;
    --bg-hover:     #1e2133;
    --bg-input:     #0f1117;
    --border:       #2a2d3e;
    --text:         #eeeeee;
    --text-muted:   #888888;
    --text-faint:   #333333;
    --accent:       #00d4ff;
    --accent-bg:    rgba(0,212,255,0.1);
    --accent-border:rgba(0,212,255,0.2);
    --pos:          #00e676;
    --pos-bg:       rgba(0,230,118,0.1);
    --neg:          #ff1744;
    --neg-bg:       rgba(255,23,68,0.1);
    --shadow:       0 8px 32px rgba(0,0,0,0.4);
}

[data-theme="light"] {
    --bg:           #f0f2f8;
    --bg-card:      #ffffff;
    --bg-hover:     #f5f7ff;
    --bg-input:     #f0f2f8;
    --border:       #e0e4f0;
    --text:         #1a1d2e;
    --text-muted:   #666680;
    --text-faint:   #cccccc;
    --accent:       #0099cc;
    --accent-bg:    rgba(0,153,204,0.08);
    --accent-border:rgba(0,153,204,0.2);
    --pos:          #00a854;
    --pos-bg:       rgba(0,168,84,0.1);
    --neg:          #e0001a;
    --neg-bg:       rgba(224,0,26,0.1);
    --shadow:       0 4px 20px rgba(0,0,0,0.08);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 2rem;
    transition: background 0.3s, color 0.3s;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1 { font-size: 1.2rem; }

/* ============================================================
   BOUTON THÈME
   ============================================================ */
.btn-theme {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-theme:hover { background: var(--accent-border); }

/* ============================================================
   STATUS
   ============================================================ */
.status {
    font-size: 0.75rem;
    color: var(--pos);
    background: var(--pos-bg);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.status.error { color: var(--neg); background: var(--neg-bg); }

/* ============================================================
   LIENS
   ============================================================ */
a.logout {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
}
a.logout:hover { color: var(--neg); }

a.btn-back {
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    padding: 5px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    white-space: nowrap;
}
a.btn-back:hover { background: var(--accent-border); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: background 0.3s;
}

.card h2 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.card-title { font-size: 1rem; font-weight: 600; }
.card-login { font-size: 0.75rem; color: var(--text-muted); }

/* ============================================================
   ROWS
   ============================================================ */
.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }

.label { color: var(--text-muted); font-size: 0.85rem; }

.value { font-weight: 600; color: var(--accent); font-size: 0.9rem; }
.value.pos { color: var(--pos); }
.value.neg { color: var(--neg); }
.value.neutral { color: var(--text); }
.value.error { color: var(--neg); font-size: 0.8rem; }

/* ============================================================
   BADGE POSITIONS
   ============================================================ */
.badge-positions {
    font-size: 0.75rem;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 20px;
}

/* ============================================================
   BOUTON DÉTAIL
   ============================================================ */
.btn-detail {
    display: block;
    text-align: center;
    margin-top: 0.75rem;
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-detail:hover { background: var(--accent-border); }

/* ============================================================
   TABLEAU POSITIONS
   ============================================================ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

.badge { padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge.buy  { background: var(--pos-bg); color: var(--pos); }
.badge.sell { background: var(--neg-bg); color: var(--neg); }

.no-positions { text-align: center; color: var(--text-faint); padding: 2rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer-update { text-align: center; font-size: 0.7rem; color: var(--text-faint); margin-top: 0.75rem; }

/* ============================================================
   GRILLES
   ============================================================ */
.grid-accounts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.grid-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}

.login-card h2 { text-align: center; margin-bottom: 2rem; font-size: 1.3rem; }

.field { margin-bottom: 1.2rem; }
.field label { display: block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.4rem; }
.field input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border 0.2s;
}
.field input:focus { border-color: var(--accent); }

.btn-submit {
    width: 100%;
    background: var(--accent);
    color: #0f1117;
    border: none;
    border-radius: 8px;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: opacity 0.2s;
}
.btn-submit:hover { opacity: 0.85; }

.alert-error {
    background: var(--neg-bg);
    color: var(--neg);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    text-align: center;
}

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 600px) {
    body { padding: 1rem; }

    h1 { font-size: 1rem; }

    .grid-detail {
        grid-template-columns: 1fr;
    }

    .grid-accounts {
        grid-template-columns: 1fr;
    }

    .topbar { gap: 0.5rem; }
    .topbar-right { gap: 0.5rem; }

    table { font-size: 0.75rem; }
    th, td { padding: 0.4rem 0.5rem; }
}

/* Tableaux stats */
#annual-table table th,
#annual-table table td,
#daily-table table th,
#daily-table table td {
    white-space: nowrap;
    text-align: right;
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
}

#annual-table table th:first-child,
#annual-table table td:first-child,
#daily-table table th:first-child,
#daily-table table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
}