:root{
    --bleu:#0b5f86;
    --bleu-fonce:#174b66;
    --bleu-clair:#eef7fb;
    --texte:#24333d;
    --muted:#6f7d86;
    --bordure:#d9e3e8;
    --fond:#f5f8fa;
    --blanc:#ffffff;
    --vert:#187b4f;
    --vert-bg:#e8f6ef;
    --orange:#936500;
    --orange-bg:#fff4d8;
    --rouge:#a23b32;
    --rouge-bg:#fdecea;
}
*{box-sizing:border-box}
body{
    margin:0;
    font-family:Arial,Helvetica,sans-serif;
    color:var(--texte);
    background:var(--fond);
}
button,input{font:inherit}
button,.button{
    border:0;
    border-radius:10px;
    padding:10px 14px;
    background:var(--bleu);
    color:#fff;
    font-weight:700;
    cursor:pointer;
    text-decoration:none;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
}
button:hover,.button:hover{background:var(--bleu-fonce)}
button:disabled{opacity:.6;cursor:wait}
button.light,.button.light{
    background:#fff;
    color:var(--bleu);
    border:1px solid var(--bordure);
}
button.danger{
    background:var(--rouge-bg);
    color:var(--rouge);
    border:1px solid #f4cbc7;
}
button.small{padding:7px 10px;font-size:12px}
.topbar{
    min-height:38px;
    padding:8px 22px;
    background:var(--bleu-fonce);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:15px;
    font-size:13px;
}
.app-header{
    max-width:1180px;
    margin:0 auto;
    padding:24px 20px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:20px;
    background:#fff;
}
body:not(.login-page)::before{
    content:"";
    position:absolute;
    left:0;right:0;top:38px;height:116px;
    background:#fff;
    z-index:-1;
    border-bottom:1px solid var(--bordure);
}
.brand{display:flex;align-items:center;gap:16px}
.brand img{width:76px;height:auto}
.kicker{color:var(--bleu);font-weight:700;font-size:14px}
h1,h2,h3,p{margin-top:0}
h1{margin-bottom:5px;color:var(--bleu-fonce);font-size:28px}
.brand p{margin:0;color:var(--muted)}
.header-actions{display:flex;gap:9px;align-items:center;flex-wrap:wrap}
main{max-width:1180px;margin:0 auto;padding:28px 20px 55px}
.hero{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:20px;
    margin-bottom:15px;
}
.hero h2{margin-bottom:5px;color:var(--bleu-fonce)}
.hero p,.panel-head p{margin:0;color:var(--muted)}
.source-strip{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    margin-bottom:18px;
    padding:13px 15px;
    background:#fff;
    border:1px solid var(--bordure);
    border-left:4px solid var(--bleu);
    border-radius:12px;
}
.source-strip strong{display:block;color:var(--bleu-fonce);font-size:13px}
.source-strip span{display:block;margin-top:3px;color:var(--muted);font-size:12px}
.kpis{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:14px;
    margin-bottom:20px;
}
.kpi{
    background:#fff;
    border:1px solid var(--bordure);
    border-radius:15px;
    padding:18px;
    min-height:130px;
    box-shadow:0 4px 14px rgba(23,75,102,.04);
}
.main-kpi{border-top:4px solid var(--bleu)}
.kpi-label,.forecast-label{
    color:var(--muted);
    font-size:13px;
    font-weight:700;
    margin-bottom:9px;
}
.kpi-value{
    color:var(--bleu-fonce);
    font-size:30px;
    font-weight:800;
    letter-spacing:-.5px;
}
.kpi-value.small{font-size:25px}
.kpi-value.down{color:var(--vert)}
.kpi-value.up{color:var(--rouge)}
.kpi-note,.forecast-note{
    margin-top:7px;
    color:var(--muted);
    font-size:12px;
    line-height:1.4;
}
.decision{
    display:inline-flex;
    padding:7px 10px;
    border-radius:999px;
    font-weight:800;
    background:#eef2f4;
    color:#50606a;
}
.decision.good{background:var(--vert-bg);color:var(--vert)}
.decision.watch{background:var(--orange-bg);color:var(--orange)}
.decision.wait{background:#eef2f4;color:#53636d}
.decision.neutral{background:var(--bleu-clair);color:var(--bleu)}
.panel{
    margin-top:18px;
    padding:20px;
    background:#fff;
    border:1px solid var(--bordure);
    border-radius:15px;
    box-shadow:0 4px 14px rgba(23,75,102,.04);
}
.panel-head{
    display:flex;
    justify-content:space-between;
    gap:20px;
    align-items:flex-start;
    margin-bottom:17px;
}
.panel-head h2{margin-bottom:4px;color:var(--bleu-fonce);font-size:20px}
.forecast-grid{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:12px;
}
.forecast-card{
    border:1px solid var(--bordure);
    border-radius:13px;
    padding:16px;
    background:#fbfdfe;
}
.forecast-value{
    font-size:26px;
    color:var(--bleu-fonce);
    font-weight:800;
}
.forecast-summary{
    margin-top:13px;
    padding:12px 14px;
    border-radius:10px;
    background:var(--bleu-clair);
    color:#365666;
    font-size:13px;
    line-height:1.45;
}
.muted-inline{color:var(--muted)}
.inline-form{display:flex;align-items:end;gap:12px;flex-wrap:wrap}
.inline-form>div{min-width:210px}
label{
    display:block;
    margin-bottom:6px;
    font-size:13px;
    font-weight:700;
    color:var(--bleu-fonce);
}
label span{color:var(--muted);font-weight:400}
input{
    width:100%;
    padding:10px 11px;
    border:1px solid #bdcbd2;
    border-radius:9px;
    background:#fff;
    color:var(--texte);
    outline:none;
}
input:focus{
    border-color:#6ba9c6;
    box-shadow:0 0 0 3px rgba(11,95,134,.09);
}
.chart-legend{
    display:flex;
    gap:18px;
    flex-wrap:wrap;
    color:var(--muted);
    font-size:12px;
    margin:-3px 0 10px;
}
.chart-legend span{display:flex;align-items:center;gap:7px}
.legend-line{display:inline-block;width:28px;border-top:3px solid var(--bleu)}
.legend-line.forecast{border-top:2px dashed #7b8790}
.chart-wrap{position:relative;min-height:330px}
canvas{display:block;width:100%;height:330px}
.empty{
    padding:28px 20px;
    text-align:center;
    border:1px dashed #c9d5da;
    border-radius:12px;
    color:var(--muted);
    background:#fbfdfe;
}
.history-list{border-top:1px solid var(--bordure)}
.history-row{
    display:grid;
    grid-template-columns:minmax(0,1fr) 150px auto;
    gap:14px;
    align-items:center;
    padding:13px 2px;
    border-bottom:1px solid var(--bordure);
}
.history-price{font-weight:800;color:var(--bleu-fonce);text-align:right}
.history-actions{display:flex;gap:7px;justify-content:flex-end;flex-wrap:wrap}
.meta{margin-top:4px;color:var(--muted);font-size:12px}
.source-badge{
    display:inline-block;
    padding:3px 6px;
    margin-right:4px;
    border-radius:999px;
    background:var(--bleu-clair);
    color:var(--bleu);
    font-size:10px;
    font-weight:800;
}
.source-badge.manual{background:#f1f3f4;color:#68747b}
.modal{
    position:fixed;inset:0;z-index:9999;
    background:rgba(13,37,49,.56);
    display:flex;align-items:center;justify-content:center;
    padding:18px;
}
.modal-card{
    width:min(620px,100%);
    max-height:calc(100vh - 36px);
    overflow:auto;
    padding:22px;
    border-radius:17px;
    background:#fff;
    box-shadow:0 20px 50px rgba(0,0,0,.25);
}
.modal-head{
    display:flex;justify-content:space-between;
    gap:20px;align-items:flex-start;margin-bottom:18px;
}
.modal-head h2{margin-bottom:4px;color:var(--bleu-fonce)}
.modal-head p{margin:0;color:var(--muted);font-size:13px}
.icon-button{
    width:36px;height:36px;padding:0;border-radius:50%;
    font-size:23px;background:#eef3f5;color:#50606a;
}
.form-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
}
.form-grid .full{grid-column:1/-1}
.form-actions{margin-top:18px;display:flex;gap:10px;flex-wrap:wrap}
.hidden{display:none!important}

/* LOGIN compatible V1 */
.login-page{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    background:var(--fond);
}
.login-card{
    width:min(430px,100%);
    padding:30px 28px;
    background:#fff;
    border:1px solid var(--bordure);
    border-radius:18px;
    box-shadow:0 12px 34px rgba(23,75,102,.09);
}
.login-logo{width:78px;display:block;margin:0 auto 16px}
.login-card .kicker,.login-card h1,.login-intro{text-align:center}
.login-card h1{margin-bottom:7px}
.login-intro{margin-bottom:22px;color:var(--muted)}
.login-card label{margin-top:13px}
.login-submit{width:100%;margin-top:18px}
.back-link{
    display:block;margin-top:18px;text-align:center;
    color:var(--bleu);text-decoration:none;font-size:13px;
}
.alert{padding:10px 12px;margin:0 0 14px;border-radius:9px;font-size:13px}
.alert.error{background:var(--rouge-bg);color:var(--rouge);border:1px solid #f3cbc7}

@media(max-width:900px){
    .kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
    .forecast-grid{grid-template-columns:1fr}
    .app-header{align-items:flex-start;flex-direction:column}
}
@media(max-width:600px){
    .topbar{padding:8px 13px;font-size:11px}
    .app-header{padding:18px 14px}
    .brand{align-items:flex-start}
    .brand img{width:62px}
    h1{font-size:23px}
    main{padding:22px 13px 40px}
    .hero{align-items:stretch;flex-direction:column}
    .hero button{width:100%}
    .source-strip{align-items:stretch;flex-direction:column}
    .source-strip button{width:100%}
    .kpis{grid-template-columns:1fr}
    .panel{padding:16px}
    .inline-form{align-items:stretch;flex-direction:column}
    .inline-form>div,.inline-form button{width:100%}
    .form-grid{grid-template-columns:1fr}
    .form-grid .full{grid-column:auto}
    .history-row{grid-template-columns:1fr auto}
    .history-row>div:last-child{grid-column:1/-1}
    .history-price{text-align:right}
    .history-actions{justify-content:flex-start}
    .header-actions{width:100%}
    .header-actions .button{flex:1}
}
