/* =============================================================
   MASTER MATRIX — Conseiller IA · charte « banque privée » (NOVA)
   Fond crème, vert forêt, or, navy · Georgia serif + Inter
   ============================================================= */
:root {
  --ink: #172820; --muted: #64736b; --faint: #8a988f;
  --line: #dfe6e1; --line-2: #cdd8d0;
  --paper: #f5f7f4; --paper-2: #eef2ee; --white: #ffffff;
  --green: #0a6f54; --green-2: #0d8b67; --mint: #cce8dc; --lime: #d8ef8d;
  --navy: #10261e; --gold: #c5a458; --gold-ink: #8a6f2b;
  --gain: #0d8b67; --loss: #b33d35; --slate: #3f6a86;
  --gain-bg: #e3f2ea; --loss-bg: #f8e5e3; --gold-bg: #f5efdd; --slate-bg: #e8eff3;
  --shadow: 0 18px 50px rgba(23,40,32,.09);
  --shadow-lg: 0 30px 80px rgba(16,38,30,.16);
  --f-serif: Georgia, 'Times New Roman', serif;
  --f-sans: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 17.5px; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--f-sans); line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: .68rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow.light { color: var(--lime); }

/* ---------- Marque ---------- */
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: 1rem; font-weight: 800; letter-spacing: .18em; text-decoration: none; }
.brand-light { color: var(--white); }
.brand-mark { position: relative; display: inline-block; width: 26px; height: 26px; border: 2px solid currentColor; border-radius: 50%; flex: none; }
.brand-mark::before, .brand-mark::after, .brand-mark span::before { content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 30px; background: currentColor; transform-origin: center; }
.brand-mark::before { transform: translate(-50%,-50%) rotate(0deg); }
.brand-mark::after { transform: translate(-50%,-50%) rotate(60deg); }
.brand-mark span::before { transform: translate(-50%,-50%) rotate(120deg); }

/* ---------- Coquille ---------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); padding: 28px 20px 22px; color: #fff; display: flex; flex-direction: column; }
.sidebar .brand { margin: 4px 10px 40px; }
.main-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 13px; border: 0; border-radius: 8px; padding: 0 13px; background: transparent; color: #9eb0a8; text-align: left; font-size: .84rem; font-weight: 700; transition: background .18s, color .18s; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-glyph { display: grid; place-items: center; width: 24px; color: var(--lime); font-size: 1.05rem; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; }
.live-card { display: flex; align-items: center; gap: 11px; margin: 0 4px 6px; padding: 13px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; }
.live-card div { display: grid; gap: 2px; }
.live-card small { color: #789086; font-size: .56rem; letter-spacing: .12em; text-transform: uppercase; }
.live-card strong { font-size: .76rem; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px rgba(197,164,88,.12); flex: none; transition: background .3s, box-shadow .3s; }
.live-dot.on { background: #5ee09d; box-shadow: 0 0 0 5px rgba(94,224,157,.14); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.workspace { min-width: 0; padding: 0 clamp(22px,4vw,54px) 60px; }
.topbar { min-height: 100px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.topbar h1 { margin: 0; font-family: var(--f-serif); font-weight: 500; font-size: 1.7rem; letter-spacing: -.01em; }
.topbar .eyebrow { margin-bottom: 5px; font-size: .58rem; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border: 1px solid var(--line-2); border-radius: 100px; background: var(--white); color: var(--green); font-size: .72rem; font-weight: 700; }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.status-pill.off { color: var(--loss); } .status-pill.off .dot { background: var(--loss); }
#clock { font-family: var(--f-mono); font-variant-numeric: tabular-nums; color: var(--green); font-weight: 600; font-size: 1.05rem; }
.square-button { width: 42px; min-height: 42px; padding: 0; background: var(--white); border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink); font-size: 1.15rem; transition: border-color .2s, transform .2s; }
.square-button:hover { border-color: var(--green); transform: translateY(-1px); }

.view { animation: reveal .3s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- Boutons ---------- */
.primary-button, .secondary-button, .light-button { border: 0; border-radius: 8px; min-height: 46px; padding: 0 20px; display: inline-flex; justify-content: center; align-items: center; gap: 12px; font-weight: 800; font-size: .86rem; transition: transform .18s, opacity .18s, box-shadow .2s; }
.primary-button { background: var(--green); color: #fff; }
.primary-button:hover, .light-button:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.primary-button:disabled, .light-button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.secondary-button { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line-2); }
.secondary-button:hover { border-color: var(--green); }
.light-button { background: var(--lime); color: var(--navy); }
.full { width: 100%; }

/* ---------- En-têtes de section ---------- */
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.view-head h2 { margin: 0 0 6px; font-family: var(--f-serif); font-size: clamp(1.5rem,2.4vw,2.1rem); font-weight: 500; }
.view-head p { margin: 0; color: var(--muted); font-size: .85rem; }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 12px; padding: 20px 22px; }
.stat-card.gold { border-top-color: var(--gold); } .stat-card.slate { border-top-color: var(--slate); } .stat-card.navy { border-top-color: var(--navy); }
.stat-card p { margin: 0 0 11px; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.stat-card strong { display: block; font-family: var(--f-serif); font-size: 1.9rem; font-weight: 500; letter-spacing: -.02em; }
.stat-card strong.num { font-family: var(--f-mono); font-size: 1.55rem; }
.stat-card small { display: block; margin-top: 6px; color: var(--faint); font-size: .66rem; }
.stat-card.positive strong { color: var(--gain); } .stat-card.negative strong { color: var(--loss); }

/* ---------- Panneaux ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-family: var(--f-serif); font-size: 1.2rem; font-weight: 500; }
.panel-head .eyebrow { margin: 0 0 4px; font-size: .56rem; }
.mini-badge { padding: 6px 10px; background: var(--gain-bg); color: var(--green); border-radius: 6px; font-size: .64rem; font-weight: 800; letter-spacing: .04em; }

/* ---------- Onglets zones ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tab-btn { min-height: 38px; padding: 0 15px; border: 1px solid var(--line-2); border-radius: 100px; background: var(--white); color: var(--muted); font-size: .78rem; font-weight: 750; display: inline-flex; align-items: center; gap: 7px; transition: all .2s; }
.tab-btn:hover { border-color: var(--green); color: var(--ink); }
.tab-btn.active { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 6px 18px rgba(10,111,84,.22); }

/* ---------- Table Marché ---------- */
.tbl-scroll { overflow-x: auto; }
table.market { width: 100%; border-collapse: collapse; min-width: 780px; }
table.market thead th { text-align: left; padding: 13px 16px; font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 750; border-bottom: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
table.market thead th:first-child { padding-left: 24px; } table.market thead th:last-child { padding-right: 24px; text-align: right; }
table.market tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: .82rem; vertical-align: middle; }
table.market tbody td:first-child { padding-left: 24px; } table.market tbody td:last-child { padding-right: 24px; text-align: right; }
table.market tbody tr { cursor: pointer; transition: background .16s; }
table.market tbody tr:hover { background: var(--paper); }
table.market tbody tr:last-child td { border-bottom: none; }
.rank { font-family: var(--f-mono); font-size: .8rem; color: var(--faint); }
.rank.top { color: var(--gold-ink); font-weight: 700; }
.tk-chip { font-family: var(--f-mono); font-weight: 600; font-size: .74rem; color: var(--green); background: var(--gain-bg); border: 1px solid #cbe4d6; padding: 4px 9px; border-radius: 6px; letter-spacing: .02em; white-space: nowrap; }
.co { font-weight: 650; font-size: .82rem; color: var(--ink); }
.px { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--ink); border-radius: 4px; padding: 1px 3px; }
.cur { font-size: .58rem; color: var(--faint); }
@keyframes flup { 0% { background: rgba(13,139,103,.22); } 100% { background: transparent; } }
@keyframes fldn { 0% { background: rgba(179,61,53,.20); } 100% { background: transparent; } }
.fl-up { animation: flup 1.1s ease; } .fl-dn { animation: fldn 1.1s ease; }
.delta { font-family: var(--f-mono); font-size: .68rem; margin-top: 3px; display: inline-block; }
.bar-wrap { display: flex; align-items: center; gap: 9px; }
.bar { width: 58px; height: 5px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--mint), var(--green)); }
.sc { font-family: var(--f-mono); font-weight: 600; color: var(--green); font-size: .8rem; }
.mono-s { font-family: var(--f-mono); font-size: .7rem; }
.up { color: var(--gain); font-size: .68rem; }
.pill { display: inline-block; padding: 5px 10px; border-radius: 100px; font-size: .58rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.p-strong { color: #fff; background: var(--green); }
.p-buy { color: var(--green); background: var(--gain-bg); border: 1px solid #bcded0; }
.p-hold { color: var(--gold-ink); background: var(--gold-bg); border: 1px solid #e6dcc0; }
.p-caution { color: var(--loss); background: var(--loss-bg); border: 1px solid #edccc8; }

/* ---------- Analyse du jour (briefing) ---------- */
.brief { border: 1px solid #cfe0d8; }
.brief .panel-head { background: linear-gradient(120deg, #f1f7f3, var(--white)); }
.brief-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px 0; font-size: .66rem; color: var(--faint); }
.ana-badge { font-size: .58rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; border-radius: 100px; padding: 3px 10px; background: var(--gain-bg); color: var(--green); }
.analysis-text { padding: 12px 24px 6px; white-space: pre-wrap; font-size: .88rem; line-height: 1.75; color: var(--ink); max-width: 82ch; }
.analysis-text strong, .analysis-text b { font-weight: 750; }
.ana-items { padding: 4px 24px 20px; display: grid; }
.ana-item { padding: 11px 0; border-top: 1px solid var(--line); font-size: .8rem; }
.ana-item b { color: var(--green); } .ana-item .f { font-size: .7rem; color: var(--muted); margin-top: 3px; }

/* ---------- Colonnes Top10 + dividendes ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cols .panel { margin-bottom: 0; }
.row-item { display: grid; align-items: center; gap: 12px; padding: 13px 24px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .16s; }
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--paper); }
.t10 { grid-template-columns: 28px 66px 1fr auto; }
.t10-rank { font-family: var(--f-mono); font-size: .78rem; color: var(--faint); } .t10-rank.pod { color: var(--gold-ink); font-weight: 700; }
.t10-meta { font-size: .66rem; color: var(--muted); }
.t10-sc { font-family: var(--f-mono); font-size: .76rem; color: var(--green); text-align: right; }
.dv { grid-template-columns: 66px 1fr auto; }
.dv-y { color: var(--gain); font-family: var(--f-mono); font-weight: 600; }
.dv-next { font-family: var(--f-mono); font-size: .66rem; color: var(--gold-ink); text-align: right; }
.empty { padding: 24px; color: var(--faint); font-size: .78rem; text-align: center; }

/* ---------- Disclaimer ---------- */
.disclaimer { background: var(--paper-2); border-left: 3px solid var(--green); border-radius: 8px; padding: 15px 18px; font-size: .72rem; color: var(--muted); line-height: 1.7; }
.disclaimer b { color: var(--gold-ink); }

/* ---------- Modal fiche actif ---------- */
dialog { color: var(--ink); background: var(--white); border: 0; border-radius: 16px; padding: 0; box-shadow: var(--shadow-lg); max-width: calc(100vw - 28px); }
dialog::backdrop { background: rgba(16,38,30,.55); backdrop-filter: blur(4px); }
.asset-dialog { width: min(640px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.m-body { padding: 26px; position: relative; }
.m-close { position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); color: var(--muted); font-size: 1rem; display: grid; place-items: center; transition: all .2s; }
.m-close:hover { border-color: var(--loss); color: var(--loss); background: var(--loss-bg); }
.m-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 6px 40px 18px 0; }
.m-px { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 1.85rem; line-height: 1; }
.m-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 8px; text-align: center; }
.kpi-l { font-size: .55rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.kpi-v { font-family: var(--f-mono); font-size: .9rem; }
.m-block { border-radius: 12px; padding: 15px 16px; margin-top: 14px; }
.m-block.gold { background: var(--gold-bg); border: 1px solid #e6dcc0; }
.m-block.slate { background: var(--slate-bg); border: 1px solid #d3e0e8; }
.m-block-t { font-size: .58rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 9px; font-weight: 800; }
.m-link { display: inline-flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 15px; text-decoration: none; color: var(--ink); font-size: .8rem; font-weight: 650; margin: 8px 8px 0 0; transition: all .2s; }
.m-link:hover { border-color: var(--green); background: var(--gain-bg); transform: translateY(-2px); }

/* ---------- Fondamentaux (fiche détaillée) ---------- */
.m-block.mint { background: var(--gain-bg); border: 1px solid #cbe4d6; }
table.kv { width: 100%; border-collapse: collapse; font-size: .78rem; }
table.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); }
table.kv td:first-child { color: var(--muted); }
table.kv td:last-child { text-align: right; font-family: var(--f-mono); font-weight: 600; }
table.kv tr:last-child td { border-bottom: none; }
.muted { color: var(--faint); font-size: .78rem; }

/* ---------- Garde-fous & fraîcheur ---------- */
.badge { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 10px;
         font-weight: 600; letter-spacing: .3px; }
.badge.warn { background: #fdeecd; color: #8a5a00; border: 1px solid #ecd9a8; }
.badge.info { background: #e8f0ec; color: #0a6f54; border: 1px solid #cfe0d7; }
.stale { color: #98a49d; }
.stale-tag { color: #98a49d; font-size: .62rem; font-weight: 600; }
.disabled { opacity: .45; pointer-events: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; }

/* =============================================================
   Responsive
   ============================================================= */
@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 82px 1fr; }
  .sidebar { padding-inline: 12px; }
  .sidebar .brand span:last-child, .nav-item span:last-child, .live-card div { display: none; }
  .sidebar .brand { margin-inline: auto; justify-content: center; }
  .nav-item { justify-content: center; padding: 0; }
  .live-card { justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid, .cols, .connect-layout { grid-template-columns: 1fr; }
  .advisor-panel, .reco-panel { flex-direction: column; align-items: stretch; }
  .advisor-actions { min-width: 0; max-width: none; }
  .advisor-positions, .reco-list { grid-template-columns: 1fr; }
  .m-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .app-shell { display: block; padding-bottom: 66px; }
  .sidebar { position: fixed; z-index: 60; inset: auto 0 0 0; height: 62px; padding: 6px 10px; flex-direction: row; }
  .sidebar > .brand, .sidebar-bottom { display: none; }
  .main-nav { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; width: 100%; }
  .nav-item { min-height: 50px; flex-direction: column; gap: 1px; font-size: .58rem; }
  .nav-item span:last-child { display: block; }
  .workspace { padding: 0 16px 34px; }
  .topbar { min-height: 78px; margin-bottom: 22px; }
  .topbar .eyebrow { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .allocation-content { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
