:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f4f5fa;
  background: #090a0f;
  font-synthesis: none;
  --bg: #090a0f;
  --panel: #121319;
  --panel-2: #171821;
  --line: #292b36;
  --line-soft: #20222b;
  --muted: #999dac;
  --text: #f4f5fa;
  --purple: #7f5af0;
  --purple-2: #9d83ff;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .13);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, .13);
  --orange: #f59e0b;
  --shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
.hidden { display: none !important; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 20% 0%, rgba(127,90,240,.25), transparent 38rem), var(--bg); }
.auth-panel { width: min(980px, 100%); display: grid; grid-template-columns: 1.1fr .85fr; gap: 3rem; align-items: center; padding: 3rem; border: 1px solid var(--line); border-radius: 28px; background: rgba(18,19,25,.95); box-shadow: var(--shadow); }
.auth-copy h1 { max-width: 680px; margin: 1rem 0; font-size: clamp(2.2rem, 5vw, 4.4rem); line-height: .98; letter-spacing: -.055em; }
.auth-copy p { max-width: 620px; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.auth-form { display: grid; gap: 1rem; padding: 1.4rem; border: 1px solid var(--line); border-radius: 20px; background: #0d0e13; }
.form-note { margin: 0; color: var(--muted); font-size: .78rem; text-align: center; }

.brand { display: flex; align-items: center; gap: .8rem; }
.brand-large { margin-bottom: 2.7rem; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .68rem; letter-spacing: .16em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(145deg, var(--purple), #b36bff); font-size: .8rem; font-weight: 900; box-shadow: 0 10px 26px rgba(127,90,240,.33); }
.pill { display: inline-flex; padding: .42rem .7rem; border-radius: 999px; color: #c7baff; background: rgba(127,90,240,.14); border: 1px solid rgba(157,131,255,.24); font-size: .75rem; font-weight: 800; }

label { display: grid; gap: .42rem; color: #c8cad3; font-size: .8rem; font-weight: 650; }
input, select, textarea { width: 100%; padding: .78rem .82rem; color: var(--text); background: #0d0e13; border: 1px solid #30323d; border-radius: 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--purple-2); box-shadow: 0 0 0 3px rgba(127,90,240,.12); }
textarea { resize: vertical; }
button { border: 0; border-radius: 10px; padding: .76rem 1rem; color: white; background: var(--purple); font-weight: 800; }
button:hover { filter: brightness(1.08); }
.button-secondary { color: #e7e8ef; background: #20222b; border: 1px solid #343641; }
.text-button { padding: 0; color: #b6a7ff; background: transparent; font-size: .78rem; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); color: #d9dbe4; background: #171820; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; z-index: 20; display: flex; flex-direction: column; padding: 1.2rem 1rem; background: #0d0e13; border-right: 1px solid var(--line-soft); }
.sidebar .brand { padding: .45rem .55rem 1.35rem; }
.add-trade-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: .45rem; margin: .3rem 0 1.3rem; }
.nav-list { display: grid; gap: .3rem; }
.nav-item { width: 100%; display: flex; align-items: center; gap: .8rem; padding: .72rem .78rem; color: #a8abb8; background: transparent; text-align: left; }
.nav-item span { width: 20px; color: #777b8b; text-align: center; }
.nav-item:hover, .nav-item.active { color: #f4f5fa; background: rgba(127,90,240,.14); }
.nav-item.active span { color: #ac96ff; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: 1rem .35rem .1rem; border-top: 1px solid var(--line-soft); }
.profile-mini { min-width: 0; display: flex; align-items: center; gap: .65rem; }
.profile-mini strong, .profile-mini small { display: block; max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-mini small { color: var(--muted); font-size: .65rem; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #d8ceff; background: #2a2440; font-size: .72rem; font-weight: 900; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.62); }

.main-area { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.6rem; background: rgba(9,10,15,.88); border-bottom: 1px solid var(--line-soft); backdrop-filter: blur(16px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: .8rem; }
.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.eyebrow { margin: 0 0 .26rem; color: #777b8b; font-size: .64rem; font-weight: 900; letter-spacing: .14em; }
.compact-field { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .72rem; }
.compact-field select { min-width: 145px; padding: .58rem .7rem; }
.mobile-only { display: none; }

.content { padding: 1.35rem; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .16s ease; }
@keyframes fadeIn { from { opacity: .25; transform: translateY(3px); } }

.card { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 16px 45px rgba(0,0,0,.13); }
.dashboard-top-grid { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(260px, .8fr); gap: 1rem; }
.hero-card, .score-card, .recent-card, .table-card, .filters-card, .full-calendar-card, .journal-editor { padding: 1.1rem; }
.hero-card-head, .section-heading, .calendar-toolbar, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.hero-card h2 { margin: 0; font-size: clamp(1.9rem, 4vw, 3.3rem); letter-spacing: -.05em; }
.trend-chip { padding: .45rem .65rem; border-radius: 999px; font-size: .7rem; font-weight: 850; }
.trend-chip.positive { color: var(--green); background: var(--green-soft); }
.trend-chip.negative { color: var(--red); background: var(--red-soft); }
.trend-chip.neutral { color: var(--muted); background: #20222b; }
.chart-wrap { position: relative; min-width: 0; }
.chart-large { height: 248px; margin-top: .6rem; }
.chart-medium { height: 230px; }
.chart-donut { width: 190px; height: 190px; }
.hero-footer { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; padding-top: .85rem; border-top: 1px solid var(--line-soft); }
.hero-footer small, .hero-footer strong { display: block; }
.hero-footer small { margin-bottom: .25rem; color: var(--muted); font-size: .68rem; }
.hero-footer strong { font-size: .88rem; }

.score-card { display: flex; flex-direction: column; }
.section-heading h2, .calendar-toolbar h2, .modal-head h2 { margin: 0; font-size: 1rem; letter-spacing: -.02em; }
.info-dot { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: #21232c; font-size: .7rem; }
.score-ring { width: 146px; height: 146px; display: grid; place-content: center; margin: 1.3rem auto .8rem; border-radius: 50%; background: conic-gradient(var(--purple) 0deg, #252732 0deg); position: relative; }
.score-ring::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--panel); }
.score-ring span, .score-ring small { position: relative; z-index: 1; text-align: center; }
.score-ring span { font-size: 2.4rem; font-weight: 900; line-height: 1; }
.score-ring small { color: var(--muted); }
.center { text-align: center; }
.muted { color: var(--muted); line-height: 1.55; }
.mini-progress { margin-top: auto; }
.mini-progress > span, .mini-progress > strong { display: inline-block; font-size: .72rem; }
.mini-progress > strong { float: right; }
.mini-progress div { height: 6px; margin-top: .5rem; overflow: hidden; border-radius: 999px; background: #242630; }
.mini-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--purple); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1rem; margin: 1rem 0; }
.metric-card { display: flex; align-items: center; gap: .85rem; padding: 1rem; }
.metric-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; color: #cfc5ff; background: rgba(127,90,240,.14); font-size: .72rem; font-weight: 900; }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: .72rem; }
.metric-card strong { margin: .15rem 0; font-size: 1.25rem; }
.metric-card small { color: #737786; font-size: .64rem; }

.dashboard-lower-grid { display: grid; grid-template-columns: .85fr 1.3fr 1.25fr; gap: 1rem; }
.dashboard-lower-grid > .card { min-width: 0; padding: 1rem; }
.donut-layout { display: flex; align-items: center; justify-content: center; gap: 1rem; min-height: 244px; }
.legend-stack { display: grid; gap: .75rem; }
.legend-stack span { color: var(--muted); font-size: .75rem; }
.legend-stack strong { display: block; margin: .15rem 0 0 1rem; color: var(--text); font-size: 1.05rem; }
.dot { width: 8px; height: 8px; display: inline-block; margin-right: .45rem; border-radius: 50%; }
.win-dot { background: var(--green); }.loss-dot { background: var(--red); }.flat-dot { background: #717584; }
.recent-card { margin-top: 1rem; }

.mini-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 1rem; }
.mini-calendar .weekday { color: #666a78; font-size: .58rem; text-align: center; }
.mini-day { min-height: 35px; display: grid; place-content: center; border-radius: 7px; color: #8e92a1; background: #171820; font-size: .65rem; }
.mini-day.positive { color: var(--green); background: var(--green-soft); }
.mini-day.negative { color: var(--red); background: var(--red-soft); }
.mini-day.empty { visibility: hidden; }

.filters-card { margin-bottom: 1rem; }
.filters-row { display: grid; grid-template-columns: minmax(200px,1.5fr) repeat(3,minmax(130px,.8fr)) auto auto; gap: .75rem; align-items: end; }
.table-card { overflow: hidden; }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: .8rem .65rem; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
th { color: #777b88; font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; }
td { color: #d4d6de; font-size: .78rem; }
tbody tr { transition: background .12s ease; }
tbody tr[data-trade-id] { cursor: pointer; }
tbody tr:hover { background: rgba(255,255,255,.022); }
.value-positive { color: var(--green) !important; font-weight: 850; }
.value-negative { color: var(--red) !important; font-weight: 850; }
.value-flat { color: #aeb1bd !important; font-weight: 850; }
.direction-tag, .plan-tag { display: inline-flex; padding: .26rem .45rem; border-radius: 6px; font-size: .62rem; font-weight: 850; }
.direction-tag.buy { color: var(--green); background: var(--green-soft); }
.direction-tag.sell { color: var(--red); background: var(--red-soft); }
.plan-tag.yes { color: var(--green); background: var(--green-soft); }
.plan-tag.no { color: var(--red); background: var(--red-soft); }
.plan-tag.unknown { color: var(--muted); background: #22242c; }
.count-badge { padding: .36rem .58rem; border-radius: 999px; color: #cbbfff; background: rgba(127,90,240,.13); font-size: .7rem; font-weight: 850; }
.empty-state { padding: 4rem 1rem; text-align: center; color: var(--muted); }
.empty-state span { font-size: 2rem; }
.empty-state h3 { margin-bottom: .2rem; color: var(--text); }
.empty-state p { margin: 0; }

.calendar-page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; }
.calendar-toolbar { justify-content: center; margin-bottom: 1.1rem; text-align: center; }
.weekday-header, .full-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.weekday-header { margin-bottom: 7px; color: #696d7a; font-size: .67rem; text-align: center; }
.calendar-cell { min-height: 112px; padding: .7rem; border: 1px solid var(--line-soft); border-radius: 10px; background: #15161c; cursor: pointer; }
.calendar-cell:hover { border-color: #454754; }
.calendar-cell.outside { opacity: .28; }
.calendar-cell.selected { border-color: var(--purple-2); box-shadow: inset 0 0 0 1px var(--purple-2); }
.calendar-cell.positive { background: linear-gradient(145deg, rgba(52,211,153,.14), rgba(52,211,153,.055)); }
.calendar-cell.negative { background: linear-gradient(145deg, rgba(251,113,133,.14), rgba(251,113,133,.055)); }
.calendar-date { color: #9da0ad; font-size: .72rem; }
.calendar-value { display: block; margin-top: 1.5rem; font-size: 1rem; font-weight: 900; }
.calendar-meta { display: block; margin-top: .35rem; color: #808491; font-size: .62rem; }
.calendar-side { display: grid; align-content: start; gap: 1rem; }
.calendar-side .card { padding: 1rem; }
.big-number { display: block; margin: 1.1rem 0; font-size: 2rem; letter-spacing: -.045em; }
.summary-list { display: grid; gap: .65rem; }
.summary-list.roomy { margin-top: 1.2rem; }
.summary-list span { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .72rem; }
.summary-list strong { color: var(--text); }

.insight-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; margin-bottom: 1rem; }
.insight-card { padding: 1rem; }
.insight-card span, .insight-card strong, .insight-card small { display: block; }
.insight-card span { color: var(--muted); font-size: .7rem; }
.insight-card strong { margin: .4rem 0; font-size: 1.15rem; }
.insight-card small { color: #777b88; }
.insight-card.positive { border-color: rgba(52,211,153,.25); }
.insight-card.negative { border-color: rgba(251,113,133,.25); }
.analytics-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.analytics-grid > .card { min-width: 0; padding: 1rem; }
.report-list { display: grid; gap: .55rem; margin-top: 1rem; }
.report-row { display: grid; grid-template-columns: minmax(110px,1fr) 2fr auto; gap: .7rem; align-items: center; }
.report-row span { overflow: hidden; color: #c8cad3; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.report-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #23252e; }
.report-bar i { display: block; height: 100%; border-radius: inherit; background: var(--purple); }
.report-row strong { font-size: .72rem; }

.journal-grid { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 1rem; }
.journal-form { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: 1rem; }
.full { grid-column: 1 / -1; }
.journal-side { display: grid; align-content: start; gap: 1rem; }
.journal-side .card { padding: 1rem; }
.checklist-card label { display: flex; align-items: center; gap: .55rem; margin-top: .8rem; color: #b4b7c2; font-size: .76rem; }
.checklist-card input { width: auto; accent-color: var(--purple); }

.modal, .drawer { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop, .drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.modal-panel { position: relative; width: min(520px, calc(100% - 1.5rem)); max-height: calc(100vh - 2rem); overflow: auto; margin: 1rem auto; padding: 1.15rem; border: 1px solid #373946; border-radius: 16px; background: #13141a; box-shadow: var(--shadow); }
.modal-wide { width: min(1050px, calc(100% - 1.5rem)); }
.form-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .8rem; margin-top: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: .5rem; }
.download-link { display: inline-block; margin: .9rem 0; color: #baaaff; font-size: .8rem; }
.drawer-panel { position: absolute; top: 0; right: 0; width: min(470px, 100%); height: 100%; overflow: auto; padding: 1.2rem; border-left: 1px solid #373946; background: #13141a; box-shadow: -20px 0 70px rgba(0,0,0,.35); }
.detail-hero { padding: 1rem; margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; background: #0e0f14; }
.detail-hero strong { display: block; font-size: 2rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.detail-item { padding: .75rem; border-radius: 9px; background: #191a21; }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { margin-bottom: .25rem; color: var(--muted); font-size: .65rem; }
.detail-item strong { font-size: .8rem; }
.detail-notes { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; color: #c7c9d2; line-height: 1.6; white-space: pre-wrap; }
.delete-trade-button { width: 100%; margin-top: 1rem; color: #ffb2bd; background: #3a1d25; border: 1px solid #612d38; }

.toast { position: fixed; top: 1rem; right: 1rem; z-index: 300; width: min(420px, calc(100% - 2rem)); padding: 1rem; border: 1px solid #434653; border-radius: 11px; color: #ededf3; background: #20222b; box-shadow: var(--shadow); }
.setup-warning { position: fixed; left: 50%; top: .8rem; z-index: 400; transform: translateX(-50%); width: min(900px, calc(100% - 2rem)); padding: .85rem 1rem; border: 1px solid #6a4e25; border-radius: 10px; color: #ffdca5; background: #342715; }

@media (max-width: 1180px) {
  .dashboard-lower-grid { grid-template-columns: 1fr 1fr; }
  .calendar-preview-card { grid-column: 1 / -1; }
  .metric-grid, .insight-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filters-row { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .form-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .dashboard-top-grid, .calendar-page-grid, .journal-grid { grid-template-columns: 1fr; }
  .calendar-side, .journal-side { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .compact-field { display: none; }
  .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 680px) {
  .auth-shell { padding: .7rem; }
  .auth-panel { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.4rem; }
  .auth-copy h1 { font-size: 2.35rem; }
  .topbar { padding: .8rem; }
  .content { padding: .75rem; }
  .metric-grid, .dashboard-lower-grid, .insight-grid, .analytics-grid, .calendar-side, .journal-side { grid-template-columns: 1fr; }
  .calendar-preview-card { grid-column: auto; }
  .hero-footer { grid-template-columns: 1fr; }
  .filters-row, .form-grid, .journal-form { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .calendar-cell { min-height: 82px; padding: .45rem; }
  .calendar-value { margin-top: 1rem; font-size: .72rem; }
  .calendar-meta { display: none; }
  .donut-layout { flex-direction: column; }
}


/* Connexion MT5 */
.mt5-grid { display:grid; grid-template-columns:minmax(0,1.15fr) minmax(320px,.85fr); gap:1rem; }
.mt5-install-card { grid-column:1 / -1; }
.mt5-status-list { display:grid; gap:.75rem; margin:1.25rem 0; }
.mt5-status-list span { display:flex; justify-content:space-between; gap:1rem; padding:.8rem 0; border-bottom:1px solid var(--border); color:var(--muted); }
.mt5-status-list strong { color:var(--text); text-align:right; overflow-wrap:anywhere; }
.mt5-actions { display:flex; flex-wrap:wrap; gap:.75rem; }
.copy-field { display:grid; grid-template-columns:1fr auto; gap:.65rem; margin:.75rem 0 1rem; }
.copy-field input { min-width:0; font-family:ui-monospace, SFMono-Regular, Consolas, monospace; }
.install-steps { display:grid; gap:.8rem; padding-left:1.35rem; color:var(--muted); line-height:1.55; }
.install-steps strong, .install-steps code { color:var(--text); }
.notice-box { margin-top:1rem; padding:1rem; border:1px solid rgba(157,131,255,.35); background:rgba(127,90,240,.08); border-radius:12px; color:var(--muted); }
.notice-box strong { color:var(--text); }
@media (max-width:900px) { .mt5-grid { grid-template-columns:1fr; } .mt5-install-card { grid-column:auto; } }
@media (max-width:520px) { .copy-field { grid-template-columns:1fr; } }


/* Version 4 : édition des trades et statistiques de risque */
.trade-edit-form { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #0e0f14; }
.edit-section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.edit-section-head h3 { margin: 0; font-size: 1rem; }
.edit-badge { padding: .32rem .5rem; border-radius: 999px; color: #bfb1ff; background: rgba(127,90,240,.12); font-size: .62rem; font-weight: 800; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.save-trade-button { width: 100%; margin-top: .9rem; }
@media (max-width: 520px) { .edit-grid { grid-template-columns: 1fr; } .edit-grid .full { grid-column: auto; } .edit-section-head { align-items: flex-start; flex-direction: column; } }
